@drift-labs/sdk 2.40.0-beta.4 → 2.40.0-beta.6
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/VERSION +1 -1
- package/lib/driftClient.d.ts +2 -1
- package/lib/driftClient.js +2 -1
- package/lib/idl/drift.json +51 -0
- package/lib/jupiter/jupiterClient.d.ts +3 -1
- package/lib/jupiter/jupiterClient.js +3 -1
- package/package.json +1 -1
- package/src/driftClient.ts +3 -0
- package/src/idl/drift.json +51 -0
- package/src/jupiter/jupiterClient.ts +3 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.40.0-beta.
|
|
1
|
+
2.40.0-beta.6
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -319,7 +319,7 @@ export declare class DriftClient {
|
|
|
319
319
|
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
|
|
320
320
|
* @param txParams
|
|
321
321
|
*/
|
|
322
|
-
swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, }: {
|
|
322
|
+
swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, onlyDirectRoutes, }: {
|
|
323
323
|
jupiterClient: JupiterClient;
|
|
324
324
|
outMarketIndex: number;
|
|
325
325
|
inMarketIndex: number;
|
|
@@ -331,6 +331,7 @@ export declare class DriftClient {
|
|
|
331
331
|
route?: Route;
|
|
332
332
|
reduceOnly?: SwapReduceOnly;
|
|
333
333
|
txParams?: TxParams;
|
|
334
|
+
onlyDirectRoutes?: boolean;
|
|
334
335
|
v6?: {
|
|
335
336
|
quote?: QuoteResponse;
|
|
336
337
|
};
|
package/lib/driftClient.js
CHANGED
|
@@ -1975,7 +1975,7 @@ class DriftClient {
|
|
|
1975
1975
|
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
|
|
1976
1976
|
* @param txParams
|
|
1977
1977
|
*/
|
|
1978
|
-
async swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, }) {
|
|
1978
|
+
async swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, onlyDirectRoutes = false, }) {
|
|
1979
1979
|
let ixs;
|
|
1980
1980
|
let lookupTables;
|
|
1981
1981
|
if (v6) {
|
|
@@ -1990,6 +1990,7 @@ class DriftClient {
|
|
|
1990
1990
|
swapMode,
|
|
1991
1991
|
quote: v6.quote,
|
|
1992
1992
|
reduceOnly,
|
|
1993
|
+
onlyDirectRoutes,
|
|
1993
1994
|
});
|
|
1994
1995
|
ixs = res.ixs;
|
|
1995
1996
|
lookupTables = res.lookupTables;
|
package/lib/idl/drift.json
CHANGED
|
@@ -6314,6 +6314,24 @@
|
|
|
6314
6314
|
]
|
|
6315
6315
|
}
|
|
6316
6316
|
},
|
|
6317
|
+
{
|
|
6318
|
+
"name": "MarketIdentifier",
|
|
6319
|
+
"type": {
|
|
6320
|
+
"kind": "struct",
|
|
6321
|
+
"fields": [
|
|
6322
|
+
{
|
|
6323
|
+
"name": "marketType",
|
|
6324
|
+
"type": {
|
|
6325
|
+
"defined": "MarketType"
|
|
6326
|
+
}
|
|
6327
|
+
},
|
|
6328
|
+
{
|
|
6329
|
+
"name": "marketIndex",
|
|
6330
|
+
"type": "u16"
|
|
6331
|
+
}
|
|
6332
|
+
]
|
|
6333
|
+
}
|
|
6334
|
+
},
|
|
6317
6335
|
{
|
|
6318
6336
|
"name": "HistoricalOracleData",
|
|
6319
6337
|
"type": {
|
|
@@ -8198,6 +8216,34 @@
|
|
|
8198
8216
|
]
|
|
8199
8217
|
}
|
|
8200
8218
|
},
|
|
8219
|
+
{
|
|
8220
|
+
"name": "MarginCalculationMode",
|
|
8221
|
+
"type": {
|
|
8222
|
+
"kind": "enum",
|
|
8223
|
+
"variants": [
|
|
8224
|
+
{
|
|
8225
|
+
"name": "Standard"
|
|
8226
|
+
},
|
|
8227
|
+
{
|
|
8228
|
+
"name": "Liquidation",
|
|
8229
|
+
"fields": [
|
|
8230
|
+
{
|
|
8231
|
+
"name": "margin_buffer",
|
|
8232
|
+
"type": "u128"
|
|
8233
|
+
},
|
|
8234
|
+
{
|
|
8235
|
+
"name": "market_to_track_margin_requirement",
|
|
8236
|
+
"type": {
|
|
8237
|
+
"option": {
|
|
8238
|
+
"defined": "MarketIdentifier"
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8241
|
+
}
|
|
8242
|
+
]
|
|
8243
|
+
}
|
|
8244
|
+
]
|
|
8245
|
+
}
|
|
8246
|
+
},
|
|
8201
8247
|
{
|
|
8202
8248
|
"name": "OracleSource",
|
|
8203
8249
|
"type": {
|
|
@@ -10781,6 +10827,11 @@
|
|
|
10781
10827
|
"code": 6254,
|
|
10782
10828
|
"name": "UserReduceOnly",
|
|
10783
10829
|
"msg": "UserReduceOnly"
|
|
10830
|
+
},
|
|
10831
|
+
{
|
|
10832
|
+
"code": 6255,
|
|
10833
|
+
"name": "InvalidMarginCalculation",
|
|
10834
|
+
"msg": "InvalidMarginCalculation"
|
|
10784
10835
|
}
|
|
10785
10836
|
]
|
|
10786
10837
|
}
|
|
@@ -229,10 +229,12 @@ export declare class JupiterClient {
|
|
|
229
229
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
230
230
|
* @param onlyDirectRoutes whether to only return direct routes
|
|
231
231
|
*/
|
|
232
|
-
getQuote({ inputMint, outputMint, amount,
|
|
232
|
+
getQuote({ inputMint, outputMint, amount, maxAccounts, // 52 is an estimated amount with buffer
|
|
233
|
+
slippageBps, swapMode, onlyDirectRoutes, }: {
|
|
233
234
|
inputMint: PublicKey;
|
|
234
235
|
outputMint: PublicKey;
|
|
235
236
|
amount: BN;
|
|
237
|
+
maxAccounts?: number;
|
|
236
238
|
slippageBps?: number;
|
|
237
239
|
swapMode?: SwapMode;
|
|
238
240
|
onlyDirectRoutes?: boolean;
|
|
@@ -43,7 +43,8 @@ class JupiterClient {
|
|
|
43
43
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
44
44
|
* @param onlyDirectRoutes whether to only return direct routes
|
|
45
45
|
*/
|
|
46
|
-
async getQuote({ inputMint, outputMint, amount,
|
|
46
|
+
async getQuote({ inputMint, outputMint, amount, maxAccounts = 52, // 52 is an estimated amount with buffer
|
|
47
|
+
slippageBps = 50, swapMode = 'ExactIn', onlyDirectRoutes = false, }) {
|
|
47
48
|
const params = new URLSearchParams({
|
|
48
49
|
inputMint: inputMint.toString(),
|
|
49
50
|
outputMint: outputMint.toString(),
|
|
@@ -51,6 +52,7 @@ class JupiterClient {
|
|
|
51
52
|
slippageBps: slippageBps.toString(),
|
|
52
53
|
swapMode,
|
|
53
54
|
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
55
|
+
maxAccounts: maxAccounts.toString(),
|
|
54
56
|
}).toString();
|
|
55
57
|
const quote = await (await (0, node_fetch_1.default)(`${this.url}/v6/quote?${params}`)).json();
|
|
56
58
|
return quote;
|
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -3424,6 +3424,7 @@ export class DriftClient {
|
|
|
3424
3424
|
reduceOnly,
|
|
3425
3425
|
txParams,
|
|
3426
3426
|
v6,
|
|
3427
|
+
onlyDirectRoutes = false,
|
|
3427
3428
|
}: {
|
|
3428
3429
|
jupiterClient: JupiterClient;
|
|
3429
3430
|
outMarketIndex: number;
|
|
@@ -3436,6 +3437,7 @@ export class DriftClient {
|
|
|
3436
3437
|
route?: Route;
|
|
3437
3438
|
reduceOnly?: SwapReduceOnly;
|
|
3438
3439
|
txParams?: TxParams;
|
|
3440
|
+
onlyDirectRoutes?: boolean;
|
|
3439
3441
|
v6?: {
|
|
3440
3442
|
quote?: QuoteResponse;
|
|
3441
3443
|
};
|
|
@@ -3455,6 +3457,7 @@ export class DriftClient {
|
|
|
3455
3457
|
swapMode,
|
|
3456
3458
|
quote: v6.quote,
|
|
3457
3459
|
reduceOnly,
|
|
3460
|
+
onlyDirectRoutes,
|
|
3458
3461
|
});
|
|
3459
3462
|
ixs = res.ixs;
|
|
3460
3463
|
lookupTables = res.lookupTables;
|
package/src/idl/drift.json
CHANGED
|
@@ -6314,6 +6314,24 @@
|
|
|
6314
6314
|
]
|
|
6315
6315
|
}
|
|
6316
6316
|
},
|
|
6317
|
+
{
|
|
6318
|
+
"name": "MarketIdentifier",
|
|
6319
|
+
"type": {
|
|
6320
|
+
"kind": "struct",
|
|
6321
|
+
"fields": [
|
|
6322
|
+
{
|
|
6323
|
+
"name": "marketType",
|
|
6324
|
+
"type": {
|
|
6325
|
+
"defined": "MarketType"
|
|
6326
|
+
}
|
|
6327
|
+
},
|
|
6328
|
+
{
|
|
6329
|
+
"name": "marketIndex",
|
|
6330
|
+
"type": "u16"
|
|
6331
|
+
}
|
|
6332
|
+
]
|
|
6333
|
+
}
|
|
6334
|
+
},
|
|
6317
6335
|
{
|
|
6318
6336
|
"name": "HistoricalOracleData",
|
|
6319
6337
|
"type": {
|
|
@@ -8198,6 +8216,34 @@
|
|
|
8198
8216
|
]
|
|
8199
8217
|
}
|
|
8200
8218
|
},
|
|
8219
|
+
{
|
|
8220
|
+
"name": "MarginCalculationMode",
|
|
8221
|
+
"type": {
|
|
8222
|
+
"kind": "enum",
|
|
8223
|
+
"variants": [
|
|
8224
|
+
{
|
|
8225
|
+
"name": "Standard"
|
|
8226
|
+
},
|
|
8227
|
+
{
|
|
8228
|
+
"name": "Liquidation",
|
|
8229
|
+
"fields": [
|
|
8230
|
+
{
|
|
8231
|
+
"name": "margin_buffer",
|
|
8232
|
+
"type": "u128"
|
|
8233
|
+
},
|
|
8234
|
+
{
|
|
8235
|
+
"name": "market_to_track_margin_requirement",
|
|
8236
|
+
"type": {
|
|
8237
|
+
"option": {
|
|
8238
|
+
"defined": "MarketIdentifier"
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8241
|
+
}
|
|
8242
|
+
]
|
|
8243
|
+
}
|
|
8244
|
+
]
|
|
8245
|
+
}
|
|
8246
|
+
},
|
|
8201
8247
|
{
|
|
8202
8248
|
"name": "OracleSource",
|
|
8203
8249
|
"type": {
|
|
@@ -10781,6 +10827,11 @@
|
|
|
10781
10827
|
"code": 6254,
|
|
10782
10828
|
"name": "UserReduceOnly",
|
|
10783
10829
|
"msg": "UserReduceOnly"
|
|
10830
|
+
},
|
|
10831
|
+
{
|
|
10832
|
+
"code": 6255,
|
|
10833
|
+
"name": "InvalidMarginCalculation",
|
|
10834
|
+
"msg": "InvalidMarginCalculation"
|
|
10784
10835
|
}
|
|
10785
10836
|
]
|
|
10786
10837
|
}
|
|
@@ -275,6 +275,7 @@ export class JupiterClient {
|
|
|
275
275
|
inputMint,
|
|
276
276
|
outputMint,
|
|
277
277
|
amount,
|
|
278
|
+
maxAccounts = 52, // 52 is an estimated amount with buffer
|
|
278
279
|
slippageBps = 50,
|
|
279
280
|
swapMode = 'ExactIn',
|
|
280
281
|
onlyDirectRoutes = false,
|
|
@@ -282,6 +283,7 @@ export class JupiterClient {
|
|
|
282
283
|
inputMint: PublicKey;
|
|
283
284
|
outputMint: PublicKey;
|
|
284
285
|
amount: BN;
|
|
286
|
+
maxAccounts?: number;
|
|
285
287
|
slippageBps?: number;
|
|
286
288
|
swapMode?: SwapMode;
|
|
287
289
|
onlyDirectRoutes?: boolean;
|
|
@@ -293,6 +295,7 @@ export class JupiterClient {
|
|
|
293
295
|
slippageBps: slippageBps.toString(),
|
|
294
296
|
swapMode,
|
|
295
297
|
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
298
|
+
maxAccounts: maxAccounts.toString(),
|
|
296
299
|
}).toString();
|
|
297
300
|
const quote = await (await fetch(`${this.url}/v6/quote?${params}`)).json();
|
|
298
301
|
return quote;
|