@liquid-af/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +776 -0
- package/dist/accounts/index.d.ts +5 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +5 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/liquid-fees.d.ts +63 -0
- package/dist/accounts/liquid-fees.d.ts.map +1 -0
- package/dist/accounts/liquid-fees.js +27 -0
- package/dist/accounts/liquid-fees.js.map +1 -0
- package/dist/accounts/liquid-state.d.ts +112 -0
- package/dist/accounts/liquid-state.d.ts.map +1 -0
- package/dist/accounts/liquid-state.js +92 -0
- package/dist/accounts/liquid-state.js.map +1 -0
- package/dist/accounts/liquid-swap.d.ts +97 -0
- package/dist/accounts/liquid-swap.d.ts.map +1 -0
- package/dist/accounts/liquid-swap.js +54 -0
- package/dist/accounts/liquid-swap.js.map +1 -0
- package/dist/accounts/liquid.d.ts +175 -0
- package/dist/accounts/liquid.d.ts.map +1 -0
- package/dist/accounts/liquid.js +66 -0
- package/dist/accounts/liquid.js.map +1 -0
- package/dist/client.d.ts +621 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +511 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +56 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +44 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +63 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +2 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/parser.d.ts +40 -0
- package/dist/events/parser.d.ts.map +1 -0
- package/dist/events/parser.js +67 -0
- package/dist/events/parser.js.map +1 -0
- package/dist/events/types.d.ts +286 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +2 -0
- package/dist/events/types.js.map +1 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/preview.d.ts +259 -0
- package/dist/helpers/preview.d.ts.map +1 -0
- package/dist/helpers/preview.js +458 -0
- package/dist/helpers/preview.js.map +1 -0
- package/dist/helpers/user.d.ts +11 -0
- package/dist/helpers/user.d.ts.map +1 -0
- package/dist/helpers/user.js +20 -0
- package/dist/helpers/user.js.map +1 -0
- package/dist/idl/index.d.ts +53 -0
- package/dist/idl/index.d.ts.map +1 -0
- package/dist/idl/index.js +64 -0
- package/dist/idl/index.js.map +1 -0
- package/dist/idl/liquid.d.ts +10523 -0
- package/dist/idl/liquid.d.ts.map +1 -0
- package/dist/idl/liquid.js +2 -0
- package/dist/idl/liquid.js.map +1 -0
- package/dist/idl/liquid.json +10516 -0
- package/dist/idl/liquid_fees.d.ts +1520 -0
- package/dist/idl/liquid_fees.d.ts.map +1 -0
- package/dist/idl/liquid_fees.js +2 -0
- package/dist/idl/liquid_fees.js.map +1 -0
- package/dist/idl/liquid_fees.json +1513 -0
- package/dist/idl/liquid_state.d.ts +2936 -0
- package/dist/idl/liquid_state.d.ts.map +1 -0
- package/dist/idl/liquid_state.js +2 -0
- package/dist/idl/liquid_state.js.map +1 -0
- package/dist/idl/liquid_state.json +2929 -0
- package/dist/idl/liquid_swap.d.ts +5849 -0
- package/dist/idl/liquid_swap.d.ts.map +1 -0
- package/dist/idl/liquid_swap.js +2 -0
- package/dist/idl/liquid_swap.js.map +1 -0
- package/dist/idl/liquid_swap.json +5842 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/index.d.ts +9 -0
- package/dist/instructions/index.d.ts.map +1 -0
- package/dist/instructions/index.js +9 -0
- package/dist/instructions/index.js.map +1 -0
- package/dist/instructions/liquid-fees.d.ts +111 -0
- package/dist/instructions/liquid-fees.d.ts.map +1 -0
- package/dist/instructions/liquid-fees.js +169 -0
- package/dist/instructions/liquid-fees.js.map +1 -0
- package/dist/instructions/liquid-state.d.ts +173 -0
- package/dist/instructions/liquid-state.d.ts.map +1 -0
- package/dist/instructions/liquid-state.js +194 -0
- package/dist/instructions/liquid-state.js.map +1 -0
- package/dist/instructions/liquid-swap.d.ts +122 -0
- package/dist/instructions/liquid-swap.d.ts.map +1 -0
- package/dist/instructions/liquid-swap.js +167 -0
- package/dist/instructions/liquid-swap.js.map +1 -0
- package/dist/instructions/liquid.d.ts +297 -0
- package/dist/instructions/liquid.d.ts.map +1 -0
- package/dist/instructions/liquid.js +483 -0
- package/dist/instructions/liquid.js.map +1 -0
- package/dist/instructions/program-cache.d.ts +35 -0
- package/dist/instructions/program-cache.d.ts.map +1 -0
- package/dist/instructions/program-cache.js +68 -0
- package/dist/instructions/program-cache.js.map +1 -0
- package/dist/math/amm.d.ts +42 -0
- package/dist/math/amm.d.ts.map +1 -0
- package/dist/math/amm.js +109 -0
- package/dist/math/amm.js.map +1 -0
- package/dist/math/bonding-curve.d.ts +34 -0
- package/dist/math/bonding-curve.d.ts.map +1 -0
- package/dist/math/bonding-curve.js +80 -0
- package/dist/math/bonding-curve.js.map +1 -0
- package/dist/math/constants.d.ts +14 -0
- package/dist/math/constants.d.ts.map +1 -0
- package/dist/math/constants.js +14 -0
- package/dist/math/constants.js.map +1 -0
- package/dist/math/fees.d.ts +88 -0
- package/dist/math/fees.d.ts.map +1 -0
- package/dist/math/fees.js +135 -0
- package/dist/math/fees.js.map +1 -0
- package/dist/math/index.d.ts +8 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math/index.js +6 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/tiered-fees.d.ts +80 -0
- package/dist/math/tiered-fees.d.ts.map +1 -0
- package/dist/math/tiered-fees.js +129 -0
- package/dist/math/tiered-fees.js.map +1 -0
- package/dist/oracle.d.ts +53 -0
- package/dist/oracle.d.ts.map +1 -0
- package/dist/oracle.js +70 -0
- package/dist/oracle.js.map +1 -0
- package/dist/pda/index.d.ts +89 -0
- package/dist/pda/index.d.ts.map +1 -0
- package/dist/pda/index.js +127 -0
- package/dist/pda/index.js.map +1 -0
- package/dist/pda/liquid-fees.d.ts +27 -0
- package/dist/pda/liquid-fees.d.ts.map +1 -0
- package/dist/pda/liquid-fees.js +36 -0
- package/dist/pda/liquid-fees.js.map +1 -0
- package/dist/pda/liquid-state.d.ts +56 -0
- package/dist/pda/liquid-state.d.ts.map +1 -0
- package/dist/pda/liquid-state.js +79 -0
- package/dist/pda/liquid-state.js.map +1 -0
- package/dist/pda/liquid-swap.d.ts +76 -0
- package/dist/pda/liquid-swap.d.ts.map +1 -0
- package/dist/pda/liquid-swap.js +103 -0
- package/dist/pda/liquid-swap.js.map +1 -0
- package/dist/pda/liquid.d.ts +67 -0
- package/dist/pda/liquid.d.ts.map +1 -0
- package/dist/pda/liquid.js +91 -0
- package/dist/pda/liquid.js.map +1 -0
- package/dist/provider.d.ts +26 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +47 -0
- package/dist/provider.js.map +1 -0
- package/dist/transaction/builder.d.ts +30 -0
- package/dist/transaction/builder.d.ts.map +1 -0
- package/dist/transaction/builder.js +48 -0
- package/dist/transaction/builder.js.map +1 -0
- package/dist/transaction/index.d.ts +3 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +3 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction/send.d.ts +25 -0
- package/dist/transaction/send.d.ts.map +1 -0
- package/dist/transaction/send.js +52 -0
- package/dist/transaction/send.js.map +1 -0
- package/dist/types.d.ts +311 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +46 -0
- package/dist/types.js.map +1 -0
- package/package.json +112 -0
- package/src/accounts/index.ts +26 -0
- package/src/accounts/liquid-fees.ts +38 -0
- package/src/accounts/liquid-state.ts +134 -0
- package/src/accounts/liquid-swap.ts +79 -0
- package/src/accounts/liquid.ts +100 -0
- package/src/client.ts +1001 -0
- package/src/config.ts +91 -0
- package/src/errors.ts +94 -0
- package/src/events/index.ts +42 -0
- package/src/events/parser.ts +90 -0
- package/src/events/types.ts +310 -0
- package/src/helpers/index.ts +23 -0
- package/src/helpers/preview.ts +798 -0
- package/src/helpers/user.ts +24 -0
- package/src/idl/index.ts +94 -0
- package/src/idl/liquid.json +10516 -0
- package/src/idl/liquid.ts +10522 -0
- package/src/idl/liquid_fees.json +1513 -0
- package/src/idl/liquid_fees.ts +1519 -0
- package/src/idl/liquid_state.json +2929 -0
- package/src/idl/liquid_state.ts +2935 -0
- package/src/idl/liquid_swap.json +5842 -0
- package/src/idl/liquid_swap.ts +5848 -0
- package/src/index.ts +98 -0
- package/src/instructions/index.ts +109 -0
- package/src/instructions/liquid-fees.ts +289 -0
- package/src/instructions/liquid-state.ts +336 -0
- package/src/instructions/liquid-swap.ts +414 -0
- package/src/instructions/liquid.ts +884 -0
- package/src/instructions/program-cache.ts +106 -0
- package/src/math/amm.ts +146 -0
- package/src/math/bonding-curve.ts +122 -0
- package/src/math/constants.ts +19 -0
- package/src/math/fees.ts +191 -0
- package/src/math/index.ts +40 -0
- package/src/math/tiered-fees.ts +165 -0
- package/src/oracle.ts +97 -0
- package/src/pda/index.ts +331 -0
- package/src/pda/liquid-fees.ts +58 -0
- package/src/pda/liquid-state.ts +123 -0
- package/src/pda/liquid-swap.ts +162 -0
- package/src/pda/liquid.ts +152 -0
- package/src/provider.ts +60 -0
- package/src/transaction/builder.ts +80 -0
- package/src/transaction/index.ts +6 -0
- package/src/transaction/send.ts +72 -0
- package/src/types.ts +354 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Connection } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Confirms a transaction with the given signature and blockhash info.
|
|
4
|
+
*
|
|
5
|
+
* @param connection - Solana RPC connection
|
|
6
|
+
* @param signature - Transaction signature to confirm
|
|
7
|
+
* @param blockhash - Recent blockhash used in the transaction
|
|
8
|
+
* @param lastValidBlockHeight - Block height after which the transaction expires
|
|
9
|
+
* @returns The confirmed transaction signature
|
|
10
|
+
*/
|
|
11
|
+
export declare const confirmTx: (connection: Connection, signature: string, blockhash: string, lastValidBlockHeight: number) => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Executes an RPC call and confirms the transaction.
|
|
14
|
+
*
|
|
15
|
+
* Handles Anchor's legacy 30s confirmation timeout: if .rpc() throws a
|
|
16
|
+
* TransactionExpiredTimeoutError the transaction may still have landed.
|
|
17
|
+
* We extract the signature from the error and re-check status before
|
|
18
|
+
* propagating the failure.
|
|
19
|
+
*
|
|
20
|
+
* @param connection - Solana RPC connection
|
|
21
|
+
* @param rpcCall - Async function that sends the transaction and returns its signature
|
|
22
|
+
* @returns The confirmed transaction signature
|
|
23
|
+
*/
|
|
24
|
+
export declare const sendAndConfirm: (connection: Connection, rpcCall: () => Promise<string>) => Promise<string>;
|
|
25
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/transaction/send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACrB,YAAY,UAAU,EACtB,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,sBAAsB,MAAM,KAC1B,OAAO,CAAC,MAAM,CAMhB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAC1B,YAAY,UAAU,EACtB,SAAS,MAAM,OAAO,CAAC,MAAM,CAAC,KAC5B,OAAO,CAAC,MAAM,CAgChB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirms a transaction with the given signature and blockhash info.
|
|
3
|
+
*
|
|
4
|
+
* @param connection - Solana RPC connection
|
|
5
|
+
* @param signature - Transaction signature to confirm
|
|
6
|
+
* @param blockhash - Recent blockhash used in the transaction
|
|
7
|
+
* @param lastValidBlockHeight - Block height after which the transaction expires
|
|
8
|
+
* @returns The confirmed transaction signature
|
|
9
|
+
*/
|
|
10
|
+
export const confirmTx = async (connection, signature, blockhash, lastValidBlockHeight) => {
|
|
11
|
+
await connection.confirmTransaction({ blockhash, lastValidBlockHeight, signature }, "confirmed");
|
|
12
|
+
return signature;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Executes an RPC call and confirms the transaction.
|
|
16
|
+
*
|
|
17
|
+
* Handles Anchor's legacy 30s confirmation timeout: if .rpc() throws a
|
|
18
|
+
* TransactionExpiredTimeoutError the transaction may still have landed.
|
|
19
|
+
* We extract the signature from the error and re-check status before
|
|
20
|
+
* propagating the failure.
|
|
21
|
+
*
|
|
22
|
+
* @param connection - Solana RPC connection
|
|
23
|
+
* @param rpcCall - Async function that sends the transaction and returns its signature
|
|
24
|
+
* @returns The confirmed transaction signature
|
|
25
|
+
*/
|
|
26
|
+
export const sendAndConfirm = async (connection, rpcCall) => {
|
|
27
|
+
try {
|
|
28
|
+
const signature = await rpcCall();
|
|
29
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
30
|
+
await confirmTx(connection, signature, blockhash, lastValidBlockHeight);
|
|
31
|
+
return signature;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (err &&
|
|
35
|
+
typeof err === "object" &&
|
|
36
|
+
"signature" in err &&
|
|
37
|
+
typeof err.signature === "string") {
|
|
38
|
+
const sig = err.signature;
|
|
39
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
40
|
+
try {
|
|
41
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
42
|
+
await confirmTx(connection, sig, blockhash, lastValidBlockHeight);
|
|
43
|
+
return sig;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Re-confirmation also failed - throw the original error
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/transaction/send.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC7B,UAAsB,EACtB,SAAiB,EACjB,SAAiB,EACjB,oBAA4B,EACV,EAAE;IACpB,MAAM,UAAU,CAAC,kBAAkB,CAClC,EAAE,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE,EAC9C,WAAW,CACX,CAAC;IACF,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAClC,UAAsB,EACtB,OAA8B,EACZ,EAAE;IACpB,IAAI,CAAC;QACJ,MAAM,SAAS,GAAG,MAAM,OAAO,EAAE,CAAC;QAClC,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GACxC,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC;QACvC,MAAM,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACxE,OAAO,SAAS,CAAC;IAClB,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACvB,IACC,GAAG;YACH,OAAO,GAAG,KAAK,QAAQ;YACvB,WAAW,IAAI,GAAG;YAClB,OAAQ,GAA+B,CAAC,SAAS,KAAK,QAAQ,EAC7D,CAAC;YACF,MAAM,GAAG,GAAI,GAA+B,CAAC,SAAmB,CAAC;YACjE,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;YAC9C,IAAI,CAAC;gBACJ,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GACxC,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC;gBACvC,MAAM,SAAS,CACd,UAAU,EACV,GAAG,EACH,SAAS,EACT,oBAAoB,CACpB,CAAC;gBACF,OAAO,GAAG,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,yDAAyD;YAC1D,CAAC;QACF,CAAC;QACD,MAAM,GAAG,CAAC;IACX,CAAC;AACF,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import type { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type BN from "bn.js";
|
|
3
|
+
/** Curve status enum values */
|
|
4
|
+
export declare const CurveStatus: {
|
|
5
|
+
readonly Active: "active";
|
|
6
|
+
readonly Complete: "complete";
|
|
7
|
+
readonly Migrated: "migrated";
|
|
8
|
+
};
|
|
9
|
+
export type CurveStatus = (typeof CurveStatus)[keyof typeof CurveStatus];
|
|
10
|
+
/** Anchor-serialized curve status representation */
|
|
11
|
+
export type CurveStatusAnchor = {
|
|
12
|
+
active: Record<string, never>;
|
|
13
|
+
} | {
|
|
14
|
+
complete: {
|
|
15
|
+
solPriceSnapshot: BN;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
migrated: Record<string, never>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Checks if an Anchor-serialized curve status matches an expected CurveStatus enum value.
|
|
22
|
+
*
|
|
23
|
+
* @param anchorStatus - The Anchor-serialized curve status to check
|
|
24
|
+
* @param expected - The expected CurveStatus enum value
|
|
25
|
+
* @returns True if the Anchor status matches the expected value
|
|
26
|
+
*/
|
|
27
|
+
export declare const curveStatusEquals: (anchorStatus: CurveStatusAnchor, expected: CurveStatus) => boolean;
|
|
28
|
+
/** Fee mode enum values */
|
|
29
|
+
export declare const FeeMode: {
|
|
30
|
+
readonly Recipients: "recipients";
|
|
31
|
+
readonly Revoked: "revoked";
|
|
32
|
+
};
|
|
33
|
+
export type FeeMode = (typeof FeeMode)[keyof typeof FeeMode];
|
|
34
|
+
/** Anchor-serialized fee mode representation */
|
|
35
|
+
export type FeeModeAnchor = {
|
|
36
|
+
recipients: Record<string, never>;
|
|
37
|
+
} | {
|
|
38
|
+
revoked: Record<string, never>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Converts a FeeMode enum value to its Anchor-compatible serialized format.
|
|
42
|
+
*
|
|
43
|
+
* @param mode - The fee mode to convert
|
|
44
|
+
* @returns Anchor-serialized fee mode object
|
|
45
|
+
*/
|
|
46
|
+
export declare const toAnchorFeeMode: (mode: FeeMode) => FeeModeAnchor;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if an Anchor-serialized fee mode matches an expected FeeMode enum value.
|
|
49
|
+
*
|
|
50
|
+
* @param anchorMode - The Anchor-serialized fee mode to check
|
|
51
|
+
* @param expected - The expected FeeMode enum value
|
|
52
|
+
* @returns True if the Anchor fee mode matches the expected value
|
|
53
|
+
*/
|
|
54
|
+
export declare const feeModeEquals: (anchorMode: FeeModeAnchor, expected: FeeMode) => boolean;
|
|
55
|
+
/** Global configuration for the bonding curve program */
|
|
56
|
+
export interface GlobalConfiguration {
|
|
57
|
+
adminAuthority: PublicKey;
|
|
58
|
+
initialVirtualTokenReserves: BN;
|
|
59
|
+
initialVirtualSolReserves: BN;
|
|
60
|
+
initialRealTokenReserves: BN;
|
|
61
|
+
tokenTotalSupply: BN;
|
|
62
|
+
traderCashbackBasisPoints: number;
|
|
63
|
+
creatorFeeBasisPoints: number;
|
|
64
|
+
creatorReferralRewardBasisPoints: number;
|
|
65
|
+
traderReferralRewardBasisPoints: number;
|
|
66
|
+
protocolFeeBasisPoints: number;
|
|
67
|
+
feeRecipients: PublicKey[];
|
|
68
|
+
quoteMints: PublicKey[];
|
|
69
|
+
paused: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** Native bonding curve account state */
|
|
72
|
+
export interface BondingCurveState {
|
|
73
|
+
creator: PublicKey;
|
|
74
|
+
tokenMint: PublicKey;
|
|
75
|
+
realTokenReserves: BN;
|
|
76
|
+
virtualTokenReserves: BN;
|
|
77
|
+
realSolReserves: BN;
|
|
78
|
+
virtualSolReserves: BN;
|
|
79
|
+
tokenTotalSupply: BN;
|
|
80
|
+
status: CurveStatusAnchor;
|
|
81
|
+
bump: number;
|
|
82
|
+
}
|
|
83
|
+
/** Market cap-based fee tier definition */
|
|
84
|
+
export interface FeeTier {
|
|
85
|
+
rangeStartInclusive: BN;
|
|
86
|
+
rangeEndExclusive: BN;
|
|
87
|
+
lpFeeRate: number;
|
|
88
|
+
protocolFeeRate: number;
|
|
89
|
+
creatorFeeRate: number;
|
|
90
|
+
}
|
|
91
|
+
/** AMM global configuration */
|
|
92
|
+
export interface AmmConfig {
|
|
93
|
+
adminAuthority: PublicKey;
|
|
94
|
+
feeRecipients: PublicKey[];
|
|
95
|
+
quoteMints: PublicKey[];
|
|
96
|
+
bump: number;
|
|
97
|
+
paused: boolean;
|
|
98
|
+
feeTiers: FeeTier[];
|
|
99
|
+
oraclePriceFeed: PublicKey;
|
|
100
|
+
}
|
|
101
|
+
/** AMM pool state account */
|
|
102
|
+
export interface PoolState {
|
|
103
|
+
baseVault: PublicKey;
|
|
104
|
+
quoteVault: PublicKey;
|
|
105
|
+
lpMint: PublicKey;
|
|
106
|
+
baseMint: PublicKey;
|
|
107
|
+
quoteMint: PublicKey;
|
|
108
|
+
baseTokenProgram: PublicKey;
|
|
109
|
+
quoteTokenProgram: PublicKey;
|
|
110
|
+
observationKey: PublicKey;
|
|
111
|
+
authBump: number;
|
|
112
|
+
lpMintDecimals: number;
|
|
113
|
+
baseDecimals: number;
|
|
114
|
+
quoteDecimals: number;
|
|
115
|
+
lpSupply: BN;
|
|
116
|
+
recentEpoch: BN;
|
|
117
|
+
creator: PublicKey;
|
|
118
|
+
}
|
|
119
|
+
/** Oracle observation entry */
|
|
120
|
+
export interface Observation {
|
|
121
|
+
blockTimestamp: BN;
|
|
122
|
+
cumulativeBasePriceX32: BN;
|
|
123
|
+
cumulativeQuotePriceX32: BN;
|
|
124
|
+
}
|
|
125
|
+
/** Oracle observation state */
|
|
126
|
+
export interface ObservationState {
|
|
127
|
+
initialized: boolean;
|
|
128
|
+
observationIndex: number;
|
|
129
|
+
poolId: PublicKey;
|
|
130
|
+
observations: Observation[];
|
|
131
|
+
lastUpdateTimestamp: BN;
|
|
132
|
+
}
|
|
133
|
+
/** Fee recipient with basis point allocation */
|
|
134
|
+
export interface FeeRecipient {
|
|
135
|
+
pubkey: PublicKey;
|
|
136
|
+
basisPoints: number;
|
|
137
|
+
}
|
|
138
|
+
/** Unified fee configuration for a token */
|
|
139
|
+
export interface UnifiedFeeConfiguration {
|
|
140
|
+
creator: PublicKey;
|
|
141
|
+
tokenMint: PublicKey;
|
|
142
|
+
feeMode: FeeModeAnchor;
|
|
143
|
+
recipientsCount: number;
|
|
144
|
+
recipients: FeeRecipient[];
|
|
145
|
+
updateAuthority: PublicKey;
|
|
146
|
+
locked: boolean;
|
|
147
|
+
bump: number;
|
|
148
|
+
}
|
|
149
|
+
/** Referrer information attached to a user */
|
|
150
|
+
export interface ReferrerInfo {
|
|
151
|
+
referrer: PublicKey;
|
|
152
|
+
deal: PublicKey | null;
|
|
153
|
+
cashbackMultiplierBps: number;
|
|
154
|
+
}
|
|
155
|
+
/** User properties account */
|
|
156
|
+
export interface UserProperties {
|
|
157
|
+
referrer: ReferrerInfo | null;
|
|
158
|
+
totalSolVolume: BN;
|
|
159
|
+
totalTokenVolume: BN;
|
|
160
|
+
cashbackCredits: BN;
|
|
161
|
+
isSpending: boolean;
|
|
162
|
+
curveSolVolume: BN;
|
|
163
|
+
ammSolVolume: BN;
|
|
164
|
+
snapshotSolVolume: BN;
|
|
165
|
+
snapshotTokenVolume: BN;
|
|
166
|
+
snapshotCount: number;
|
|
167
|
+
latestSnapshot: PublicKey | null;
|
|
168
|
+
}
|
|
169
|
+
/** User volume snapshot account */
|
|
170
|
+
export interface UserSnapshot {
|
|
171
|
+
user: PublicKey;
|
|
172
|
+
index: number;
|
|
173
|
+
prevSnapshot: PublicKey | null;
|
|
174
|
+
solVolume: BN;
|
|
175
|
+
tokenVolume: BN;
|
|
176
|
+
createdAt: BN;
|
|
177
|
+
}
|
|
178
|
+
/** Exclusive deal for a referrer/influencer */
|
|
179
|
+
export interface Deal {
|
|
180
|
+
owner: PublicKey;
|
|
181
|
+
cashbackMultiplierBps: number;
|
|
182
|
+
redemptionCount: number;
|
|
183
|
+
}
|
|
184
|
+
/** Arguments for admin_update_user instruction */
|
|
185
|
+
export interface AdminUpdateUserArgs {
|
|
186
|
+
newReferrer: PublicKey | null;
|
|
187
|
+
newCashbackMultiplierBps: number | null;
|
|
188
|
+
}
|
|
189
|
+
/** Per-token volume accumulator */
|
|
190
|
+
export interface TokenVolumeAccumulator {
|
|
191
|
+
mint: PublicKey;
|
|
192
|
+
totalSolVolume: BN;
|
|
193
|
+
totalTokenVolume: BN;
|
|
194
|
+
curveSolVolume: BN;
|
|
195
|
+
ammSolVolume: BN;
|
|
196
|
+
}
|
|
197
|
+
/** Global curve volume accumulator */
|
|
198
|
+
export interface GlobalCurveVolume {
|
|
199
|
+
totalSolVolume: BN;
|
|
200
|
+
totalTokenVolume: BN;
|
|
201
|
+
}
|
|
202
|
+
/** Global AMM volume accumulator */
|
|
203
|
+
export interface GlobalAmmVolume {
|
|
204
|
+
totalSolVolume: BN;
|
|
205
|
+
totalTokenVolume: BN;
|
|
206
|
+
}
|
|
207
|
+
/** Cashback range tier */
|
|
208
|
+
export interface CashbackRange {
|
|
209
|
+
rangeStartInclusive: BN;
|
|
210
|
+
rangeEndExclusive: BN;
|
|
211
|
+
multiplierBasisPoints: number;
|
|
212
|
+
}
|
|
213
|
+
/** Cashback configuration */
|
|
214
|
+
export interface CashbackConfiguration {
|
|
215
|
+
adminAuthority: PublicKey;
|
|
216
|
+
rangesCount: number;
|
|
217
|
+
ranges: CashbackRange[];
|
|
218
|
+
traderCashbackBasisPoints: number;
|
|
219
|
+
}
|
|
220
|
+
/** Fee breakdown from a trade */
|
|
221
|
+
export interface FeeDistribution {
|
|
222
|
+
protocolFee: BN;
|
|
223
|
+
creatorFee: BN;
|
|
224
|
+
creatorReferralFee: BN;
|
|
225
|
+
traderReferralFee: BN;
|
|
226
|
+
totalFees: BN;
|
|
227
|
+
}
|
|
228
|
+
/** Buy calculation result for bonding curve */
|
|
229
|
+
export interface BondingCurveBuyResult extends FeeDistribution {
|
|
230
|
+
tokensOut: BN;
|
|
231
|
+
newVirtualQuote: BN;
|
|
232
|
+
newVirtualToken: BN;
|
|
233
|
+
amountInNet: BN;
|
|
234
|
+
}
|
|
235
|
+
/** Sell calculation result for bonding curve */
|
|
236
|
+
export interface BondingCurveSellResult extends FeeDistribution {
|
|
237
|
+
quoteOutGross: BN;
|
|
238
|
+
quoteOutNet: BN;
|
|
239
|
+
newVirtualQuote: BN;
|
|
240
|
+
newVirtualToken: BN;
|
|
241
|
+
}
|
|
242
|
+
/** AMM swap fees breakdown */
|
|
243
|
+
export interface SwapFees {
|
|
244
|
+
lpFee: BN;
|
|
245
|
+
creatorFee: BN;
|
|
246
|
+
protocolFee: BN;
|
|
247
|
+
totalFees: BN;
|
|
248
|
+
}
|
|
249
|
+
/** AMM sell output calculation */
|
|
250
|
+
export interface AmmSellOutput extends SwapFees {
|
|
251
|
+
quoteOut: BN;
|
|
252
|
+
quoteOutNet: BN;
|
|
253
|
+
}
|
|
254
|
+
/** AMM buy input calculation */
|
|
255
|
+
export interface AmmBuyInput extends SwapFees {
|
|
256
|
+
quoteIn: BN;
|
|
257
|
+
quoteInGross: BN;
|
|
258
|
+
}
|
|
259
|
+
/** LP token to trading token conversion */
|
|
260
|
+
export interface LpTokenAmounts {
|
|
261
|
+
baseAmount: BN;
|
|
262
|
+
quoteAmount: BN;
|
|
263
|
+
}
|
|
264
|
+
/** Fee distribution result for multi-recipient */
|
|
265
|
+
export interface DistributionResult {
|
|
266
|
+
pubkey: PublicKey;
|
|
267
|
+
amount: number;
|
|
268
|
+
}
|
|
269
|
+
/** Convenience type aggregating pool state with derived addresses */
|
|
270
|
+
export interface PoolInfo {
|
|
271
|
+
poolAddress: PublicKey;
|
|
272
|
+
poolState: PoolState;
|
|
273
|
+
baseMint: PublicKey;
|
|
274
|
+
quoteMint: PublicKey;
|
|
275
|
+
baseTokenProgram: PublicKey;
|
|
276
|
+
quoteTokenProgram: PublicKey;
|
|
277
|
+
baseVault: PublicKey;
|
|
278
|
+
quoteVault: PublicKey;
|
|
279
|
+
lpMint: PublicKey;
|
|
280
|
+
creator: PublicKey;
|
|
281
|
+
}
|
|
282
|
+
/** Preview result for buying on the bonding curve */
|
|
283
|
+
export interface BuyCurvePreview {
|
|
284
|
+
tokensOut: BN;
|
|
285
|
+
fees: FeeDistribution;
|
|
286
|
+
priceImpactBps: number;
|
|
287
|
+
newReserves: {
|
|
288
|
+
virtualQuote: BN;
|
|
289
|
+
virtualToken: BN;
|
|
290
|
+
};
|
|
291
|
+
willComplete: boolean;
|
|
292
|
+
}
|
|
293
|
+
/** Preview result for selling on the bonding curve */
|
|
294
|
+
export interface SellCurvePreview {
|
|
295
|
+
quoteOut: BN;
|
|
296
|
+
quoteOutNet: BN;
|
|
297
|
+
fees: FeeDistribution;
|
|
298
|
+
priceImpactBps: number;
|
|
299
|
+
newReserves: {
|
|
300
|
+
virtualQuote: BN;
|
|
301
|
+
virtualToken: BN;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** Preview result for AMM swaps */
|
|
305
|
+
export interface SwapPreview {
|
|
306
|
+
amountOut: BN;
|
|
307
|
+
amountOutNet: BN;
|
|
308
|
+
fees: SwapFees;
|
|
309
|
+
priceImpactBps: number;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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AE,MAAM,CAAC;IACvB,WAAW,EAAE;QAAE,YAAY,EAAE,EAAE,CAAC;QAAC,YAAY,EAAE,EAAE,CAAA;KAAE,CAAC;CACpD;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,EAAE,CAAC;IACd,YAAY,EAAE,EAAE,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Curve status enum values */
|
|
2
|
+
export const CurveStatus = {
|
|
3
|
+
Active: "active",
|
|
4
|
+
Complete: "complete",
|
|
5
|
+
Migrated: "migrated",
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Checks if an Anchor-serialized curve status matches an expected CurveStatus enum value.
|
|
9
|
+
*
|
|
10
|
+
* @param anchorStatus - The Anchor-serialized curve status to check
|
|
11
|
+
* @param expected - The expected CurveStatus enum value
|
|
12
|
+
* @returns True if the Anchor status matches the expected value
|
|
13
|
+
*/
|
|
14
|
+
export const curveStatusEquals = (anchorStatus, expected) => {
|
|
15
|
+
return Object.keys(anchorStatus)[0] === expected;
|
|
16
|
+
};
|
|
17
|
+
/** Fee mode enum values */
|
|
18
|
+
export const FeeMode = {
|
|
19
|
+
Recipients: "recipients",
|
|
20
|
+
Revoked: "revoked",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Converts a FeeMode enum value to its Anchor-compatible serialized format.
|
|
24
|
+
*
|
|
25
|
+
* @param mode - The fee mode to convert
|
|
26
|
+
* @returns Anchor-serialized fee mode object
|
|
27
|
+
*/
|
|
28
|
+
export const toAnchorFeeMode = (mode) => {
|
|
29
|
+
switch (mode) {
|
|
30
|
+
case FeeMode.Recipients:
|
|
31
|
+
return { recipients: {} };
|
|
32
|
+
case FeeMode.Revoked:
|
|
33
|
+
return { revoked: {} };
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Checks if an Anchor-serialized fee mode matches an expected FeeMode enum value.
|
|
38
|
+
*
|
|
39
|
+
* @param anchorMode - The Anchor-serialized fee mode to check
|
|
40
|
+
* @param expected - The expected FeeMode enum value
|
|
41
|
+
* @returns True if the Anchor fee mode matches the expected value
|
|
42
|
+
*/
|
|
43
|
+
export const feeModeEquals = (anchorMode, expected) => {
|
|
44
|
+
return Object.keys(anchorMode)[0] === expected;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACX,CAAC;AAUX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAChC,YAA+B,EAC/B,QAAqB,EACX,EAAE;IACZ,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AAClD,CAAC,CAAC;AAEF,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACT,CAAC;AASX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAiB,EAAE;IAC/D,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,OAAO,CAAC,UAAU;YACtB,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAC3B,KAAK,OAAO,CAAC,OAAO;YACnB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;AACF,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,UAAyB,EACzB,QAAiB,EACP,EAAE;IACZ,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AAChD,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@liquid-af/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Liquid DeFi protocol on Solana",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./pda": {
|
|
17
|
+
"types": "./dist/pda/index.d.ts",
|
|
18
|
+
"default": "./dist/pda/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./math": {
|
|
21
|
+
"types": "./dist/math/index.d.ts",
|
|
22
|
+
"default": "./dist/math/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./accounts": {
|
|
25
|
+
"types": "./dist/accounts/index.d.ts",
|
|
26
|
+
"default": "./dist/accounts/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./instructions": {
|
|
29
|
+
"types": "./dist/instructions/index.d.ts",
|
|
30
|
+
"default": "./dist/instructions/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./helpers": {
|
|
33
|
+
"types": "./dist/helpers/index.d.ts",
|
|
34
|
+
"default": "./dist/helpers/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./events": {
|
|
37
|
+
"types": "./dist/events/index.d.ts",
|
|
38
|
+
"default": "./dist/events/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./transaction": {
|
|
41
|
+
"types": "./dist/transaction/index.d.ts",
|
|
42
|
+
"default": "./dist/transaction/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./client": {
|
|
45
|
+
"types": "./dist/client.d.ts",
|
|
46
|
+
"default": "./dist/client.js"
|
|
47
|
+
},
|
|
48
|
+
"./provider": {
|
|
49
|
+
"types": "./dist/provider.d.ts",
|
|
50
|
+
"default": "./dist/provider.js"
|
|
51
|
+
},
|
|
52
|
+
"./errors": {
|
|
53
|
+
"types": "./dist/errors.d.ts",
|
|
54
|
+
"default": "./dist/errors.js"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"solana",
|
|
59
|
+
"defi",
|
|
60
|
+
"dex",
|
|
61
|
+
"amm",
|
|
62
|
+
"bonding-curve",
|
|
63
|
+
"token-launch",
|
|
64
|
+
"cpmm",
|
|
65
|
+
"swap",
|
|
66
|
+
"liquidity",
|
|
67
|
+
"typescript",
|
|
68
|
+
"sdk",
|
|
69
|
+
"web3",
|
|
70
|
+
"crypto"
|
|
71
|
+
],
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=18.0.0",
|
|
74
|
+
"npm": ">=8.0.0"
|
|
75
|
+
},
|
|
76
|
+
"sideEffects": false,
|
|
77
|
+
"files": [
|
|
78
|
+
"dist",
|
|
79
|
+
"src"
|
|
80
|
+
],
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "yarn copy-idl && tsc",
|
|
83
|
+
"copy-idl": "cp ../../target/idl/*.json src/idl/ && cp ../../target/types/*.ts src/idl/",
|
|
84
|
+
"clean": "rm -rf dist",
|
|
85
|
+
"prebuild": "yarn clean",
|
|
86
|
+
"prepack": "yarn build",
|
|
87
|
+
"prepublishOnly": "yarn test:build",
|
|
88
|
+
"test:build": "tsc --noEmit",
|
|
89
|
+
"version:patch": "npm version patch",
|
|
90
|
+
"version:minor": "npm version minor",
|
|
91
|
+
"version:major": "npm version major",
|
|
92
|
+
"docs": "typedoc",
|
|
93
|
+
"publish:test": "npm publish --dry-run",
|
|
94
|
+
"publish:prod": "npm publish"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@coral-xyz/anchor": ">=0.30.0",
|
|
98
|
+
"@solana/spl-token": ">=0.4.0",
|
|
99
|
+
"@solana/web3.js": ">=1.70.0",
|
|
100
|
+
"bn.js": ">=5.0.0"
|
|
101
|
+
},
|
|
102
|
+
"devDependencies": {
|
|
103
|
+
"@coral-xyz/anchor": "^0.32.1",
|
|
104
|
+
"@solana/spl-token": "^0.4.14",
|
|
105
|
+
"@solana/web3.js": "^1.95.0",
|
|
106
|
+
"@types/bn.js": "^5.1.0",
|
|
107
|
+
"bn.js": "^5.2.1",
|
|
108
|
+
"typedoc": "^0.28.16",
|
|
109
|
+
"typescript": "^5.7.3"
|
|
110
|
+
},
|
|
111
|
+
"license": "ISC"
|
|
112
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export {
|
|
2
|
+
fetchLiquidGlobalConfig,
|
|
3
|
+
fetchNativeBondingCurve,
|
|
4
|
+
fetchNativeBondingCurveByAddress,
|
|
5
|
+
fetchStableBondingCurve,
|
|
6
|
+
fetchStableBondingCurveByAddress,
|
|
7
|
+
} from "./liquid.js";
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
fetchAmmConfig,
|
|
11
|
+
fetchPoolState,
|
|
12
|
+
fetchPoolStateByAddress,
|
|
13
|
+
fetchObservationState,
|
|
14
|
+
} from "./liquid-swap.js";
|
|
15
|
+
|
|
16
|
+
export { fetchFeeConfig, fetchFeeConfigByAddress } from "./liquid-fees.js";
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
fetchUserProperties,
|
|
20
|
+
fetchTokenVolume,
|
|
21
|
+
fetchGlobalCurveVolume,
|
|
22
|
+
fetchGlobalAmmVolume,
|
|
23
|
+
fetchCashbackConfig,
|
|
24
|
+
fetchUserSnapshot,
|
|
25
|
+
fetchDeal,
|
|
26
|
+
} from "./liquid-state.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { LiquidConfig } from "../config.js";
|
|
3
|
+
import { getFeeConfigPDA } from "../pda/liquid-fees.js";
|
|
4
|
+
import { getLiquidFeesProgram } from "../idl/index.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the fee configuration for a token mint.
|
|
8
|
+
*
|
|
9
|
+
* @param connection - Solana RPC connection
|
|
10
|
+
* @param tokenMint - Token mint address
|
|
11
|
+
* @param config - Liquid protocol configuration
|
|
12
|
+
* @returns The deserialized fee configuration account
|
|
13
|
+
*/
|
|
14
|
+
export async function fetchFeeConfig(
|
|
15
|
+
connection: Connection,
|
|
16
|
+
tokenMint: PublicKey,
|
|
17
|
+
config: LiquidConfig
|
|
18
|
+
) {
|
|
19
|
+
const [pda] = getFeeConfigPDA(tokenMint, config.liquidFeesProgramId);
|
|
20
|
+
return fetchFeeConfigByAddress(connection, pda, config);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Fetches the fee configuration by its PDA address directly.
|
|
25
|
+
*
|
|
26
|
+
* @param connection - Solana RPC connection
|
|
27
|
+
* @param feeConfigAddress - The fee configuration PDA address
|
|
28
|
+
* @param config - Liquid protocol configuration
|
|
29
|
+
* @returns The deserialized fee configuration account
|
|
30
|
+
*/
|
|
31
|
+
export async function fetchFeeConfigByAddress(
|
|
32
|
+
connection: Connection,
|
|
33
|
+
feeConfigAddress: PublicKey,
|
|
34
|
+
config: LiquidConfig
|
|
35
|
+
) {
|
|
36
|
+
const program = getLiquidFeesProgram(connection, config);
|
|
37
|
+
return program.account.unifiedFeeConfiguration.fetch(feeConfigAddress);
|
|
38
|
+
}
|