@meteora-ag/dlmm 1.3.17-rc.3 → 1.4.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 +158 -60
- package/dist/index.d.ts +3 -51
- package/dist/index.js +26 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# DLMM SDK
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img align="center" src="https://
|
|
4
|
+
<img align="center" src="https://app.meteora.ag/icons/logo.svg" width="180" height="180" />
|
|
5
5
|
</p>
|
|
6
6
|
<br>
|
|
7
7
|
|
|
@@ -48,32 +48,39 @@ const activeBinPricePerToken = dlmmPool.fromPricePerLamport(
|
|
|
48
48
|
);
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
- Create Position
|
|
51
|
+
- Create Balance Position
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
54
|
const TOTAL_RANGE_INTERVAL = 10; // 10 bins on each side of the active bin
|
|
55
|
-
const minBinId = activeBin.
|
|
56
|
-
const maxBinId = activeBin.
|
|
55
|
+
const minBinId = activeBin.binId - TOTAL_RANGE_INTERVAL;
|
|
56
|
+
const maxBinId = activeBin.binId + TOTAL_RANGE_INTERVAL;
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const totalYAmount = totalXAmount.mul(new BN(Number(activeBinPricePerToken)));
|
|
63
|
-
|
|
64
|
-
// Create Position (Spot Balance deposit, Please refer ``example.ts` for more example)
|
|
65
|
-
const createPositionTx =
|
|
66
|
-
await dlmmPool.initializePositionAndAddLiquidityByStrategy({
|
|
67
|
-
positionPubKey: newBalancePosition.publicKey,
|
|
68
|
-
user: user.publicKey,
|
|
58
|
+
const totalXAmount = new BN(100 * 10 ** baseMint.decimals);
|
|
59
|
+
const totalYAmount = autoFillYByStrategy(
|
|
60
|
+
activeBin.binId,
|
|
61
|
+
dlmmPool.lbPair.binStep,
|
|
69
62
|
totalXAmount,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
activeBin.xAmount,
|
|
64
|
+
activeBin.yAmount,
|
|
65
|
+
minBinId,
|
|
66
|
+
maxBinId,
|
|
67
|
+
StrategyType.Spot // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
68
|
+
);
|
|
69
|
+
const newBalancePosition = new Keypair();
|
|
70
|
+
|
|
71
|
+
// Create Position
|
|
72
|
+
const createPositionTx =
|
|
73
|
+
await dlmmPool.initializePositionAndAddLiquidityByStrategy({
|
|
74
|
+
positionPubKey: newBalancePosition.publicKey,
|
|
75
|
+
user: user.publicKey,
|
|
76
|
+
totalXAmount,
|
|
77
|
+
totalYAmount,
|
|
78
|
+
strategy: {
|
|
79
|
+
maxBinId,
|
|
80
|
+
minBinId,
|
|
81
|
+
strategyType: StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
82
|
+
},
|
|
83
|
+
});
|
|
77
84
|
|
|
78
85
|
try {
|
|
79
86
|
const createBalancePositionTxHash = await sendAndConfirmTransaction(
|
|
@@ -84,6 +91,73 @@ try {
|
|
|
84
91
|
} catch (error) {}
|
|
85
92
|
```
|
|
86
93
|
|
|
94
|
+
- Create Imbalance Position
|
|
95
|
+
```ts
|
|
96
|
+
const TOTAL_RANGE_INTERVAL = 10; // 10 bins on each side of the active bin
|
|
97
|
+
const minBinId = activeBin.binId - TOTAL_RANGE_INTERVAL;
|
|
98
|
+
const maxBinId = activeBin.binId + TOTAL_RANGE_INTERVAL;
|
|
99
|
+
|
|
100
|
+
const totalXAmount = new BN(100 * 10 ** baseMint.decimals);
|
|
101
|
+
const totalYAmount = new BN(0.5 * 10 ** 9); // SOL
|
|
102
|
+
const newImbalancePosition = new Keypair();
|
|
103
|
+
|
|
104
|
+
// Create Position
|
|
105
|
+
const createPositionTx =
|
|
106
|
+
await dlmmPool.initializePositionAndAddLiquidityByStrategy({
|
|
107
|
+
positionPubKey: newImbalancePosition.publicKey,
|
|
108
|
+
user: user.publicKey,
|
|
109
|
+
totalXAmount,
|
|
110
|
+
totalYAmount,
|
|
111
|
+
strategy: {
|
|
112
|
+
maxBinId,
|
|
113
|
+
minBinId,
|
|
114
|
+
strategyType: StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const createBalancePositionTxHash = await sendAndConfirmTransaction(
|
|
120
|
+
connection,
|
|
121
|
+
createPositionTx,
|
|
122
|
+
[user, newImbalancePosition]
|
|
123
|
+
);
|
|
124
|
+
} catch (error) {}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- Create One Side Position
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
const TOTAL_RANGE_INTERVAL = 10; // 10 bins on each side of the active bin
|
|
131
|
+
const minBinId = activeBin.binId;
|
|
132
|
+
const maxBinId = activeBin.binId + TOTAL_RANGE_INTERVAL * 2;
|
|
133
|
+
|
|
134
|
+
const totalXAmount = new BN(100 * 10 ** baseMint.decimals);
|
|
135
|
+
const totalYAmount = new BN(0);
|
|
136
|
+
const newOneSidePosition = new Keypair();
|
|
137
|
+
|
|
138
|
+
// Create Position
|
|
139
|
+
const createPositionTx =
|
|
140
|
+
await dlmmPool.initializePositionAndAddLiquidityByStrategy({
|
|
141
|
+
positionPubKey: newOneSidePosition.publicKey,
|
|
142
|
+
user: user.publicKey,
|
|
143
|
+
totalXAmount,
|
|
144
|
+
totalYAmount,
|
|
145
|
+
strategy: {
|
|
146
|
+
maxBinId,
|
|
147
|
+
minBinId,
|
|
148
|
+
strategyType: StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
const createOneSidePositionTxHash = await sendAndConfirmTransaction(
|
|
154
|
+
connection,
|
|
155
|
+
createPositionTx,
|
|
156
|
+
[user, newOneSidePosition]
|
|
157
|
+
);
|
|
158
|
+
} catch (error) {}
|
|
159
|
+
```
|
|
160
|
+
|
|
87
161
|
- Get list of positions
|
|
88
162
|
|
|
89
163
|
```ts
|
|
@@ -97,27 +171,33 @@ const binData = userPositions[0].positionData.positionBinData;
|
|
|
97
171
|
|
|
98
172
|
```ts
|
|
99
173
|
const TOTAL_RANGE_INTERVAL = 10; // 10 bins on each side of the active bin
|
|
100
|
-
const minBinId = activeBin.
|
|
101
|
-
const maxBinId = activeBin.
|
|
102
|
-
|
|
103
|
-
const activeBinPricePerToken = dlmmPool.fromPricePerLamport(
|
|
104
|
-
Number(activeBin.price)
|
|
105
|
-
);
|
|
106
|
-
const totalXAmount = new BN(100);
|
|
107
|
-
const totalYAmount = totalXAmount.mul(new BN(Number(activeBinPricePerToken)));
|
|
174
|
+
const minBinId = activeBin.binId - TOTAL_RANGE_INTERVAL;
|
|
175
|
+
const maxBinId = activeBin.binId + TOTAL_RANGE_INTERVAL;
|
|
108
176
|
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
maxBinId,
|
|
177
|
+
const totalXAmount = new BN(100 * 10 ** baseMint.decimals);
|
|
178
|
+
const totalYAmount = autoFillYByStrategy(
|
|
179
|
+
activeBin.binId,
|
|
180
|
+
dlmmPool.lbPair.binStep,
|
|
181
|
+
totalXAmount,
|
|
182
|
+
activeBin.xAmount,
|
|
183
|
+
activeBin.yAmount,
|
|
117
184
|
minBinId,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
185
|
+
maxBinId,
|
|
186
|
+
StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// Add Liquidity to existing position
|
|
190
|
+
const addLiquidityTx = await dlmmPool.addLiquidityByStrategy({
|
|
191
|
+
positionPubKey: newBalancePosition.publicKey,
|
|
192
|
+
user: user.publicKey,
|
|
193
|
+
totalXAmount,
|
|
194
|
+
totalYAmount,
|
|
195
|
+
strategy: {
|
|
196
|
+
maxBinId,
|
|
197
|
+
minBinId,
|
|
198
|
+
strategyType: StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
199
|
+
},
|
|
200
|
+
});
|
|
121
201
|
|
|
122
202
|
try {
|
|
123
203
|
const addLiquidityTxHash = await sendAndConfirmTransaction(
|
|
@@ -162,30 +242,44 @@ try {
|
|
|
162
242
|
} catch (error) {}
|
|
163
243
|
```
|
|
164
244
|
|
|
245
|
+
- Close Position
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
const closePositionTx = await dlmmPool.closePosition({
|
|
249
|
+
owner: user.publicKey,
|
|
250
|
+
position: newBalancePosition.publicKey,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
const closePositionTxHash = await sendAndConfirmTransaction(
|
|
255
|
+
connection,
|
|
256
|
+
closePositionTx,
|
|
257
|
+
[user],
|
|
258
|
+
{ skipPreflight: false, preflightCommitment: "singleGossip" }
|
|
259
|
+
);
|
|
260
|
+
} catch (error) {}
|
|
261
|
+
```
|
|
262
|
+
|
|
165
263
|
- Swap
|
|
166
264
|
|
|
167
265
|
```ts
|
|
168
|
-
const swapAmount = new BN(
|
|
169
|
-
// Swap quote
|
|
170
|
-
const swapYtoX = true;
|
|
171
|
-
const binArrays = await dlmmPool.getBinArrayForSwap(swapYtoX);
|
|
172
|
-
|
|
173
|
-
swapAmount,
|
|
174
|
-
swapYtoX,
|
|
175
|
-
new BN(10),
|
|
176
|
-
binArrays
|
|
177
|
-
);
|
|
266
|
+
const swapAmount = new BN(0.1 * 10 ** 9);
|
|
267
|
+
// Swap quote
|
|
268
|
+
const swapYtoX = true;
|
|
269
|
+
const binArrays = await dlmmPool.getBinArrayForSwap(swapYtoX);
|
|
270
|
+
|
|
271
|
+
const swapQuote = await dlmmPool.swapQuote(swapAmount, swapYtoX, new BN(1), binArrays);
|
|
178
272
|
|
|
179
273
|
// Swap
|
|
180
274
|
const swapTx = await dlmmPool.swap({
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
275
|
+
inToken: dlmmPool.tokenX.publicKey,
|
|
276
|
+
binArraysPubkey: swapQuote.binArraysPubkey,
|
|
277
|
+
inAmount: swapAmount,
|
|
278
|
+
lbPair: dlmmPool.pubkey,
|
|
279
|
+
user: user.publicKey,
|
|
280
|
+
minOutAmount: swapQuote.minOutAmount,
|
|
281
|
+
outToken: dlmmPool.tokenY.publicKey,
|
|
282
|
+
});
|
|
189
283
|
|
|
190
284
|
try {
|
|
191
285
|
const swapTxHash = await sendAndConfirmTransaction(connection, swapTx, [
|
|
@@ -200,7 +294,11 @@ try {
|
|
|
200
294
|
| ----------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------ |
|
|
201
295
|
| `create` | Given the DLMM address, create an instance to access the state and functions | `Promise<DLMM>` |
|
|
202
296
|
| `createMultiple` | Given a list of DLMM addresses, create instances to access the state and functions | `Promise<Array<DLMM>>` |
|
|
203
|
-
| `
|
|
297
|
+
| `getAllPresetParameters` | Get all the preset params (use to create DLMM pool) | `Promise<PresetParams>` |
|
|
298
|
+
| `createPermissionLbPair` | Create DLMM Pool | `Promise<Transcation>` |
|
|
299
|
+
| `getClaimableLMReward` | Get Claimable LM reward for a position | `Promise<LMRewards>` |
|
|
300
|
+
| `getClaimableSwapFee` | Get Claimable Swap Fee for a position | `Promise<SwapFee>` |
|
|
301
|
+
| `getAllLbPairPositionsByUser` | Get user's all positions for all DLMM pools | `Promise<Map<string, PositionInfo>>` |
|
|
204
302
|
|
|
205
303
|
## DLMM instance functions
|
|
206
304
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5528,12 +5528,9 @@ declare const Strategy: {
|
|
|
5528
5528
|
};
|
|
5529
5529
|
};
|
|
5530
5530
|
declare enum StrategyType {
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
SpotBalanced = 3,
|
|
5535
|
-
CurveBalanced = 4,
|
|
5536
|
-
BidAskBalanced = 5
|
|
5531
|
+
Spot = 0,
|
|
5532
|
+
Curve = 1,
|
|
5533
|
+
BidAsk = 2
|
|
5537
5534
|
}
|
|
5538
5535
|
declare enum ActivationType {
|
|
5539
5536
|
Slot = 0,
|
|
@@ -6457,49 +6454,10 @@ declare function toAmountsBothSideByStrategy(activeId: number, binStep: number,
|
|
|
6457
6454
|
declare function autoFillYByStrategy(activeId: number, binStep: number, amountX: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, minBinId: number, maxBinId: number, strategyType: StrategyType): BN;
|
|
6458
6455
|
declare function autoFillXByStrategy(activeId: number, binStep: number, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, minBinId: number, maxBinId: number, strategyType: StrategyType): BN;
|
|
6459
6456
|
declare function toStrategyParameters({ maxBinId, minBinId, strategyType, singleSidedX, }: StrategyParameters): {
|
|
6460
|
-
minBinId: number;
|
|
6461
|
-
maxBinId: number;
|
|
6462
|
-
strategyType: {
|
|
6463
|
-
spotBalanced: {};
|
|
6464
|
-
curveBalanced?: undefined;
|
|
6465
|
-
bidAskBalanced?: undefined;
|
|
6466
|
-
spotImBalanced?: undefined;
|
|
6467
|
-
curveImBalanced?: undefined;
|
|
6468
|
-
bidAskImBalanced?: undefined;
|
|
6469
|
-
};
|
|
6470
|
-
parameteres: number[];
|
|
6471
|
-
} | {
|
|
6472
|
-
minBinId: number;
|
|
6473
|
-
maxBinId: number;
|
|
6474
|
-
strategyType: {
|
|
6475
|
-
curveBalanced: {};
|
|
6476
|
-
spotBalanced?: undefined;
|
|
6477
|
-
bidAskBalanced?: undefined;
|
|
6478
|
-
spotImBalanced?: undefined;
|
|
6479
|
-
curveImBalanced?: undefined;
|
|
6480
|
-
bidAskImBalanced?: undefined;
|
|
6481
|
-
};
|
|
6482
|
-
parameteres: number[];
|
|
6483
|
-
} | {
|
|
6484
|
-
minBinId: number;
|
|
6485
|
-
maxBinId: number;
|
|
6486
|
-
strategyType: {
|
|
6487
|
-
bidAskBalanced: {};
|
|
6488
|
-
spotBalanced?: undefined;
|
|
6489
|
-
curveBalanced?: undefined;
|
|
6490
|
-
spotImBalanced?: undefined;
|
|
6491
|
-
curveImBalanced?: undefined;
|
|
6492
|
-
bidAskImBalanced?: undefined;
|
|
6493
|
-
};
|
|
6494
|
-
parameteres: number[];
|
|
6495
|
-
} | {
|
|
6496
6457
|
minBinId: number;
|
|
6497
6458
|
maxBinId: number;
|
|
6498
6459
|
strategyType: {
|
|
6499
6460
|
spotImBalanced: {};
|
|
6500
|
-
spotBalanced?: undefined;
|
|
6501
|
-
curveBalanced?: undefined;
|
|
6502
|
-
bidAskBalanced?: undefined;
|
|
6503
6461
|
curveImBalanced?: undefined;
|
|
6504
6462
|
bidAskImBalanced?: undefined;
|
|
6505
6463
|
};
|
|
@@ -6509,9 +6467,6 @@ declare function toStrategyParameters({ maxBinId, minBinId, strategyType, single
|
|
|
6509
6467
|
maxBinId: number;
|
|
6510
6468
|
strategyType: {
|
|
6511
6469
|
curveImBalanced: {};
|
|
6512
|
-
spotBalanced?: undefined;
|
|
6513
|
-
curveBalanced?: undefined;
|
|
6514
|
-
bidAskBalanced?: undefined;
|
|
6515
6470
|
spotImBalanced?: undefined;
|
|
6516
6471
|
bidAskImBalanced?: undefined;
|
|
6517
6472
|
};
|
|
@@ -6521,9 +6476,6 @@ declare function toStrategyParameters({ maxBinId, minBinId, strategyType, single
|
|
|
6521
6476
|
maxBinId: number;
|
|
6522
6477
|
strategyType: {
|
|
6523
6478
|
bidAskImBalanced: {};
|
|
6524
|
-
spotBalanced?: undefined;
|
|
6525
|
-
curveBalanced?: undefined;
|
|
6526
|
-
bidAskBalanced?: undefined;
|
|
6527
6479
|
spotImBalanced?: undefined;
|
|
6528
6480
|
curveImBalanced?: undefined;
|
|
6529
6481
|
};
|
package/dist/index.js
CHANGED
|
@@ -6643,7 +6643,7 @@ function derivePosition(lbPair, base, lowerBinId, width, programId) {
|
|
|
6643
6643
|
lbPair.toBuffer(),
|
|
6644
6644
|
base.toBuffer(),
|
|
6645
6645
|
lowerBinIdBytes,
|
|
6646
|
-
new Uint8Array(width.
|
|
6646
|
+
new Uint8Array(width.toBuffer("le", 4))
|
|
6647
6647
|
],
|
|
6648
6648
|
programId
|
|
6649
6649
|
);
|
|
@@ -6698,12 +6698,9 @@ var Strategy = {
|
|
|
6698
6698
|
BidAskImBalanced: { bidAskImBalanced: {} }
|
|
6699
6699
|
};
|
|
6700
6700
|
var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
|
|
6701
|
-
StrategyType2[StrategyType2["
|
|
6702
|
-
StrategyType2[StrategyType2["
|
|
6703
|
-
StrategyType2[StrategyType2["
|
|
6704
|
-
StrategyType2[StrategyType2["SpotBalanced"] = 3] = "SpotBalanced";
|
|
6705
|
-
StrategyType2[StrategyType2["CurveBalanced"] = 4] = "CurveBalanced";
|
|
6706
|
-
StrategyType2[StrategyType2["BidAskBalanced"] = 5] = "BidAskBalanced";
|
|
6701
|
+
StrategyType2[StrategyType2["Spot"] = 0] = "Spot";
|
|
6702
|
+
StrategyType2[StrategyType2["Curve"] = 1] = "Curve";
|
|
6703
|
+
StrategyType2[StrategyType2["BidAsk"] = 2] = "BidAsk";
|
|
6707
6704
|
return StrategyType2;
|
|
6708
6705
|
})(StrategyType || {});
|
|
6709
6706
|
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
@@ -7258,7 +7255,7 @@ function toWeightBidAsk(minBinId, maxBinId, activeId) {
|
|
|
7258
7255
|
function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amountX, amountY, amountXInActiveBin, amountYInActiveBin, strategyType) {
|
|
7259
7256
|
const isSingleSideX = amountY.isZero();
|
|
7260
7257
|
switch (strategyType) {
|
|
7261
|
-
case 0 /*
|
|
7258
|
+
case 0 /* Spot */: {
|
|
7262
7259
|
if (activeId < minBinId || activeId > maxBinId) {
|
|
7263
7260
|
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7264
7261
|
return toAmountBothSide(
|
|
@@ -7330,7 +7327,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7330
7327
|
}
|
|
7331
7328
|
return amountsInBin;
|
|
7332
7329
|
}
|
|
7333
|
-
case 1 /*
|
|
7330
|
+
case 1 /* Curve */: {
|
|
7334
7331
|
if (activeId < minBinId) {
|
|
7335
7332
|
let weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
7336
7333
|
return toAmountBothSide(
|
|
@@ -7414,7 +7411,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7414
7411
|
}
|
|
7415
7412
|
return amountsInBin;
|
|
7416
7413
|
}
|
|
7417
|
-
case 2 /*
|
|
7414
|
+
case 2 /* BidAsk */: {
|
|
7418
7415
|
if (activeId < minBinId) {
|
|
7419
7416
|
const weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
7420
7417
|
return toAmountBothSide(
|
|
@@ -7498,7 +7495,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7498
7495
|
}
|
|
7499
7496
|
return amountsInBin;
|
|
7500
7497
|
}
|
|
7501
|
-
case
|
|
7498
|
+
case 0 /* Spot */: {
|
|
7502
7499
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7503
7500
|
return toAmountBothSide(
|
|
7504
7501
|
activeId,
|
|
@@ -7510,7 +7507,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7510
7507
|
weights
|
|
7511
7508
|
);
|
|
7512
7509
|
}
|
|
7513
|
-
case
|
|
7510
|
+
case 1 /* Curve */: {
|
|
7514
7511
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7515
7512
|
return toAmountBothSide(
|
|
7516
7513
|
activeId,
|
|
@@ -7522,7 +7519,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7522
7519
|
weights
|
|
7523
7520
|
);
|
|
7524
7521
|
}
|
|
7525
|
-
case
|
|
7522
|
+
case 2 /* BidAsk */: {
|
|
7526
7523
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7527
7524
|
return toAmountBothSide(
|
|
7528
7525
|
activeId,
|
|
@@ -7538,12 +7535,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7538
7535
|
}
|
|
7539
7536
|
function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
7540
7537
|
switch (strategyType) {
|
|
7541
|
-
case 0 /*
|
|
7542
|
-
case 1 /* CurveImBalanced */:
|
|
7543
|
-
case 2 /* BidAskImBalanced */: {
|
|
7544
|
-
throw "Invalid Strategy Parameters";
|
|
7545
|
-
}
|
|
7546
|
-
case 3 /* SpotBalanced */: {
|
|
7538
|
+
case 0 /* Spot */: {
|
|
7547
7539
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7548
7540
|
return autoFillYByWeight(
|
|
7549
7541
|
activeId,
|
|
@@ -7554,7 +7546,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7554
7546
|
weights
|
|
7555
7547
|
);
|
|
7556
7548
|
}
|
|
7557
|
-
case
|
|
7549
|
+
case 1 /* Curve */: {
|
|
7558
7550
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7559
7551
|
return autoFillYByWeight(
|
|
7560
7552
|
activeId,
|
|
@@ -7565,7 +7557,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7565
7557
|
weights
|
|
7566
7558
|
);
|
|
7567
7559
|
}
|
|
7568
|
-
case
|
|
7560
|
+
case 2 /* BidAsk */: {
|
|
7569
7561
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7570
7562
|
return autoFillYByWeight(
|
|
7571
7563
|
activeId,
|
|
@@ -7580,12 +7572,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7580
7572
|
}
|
|
7581
7573
|
function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
7582
7574
|
switch (strategyType) {
|
|
7583
|
-
case 0 /*
|
|
7584
|
-
case 1 /* CurveImBalanced */:
|
|
7585
|
-
case 2 /* BidAskImBalanced */: {
|
|
7586
|
-
throw "Invalid Strategy Parameters";
|
|
7587
|
-
}
|
|
7588
|
-
case 3 /* SpotBalanced */: {
|
|
7575
|
+
case 0 /* Spot */: {
|
|
7589
7576
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7590
7577
|
return autoFillXByWeight(
|
|
7591
7578
|
activeId,
|
|
@@ -7596,7 +7583,7 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
7596
7583
|
weights
|
|
7597
7584
|
);
|
|
7598
7585
|
}
|
|
7599
|
-
case
|
|
7586
|
+
case 1 /* Curve */: {
|
|
7600
7587
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7601
7588
|
return autoFillXByWeight(
|
|
7602
7589
|
activeId,
|
|
@@ -7607,7 +7594,7 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
7607
7594
|
weights
|
|
7608
7595
|
);
|
|
7609
7596
|
}
|
|
7610
|
-
case
|
|
7597
|
+
case 2 /* BidAsk */: {
|
|
7611
7598
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7612
7599
|
return autoFillXByWeight(
|
|
7613
7600
|
activeId,
|
|
@@ -7628,31 +7615,7 @@ function toStrategyParameters({
|
|
|
7628
7615
|
}) {
|
|
7629
7616
|
const parameters = [singleSidedX ? 1 : 0, ...new Array(63).fill(0)];
|
|
7630
7617
|
switch (strategyType) {
|
|
7631
|
-
case
|
|
7632
|
-
return {
|
|
7633
|
-
minBinId,
|
|
7634
|
-
maxBinId,
|
|
7635
|
-
strategyType: { spotBalanced: {} },
|
|
7636
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7637
|
-
};
|
|
7638
|
-
}
|
|
7639
|
-
case 4 /* CurveBalanced */: {
|
|
7640
|
-
return {
|
|
7641
|
-
minBinId,
|
|
7642
|
-
maxBinId,
|
|
7643
|
-
strategyType: { curveBalanced: {} },
|
|
7644
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7645
|
-
};
|
|
7646
|
-
}
|
|
7647
|
-
case 5 /* BidAskBalanced */: {
|
|
7648
|
-
return {
|
|
7649
|
-
minBinId,
|
|
7650
|
-
maxBinId,
|
|
7651
|
-
strategyType: { bidAskBalanced: {} },
|
|
7652
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7653
|
-
};
|
|
7654
|
-
}
|
|
7655
|
-
case 0 /* SpotImBalanced */: {
|
|
7618
|
+
case 0 /* Spot */: {
|
|
7656
7619
|
return {
|
|
7657
7620
|
minBinId,
|
|
7658
7621
|
maxBinId,
|
|
@@ -7660,7 +7623,7 @@ function toStrategyParameters({
|
|
|
7660
7623
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7661
7624
|
};
|
|
7662
7625
|
}
|
|
7663
|
-
case 1 /*
|
|
7626
|
+
case 1 /* Curve */: {
|
|
7664
7627
|
return {
|
|
7665
7628
|
minBinId,
|
|
7666
7629
|
maxBinId,
|
|
@@ -7668,7 +7631,7 @@ function toStrategyParameters({
|
|
|
7668
7631
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7669
7632
|
};
|
|
7670
7633
|
}
|
|
7671
|
-
case 2 /*
|
|
7634
|
+
case 2 /* BidAsk */: {
|
|
7672
7635
|
return {
|
|
7673
7636
|
minBinId,
|
|
7674
7637
|
maxBinId,
|
|
@@ -11218,6 +11181,13 @@ var DLMM = class {
|
|
|
11218
11181
|
);
|
|
11219
11182
|
}
|
|
11220
11183
|
if (instructions.length > 1) {
|
|
11184
|
+
instructions.push(
|
|
11185
|
+
await getEstimatedComputeUnitIxWithBuffer(
|
|
11186
|
+
this.program.provider.connection,
|
|
11187
|
+
instructions,
|
|
11188
|
+
payer
|
|
11189
|
+
)
|
|
11190
|
+
);
|
|
11221
11191
|
initializeBinArraysAndPositionIxs.push(instructions);
|
|
11222
11192
|
instructions = [];
|
|
11223
11193
|
}
|
|
@@ -11283,7 +11253,6 @@ var DLMM = class {
|
|
|
11283
11253
|
]);
|
|
11284
11254
|
}
|
|
11285
11255
|
}
|
|
11286
|
-
console.log("let return");
|
|
11287
11256
|
return {
|
|
11288
11257
|
sendPositionOwnerTokenProveIxs,
|
|
11289
11258
|
initializeBinArraysAndPositionIxs,
|