@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,134 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { LiquidConfig } from "../config.js";
|
|
3
|
+
import {
|
|
4
|
+
getUserPropertiesPDA,
|
|
5
|
+
getTokenVolumePDA,
|
|
6
|
+
getGlobalCurveVolumePDA,
|
|
7
|
+
getGlobalAmmVolumePDA,
|
|
8
|
+
getCashbackConfigPDA,
|
|
9
|
+
getUserSnapshotPDA,
|
|
10
|
+
getDealPDA,
|
|
11
|
+
} from "../pda/liquid-state.js";
|
|
12
|
+
import { getLiquidStateProgram } from "../idl/index.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Fetches a user's properties (referrer, volumes, cashback state).
|
|
16
|
+
*
|
|
17
|
+
* @param connection - Solana RPC connection
|
|
18
|
+
* @param user - User's public key
|
|
19
|
+
* @param config - Liquid protocol configuration
|
|
20
|
+
* @returns The deserialized user properties account
|
|
21
|
+
*/
|
|
22
|
+
export async function fetchUserProperties(
|
|
23
|
+
connection: Connection,
|
|
24
|
+
user: PublicKey,
|
|
25
|
+
config: LiquidConfig
|
|
26
|
+
) {
|
|
27
|
+
const program = getLiquidStateProgram(connection, config);
|
|
28
|
+
const [pda] = getUserPropertiesPDA(user, config.liquidStateProgramId);
|
|
29
|
+
return program.account.userProperties.fetch(pda);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fetches the token volume accumulator for a mint.
|
|
34
|
+
*
|
|
35
|
+
* @param connection - Solana RPC connection
|
|
36
|
+
* @param mint - Token mint address
|
|
37
|
+
* @param config - Liquid protocol configuration
|
|
38
|
+
* @returns The deserialized token volume accumulator account
|
|
39
|
+
*/
|
|
40
|
+
export async function fetchTokenVolume(
|
|
41
|
+
connection: Connection,
|
|
42
|
+
mint: PublicKey,
|
|
43
|
+
config: LiquidConfig
|
|
44
|
+
) {
|
|
45
|
+
const program = getLiquidStateProgram(connection, config);
|
|
46
|
+
const [pda] = getTokenVolumePDA(mint, config.liquidStateProgramId);
|
|
47
|
+
return program.account.tokenVolumeAccumulator.fetch(pda);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Fetches the global curve volume accumulator.
|
|
52
|
+
*
|
|
53
|
+
* @param connection - Solana RPC connection
|
|
54
|
+
* @param config - Liquid protocol configuration
|
|
55
|
+
* @returns The deserialized global curve volume accumulator account
|
|
56
|
+
*/
|
|
57
|
+
export async function fetchGlobalCurveVolume(
|
|
58
|
+
connection: Connection,
|
|
59
|
+
config: LiquidConfig
|
|
60
|
+
) {
|
|
61
|
+
const program = getLiquidStateProgram(connection, config);
|
|
62
|
+
const [pda] = getGlobalCurveVolumePDA(config.liquidStateProgramId);
|
|
63
|
+
return program.account.globalCurveVolumeAccumulator.fetch(pda);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Fetches the global AMM volume accumulator.
|
|
68
|
+
*
|
|
69
|
+
* @param connection - Solana RPC connection
|
|
70
|
+
* @param config - Liquid protocol configuration
|
|
71
|
+
* @returns The deserialized global AMM volume accumulator account
|
|
72
|
+
*/
|
|
73
|
+
export async function fetchGlobalAmmVolume(
|
|
74
|
+
connection: Connection,
|
|
75
|
+
config: LiquidConfig
|
|
76
|
+
) {
|
|
77
|
+
const program = getLiquidStateProgram(connection, config);
|
|
78
|
+
const [pda] = getGlobalAmmVolumePDA(config.liquidStateProgramId);
|
|
79
|
+
return program.account.globalAmmVolumeAccumulator.fetch(pda);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Fetches the cashback configuration.
|
|
84
|
+
*
|
|
85
|
+
* @param connection - Solana RPC connection
|
|
86
|
+
* @param config - Liquid protocol configuration
|
|
87
|
+
* @returns The deserialized cashback configuration account
|
|
88
|
+
*/
|
|
89
|
+
export async function fetchCashbackConfig(
|
|
90
|
+
connection: Connection,
|
|
91
|
+
config: LiquidConfig
|
|
92
|
+
) {
|
|
93
|
+
const program = getLiquidStateProgram(connection, config);
|
|
94
|
+
const [pda] = getCashbackConfigPDA(config.liquidStateProgramId);
|
|
95
|
+
return program.account.cashbackConfiguration.fetch(pda);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Fetches a user snapshot by user and index.
|
|
100
|
+
*
|
|
101
|
+
* @param connection - Solana RPC connection
|
|
102
|
+
* @param user - User's public key
|
|
103
|
+
* @param index - Snapshot index (0-based)
|
|
104
|
+
* @param config - Liquid protocol configuration
|
|
105
|
+
* @returns The deserialized user snapshot account
|
|
106
|
+
*/
|
|
107
|
+
export async function fetchUserSnapshot(
|
|
108
|
+
connection: Connection,
|
|
109
|
+
user: PublicKey,
|
|
110
|
+
index: number,
|
|
111
|
+
config: LiquidConfig
|
|
112
|
+
) {
|
|
113
|
+
const program = getLiquidStateProgram(connection, config);
|
|
114
|
+
const [pda] = getUserSnapshotPDA(user, index, config.liquidStateProgramId);
|
|
115
|
+
return program.account.userSnapshot.fetch(pda);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Fetches a deal account by its owner.
|
|
120
|
+
*
|
|
121
|
+
* @param connection - Solana RPC connection
|
|
122
|
+
* @param owner - Deal owner's public key
|
|
123
|
+
* @param config - Liquid protocol configuration
|
|
124
|
+
* @returns The deserialized deal account
|
|
125
|
+
*/
|
|
126
|
+
export async function fetchDeal(
|
|
127
|
+
connection: Connection,
|
|
128
|
+
owner: PublicKey,
|
|
129
|
+
config: LiquidConfig
|
|
130
|
+
) {
|
|
131
|
+
const program = getLiquidStateProgram(connection, config);
|
|
132
|
+
const [pda] = getDealPDA(owner, config.liquidStateProgramId);
|
|
133
|
+
return program.account.deal.fetch(pda);
|
|
134
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { LiquidConfig } from "../config.js";
|
|
3
|
+
import {
|
|
4
|
+
getSwapGlobalConfigPDA,
|
|
5
|
+
getPoolPDA,
|
|
6
|
+
getObservationPDA,
|
|
7
|
+
} from "../pda/liquid-swap.js";
|
|
8
|
+
import { getLiquidSwapProgram } from "../idl/index.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Fetches the AMM global configuration.
|
|
12
|
+
*
|
|
13
|
+
* @param connection - Solana RPC connection
|
|
14
|
+
* @param config - Liquid protocol configuration
|
|
15
|
+
* @returns The deserialized AMM configuration account
|
|
16
|
+
*/
|
|
17
|
+
export async function fetchAmmConfig(
|
|
18
|
+
connection: Connection,
|
|
19
|
+
config: LiquidConfig
|
|
20
|
+
) {
|
|
21
|
+
const program = getLiquidSwapProgram(connection, config);
|
|
22
|
+
const [pda] = getSwapGlobalConfigPDA(config.liquidSwapProgramId);
|
|
23
|
+
return program.account.ammConfig.fetch(pda);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches an AMM pool state by base and quote mint.
|
|
28
|
+
*
|
|
29
|
+
* @param connection - Solana RPC connection
|
|
30
|
+
* @param baseMint - Base token mint address
|
|
31
|
+
* @param quoteMint - Quote token mint address
|
|
32
|
+
* @param config - Liquid protocol configuration
|
|
33
|
+
* @returns The deserialized pool state account
|
|
34
|
+
*/
|
|
35
|
+
export async function fetchPoolState(
|
|
36
|
+
connection: Connection,
|
|
37
|
+
baseMint: PublicKey,
|
|
38
|
+
quoteMint: PublicKey,
|
|
39
|
+
config: LiquidConfig
|
|
40
|
+
) {
|
|
41
|
+
const program = getLiquidSwapProgram(connection, config);
|
|
42
|
+
const [pda] = getPoolPDA(baseMint, quoteMint, config.liquidSwapProgramId);
|
|
43
|
+
return program.account.poolState.fetch(pda);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Fetches a pool state by its PDA address directly.
|
|
48
|
+
*
|
|
49
|
+
* @param connection - Solana RPC connection
|
|
50
|
+
* @param poolAddress - The pool state PDA address
|
|
51
|
+
* @param config - Liquid protocol configuration
|
|
52
|
+
* @returns The deserialized pool state account
|
|
53
|
+
*/
|
|
54
|
+
export async function fetchPoolStateByAddress(
|
|
55
|
+
connection: Connection,
|
|
56
|
+
poolAddress: PublicKey,
|
|
57
|
+
config: LiquidConfig
|
|
58
|
+
) {
|
|
59
|
+
const program = getLiquidSwapProgram(connection, config);
|
|
60
|
+
return program.account.poolState.fetch(poolAddress);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Fetches the observation state (oracle) for a pool.
|
|
65
|
+
*
|
|
66
|
+
* @param connection - Solana RPC connection
|
|
67
|
+
* @param poolAddress - The pool state PDA address
|
|
68
|
+
* @param config - Liquid protocol configuration
|
|
69
|
+
* @returns The deserialized observation state account
|
|
70
|
+
*/
|
|
71
|
+
export async function fetchObservationState(
|
|
72
|
+
connection: Connection,
|
|
73
|
+
poolAddress: PublicKey,
|
|
74
|
+
config: LiquidConfig
|
|
75
|
+
) {
|
|
76
|
+
const program = getLiquidSwapProgram(connection, config);
|
|
77
|
+
const [pda] = getObservationPDA(poolAddress, config.liquidSwapProgramId);
|
|
78
|
+
return program.account.observationState.fetch(pda);
|
|
79
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { LiquidConfig } from "../config.js";
|
|
3
|
+
import {
|
|
4
|
+
getLiquidGlobalConfigPDA,
|
|
5
|
+
getBondingCurvePDA,
|
|
6
|
+
getStableBondingCurvePDA,
|
|
7
|
+
} from "../pda/liquid.js";
|
|
8
|
+
import { getLiquidProgram } from "../idl/index.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Fetches the global configuration for the bonding curve program.
|
|
12
|
+
*
|
|
13
|
+
* @param connection - Solana RPC connection
|
|
14
|
+
* @param config - Liquid protocol configuration
|
|
15
|
+
* @returns The deserialized global configuration account
|
|
16
|
+
*/
|
|
17
|
+
export async function fetchLiquidGlobalConfig(
|
|
18
|
+
connection: Connection,
|
|
19
|
+
config: LiquidConfig
|
|
20
|
+
) {
|
|
21
|
+
const program = getLiquidProgram(connection, config);
|
|
22
|
+
const [pda] = getLiquidGlobalConfigPDA(config.liquidProgramId);
|
|
23
|
+
return program.account.globalConfiguration.fetch(pda);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches a bonding curve account by mint address.
|
|
28
|
+
*
|
|
29
|
+
* @param connection - Solana RPC connection
|
|
30
|
+
* @param mint - Token mint address
|
|
31
|
+
* @param config - Liquid protocol configuration
|
|
32
|
+
* @returns The deserialized bonding curve account
|
|
33
|
+
*/
|
|
34
|
+
export async function fetchNativeBondingCurve(
|
|
35
|
+
connection: Connection,
|
|
36
|
+
mint: PublicKey,
|
|
37
|
+
config: LiquidConfig
|
|
38
|
+
) {
|
|
39
|
+
const program = getLiquidProgram(connection, config);
|
|
40
|
+
const [pda] = getBondingCurvePDA(mint, config.liquidProgramId);
|
|
41
|
+
return program.account.nativeBondingCurve.fetch(pda);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Fetches a bonding curve account by its PDA address directly.
|
|
46
|
+
*
|
|
47
|
+
* @param connection - Solana RPC connection
|
|
48
|
+
* @param bondingCurveAddress - The bonding curve PDA address
|
|
49
|
+
* @param config - Liquid protocol configuration
|
|
50
|
+
* @returns The deserialized bonding curve account
|
|
51
|
+
*/
|
|
52
|
+
export async function fetchNativeBondingCurveByAddress(
|
|
53
|
+
connection: Connection,
|
|
54
|
+
bondingCurveAddress: PublicKey,
|
|
55
|
+
config: LiquidConfig
|
|
56
|
+
) {
|
|
57
|
+
const program = getLiquidProgram(connection, config);
|
|
58
|
+
return program.account.nativeBondingCurve.fetch(bondingCurveAddress);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Fetches a token bonding curve account by mint and quote mint addresses.
|
|
63
|
+
*
|
|
64
|
+
* @param connection - Solana RPC connection
|
|
65
|
+
* @param mint - Token mint address (base token)
|
|
66
|
+
* @param quoteMint - Quote token mint address (e.g., USDC)
|
|
67
|
+
* @param config - Liquid protocol configuration
|
|
68
|
+
* @returns The deserialized token bonding curve account
|
|
69
|
+
*/
|
|
70
|
+
export async function fetchStableBondingCurve(
|
|
71
|
+
connection: Connection,
|
|
72
|
+
mint: PublicKey,
|
|
73
|
+
quoteMint: PublicKey,
|
|
74
|
+
config: LiquidConfig
|
|
75
|
+
) {
|
|
76
|
+
const program = getLiquidProgram(connection, config);
|
|
77
|
+
const [pda] = getStableBondingCurvePDA(
|
|
78
|
+
mint,
|
|
79
|
+
quoteMint,
|
|
80
|
+
config.liquidProgramId
|
|
81
|
+
);
|
|
82
|
+
return program.account.stableBondingCurve.fetch(pda);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Fetches a token bonding curve account by its PDA address directly.
|
|
87
|
+
*
|
|
88
|
+
* @param connection - Solana RPC connection
|
|
89
|
+
* @param stableBondingCurveAddress - The token bonding curve PDA address
|
|
90
|
+
* @param config - Liquid protocol configuration
|
|
91
|
+
* @returns The deserialized token bonding curve account
|
|
92
|
+
*/
|
|
93
|
+
export async function fetchStableBondingCurveByAddress(
|
|
94
|
+
connection: Connection,
|
|
95
|
+
stableBondingCurveAddress: PublicKey,
|
|
96
|
+
config: LiquidConfig
|
|
97
|
+
) {
|
|
98
|
+
const program = getLiquidProgram(connection, config);
|
|
99
|
+
return program.account.stableBondingCurve.fetch(stableBondingCurveAddress);
|
|
100
|
+
}
|