@meteora-ag/dynamic-bonding-curve-sdk 1.0.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/docs.md ADDED
@@ -0,0 +1,317 @@
1
+ # Dynamic Bonding Curve SDK: Function Documentation
2
+
3
+ ## Table of Contents
4
+
5
+ - [Partner Functions](#partner-functions)
6
+
7
+ - [createConfig](#createConfig)
8
+ - [createConstantProductConfigWithLockVesting](#createConstantProductConfigWithLockVesting)
9
+ - [createConstantProductConfigWithoutLockVesting](#createConstantProductConfigWithoutLockVesting)
10
+ - [createPartnerMetadata](#createPartnerMetadata)
11
+ - [claimTradingFee](#claimTradingFee)
12
+ - [partnerWithdrawSurplus](#partnerWithdrawSurplus)
13
+ - [withdrawLeftover](#withdrawLeftover)
14
+
15
+ - [Pool Functions](#pool-functions)
16
+
17
+ - [createPool](#createPool)
18
+ - [createPoolMetadata](#createPoolMetadata)
19
+ - [swap](#swap)
20
+ - [swapQuote](#swapQuote)
21
+
22
+ - [Migration Functions](#migration-functions)
23
+
24
+ - [createDammMigrationMetadata](#createDammMigrationMetadata)
25
+ - [createLocker](#createLocker)
26
+ - [migrateToDammV1](#migrateToDammV1)
27
+ - [lockDammV1LpToken](#lockDammV1LpToken)
28
+ - [claimDammV1LpToken](#claimDammV1LpToken)
29
+ - [migrateToDammV2](#migrateToDammV2)
30
+
31
+ - [Helper Functions](#helper-functions)
32
+
33
+ - [getPool](#getPool)
34
+ - [getPools](#getPools)
35
+ - [getPoolConfig](#getPoolConfig)
36
+ - [getPoolMigrationQuoteThreshold](#getPoolMigrationQuoteThreshold)
37
+ - [getPoolMetadata](#getPoolMetadata)
38
+ - [getPartnerMetadata](#getPartnerMetadata)
39
+ - [getDammV1MigrationMetadata](#getDammV1MigrationMetadata)
40
+ - [getLockedLpTokenAmount](#getLockedLpTokenAmount)
41
+
42
+ ---
43
+
44
+ ## Partner Functions
45
+
46
+ ### createConfig
47
+
48
+ Creates a new configuration key that will dictate the behavior of all pools created with this key.
49
+
50
+ #### Function
51
+
52
+ ```typescript
53
+ async createConfig(createConfigParam: CreateConfigParam): Promise<Transaction>
54
+ ```
55
+
56
+ #### Parameters
57
+
58
+ ```typescript
59
+ interface CreateConfigParam {
60
+ payer: PublicKey
61
+ config: PublicKey
62
+ feeClaimer: PublicKey
63
+ leftoverReceiver: PublicKey
64
+ quoteMint: PublicKey
65
+ poolFees: {
66
+ baseFee: {
67
+ cliffFeeNumerator: BN
68
+ numberOfPeriod: number
69
+ reductionFactor: BN
70
+ periodFrequency: BN
71
+ feeSchedulerMode: number
72
+ }
73
+ dynamicFee: {
74
+ binStep: number
75
+ binStepU128: BN
76
+ filterPeriod: number
77
+ decayPeriod: number
78
+ reductionFactor: number
79
+ variableFeeControl: number
80
+ maxVolatilityAccumulator: number
81
+ }
82
+ }
83
+ activationType: number
84
+ collectFeeMode: number
85
+ migrationOption: number
86
+ tokenType: number
87
+ tokenDecimal: number
88
+ migrationQuoteThreshold: BN
89
+ partnerLpPercentage: number
90
+ creatorLpPercentage: number
91
+ partnerLockedLpPercentage: number
92
+ creatorLockedLpPercentage: number
93
+ sqrtStartPrice: BN
94
+ lockedVesting: {
95
+ amountPerPeriod: BN
96
+ cliffDurationFromMigrationTime: BN
97
+ frequency: BN
98
+ numberOfPeriod: BN
99
+ cliffUnlockAmount: BN
100
+ }
101
+ migrationFeeOption: number
102
+ tokenSupply: {
103
+ preMigrationTokenSupply: BN
104
+ postMigrationTokenSupply: BN
105
+ }
106
+ padding: BN[]
107
+ curve: {
108
+ sqrtPrice: BN
109
+ liquidity: BN
110
+ }[]
111
+ }
112
+ ```
113
+
114
+ #### Returns
115
+
116
+ A transaction that can be partially signed and sent to the network.
117
+
118
+ #### Example
119
+
120
+ ```typescript
121
+ const transaction = await client.partners.createConfig({
122
+ payer: wallet.publicKey,
123
+ config: config.publicKey,
124
+ feeClaimer: wallet.publicKey,
125
+ leftoverReceiver: wallet.publicKey,
126
+ quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
127
+ poolFees: {
128
+ baseFee: {
129
+ cliffFeeNumerator: new BN('2500000'),
130
+ numberOfPeriod: 0,
131
+ reductionFactor: new BN('0'),
132
+ periodFrequency: new BN('0'),
133
+ feeSchedulerMode: FeeSchedulerMode.Linear,
134
+ },
135
+ dynamicFee: {
136
+ binStep: 1,
137
+ binStepU128: new BN('1844674407370955'),
138
+ filterPeriod: 10,
139
+ decayPeriod: 120,
140
+ reductionFactor: 1000,
141
+ variableFeeControl: 100000,
142
+ maxVolatilityAccumulator: 100000,
143
+ },
144
+ },
145
+ activationType: 0,
146
+ collectFeeMode: 0,
147
+ migrationOption: 0
148
+ tokenType: 0,
149
+ tokenDecimal: 9,
150
+ migrationQuoteThreshold: new BN('1000000000'),
151
+ partnerLpPercentage: 25,
152
+ creatorLpPercentage: 25,
153
+ partnerLockedLpPercentage: 25,
154
+ creatorLockedLpPercentage: 25,
155
+ sqrtStartPrice: new BN('58333726687135158'),
156
+ lockedVesting: {
157
+ amountPerPeriod: new BN('0'),
158
+ cliffDurationFromMigrationTime: new BN('0'),
159
+ frequency: new BN('0'),
160
+ numberOfPeriod: new BN('0'),
161
+ cliffUnlockAmount: new BN('0'),
162
+ },
163
+ migrationFeeOption: 0,
164
+ tokenSupply: {
165
+ preMigrationTokenSupply: new BN('10000000000000000000'),
166
+ postMigrationTokenSupply: new BN('10000000000000000000'),
167
+ },
168
+ padding: [
169
+ new BN(0),
170
+ new BN(0),
171
+ new BN(0),
172
+ new BN(0),
173
+ new BN(0),
174
+ new BN(0),
175
+ new BN(0),
176
+ ],
177
+ curve: [
178
+ {
179
+ sqrtPrice: new BN('233334906748540631'),
180
+ liquidity: new BN('622226417996106429201027821619672729'),
181
+ },
182
+ {
183
+ sqrtPrice: new BN('79226673521066979257578248091'),
184
+ liquidity: new BN('1'),
185
+ },
186
+ ],
187
+ })
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Pool Functions
193
+
194
+ ### createPool
195
+
196
+ Creates a new pool with the configuration key.
197
+
198
+ #### Function
199
+
200
+ ```typescript
201
+ async createPool(createPoolParam: CreatePoolParam): Promise<Transaction>
202
+ ```
203
+
204
+ #### Parameters
205
+
206
+ ```typescript
207
+ interface CreatePoolParam {
208
+ quoteMint: PublicKey
209
+ baseMint: PublicKey
210
+ config: PublicKey
211
+ baseTokenType: number
212
+ quoteTokenType: number
213
+ name: string
214
+ symbol: string
215
+ uri: string
216
+ creator: PublicKey
217
+ }
218
+ ```
219
+
220
+ #### Returns
221
+
222
+ A transaction that requires signatures from both the creator's wallet and the baseMint keypair before being submitted to the network.
223
+
224
+ #### Example
225
+
226
+ ```typescript
227
+ const transaction = await client.pools.createPool({
228
+ quoteMint: new PublicKey('So11111111111111111111111111111111111111112'),
229
+ baseMint: new PublicKey('JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN'),
230
+ config: config.publicKey,
231
+ baseTokenType: 0,
232
+ quoteTokenType: 0,
233
+ name: 'Jupiter',
234
+ symbol: 'JUP',
235
+ uri: 'https://jup.ag',
236
+ creator: wallet.publicKey,
237
+ })
238
+ ```
239
+
240
+ ---
241
+
242
+ ### swap
243
+
244
+ Swaps between base and quote or quote and base.
245
+
246
+ #### Function
247
+
248
+ ```typescript
249
+ async swap(pool: PublicKey, swapParam: SwapParam): Promise<Transaction>
250
+ ```
251
+
252
+ #### Parameters
253
+
254
+ ```typescript
255
+ interface SwapParam {
256
+ owner: PublicKey
257
+ amountIn: BN
258
+ minimumAmountOut: BN
259
+ swapBaseForQuote: boolean
260
+ }
261
+ ```
262
+
263
+ #### Returns
264
+
265
+ A transaction that can be signed and sent to the network.
266
+
267
+ #### Example
268
+
269
+ ```typescript
270
+ const transaction = await client.pools.swap(poolAddress, {
271
+ owner: wallet.publicKey,
272
+ amountIn: new BN(1000000000),
273
+ minimumAmountOut: new BN(0),
274
+ swapBaseForQuote: false,
275
+ })
276
+ ```
277
+
278
+ ---
279
+
280
+ ### swapQuote
281
+
282
+ Swaps between base and quote or quote and base.
283
+
284
+ #### Function
285
+
286
+ ```typescript
287
+ swapQuote(swapQuoteParam: SwapQuoteParam): Promise<QuoteResult>
288
+ ```
289
+
290
+ #### Parameters
291
+
292
+ ```typescript
293
+ interface SwapQuoteParam {
294
+ virtualPool: VirtualPool
295
+ config: PoolConfig
296
+ swapBaseForQuote: boolean
297
+ amountIn: BN
298
+ hasReferral: boolean
299
+ currentPoint: BN
300
+ }
301
+ ```
302
+
303
+ #### Returns
304
+
305
+ The quote result of the swap.
306
+
307
+ #### Example
308
+
309
+ ```typescript
310
+ const quote = client.pools.swapQuote({
311
+ virtualPool,
312
+ swapBaseForQuote,
313
+ amountIn,
314
+ hasReferral,
315
+ currentPoint,
316
+ })
317
+ ```
@@ -0,0 +1,4 @@
1
+ import { config } from "@meteora-ag/ts-sdk-config/base";
2
+
3
+ /** @type {import("eslint").Linter.Config} */
4
+ export default config;
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@meteora-ag/dynamic-bonding-curve-sdk",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.cjs",
5
+ "module": "dist/index.js",
6
+ "source": "src/index.ts",
7
+ "types": "dist/index.d.ts",
8
+ "author": "Dann Wee <dann@raccoons.dev>",
9
+ "keywords": [
10
+ "meteora-ag",
11
+ "dynamic-bonding-curve",
12
+ "damm-v1",
13
+ "damm-v2",
14
+ "dynamic-vaults"
15
+ ],
16
+ "description": "A Typescript SDK for interacting with the Dynamic Bonding Curve on Meteora.",
17
+ "license": "MIT",
18
+ "type": "module",
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format esm,cjs --dts",
21
+ "clean": "rm -rf node_modules dist"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "devDependencies": {
31
+ "@meteora-ag/ts-sdk-config": "*",
32
+ "@types/bun": "latest",
33
+ "eslint": "^9.24.0",
34
+ "tsup": "^8.4.0",
35
+ "tsx": "^4.19.3"
36
+ },
37
+ "peerDependencies": {
38
+ "typescript": "^5"
39
+ },
40
+ "dependencies": {
41
+ "@coral-xyz/anchor": "^0.31.0",
42
+ "@solana/spl-token": "^0.4.13",
43
+ "@solana/web3.js": "^1.98.0",
44
+ "solana-bankrun": "^0.4.0"
45
+ }
46
+ }