@meteora-ag/zap-sdk 1.0.8 → 1.1.0-rc.2
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/dist/index.d.mts +1766 -25
- package/dist/index.d.ts +1766 -25
- package/dist/index.js +4094 -599
- package/dist/index.mjs +4135 -625
- package/package.json +7 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
-
import { PublicKey,
|
|
3
|
-
import {
|
|
2
|
+
import { PublicKey, TransactionInstruction, Transaction, AccountMeta, Connection } from '@solana/web3.js';
|
|
3
|
+
import { Program, IdlTypes } from '@coral-xyz/anchor';
|
|
4
4
|
import BN from 'bn.js';
|
|
5
|
+
import Decimal from 'decimal.js';
|
|
6
|
+
import DLMM, { StrategyType, SwapQuote, LbPair, BinArrayBitmapExtension, RemainingAccountInfo } from '@meteora-ag/dlmm';
|
|
5
7
|
import { PoolState } from '@meteora-ag/cp-amm-sdk';
|
|
6
|
-
import { LbPair, BinArrayBitmapExtension, RemainingAccountInfo } from '@meteora-ag/dlmm';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -12,14 +13,432 @@ import { LbPair, BinArrayBitmapExtension, RemainingAccountInfo } from '@meteora-
|
|
|
12
13
|
* IDL can be found at `target/idl/zap.json`.
|
|
13
14
|
*/
|
|
14
15
|
type Zap$1 = {
|
|
15
|
-
address: "
|
|
16
|
+
address: "TzaptpzVczx3Q3rwujjXdhx1HFBXLP7UApACiqWujtA";
|
|
16
17
|
metadata: {
|
|
17
18
|
name: "zap";
|
|
18
|
-
version: "0.
|
|
19
|
+
version: "0.2.0";
|
|
19
20
|
spec: "0.1.0";
|
|
20
21
|
description: "Created with Anchor";
|
|
21
22
|
};
|
|
22
23
|
instructions: [
|
|
24
|
+
{
|
|
25
|
+
name: "closeLedgerAccount";
|
|
26
|
+
discriminator: [189, 122, 172, 13, 122, 54, 54, 51];
|
|
27
|
+
accounts: [
|
|
28
|
+
{
|
|
29
|
+
name: "ledger";
|
|
30
|
+
writable: true;
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "owner";
|
|
34
|
+
signer: true;
|
|
35
|
+
relations: ["ledger"];
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "rentReceiver";
|
|
39
|
+
writable: true;
|
|
40
|
+
signer: true;
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
args: [];
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "initializeLedgerAccount";
|
|
47
|
+
discriminator: [120, 69, 30, 74, 76, 242, 153, 162];
|
|
48
|
+
accounts: [
|
|
49
|
+
{
|
|
50
|
+
name: "ledger";
|
|
51
|
+
writable: true;
|
|
52
|
+
pda: {
|
|
53
|
+
seeds: [
|
|
54
|
+
{
|
|
55
|
+
kind: "const";
|
|
56
|
+
value: [117, 115, 101, 114, 95, 108, 101, 100, 103, 101, 114];
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
kind: "account";
|
|
60
|
+
path: "owner";
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "owner";
|
|
67
|
+
signer: true;
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "payer";
|
|
71
|
+
writable: true;
|
|
72
|
+
signer: true;
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "systemProgram";
|
|
76
|
+
address: "11111111111111111111111111111111";
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
args: [];
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "setLedgerBalance";
|
|
83
|
+
discriminator: [131, 49, 240, 17, 228, 248, 156, 54];
|
|
84
|
+
accounts: [
|
|
85
|
+
{
|
|
86
|
+
name: "ledger";
|
|
87
|
+
writable: true;
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "owner";
|
|
91
|
+
signer: true;
|
|
92
|
+
relations: ["ledger"];
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
args: [
|
|
96
|
+
{
|
|
97
|
+
name: "amount";
|
|
98
|
+
type: "u64";
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "isTokenA";
|
|
102
|
+
type: "bool";
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "updateLedgerBalanceAfterSwap";
|
|
108
|
+
discriminator: [59, 206, 173, 232, 94, 57, 174, 202];
|
|
109
|
+
accounts: [
|
|
110
|
+
{
|
|
111
|
+
name: "ledger";
|
|
112
|
+
writable: true;
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "tokenAccount";
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "owner";
|
|
119
|
+
signer: true;
|
|
120
|
+
relations: ["ledger"];
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
args: [
|
|
124
|
+
{
|
|
125
|
+
name: "preSourceTokenBalance";
|
|
126
|
+
type: "u64";
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "maxTransferAmount";
|
|
130
|
+
type: "u64";
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "isTokenA";
|
|
134
|
+
type: "bool";
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "zapInDammV2";
|
|
140
|
+
discriminator: [243, 243, 119, 52, 199, 44, 154, 186];
|
|
141
|
+
accounts: [
|
|
142
|
+
{
|
|
143
|
+
name: "ledger";
|
|
144
|
+
writable: true;
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "pool";
|
|
148
|
+
writable: true;
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "poolAuthority";
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "position";
|
|
155
|
+
writable: true;
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "tokenAAccount";
|
|
159
|
+
writable: true;
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "tokenBAccount";
|
|
163
|
+
writable: true;
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "tokenAVault";
|
|
167
|
+
writable: true;
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "tokenBVault";
|
|
171
|
+
writable: true;
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "tokenAMint";
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "tokenBMint";
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "positionNftAccount";
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "owner";
|
|
184
|
+
docs: ["owner of position"];
|
|
185
|
+
signer: true;
|
|
186
|
+
relations: ["ledger"];
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "tokenAProgram";
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "tokenBProgram";
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "dammProgram";
|
|
196
|
+
address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "dammEventAuthority";
|
|
200
|
+
}
|
|
201
|
+
];
|
|
202
|
+
args: [
|
|
203
|
+
{
|
|
204
|
+
name: "preSqrtPrice";
|
|
205
|
+
type: "u128";
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "maxSqrtPriceChangeBps";
|
|
209
|
+
type: "u32";
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "zapInDlmmForInitializedPosition";
|
|
215
|
+
discriminator: [184, 71, 198, 231, 129, 110, 193, 67];
|
|
216
|
+
accounts: [
|
|
217
|
+
{
|
|
218
|
+
name: "ledger";
|
|
219
|
+
writable: true;
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "lbPair";
|
|
223
|
+
docs: ["lb pair"];
|
|
224
|
+
writable: true;
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "position";
|
|
228
|
+
writable: true;
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "binArrayBitmapExtension";
|
|
232
|
+
writable: true;
|
|
233
|
+
optional: true;
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "userTokenX";
|
|
237
|
+
writable: true;
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "userTokenY";
|
|
241
|
+
writable: true;
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "reserveX";
|
|
245
|
+
writable: true;
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "reserveY";
|
|
249
|
+
writable: true;
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "tokenXMint";
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "tokenYMint";
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "dlmmProgram";
|
|
259
|
+
address: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: "owner";
|
|
263
|
+
docs: ["owner of position"];
|
|
264
|
+
signer: true;
|
|
265
|
+
relations: ["ledger"];
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "rentPayer";
|
|
269
|
+
writable: true;
|
|
270
|
+
signer: true;
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "tokenXProgram";
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "tokenYProgram";
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "memoProgram";
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "systemProgram";
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "dlmmEventAuthority";
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
args: [
|
|
289
|
+
{
|
|
290
|
+
name: "activeId";
|
|
291
|
+
type: "i32";
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "minDeltaId";
|
|
295
|
+
type: "i32";
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "maxDeltaId";
|
|
299
|
+
type: "i32";
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "maxActiveBinSlippage";
|
|
303
|
+
type: "u16";
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
name: "favorXInActiveId";
|
|
307
|
+
type: "bool";
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "strategy";
|
|
311
|
+
type: {
|
|
312
|
+
defined: {
|
|
313
|
+
name: "strategyType";
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: "remainingAccountsInfo";
|
|
319
|
+
type: {
|
|
320
|
+
defined: {
|
|
321
|
+
name: "remainingAccountsInfo";
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
];
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "zapInDlmmForUninitializedPosition";
|
|
329
|
+
discriminator: [59, 220, 182, 27, 254, 253, 2, 232];
|
|
330
|
+
accounts: [
|
|
331
|
+
{
|
|
332
|
+
name: "ledger";
|
|
333
|
+
writable: true;
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "lbPair";
|
|
337
|
+
docs: ["lb pair"];
|
|
338
|
+
writable: true;
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "position";
|
|
342
|
+
docs: [
|
|
343
|
+
"user position",
|
|
344
|
+
"Check it is different from owner to advoid user to pass owner address wrongly"
|
|
345
|
+
];
|
|
346
|
+
writable: true;
|
|
347
|
+
signer: true;
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: "binArrayBitmapExtension";
|
|
351
|
+
writable: true;
|
|
352
|
+
optional: true;
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "userTokenX";
|
|
356
|
+
writable: true;
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "userTokenY";
|
|
360
|
+
writable: true;
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "reserveX";
|
|
364
|
+
writable: true;
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "reserveY";
|
|
368
|
+
writable: true;
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "tokenXMint";
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "tokenYMint";
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: "dlmmProgram";
|
|
378
|
+
address: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "owner";
|
|
382
|
+
docs: ["owner of position"];
|
|
383
|
+
signer: true;
|
|
384
|
+
relations: ["ledger"];
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
name: "rentPayer";
|
|
388
|
+
writable: true;
|
|
389
|
+
signer: true;
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "tokenXProgram";
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "tokenYProgram";
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
name: "memoProgram";
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "systemProgram";
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: "dlmmEventAuthority";
|
|
405
|
+
}
|
|
406
|
+
];
|
|
407
|
+
args: [
|
|
408
|
+
{
|
|
409
|
+
name: "binDelta";
|
|
410
|
+
type: "u8";
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "activeId";
|
|
414
|
+
type: "i32";
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "maxActiveBinSlippage";
|
|
418
|
+
type: "u16";
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: "favorXInActiveId";
|
|
422
|
+
type: "bool";
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "strategy";
|
|
426
|
+
type: {
|
|
427
|
+
defined: {
|
|
428
|
+
name: "strategyType";
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
name: "remainingAccountsInfo";
|
|
434
|
+
type: {
|
|
435
|
+
defined: {
|
|
436
|
+
name: "remainingAccountsInfo";
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
];
|
|
441
|
+
},
|
|
23
442
|
{
|
|
24
443
|
name: "zapOut";
|
|
25
444
|
discriminator: [155, 108, 185, 112, 104, 210, 161, 64];
|
|
@@ -44,34 +463,890 @@ type Zap$1 = {
|
|
|
44
463
|
];
|
|
45
464
|
}
|
|
46
465
|
];
|
|
47
|
-
|
|
466
|
+
accounts: [
|
|
48
467
|
{
|
|
49
|
-
|
|
468
|
+
name: "lbPair";
|
|
469
|
+
discriminator: [33, 11, 49, 98, 181, 101, 177, 13];
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: "pool";
|
|
473
|
+
discriminator: [241, 154, 109, 4, 17, 177, 109, 188];
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: "userLedger";
|
|
477
|
+
discriminator: [185, 84, 101, 128, 8, 6, 160, 83];
|
|
478
|
+
}
|
|
479
|
+
];
|
|
480
|
+
errors: [
|
|
481
|
+
{
|
|
482
|
+
code: 6000;
|
|
50
483
|
name: "mathOverflow";
|
|
51
484
|
msg: "Math operation overflow";
|
|
52
485
|
},
|
|
53
486
|
{
|
|
54
|
-
code: 6001;
|
|
55
|
-
name: "invalidOffset";
|
|
56
|
-
msg: "Invalid offset";
|
|
487
|
+
code: 6001;
|
|
488
|
+
name: "invalidOffset";
|
|
489
|
+
msg: "Invalid offset";
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
code: 6002;
|
|
493
|
+
name: "invalidZapOutParameters";
|
|
494
|
+
msg: "Invalid zapout parameters";
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
code: 6003;
|
|
498
|
+
name: "typeCastFailed";
|
|
499
|
+
msg: "Type cast error";
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
code: 6004;
|
|
503
|
+
name: "ammIsNotSupported";
|
|
504
|
+
msg: "Amm program is not supported";
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
code: 6005;
|
|
508
|
+
name: "invalidPosition";
|
|
509
|
+
msg: "Position is not empty";
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
code: 6006;
|
|
513
|
+
name: "exceededSlippage";
|
|
514
|
+
msg: "Exceeded slippage tolerance";
|
|
515
|
+
}
|
|
516
|
+
];
|
|
517
|
+
types: [
|
|
518
|
+
{
|
|
519
|
+
name: "accountsType";
|
|
520
|
+
type: {
|
|
521
|
+
kind: "enum";
|
|
522
|
+
variants: [
|
|
523
|
+
{
|
|
524
|
+
name: "transferHookX";
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
name: "transferHookY";
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: "transferHookReward";
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
name: "transferHookMultiReward";
|
|
534
|
+
fields: ["u8"];
|
|
535
|
+
}
|
|
536
|
+
];
|
|
537
|
+
};
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
name: "baseFeeStruct";
|
|
541
|
+
serialization: "bytemuck";
|
|
542
|
+
repr: {
|
|
543
|
+
kind: "c";
|
|
544
|
+
};
|
|
545
|
+
type: {
|
|
546
|
+
kind: "struct";
|
|
547
|
+
fields: [
|
|
548
|
+
{
|
|
549
|
+
name: "cliffFeeNumerator";
|
|
550
|
+
type: "u64";
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
name: "baseFeeMode";
|
|
554
|
+
type: "u8";
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
name: "padding0";
|
|
558
|
+
type: {
|
|
559
|
+
array: ["u8", 5];
|
|
560
|
+
};
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: "firstFactor";
|
|
564
|
+
type: "u16";
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
name: "secondFactor";
|
|
568
|
+
type: {
|
|
569
|
+
array: ["u8", 8];
|
|
570
|
+
};
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
name: "thirdFactor";
|
|
574
|
+
type: "u64";
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: "padding1";
|
|
578
|
+
type: "u64";
|
|
579
|
+
}
|
|
580
|
+
];
|
|
581
|
+
};
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
name: "dynamicFeeStruct";
|
|
585
|
+
serialization: "bytemuck";
|
|
586
|
+
repr: {
|
|
587
|
+
kind: "c";
|
|
588
|
+
};
|
|
589
|
+
type: {
|
|
590
|
+
kind: "struct";
|
|
591
|
+
fields: [
|
|
592
|
+
{
|
|
593
|
+
name: "initialized";
|
|
594
|
+
type: "u8";
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
name: "padding";
|
|
598
|
+
type: {
|
|
599
|
+
array: ["u8", 7];
|
|
600
|
+
};
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
name: "maxVolatilityAccumulator";
|
|
604
|
+
type: "u32";
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: "variableFeeControl";
|
|
608
|
+
type: "u32";
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
name: "binStep";
|
|
612
|
+
type: "u16";
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "filterPeriod";
|
|
616
|
+
type: "u16";
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "decayPeriod";
|
|
620
|
+
type: "u16";
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "reductionFactor";
|
|
624
|
+
type: "u16";
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: "lastUpdateTimestamp";
|
|
628
|
+
type: "u64";
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
name: "binStepU128";
|
|
632
|
+
type: "u128";
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: "sqrtPriceReference";
|
|
636
|
+
type: "u128";
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
name: "volatilityAccumulator";
|
|
640
|
+
type: "u128";
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
name: "volatilityReference";
|
|
644
|
+
type: "u128";
|
|
645
|
+
}
|
|
646
|
+
];
|
|
647
|
+
};
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
name: "lbPair";
|
|
651
|
+
serialization: "bytemuck";
|
|
652
|
+
repr: {
|
|
653
|
+
kind: "c";
|
|
654
|
+
};
|
|
655
|
+
type: {
|
|
656
|
+
kind: "struct";
|
|
657
|
+
fields: [
|
|
658
|
+
{
|
|
659
|
+
name: "parameters";
|
|
660
|
+
type: {
|
|
661
|
+
defined: {
|
|
662
|
+
name: "staticParameters";
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: "vParameters";
|
|
668
|
+
type: {
|
|
669
|
+
defined: {
|
|
670
|
+
name: "variableParameters";
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: "bumpSeed";
|
|
676
|
+
type: {
|
|
677
|
+
array: ["u8", 1];
|
|
678
|
+
};
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
name: "binStepSeed";
|
|
682
|
+
type: {
|
|
683
|
+
array: ["u8", 2];
|
|
684
|
+
};
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
name: "pairType";
|
|
688
|
+
type: "u8";
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
name: "activeId";
|
|
692
|
+
type: "i32";
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "binStep";
|
|
696
|
+
type: "u16";
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "status";
|
|
700
|
+
type: "u8";
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
name: "requireBaseFactorSeed";
|
|
704
|
+
type: "u8";
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
name: "baseFactorSeed";
|
|
708
|
+
type: {
|
|
709
|
+
array: ["u8", 2];
|
|
710
|
+
};
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
name: "activationType";
|
|
714
|
+
type: "u8";
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
name: "creatorPoolOnOffControl";
|
|
718
|
+
type: "u8";
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
name: "tokenXMint";
|
|
722
|
+
type: "pubkey";
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
name: "tokenYMint";
|
|
726
|
+
type: "pubkey";
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: "reserveX";
|
|
730
|
+
type: "pubkey";
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
name: "reserveY";
|
|
734
|
+
type: "pubkey";
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
name: "protocolFee";
|
|
738
|
+
type: {
|
|
739
|
+
defined: {
|
|
740
|
+
name: "protocolFee";
|
|
741
|
+
};
|
|
742
|
+
};
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
name: "padding1";
|
|
746
|
+
type: {
|
|
747
|
+
array: ["u8", 32];
|
|
748
|
+
};
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
name: "rewardInfos";
|
|
752
|
+
type: {
|
|
753
|
+
array: [
|
|
754
|
+
{
|
|
755
|
+
defined: {
|
|
756
|
+
name: "dlmm::dlmm::types::RewardInfo";
|
|
757
|
+
};
|
|
758
|
+
},
|
|
759
|
+
2
|
|
760
|
+
];
|
|
761
|
+
};
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
name: "oracle";
|
|
765
|
+
type: "pubkey";
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
name: "binArrayBitmap";
|
|
769
|
+
type: {
|
|
770
|
+
array: ["u64", 16];
|
|
771
|
+
};
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
name: "lastUpdatedAt";
|
|
775
|
+
type: "i64";
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
name: "padding2";
|
|
779
|
+
type: {
|
|
780
|
+
array: ["u8", 32];
|
|
781
|
+
};
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
name: "preActivationSwapAddress";
|
|
785
|
+
type: "pubkey";
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
name: "baseKey";
|
|
789
|
+
type: "pubkey";
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
name: "activationPoint";
|
|
793
|
+
type: "u64";
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
name: "preActivationDuration";
|
|
797
|
+
type: "u64";
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
name: "padding3";
|
|
801
|
+
type: {
|
|
802
|
+
array: ["u8", 8];
|
|
803
|
+
};
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
name: "padding4";
|
|
807
|
+
type: "u64";
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
name: "creator";
|
|
811
|
+
type: "pubkey";
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
name: "tokenMintXProgramFlag";
|
|
815
|
+
type: "u8";
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
name: "tokenMintYProgramFlag";
|
|
819
|
+
type: "u8";
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
name: "reserved";
|
|
823
|
+
type: {
|
|
824
|
+
array: ["u8", 22];
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
];
|
|
828
|
+
};
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
name: "pool";
|
|
832
|
+
serialization: "bytemuck";
|
|
833
|
+
repr: {
|
|
834
|
+
kind: "c";
|
|
835
|
+
};
|
|
836
|
+
type: {
|
|
837
|
+
kind: "struct";
|
|
838
|
+
fields: [
|
|
839
|
+
{
|
|
840
|
+
name: "poolFees";
|
|
841
|
+
docs: ["Pool fee"];
|
|
842
|
+
type: {
|
|
843
|
+
defined: {
|
|
844
|
+
name: "poolFeesStruct";
|
|
845
|
+
};
|
|
846
|
+
};
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
name: "tokenAMint";
|
|
850
|
+
docs: ["token a mint"];
|
|
851
|
+
type: "pubkey";
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
name: "tokenBMint";
|
|
855
|
+
docs: ["token b mint"];
|
|
856
|
+
type: "pubkey";
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
name: "tokenAVault";
|
|
860
|
+
docs: ["token a vault"];
|
|
861
|
+
type: "pubkey";
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: "tokenBVault";
|
|
865
|
+
docs: ["token b vault"];
|
|
866
|
+
type: "pubkey";
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
name: "whitelistedVault";
|
|
870
|
+
docs: [
|
|
871
|
+
"Whitelisted vault to be able to buy pool before activation_point"
|
|
872
|
+
];
|
|
873
|
+
type: "pubkey";
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
name: "partner";
|
|
877
|
+
docs: ["partner"];
|
|
878
|
+
type: "pubkey";
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
name: "liquidity";
|
|
882
|
+
docs: ["liquidity share"];
|
|
883
|
+
type: "u128";
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
name: "padding";
|
|
887
|
+
docs: [
|
|
888
|
+
"padding, previous reserve amount, be careful to use that field"
|
|
889
|
+
];
|
|
890
|
+
type: "u128";
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
name: "protocolAFee";
|
|
894
|
+
docs: ["protocol a fee"];
|
|
895
|
+
type: "u64";
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
name: "protocolBFee";
|
|
899
|
+
docs: ["protocol b fee"];
|
|
900
|
+
type: "u64";
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
name: "partnerAFee";
|
|
904
|
+
docs: ["partner a fee"];
|
|
905
|
+
type: "u64";
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
name: "partnerBFee";
|
|
909
|
+
docs: ["partner b fee"];
|
|
910
|
+
type: "u64";
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
name: "sqrtMinPrice";
|
|
914
|
+
docs: ["min price"];
|
|
915
|
+
type: "u128";
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
name: "sqrtMaxPrice";
|
|
919
|
+
docs: ["max price"];
|
|
920
|
+
type: "u128";
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
name: "sqrtPrice";
|
|
924
|
+
docs: ["current price"];
|
|
925
|
+
type: "u128";
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
name: "activationPoint";
|
|
929
|
+
docs: ["Activation point, can be slot or timestamp"];
|
|
930
|
+
type: "u64";
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
name: "activationType";
|
|
934
|
+
docs: ["Activation type, 0 means by slot, 1 means by timestamp"];
|
|
935
|
+
type: "u8";
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
name: "poolStatus";
|
|
939
|
+
docs: ["pool status, 0: enable, 1 disable"];
|
|
940
|
+
type: "u8";
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
name: "tokenAFlag";
|
|
944
|
+
docs: ["token a flag"];
|
|
945
|
+
type: "u8";
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
name: "tokenBFlag";
|
|
949
|
+
docs: ["token b flag"];
|
|
950
|
+
type: "u8";
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
name: "collectFeeMode";
|
|
954
|
+
docs: [
|
|
955
|
+
"0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b"
|
|
956
|
+
];
|
|
957
|
+
type: "u8";
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
name: "poolType";
|
|
961
|
+
docs: ["pool type"];
|
|
962
|
+
type: "u8";
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
name: "version";
|
|
966
|
+
docs: [
|
|
967
|
+
"pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
|
|
968
|
+
];
|
|
969
|
+
type: "u8";
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
name: "padding0";
|
|
973
|
+
docs: ["padding"];
|
|
974
|
+
type: "u8";
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
name: "feeAPerLiquidity";
|
|
978
|
+
docs: ["cumulative"];
|
|
979
|
+
type: {
|
|
980
|
+
array: ["u8", 32];
|
|
981
|
+
};
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
name: "feeBPerLiquidity";
|
|
985
|
+
docs: ["cumulative"];
|
|
986
|
+
type: {
|
|
987
|
+
array: ["u8", 32];
|
|
988
|
+
};
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
name: "permanentLockLiquidity";
|
|
992
|
+
type: "u128";
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
name: "metrics";
|
|
996
|
+
docs: ["metrics"];
|
|
997
|
+
type: {
|
|
998
|
+
defined: {
|
|
999
|
+
name: "poolMetrics";
|
|
1000
|
+
};
|
|
1001
|
+
};
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
name: "creator";
|
|
1005
|
+
docs: ["pool creator"];
|
|
1006
|
+
type: "pubkey";
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
name: "padding1";
|
|
1010
|
+
docs: ["Padding for further use"];
|
|
1011
|
+
type: {
|
|
1012
|
+
array: ["u64", 6];
|
|
1013
|
+
};
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
name: "rewardInfos";
|
|
1017
|
+
docs: ["Farming reward information"];
|
|
1018
|
+
type: {
|
|
1019
|
+
array: [
|
|
1020
|
+
{
|
|
1021
|
+
defined: {
|
|
1022
|
+
name: "cp_amm::state::pool::RewardInfo";
|
|
1023
|
+
};
|
|
1024
|
+
},
|
|
1025
|
+
2
|
|
1026
|
+
];
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
];
|
|
1030
|
+
};
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
name: "poolFeesStruct";
|
|
1034
|
+
docs: [
|
|
1035
|
+
"Information regarding fee charges",
|
|
1036
|
+
"trading_fee = amount * trade_fee_numerator / denominator",
|
|
1037
|
+
"protocol_fee = trading_fee * protocol_fee_percentage / 100",
|
|
1038
|
+
"referral_fee = protocol_fee * referral_percentage / 100",
|
|
1039
|
+
"partner_fee = (protocol_fee - referral_fee) * partner_fee_percentage / denominator"
|
|
1040
|
+
];
|
|
1041
|
+
serialization: "bytemuck";
|
|
1042
|
+
repr: {
|
|
1043
|
+
kind: "c";
|
|
1044
|
+
};
|
|
1045
|
+
type: {
|
|
1046
|
+
kind: "struct";
|
|
1047
|
+
fields: [
|
|
1048
|
+
{
|
|
1049
|
+
name: "baseFee";
|
|
1050
|
+
docs: [
|
|
1051
|
+
"Trade fees are extra token amounts that are held inside the token",
|
|
1052
|
+
"accounts during a trade, making the value of liquidity tokens rise.",
|
|
1053
|
+
"Trade fee numerator"
|
|
1054
|
+
];
|
|
1055
|
+
type: {
|
|
1056
|
+
defined: {
|
|
1057
|
+
name: "baseFeeStruct";
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
name: "protocolFeePercent";
|
|
1063
|
+
docs: [
|
|
1064
|
+
"Protocol trading fees are extra token amounts that are held inside the token",
|
|
1065
|
+
"accounts during a trade, with the equivalent in pool tokens minted to",
|
|
1066
|
+
"the protocol of the program.",
|
|
1067
|
+
"Protocol trade fee numerator"
|
|
1068
|
+
];
|
|
1069
|
+
type: "u8";
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
name: "partnerFeePercent";
|
|
1073
|
+
docs: ["partner fee"];
|
|
1074
|
+
type: "u8";
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
name: "referralFeePercent";
|
|
1078
|
+
docs: ["referral fee"];
|
|
1079
|
+
type: "u8";
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
name: "padding0";
|
|
1083
|
+
docs: ["padding"];
|
|
1084
|
+
type: {
|
|
1085
|
+
array: ["u8", 5];
|
|
1086
|
+
};
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
name: "dynamicFee";
|
|
1090
|
+
docs: ["dynamic fee"];
|
|
1091
|
+
type: {
|
|
1092
|
+
defined: {
|
|
1093
|
+
name: "dynamicFeeStruct";
|
|
1094
|
+
};
|
|
1095
|
+
};
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
name: "padding1";
|
|
1099
|
+
docs: ["padding"];
|
|
1100
|
+
type: {
|
|
1101
|
+
array: ["u64", 2];
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
];
|
|
1105
|
+
};
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "poolMetrics";
|
|
1109
|
+
serialization: "bytemuck";
|
|
1110
|
+
repr: {
|
|
1111
|
+
kind: "c";
|
|
1112
|
+
};
|
|
1113
|
+
type: {
|
|
1114
|
+
kind: "struct";
|
|
1115
|
+
fields: [
|
|
1116
|
+
{
|
|
1117
|
+
name: "totalLpAFee";
|
|
1118
|
+
type: "u128";
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
name: "totalLpBFee";
|
|
1122
|
+
type: "u128";
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
name: "totalProtocolAFee";
|
|
1126
|
+
type: "u64";
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
name: "totalProtocolBFee";
|
|
1130
|
+
type: "u64";
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
name: "totalPartnerAFee";
|
|
1134
|
+
type: "u64";
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: "totalPartnerBFee";
|
|
1138
|
+
type: "u64";
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
name: "totalPosition";
|
|
1142
|
+
type: "u64";
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
name: "padding";
|
|
1146
|
+
type: "u64";
|
|
1147
|
+
}
|
|
1148
|
+
];
|
|
1149
|
+
};
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
name: "protocolFee";
|
|
1153
|
+
serialization: "bytemuck";
|
|
1154
|
+
repr: {
|
|
1155
|
+
kind: "c";
|
|
1156
|
+
};
|
|
1157
|
+
type: {
|
|
1158
|
+
kind: "struct";
|
|
1159
|
+
fields: [
|
|
1160
|
+
{
|
|
1161
|
+
name: "amountX";
|
|
1162
|
+
type: "u64";
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
name: "amountY";
|
|
1166
|
+
type: "u64";
|
|
1167
|
+
}
|
|
1168
|
+
];
|
|
1169
|
+
};
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
name: "remainingAccountsInfo";
|
|
1173
|
+
type: {
|
|
1174
|
+
kind: "struct";
|
|
1175
|
+
fields: [
|
|
1176
|
+
{
|
|
1177
|
+
name: "slices";
|
|
1178
|
+
type: {
|
|
1179
|
+
vec: {
|
|
1180
|
+
defined: {
|
|
1181
|
+
name: "remainingAccountsSlice";
|
|
1182
|
+
};
|
|
1183
|
+
};
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
];
|
|
1187
|
+
};
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
name: "remainingAccountsSlice";
|
|
1191
|
+
type: {
|
|
1192
|
+
kind: "struct";
|
|
1193
|
+
fields: [
|
|
1194
|
+
{
|
|
1195
|
+
name: "accountsType";
|
|
1196
|
+
type: {
|
|
1197
|
+
defined: {
|
|
1198
|
+
name: "accountsType";
|
|
1199
|
+
};
|
|
1200
|
+
};
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
name: "length";
|
|
1204
|
+
type: "u8";
|
|
1205
|
+
}
|
|
1206
|
+
];
|
|
1207
|
+
};
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
name: "staticParameters";
|
|
1211
|
+
docs: ["Parameter that set by the protocol"];
|
|
1212
|
+
serialization: "bytemuck";
|
|
1213
|
+
repr: {
|
|
1214
|
+
kind: "c";
|
|
1215
|
+
};
|
|
1216
|
+
type: {
|
|
1217
|
+
kind: "struct";
|
|
1218
|
+
fields: [
|
|
1219
|
+
{
|
|
1220
|
+
name: "baseFactor";
|
|
1221
|
+
type: "u16";
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
name: "filterPeriod";
|
|
1225
|
+
type: "u16";
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
name: "decayPeriod";
|
|
1229
|
+
type: "u16";
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
name: "reductionFactor";
|
|
1233
|
+
type: "u16";
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
name: "variableFeeControl";
|
|
1237
|
+
type: "u32";
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: "maxVolatilityAccumulator";
|
|
1241
|
+
type: "u32";
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
name: "minBinId";
|
|
1245
|
+
type: "i32";
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
name: "maxBinId";
|
|
1249
|
+
type: "i32";
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
name: "protocolShare";
|
|
1253
|
+
type: "u16";
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
name: "baseFeePowerFactor";
|
|
1257
|
+
type: "u8";
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: "padding";
|
|
1261
|
+
type: {
|
|
1262
|
+
array: ["u8", 5];
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
];
|
|
1266
|
+
};
|
|
57
1267
|
},
|
|
58
1268
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1269
|
+
name: "strategyType";
|
|
1270
|
+
type: {
|
|
1271
|
+
kind: "enum";
|
|
1272
|
+
variants: [
|
|
1273
|
+
{
|
|
1274
|
+
name: "spot";
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
name: "curve";
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
name: "bidAsk";
|
|
1281
|
+
}
|
|
1282
|
+
];
|
|
1283
|
+
};
|
|
62
1284
|
},
|
|
63
1285
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1286
|
+
name: "userLedger";
|
|
1287
|
+
serialization: "bytemuck";
|
|
1288
|
+
repr: {
|
|
1289
|
+
kind: "c";
|
|
1290
|
+
};
|
|
1291
|
+
type: {
|
|
1292
|
+
kind: "struct";
|
|
1293
|
+
fields: [
|
|
1294
|
+
{
|
|
1295
|
+
name: "owner";
|
|
1296
|
+
type: "pubkey";
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
name: "amountA";
|
|
1300
|
+
type: "u64";
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
name: "amountB";
|
|
1304
|
+
type: "u64";
|
|
1305
|
+
}
|
|
1306
|
+
];
|
|
1307
|
+
};
|
|
67
1308
|
},
|
|
68
1309
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
1310
|
+
name: "variableParameters";
|
|
1311
|
+
docs: ["Parameters that changes based on dynamic of the market"];
|
|
1312
|
+
serialization: "bytemuck";
|
|
1313
|
+
repr: {
|
|
1314
|
+
kind: "c";
|
|
1315
|
+
};
|
|
1316
|
+
type: {
|
|
1317
|
+
kind: "struct";
|
|
1318
|
+
fields: [
|
|
1319
|
+
{
|
|
1320
|
+
name: "volatilityAccumulator";
|
|
1321
|
+
type: "u32";
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
name: "volatilityReference";
|
|
1325
|
+
type: "u32";
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
name: "indexReference";
|
|
1329
|
+
type: "i32";
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
name: "padding";
|
|
1333
|
+
type: {
|
|
1334
|
+
array: ["u8", 4];
|
|
1335
|
+
};
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
name: "lastUpdateTimestamp";
|
|
1339
|
+
type: "i64";
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
name: "padding1";
|
|
1343
|
+
type: {
|
|
1344
|
+
array: ["u8", 8];
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
];
|
|
1348
|
+
};
|
|
1349
|
+
},
|
|
75
1350
|
{
|
|
76
1351
|
name: "zapOutParameters";
|
|
77
1352
|
type: {
|
|
@@ -99,6 +1374,188 @@ type Zap$1 = {
|
|
|
99
1374
|
}
|
|
100
1375
|
];
|
|
101
1376
|
};
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
name: "cp_amm::state::pool::RewardInfo";
|
|
1380
|
+
docs: ["Stores the state relevant for tracking liquidity mining rewards"];
|
|
1381
|
+
serialization: "bytemuck";
|
|
1382
|
+
repr: {
|
|
1383
|
+
kind: "c";
|
|
1384
|
+
};
|
|
1385
|
+
type: {
|
|
1386
|
+
kind: "struct";
|
|
1387
|
+
fields: [
|
|
1388
|
+
{
|
|
1389
|
+
name: "initialized";
|
|
1390
|
+
docs: ["Indicates if the reward has been initialized"];
|
|
1391
|
+
type: "u8";
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
name: "rewardTokenFlag";
|
|
1395
|
+
docs: ["reward token flag"];
|
|
1396
|
+
type: "u8";
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
name: "padding0";
|
|
1400
|
+
docs: ["padding"];
|
|
1401
|
+
type: {
|
|
1402
|
+
array: ["u8", 6];
|
|
1403
|
+
};
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
name: "padding1";
|
|
1407
|
+
docs: ["Padding to ensure `reward_rate: u128` is 16-byte aligned"];
|
|
1408
|
+
type: {
|
|
1409
|
+
array: ["u8", 8];
|
|
1410
|
+
};
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
name: "mint";
|
|
1414
|
+
docs: ["Reward token mint."];
|
|
1415
|
+
type: "pubkey";
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
name: "vault";
|
|
1419
|
+
docs: ["Reward vault token account."];
|
|
1420
|
+
type: "pubkey";
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
name: "funder";
|
|
1424
|
+
docs: ["Authority account that allows to fund rewards"];
|
|
1425
|
+
type: "pubkey";
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
name: "rewardDuration";
|
|
1429
|
+
docs: ["reward duration"];
|
|
1430
|
+
type: "u64";
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
name: "rewardDurationEnd";
|
|
1434
|
+
docs: ["reward duration end"];
|
|
1435
|
+
type: "u64";
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
name: "rewardRate";
|
|
1439
|
+
docs: ["reward rate"];
|
|
1440
|
+
type: "u128";
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
name: "rewardPerTokenStored";
|
|
1444
|
+
docs: ["Reward per token stored"];
|
|
1445
|
+
type: {
|
|
1446
|
+
array: ["u8", 32];
|
|
1447
|
+
};
|
|
1448
|
+
},
|
|
1449
|
+
{
|
|
1450
|
+
name: "lastUpdateTime";
|
|
1451
|
+
docs: ["The last time reward states were updated."];
|
|
1452
|
+
type: "u64";
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
name: "cumulativeSecondsWithEmptyLiquidityReward";
|
|
1456
|
+
docs: [
|
|
1457
|
+
"Accumulated seconds when the farm distributed rewards but the bin was empty.",
|
|
1458
|
+
"These rewards will be carried over to the next reward time window."
|
|
1459
|
+
];
|
|
1460
|
+
type: "u64";
|
|
1461
|
+
}
|
|
1462
|
+
];
|
|
1463
|
+
};
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
name: "dlmm::dlmm::types::RewardInfo";
|
|
1467
|
+
docs: ["Stores the state relevant for tracking liquidity mining rewards"];
|
|
1468
|
+
serialization: "bytemuck";
|
|
1469
|
+
repr: {
|
|
1470
|
+
kind: "c";
|
|
1471
|
+
};
|
|
1472
|
+
type: {
|
|
1473
|
+
kind: "struct";
|
|
1474
|
+
fields: [
|
|
1475
|
+
{
|
|
1476
|
+
name: "mint";
|
|
1477
|
+
type: "pubkey";
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
name: "vault";
|
|
1481
|
+
type: "pubkey";
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
name: "funder";
|
|
1485
|
+
type: "pubkey";
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
name: "rewardDuration";
|
|
1489
|
+
type: "u64";
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
name: "rewardDurationEnd";
|
|
1493
|
+
type: "u64";
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
name: "rewardRate";
|
|
1497
|
+
type: "u128";
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
name: "lastUpdateTime";
|
|
1501
|
+
type: "u64";
|
|
1502
|
+
},
|
|
1503
|
+
{
|
|
1504
|
+
name: "cumulativeSecondsWithEmptyLiquidityReward";
|
|
1505
|
+
type: "u64";
|
|
1506
|
+
}
|
|
1507
|
+
];
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
];
|
|
1511
|
+
constants: [
|
|
1512
|
+
{
|
|
1513
|
+
name: "dammV2";
|
|
1514
|
+
type: "pubkey";
|
|
1515
|
+
value: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
name: "dammV2SwapDisc";
|
|
1519
|
+
type: {
|
|
1520
|
+
array: ["u8", 8];
|
|
1521
|
+
};
|
|
1522
|
+
value: "[248, 198, 158, 145, 225, 117, 135, 200]";
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
name: "dlmmSwap2Disc";
|
|
1526
|
+
type: {
|
|
1527
|
+
array: ["u8", 8];
|
|
1528
|
+
};
|
|
1529
|
+
value: "[65, 75, 63, 76, 235, 91, 91, 136]";
|
|
1530
|
+
},
|
|
1531
|
+
{
|
|
1532
|
+
name: "jupV6";
|
|
1533
|
+
type: "pubkey";
|
|
1534
|
+
value: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
name: "jupV6RouteDisc";
|
|
1538
|
+
type: {
|
|
1539
|
+
array: ["u8", 8];
|
|
1540
|
+
};
|
|
1541
|
+
value: "[229, 23, 203, 151, 122, 227, 173, 42]";
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
name: "jupV6SharedAccountRouteDisc";
|
|
1545
|
+
type: {
|
|
1546
|
+
array: ["u8", 8];
|
|
1547
|
+
};
|
|
1548
|
+
value: "[193, 32, 155, 51, 65, 214, 156, 129]";
|
|
1549
|
+
},
|
|
1550
|
+
{
|
|
1551
|
+
name: "maxBasisPoint";
|
|
1552
|
+
type: "u16";
|
|
1553
|
+
value: "10000";
|
|
1554
|
+
},
|
|
1555
|
+
{
|
|
1556
|
+
name: "userLedgerPrefix";
|
|
1557
|
+
type: "bytes";
|
|
1558
|
+
value: "[117, 115, 101, 114, 95, 108, 101, 100, 103, 101, 114]";
|
|
102
1559
|
}
|
|
103
1560
|
];
|
|
104
1561
|
};
|
|
@@ -136,6 +1593,7 @@ type ZapOutThroughDlmmParams = {
|
|
|
136
1593
|
minimumSwapAmountOut: BN;
|
|
137
1594
|
maxSwapAmount: BN;
|
|
138
1595
|
percentageToZapOut: number;
|
|
1596
|
+
skipUnwrapSOL?: boolean;
|
|
139
1597
|
};
|
|
140
1598
|
interface ZapOutThroughJupiterParams {
|
|
141
1599
|
user: PublicKey;
|
|
@@ -146,6 +1604,7 @@ interface ZapOutThroughJupiterParams {
|
|
|
146
1604
|
jupiterSwapResponse: JupiterSwapInstructionResponse;
|
|
147
1605
|
maxSwapAmount: BN;
|
|
148
1606
|
percentageToZapOut: number;
|
|
1607
|
+
skipUnwrapSOL?: boolean;
|
|
149
1608
|
}
|
|
150
1609
|
interface JupiterQuoteResponse {
|
|
151
1610
|
inputMint: string;
|
|
@@ -208,11 +1667,260 @@ interface JupiterSwapInstructionResponse {
|
|
|
208
1667
|
};
|
|
209
1668
|
};
|
|
210
1669
|
}
|
|
1670
|
+
type ProgramStrategyType = IdlTypes<Zap$1>["strategyType"];
|
|
1671
|
+
type GetZapInDammV2DirectPoolParams = {
|
|
1672
|
+
user: PublicKey;
|
|
1673
|
+
inputTokenMint: PublicKey;
|
|
1674
|
+
amountIn: Decimal;
|
|
1675
|
+
pool: PublicKey;
|
|
1676
|
+
position: PublicKey;
|
|
1677
|
+
positionNftAccount: PublicKey;
|
|
1678
|
+
maxSqrtPriceChangeBps: number;
|
|
1679
|
+
maxTransferAmountExtendPercentage: number;
|
|
1680
|
+
maxAccounts: number;
|
|
1681
|
+
slippageBps: number;
|
|
1682
|
+
dammV2Quote: {
|
|
1683
|
+
swapInAmount: BN;
|
|
1684
|
+
consumedInAmount: BN;
|
|
1685
|
+
swapOutAmount: BN;
|
|
1686
|
+
minSwapOutAmount: BN;
|
|
1687
|
+
totalFee: BN;
|
|
1688
|
+
priceImpact: Decimal;
|
|
1689
|
+
};
|
|
1690
|
+
jupiterQuote: JupiterQuoteResponse | null;
|
|
1691
|
+
};
|
|
1692
|
+
type GetZapInDammV2InDirectPoolParams = {
|
|
1693
|
+
user: PublicKey;
|
|
1694
|
+
inputTokenMint: PublicKey;
|
|
1695
|
+
amountIn: Decimal;
|
|
1696
|
+
pool: PublicKey;
|
|
1697
|
+
position: PublicKey;
|
|
1698
|
+
positionNftAccount: PublicKey;
|
|
1699
|
+
maxSqrtPriceChangeBps: number;
|
|
1700
|
+
maxTransferAmountExtendPercentage: number;
|
|
1701
|
+
maxAccounts: number;
|
|
1702
|
+
slippageBps: number;
|
|
1703
|
+
jupiterQuoteToA: JupiterQuoteResponse | null;
|
|
1704
|
+
jupiterQuoteToB: JupiterQuoteResponse | null;
|
|
1705
|
+
};
|
|
1706
|
+
type ZapInDammV2DirectPoolParam = {
|
|
1707
|
+
user: PublicKey;
|
|
1708
|
+
pool: PublicKey;
|
|
1709
|
+
position: PublicKey;
|
|
1710
|
+
positionNftAccount: PublicKey;
|
|
1711
|
+
tokenAMint: PublicKey;
|
|
1712
|
+
tokenBMint: PublicKey;
|
|
1713
|
+
tokenAVault: PublicKey;
|
|
1714
|
+
tokenBVault: PublicKey;
|
|
1715
|
+
tokenAProgram: PublicKey;
|
|
1716
|
+
tokenBProgram: PublicKey;
|
|
1717
|
+
isDirectPool: boolean;
|
|
1718
|
+
maxTransferAmount: BN;
|
|
1719
|
+
preSqrtPrice: BN;
|
|
1720
|
+
maxSqrtPriceChangeBps: number;
|
|
1721
|
+
amount: BN;
|
|
1722
|
+
preInstructions: TransactionInstruction[];
|
|
1723
|
+
swapTransactions: Transaction[];
|
|
1724
|
+
cleanUpInstructions: TransactionInstruction[];
|
|
1725
|
+
isTokenA?: boolean;
|
|
1726
|
+
};
|
|
1727
|
+
declare enum SwapExternalType {
|
|
1728
|
+
swapToA = 0,
|
|
1729
|
+
swapToB = 1,
|
|
1730
|
+
swapToBoth = 2
|
|
1731
|
+
}
|
|
1732
|
+
type ZapInDammV2InDirectPoolParam = Omit<ZapInDammV2DirectPoolParam, "maxTransferAmount"> & {
|
|
1733
|
+
swapType: SwapExternalType;
|
|
1734
|
+
maxTransferAmountA: BN;
|
|
1735
|
+
maxTransferAmountB: BN;
|
|
1736
|
+
};
|
|
1737
|
+
type ZapInDammV2Response = {
|
|
1738
|
+
setupTransaction?: Transaction;
|
|
1739
|
+
swapTransactions: Transaction[];
|
|
1740
|
+
ledgerTransaction: Transaction;
|
|
1741
|
+
zapInTransaction: Transaction;
|
|
1742
|
+
cleanUpTransaction: Transaction;
|
|
1743
|
+
};
|
|
1744
|
+
declare enum DlmmDirectSwapQuoteRoute {
|
|
1745
|
+
Jupiter = 0,
|
|
1746
|
+
Dlmm = 1
|
|
1747
|
+
}
|
|
1748
|
+
interface SwapQuoteResult {
|
|
1749
|
+
inAmount: BN;
|
|
1750
|
+
outAmount: BN;
|
|
1751
|
+
route: DlmmDirectSwapQuoteRoute;
|
|
1752
|
+
originalQuote: JupiterQuoteResponse | SwapQuote;
|
|
1753
|
+
}
|
|
1754
|
+
declare enum DlmmSwapType {
|
|
1755
|
+
XToY = 0,
|
|
1756
|
+
YToX = 1,
|
|
1757
|
+
NoSwap = 2
|
|
1758
|
+
}
|
|
1759
|
+
interface DirectSwapEstimate {
|
|
1760
|
+
swapType: DlmmSwapType;
|
|
1761
|
+
swapAmount: BN;
|
|
1762
|
+
expectedOutput: BN;
|
|
1763
|
+
postSwapX: BN;
|
|
1764
|
+
postSwapY: BN;
|
|
1765
|
+
quote: SwapQuoteResult | null;
|
|
1766
|
+
}
|
|
1767
|
+
interface IndirectSwapEstimate {
|
|
1768
|
+
swapToX: JupiterQuoteResponse | null;
|
|
1769
|
+
swapToY: JupiterQuoteResponse | null;
|
|
1770
|
+
swapAmountToX: BN;
|
|
1771
|
+
swapAmountToY: BN;
|
|
1772
|
+
postSwapX: BN;
|
|
1773
|
+
postSwapY: BN;
|
|
1774
|
+
}
|
|
1775
|
+
interface RebalanceDlmmPositionParams {
|
|
1776
|
+
lbPairAddress: PublicKey;
|
|
1777
|
+
positionAddress: PublicKey;
|
|
1778
|
+
user: PublicKey;
|
|
1779
|
+
binDelta: number;
|
|
1780
|
+
liquiditySlippageBps: number;
|
|
1781
|
+
strategy: StrategyType;
|
|
1782
|
+
favorXInActiveId: boolean;
|
|
1783
|
+
directSwapEstimate: DirectSwapEstimate;
|
|
1784
|
+
}
|
|
1785
|
+
interface RebalanceDlmmPositionResponse {
|
|
1786
|
+
setupTransaction?: Transaction;
|
|
1787
|
+
removeLiquidityTransactions: Transaction[];
|
|
1788
|
+
swapTransaction?: Transaction;
|
|
1789
|
+
ledgerTransaction: Transaction;
|
|
1790
|
+
zapInTransaction: Transaction;
|
|
1791
|
+
cleanUpTransaction: Transaction;
|
|
1792
|
+
estimation: {
|
|
1793
|
+
currentBalances: {
|
|
1794
|
+
tokenX: BN;
|
|
1795
|
+
tokenY: BN;
|
|
1796
|
+
};
|
|
1797
|
+
afterSwap: {
|
|
1798
|
+
tokenX: BN;
|
|
1799
|
+
tokenY: BN;
|
|
1800
|
+
};
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
interface EstimateBalancedSwapThroughJupiterAndDlmmParams {
|
|
1804
|
+
lbPairAddress: PublicKey;
|
|
1805
|
+
tokenXAmount: BN;
|
|
1806
|
+
tokenYAmount: BN;
|
|
1807
|
+
slippage: number;
|
|
1808
|
+
}
|
|
1809
|
+
interface GetZapInDlmmIndirectParams {
|
|
1810
|
+
user: PublicKey;
|
|
1811
|
+
lbPair: PublicKey;
|
|
1812
|
+
inputTokenMint: PublicKey;
|
|
1813
|
+
amountIn: BN;
|
|
1814
|
+
maxActiveBinSlippage: number;
|
|
1815
|
+
binDelta: number;
|
|
1816
|
+
strategy: StrategyType;
|
|
1817
|
+
favorXInActiveId: boolean;
|
|
1818
|
+
indirectSwapEstimate: IndirectSwapEstimate;
|
|
1819
|
+
maxAccounts: number;
|
|
1820
|
+
slippageBps: number;
|
|
1821
|
+
maxTransferAmountExtendPercentage: number;
|
|
1822
|
+
}
|
|
1823
|
+
interface GetZapInDlmmDirectParams {
|
|
1824
|
+
user: PublicKey;
|
|
1825
|
+
lbPair: PublicKey;
|
|
1826
|
+
inputTokenMint: PublicKey;
|
|
1827
|
+
amountIn: BN;
|
|
1828
|
+
maxActiveBinSlippage: number;
|
|
1829
|
+
binDelta: number;
|
|
1830
|
+
strategy: StrategyType;
|
|
1831
|
+
favorXInActiveId: boolean;
|
|
1832
|
+
maxAccounts: number;
|
|
1833
|
+
slippageBps: number;
|
|
1834
|
+
maxTransferAmountExtendPercentage: number;
|
|
1835
|
+
directSwapEstimate: DirectSwapEstimate;
|
|
1836
|
+
}
|
|
1837
|
+
type ZapInDlmmIndirectPoolParam = {
|
|
1838
|
+
user: PublicKey;
|
|
1839
|
+
lbPair: PublicKey;
|
|
1840
|
+
tokenXMint: PublicKey;
|
|
1841
|
+
tokenYMint: PublicKey;
|
|
1842
|
+
tokenXProgram: PublicKey;
|
|
1843
|
+
tokenYProgram: PublicKey;
|
|
1844
|
+
activeId: number;
|
|
1845
|
+
binDelta: number;
|
|
1846
|
+
maxActiveBinSlippage: number;
|
|
1847
|
+
favorXInActiveId: boolean;
|
|
1848
|
+
strategy: StrategyType;
|
|
1849
|
+
maxTransferAmountX: BN;
|
|
1850
|
+
maxTransferAmountY: BN;
|
|
1851
|
+
preInstructions: TransactionInstruction[];
|
|
1852
|
+
swapTransactions: Transaction[];
|
|
1853
|
+
cleanUpInstructions: TransactionInstruction[];
|
|
1854
|
+
binArrays: AccountMeta[];
|
|
1855
|
+
binArrayBitmapExtension: PublicKey | null;
|
|
1856
|
+
isDirectRoute: boolean;
|
|
1857
|
+
};
|
|
1858
|
+
type ZapInDlmmDirectPoolParam = {
|
|
1859
|
+
user: PublicKey;
|
|
1860
|
+
lbPair: PublicKey;
|
|
1861
|
+
tokenXMint: PublicKey;
|
|
1862
|
+
tokenYMint: PublicKey;
|
|
1863
|
+
tokenXProgram: PublicKey;
|
|
1864
|
+
tokenYProgram: PublicKey;
|
|
1865
|
+
activeId: number;
|
|
1866
|
+
binDelta: number;
|
|
1867
|
+
maxActiveBinSlippage: number;
|
|
1868
|
+
favorXInActiveId: boolean;
|
|
1869
|
+
strategy: StrategyType;
|
|
1870
|
+
amount: BN;
|
|
1871
|
+
maxTransferAmount: BN;
|
|
1872
|
+
preInstructions: TransactionInstruction[];
|
|
1873
|
+
swapTransactions: Transaction[];
|
|
1874
|
+
cleanUpInstructions: TransactionInstruction[];
|
|
1875
|
+
binArrays: AccountMeta[];
|
|
1876
|
+
binArrayBitmapExtension: PublicKey | null;
|
|
1877
|
+
isDirectRoute: boolean;
|
|
1878
|
+
isTokenX: boolean;
|
|
1879
|
+
};
|
|
1880
|
+
type ZapInDlmmResponse = {
|
|
1881
|
+
setupTransaction?: Transaction;
|
|
1882
|
+
swapTransactions: Transaction[];
|
|
1883
|
+
ledgerTransaction: Transaction;
|
|
1884
|
+
zapInTransaction: Transaction;
|
|
1885
|
+
cleanUpTransaction: Transaction;
|
|
1886
|
+
};
|
|
211
1887
|
|
|
212
1888
|
declare class Zap {
|
|
213
1889
|
private connection;
|
|
214
|
-
|
|
1890
|
+
zapProgram: ZapProgram;
|
|
215
1891
|
constructor(connection: Connection);
|
|
1892
|
+
private initializeLedgerAccount;
|
|
1893
|
+
private closeLedgerAccount;
|
|
1894
|
+
private setLedgerBalance;
|
|
1895
|
+
private updateLedgerBalanceAfterSwap;
|
|
1896
|
+
private zapInDammV2;
|
|
1897
|
+
private resetOrInitializeLedgerAccount;
|
|
1898
|
+
private zapInDlmmForInitializedPosition;
|
|
1899
|
+
private zapInDlmmForUninitializedPosition;
|
|
1900
|
+
getZapInDammV2DirectPoolParams(params: GetZapInDammV2DirectPoolParams): Promise<ZapInDammV2DirectPoolParam>;
|
|
1901
|
+
getZapInDammV2IndirectPoolParams(params: GetZapInDammV2InDirectPoolParams): Promise<ZapInDammV2InDirectPoolParam | null>;
|
|
1902
|
+
buildZapInDammV2Transaction(params: ZapInDammV2DirectPoolParam | ZapInDammV2InDirectPoolParam): Promise<ZapInDammV2Response>;
|
|
1903
|
+
getZapInDlmmDirectParams(params: GetZapInDlmmDirectParams): Promise<ZapInDlmmDirectPoolParam>;
|
|
1904
|
+
getZapInDlmmIndirectParams(params: GetZapInDlmmIndirectParams): Promise<ZapInDlmmIndirectPoolParam>;
|
|
1905
|
+
buildZapInDlmmTransaction(params: (ZapInDlmmIndirectPoolParam | ZapInDlmmDirectPoolParam) & {
|
|
1906
|
+
position: PublicKey;
|
|
1907
|
+
}): Promise<ZapInDlmmResponse>;
|
|
1908
|
+
/**
|
|
1909
|
+
* High level method for DLMM position rebalancing
|
|
1910
|
+
* Consist of remove liquidity, zap out through Jupiter or DLMM, and zap back in to rebalance the position
|
|
1911
|
+
*
|
|
1912
|
+
* @param params - Rebalancing DLMM position parameters
|
|
1913
|
+
* @param params.lbPairAddress - The DLMM pool address
|
|
1914
|
+
* @param params.positionAddress - The position address
|
|
1915
|
+
* @param params.user - Public key of the user performing the rebalance
|
|
1916
|
+
* @param params.binDelta - The delta of bins for the rebalanced position relative to the active bin
|
|
1917
|
+
* @param params.liquiditySlippageBps - The maximum slippage in basis points for the rebalance liquidity operation (percentage * 100)
|
|
1918
|
+
* @param params.strategy - The strategy to use for the rebalance
|
|
1919
|
+
* @param params.favorXInActiveId - Whether to favor token X in the active bin
|
|
1920
|
+
* @param params.directSwapEstimate - The estimate of the direct swap operation
|
|
1921
|
+
* @returns Response containing transactions and estimation details
|
|
1922
|
+
*/
|
|
1923
|
+
rebalanceDlmmPosition(params: RebalanceDlmmPositionParams): Promise<RebalanceDlmmPositionResponse>;
|
|
216
1924
|
/**
|
|
217
1925
|
* Executes a generic zap out operation with custom parameters.
|
|
218
1926
|
*
|
|
@@ -239,6 +1947,7 @@ declare class Zap {
|
|
|
239
1947
|
* @param params.outputTokenProgram - Token program for the output token (defaults to SPL Token)
|
|
240
1948
|
* @param params.maxSwapAmount - Maximum amount of input token to swap
|
|
241
1949
|
* @param params.percentageToZapOut - Percentage of input token to zap out
|
|
1950
|
+
* @param params.skipUnwrapSOL - A boolean flag that indicates whether to skip unwrapping SOL (default: false)
|
|
242
1951
|
* @returns built transaction
|
|
243
1952
|
*/
|
|
244
1953
|
zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<Transaction>;
|
|
@@ -270,12 +1979,17 @@ declare class Zap {
|
|
|
270
1979
|
* @param params.minimumSwapAmountOut - Minimum amount of output token to receive
|
|
271
1980
|
* @param params.maxSwapAmount - Maximum amount of input token to swap
|
|
272
1981
|
* @param params.percentageToZapOut - Percentage of input token to zap out
|
|
1982
|
+
* @param params.skipUnwrapSOL - A boolean flag that indicates whether to skip unwrapping SOL (default: false)
|
|
273
1983
|
*/
|
|
274
1984
|
zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
|
|
275
1985
|
}
|
|
276
1986
|
|
|
277
|
-
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse>;
|
|
1987
|
+
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse | null>;
|
|
278
1988
|
declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, apiUrl?: string, apiKey?: string): Promise<JupiterSwapInstructionResponse>;
|
|
1989
|
+
declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number): Promise<{
|
|
1990
|
+
transaction: Transaction;
|
|
1991
|
+
quoteResponse: JupiterQuoteResponse | null;
|
|
1992
|
+
}>;
|
|
279
1993
|
|
|
280
1994
|
declare function getDammV2Pool(connection: Connection, poolAddress: PublicKey): Promise<PoolState>;
|
|
281
1995
|
declare function getDammV2RemainingAccounts(poolAddress: PublicKey, user: PublicKey, userInputTokenAccount: PublicKey, userTokenOutAccount: PublicKey, tokenAProgram: PublicKey | undefined, tokenBProgram: PublicKey | undefined, poolState: PoolState): Promise<Array<{
|
|
@@ -295,8 +2009,13 @@ declare function getDammV2RemainingAccounts(poolAddress: PublicKey, user: Public
|
|
|
295
2009
|
declare function createDammV2SwapPayload(amountIn: BN, minimumSwapAmountOut: BN): Buffer;
|
|
296
2010
|
|
|
297
2011
|
declare function deriveDammV2EventAuthority(): PublicKey;
|
|
2012
|
+
declare function deriveDammV2PoolAuthority(): PublicKey;
|
|
2013
|
+
declare function deriveLedgerAccount(owner: PublicKey): PublicKey;
|
|
2014
|
+
declare function deriveDlmmEventAuthority(): PublicKey;
|
|
298
2015
|
|
|
299
2016
|
declare function getTokenProgramFromMint(connection: Connection, mint: PublicKey): Promise<PublicKey>;
|
|
2017
|
+
declare function convertLamportsToUiAmount(amount: Decimal, decimals: number): Decimal;
|
|
2018
|
+
declare function convertUiAmountToLamports(amount: Decimal, decimals: number): Decimal;
|
|
300
2019
|
|
|
301
2020
|
/**
|
|
302
2021
|
* Get or create a token account
|
|
@@ -361,9 +2080,31 @@ declare function convertAccountTypeToNumber(accountType: object): number;
|
|
|
361
2080
|
* -> Length (1 byte): number of accounts in this slice.
|
|
362
2081
|
*/
|
|
363
2082
|
declare function createDlmmSwapPayload(amountIn: BN, minimumSwapAmountOut: BN, remainingAccountsInfo: RemainingAccountInfo): Buffer;
|
|
2083
|
+
declare function toProgramStrategyType(strategy: StrategyType): ProgramStrategyType;
|
|
2084
|
+
declare function binDeltaToMinMaxBinId(binDelta: number, activeBinId: number): {
|
|
2085
|
+
minBinId: number;
|
|
2086
|
+
maxBinId: number;
|
|
2087
|
+
};
|
|
364
2088
|
|
|
365
2089
|
declare function getExtraAccountMetasForTransferHook(connection: Connection, mint: PublicKey): Promise<_solana_web3_js.AccountMeta[]>;
|
|
366
2090
|
|
|
2091
|
+
/**
|
|
2092
|
+
* Calculate swap amounts from a single input token (that is not tokenX or tokenY)
|
|
2093
|
+
* to achieve balanced tokenX and tokenY amounts
|
|
2094
|
+
*
|
|
2095
|
+
* Uses Jupiter for swaps since input token is not part of the DLMM pool
|
|
2096
|
+
* First tries a 50:50 split (inputToken -> X and inputToken -> Y)
|
|
2097
|
+
* then refines using binary search if the resulting X and Y values are not balanced enough.
|
|
2098
|
+
*/
|
|
2099
|
+
declare function estimateIndirectSwap(inputTokenAmount: BN, inputTokenMint: PublicKey, dlmm: DLMM, swapSlippageBps: number, binDelta: number, strategy: StrategyType): Promise<IndirectSwapEstimate>;
|
|
2100
|
+
/**
|
|
2101
|
+
* Calculate optimal swap amount to achieve equal value (1:1 ratio)
|
|
2102
|
+
*
|
|
2103
|
+
* Balances tokenX and tokenY to achieve equal value by swapping excess of one token to the other
|
|
2104
|
+
* using either the DLMM pool or Jupiter
|
|
2105
|
+
*/
|
|
2106
|
+
declare function estimateDirectSwap(tokenXAmount: BN, tokenYAmount: BN, dlmm: DLMM, swapSlippageBps: number, binDelta: number, strategy: StrategyType): Promise<DirectSwapEstimate>;
|
|
2107
|
+
|
|
367
2108
|
declare const ZAP_PROGRAM_ID: PublicKey;
|
|
368
2109
|
declare const JUP_V6_PROGRAM_ID: PublicKey;
|
|
369
2110
|
declare const DAMM_V2_PROGRAM_ID: PublicKey;
|
|
@@ -387,4 +2128,4 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
|
|
|
387
2128
|
declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
|
|
388
2129
|
declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
|
|
389
2130
|
|
|
390
|
-
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
|
|
2131
|
+
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, type DirectSwapEstimate, DlmmDirectSwapQuoteRoute, DlmmSwapType, type EstimateBalancedSwapThroughJupiterAndDlmmParams, type GetZapInDammV2DirectPoolParams, type GetZapInDammV2InDirectPoolParams, type GetZapInDlmmDirectParams, type GetZapInDlmmIndirectParams, type IndirectSwapEstimate, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, type ProgramStrategyType, type RebalanceDlmmPositionParams, type RebalanceDlmmPositionResponse, SwapExternalType, type SwapQuoteResult, ZAP_PROGRAM_ID, Zap, type ZapInDammV2DirectPoolParam, type ZapInDammV2InDirectPoolParam, type ZapInDammV2Response, type ZapInDlmmDirectPoolParam, type ZapInDlmmIndirectPoolParam, type ZapInDlmmResponse, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, binDeltaToMinMaxBinId, buildJupiterSwapTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDirectSwap, estimateIndirectSwap, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
|