@drift-labs/sdk 2.146.0-beta.8 → 2.147.0-beta.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/VERSION +1 -1
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +8 -1
- package/lib/browser/adminClient.d.ts +3 -3
- package/lib/browser/adminClient.js +13 -17
- package/lib/browser/constants/numericConstants.d.ts +2 -0
- package/lib/browser/constants/numericConstants.js +5 -1
- package/lib/browser/constants/perpMarkets.d.ts +2 -1
- package/lib/browser/constants/perpMarkets.js +31 -2
- package/lib/browser/constants/spotMarkets.d.ts +2 -0
- package/lib/browser/driftClient.d.ts +22 -12
- package/lib/browser/driftClient.js +37 -25
- package/lib/browser/idl/drift.json +38 -251
- package/lib/browser/math/superStake.d.ts +1 -1
- package/lib/browser/math/superStake.js +1 -1
- package/lib/browser/swap/UnifiedSwapClient.d.ts +28 -3
- package/lib/browser/swap/UnifiedSwapClient.js +2 -2
- package/lib/browser/types.d.ts +3 -1
- package/lib/browser/types.js +1 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +8 -1
- package/lib/node/adminClient.d.ts +3 -3
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +13 -17
- package/lib/node/constants/numericConstants.d.ts +2 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +5 -1
- package/lib/node/constants/perpMarkets.d.ts +2 -1
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +31 -2
- package/lib/node/constants/spotMarkets.d.ts +2 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/driftClient.d.ts +22 -12
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +37 -25
- package/lib/node/idl/drift.json +38 -251
- package/lib/node/math/superStake.d.ts +1 -1
- package/lib/node/math/superStake.js +1 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts +28 -3
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +2 -2
- package/lib/node/types.d.ts +3 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +1 -0
- package/package.json +1 -1
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +8 -1
- package/src/adminClient.ts +28 -30
- package/src/constants/numericConstants.ts +5 -0
- package/src/constants/perpMarkets.ts +33 -4
- package/src/constants/spotMarkets.ts +2 -0
- package/src/driftClient.ts +65 -36
- package/src/idl/drift.json +39 -252
- package/src/math/superStake.ts +1 -1
- package/src/swap/UnifiedSwapClient.ts +25 -3
- package/src/types.ts +2 -0
- package/tests/dlob/helpers.ts +3 -3
|
@@ -987,13 +987,17 @@ class DriftClient {
|
|
|
987
987
|
});
|
|
988
988
|
return ix;
|
|
989
989
|
}
|
|
990
|
-
async getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex, marginRatio, subAccountId = 0) {
|
|
991
|
-
|
|
992
|
-
|
|
990
|
+
async getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex, marginRatio, subAccountId = 0, overrides) {
|
|
991
|
+
var _a, _b;
|
|
992
|
+
let userAccountPublicKey = overrides === null || overrides === void 0 ? void 0 : overrides.userAccountPublicKey;
|
|
993
|
+
if (!userAccountPublicKey) {
|
|
994
|
+
userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, (_a = overrides === null || overrides === void 0 ? void 0 : overrides.authority) !== null && _a !== void 0 ? _a : this.authority, subAccountId);
|
|
995
|
+
}
|
|
996
|
+
const signingAuthority = (_b = overrides === null || overrides === void 0 ? void 0 : overrides.signingAuthority) !== null && _b !== void 0 ? _b : this.wallet.publicKey;
|
|
993
997
|
const ix = this.program.instruction.updateUserPerpPositionCustomMarginRatio(subAccountId, perpMarketIndex, marginRatio, {
|
|
994
998
|
accounts: {
|
|
995
999
|
user: userAccountPublicKey,
|
|
996
|
-
authority:
|
|
1000
|
+
authority: signingAuthority,
|
|
997
1001
|
},
|
|
998
1002
|
});
|
|
999
1003
|
return ix;
|
|
@@ -3104,25 +3108,31 @@ class DriftClient {
|
|
|
3104
3108
|
/**
|
|
3105
3109
|
* Swap tokens in drift account using titan or jupiter
|
|
3106
3110
|
* @param swapClient swap client to find routes and instructions (Titan or Jupiter)
|
|
3111
|
+
* @param jupiterClient @deprecated Use swapClient instead. Legacy parameter for backward compatibility
|
|
3107
3112
|
* @param outMarketIndex the market index of the token you're buying
|
|
3108
3113
|
* @param inMarketIndex the market index of the token you're selling
|
|
3109
|
-
* @param outAssociatedTokenAccount the token account to receive the token being sold on
|
|
3114
|
+
* @param outAssociatedTokenAccount the token account to receive the token being sold on the swap provider
|
|
3110
3115
|
* @param inAssociatedTokenAccount the token account to
|
|
3111
3116
|
* @param amount the amount of TokenIn, regardless of swapMode
|
|
3112
|
-
* @param slippageBps the max slippage passed to
|
|
3113
|
-
* @param swapMode
|
|
3114
|
-
* @param route the
|
|
3117
|
+
* @param slippageBps the max slippage passed to the swap provider api
|
|
3118
|
+
* @param swapMode swap provider swapMode (ExactIn or ExactOut), default is ExactIn
|
|
3119
|
+
* @param route the swap provider route to use for the swap
|
|
3115
3120
|
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
|
|
3116
|
-
* @param v6 pass in the quote response from
|
|
3117
|
-
* @param quote pass in the quote response from
|
|
3121
|
+
* @param v6 pass in the quote response from swap provider quote's API (deprecated, use quote instead)
|
|
3122
|
+
* @param quote pass in the quote response from swap provider quote's API
|
|
3118
3123
|
* @param txParams
|
|
3119
3124
|
*/
|
|
3120
|
-
async swap({ swapClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, v6, quote, onlyDirectRoutes = false, }) {
|
|
3125
|
+
async swap({ swapClient, jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, v6, quote, onlyDirectRoutes = false, }) {
|
|
3126
|
+
// Handle backward compatibility: use jupiterClient if swapClient is not provided
|
|
3127
|
+
const clientToUse = swapClient || jupiterClient;
|
|
3128
|
+
if (!clientToUse) {
|
|
3129
|
+
throw new Error('Either swapClient or jupiterClient must be provided');
|
|
3130
|
+
}
|
|
3121
3131
|
let res;
|
|
3122
3132
|
// Use unified SwapClient if available
|
|
3123
|
-
if (
|
|
3133
|
+
if (clientToUse instanceof UnifiedSwapClient_1.UnifiedSwapClient) {
|
|
3124
3134
|
res = await this.getSwapIxV2({
|
|
3125
|
-
swapClient,
|
|
3135
|
+
swapClient: clientToUse,
|
|
3126
3136
|
outMarketIndex,
|
|
3127
3137
|
inMarketIndex,
|
|
3128
3138
|
outAssociatedTokenAccount,
|
|
@@ -3136,9 +3146,9 @@ class DriftClient {
|
|
|
3136
3146
|
v6,
|
|
3137
3147
|
});
|
|
3138
3148
|
}
|
|
3139
|
-
else if (
|
|
3149
|
+
else if (clientToUse instanceof titanClient_1.TitanClient) {
|
|
3140
3150
|
res = await this.getTitanSwapIx({
|
|
3141
|
-
titanClient:
|
|
3151
|
+
titanClient: clientToUse,
|
|
3142
3152
|
outMarketIndex,
|
|
3143
3153
|
inMarketIndex,
|
|
3144
3154
|
outAssociatedTokenAccount,
|
|
@@ -3150,10 +3160,10 @@ class DriftClient {
|
|
|
3150
3160
|
reduceOnly,
|
|
3151
3161
|
});
|
|
3152
3162
|
}
|
|
3153
|
-
else if (
|
|
3163
|
+
else if (clientToUse instanceof jupiterClient_1.JupiterClient) {
|
|
3154
3164
|
const quoteToUse = quote !== null && quote !== void 0 ? quote : v6 === null || v6 === void 0 ? void 0 : v6.quote;
|
|
3155
3165
|
res = await this.getJupiterSwapIxV6({
|
|
3156
|
-
jupiterClient:
|
|
3166
|
+
jupiterClient: clientToUse,
|
|
3157
3167
|
outMarketIndex,
|
|
3158
3168
|
inMarketIndex,
|
|
3159
3169
|
outAssociatedTokenAccount,
|
|
@@ -3246,7 +3256,7 @@ class DriftClient {
|
|
|
3246
3256
|
quote = fetchedQuote;
|
|
3247
3257
|
}
|
|
3248
3258
|
if (!quote) {
|
|
3249
|
-
throw new Error(
|
|
3259
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
3250
3260
|
}
|
|
3251
3261
|
const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
|
|
3252
3262
|
const amountIn = new anchor_1.BN(quote.inAmount);
|
|
@@ -4655,7 +4665,7 @@ class DriftClient {
|
|
|
4655
4665
|
quote = fetchedQuote;
|
|
4656
4666
|
}
|
|
4657
4667
|
if (!quote) {
|
|
4658
|
-
throw new Error(
|
|
4668
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
4659
4669
|
}
|
|
4660
4670
|
const amountIn = new anchor_1.BN(quote.inAmount);
|
|
4661
4671
|
const transaction = await jupiterClient.getSwap({
|
|
@@ -5753,12 +5763,14 @@ class DriftClient {
|
|
|
5753
5763
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getEnableHighLeverageModeIx(subAccountId), txParams), [], this.opts);
|
|
5754
5764
|
return txSig;
|
|
5755
5765
|
}
|
|
5756
|
-
async getEnableHighLeverageModeIx(subAccountId, depositToTradeArgs) {
|
|
5766
|
+
async getEnableHighLeverageModeIx(subAccountId, depositToTradeArgs, overrides) {
|
|
5767
|
+
var _a, _b, _c, _d;
|
|
5757
5768
|
const isDepositToTradeTx = depositToTradeArgs !== undefined;
|
|
5769
|
+
const userAccountPublicKey = (_b = (_a = overrides === null || overrides === void 0 ? void 0 : overrides.user) === null || _a === void 0 ? void 0 : _a.getUserAccountPublicKey()) !== null && _b !== void 0 ? _b : (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
5770
|
+
const signingAuthority = (_c = overrides === null || overrides === void 0 ? void 0 : overrides.signingAuthority) !== null && _c !== void 0 ? _c : this.wallet.publicKey;
|
|
5771
|
+
const userAccount = (_d = overrides === null || overrides === void 0 ? void 0 : overrides.user.getUserAccount()) !== null && _d !== void 0 ? _d : this.getUserAccount(subAccountId);
|
|
5758
5772
|
const remainingAccounts = this.getRemainingAccounts({
|
|
5759
|
-
userAccounts: (depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.isMakingNewAccount)
|
|
5760
|
-
? []
|
|
5761
|
-
: [this.getUserAccount(subAccountId)],
|
|
5773
|
+
userAccounts: (depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.isMakingNewAccount) ? [] : [userAccount],
|
|
5762
5774
|
useMarketLastSlotCache: false,
|
|
5763
5775
|
readablePerpMarketIndex: depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.orderMarketIndex,
|
|
5764
5776
|
readableSpotMarketIndexes: isDepositToTradeTx
|
|
@@ -5768,8 +5780,8 @@ class DriftClient {
|
|
|
5768
5780
|
const ix = await this.program.instruction.enableUserHighLeverageMode(subAccountId, {
|
|
5769
5781
|
accounts: {
|
|
5770
5782
|
state: await this.getStatePublicKey(),
|
|
5771
|
-
user:
|
|
5772
|
-
authority:
|
|
5783
|
+
user: userAccountPublicKey,
|
|
5784
|
+
authority: signingAuthority,
|
|
5773
5785
|
highLeverageModeConfig: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
5774
5786
|
},
|
|
5775
5787
|
remainingAccounts,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.146.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -2020,32 +2020,6 @@
|
|
|
2020
2020
|
}
|
|
2021
2021
|
]
|
|
2022
2022
|
},
|
|
2023
|
-
{
|
|
2024
|
-
"name": "updateUserFuelBonus",
|
|
2025
|
-
"accounts": [
|
|
2026
|
-
{
|
|
2027
|
-
"name": "state",
|
|
2028
|
-
"isMut": false,
|
|
2029
|
-
"isSigner": false
|
|
2030
|
-
},
|
|
2031
|
-
{
|
|
2032
|
-
"name": "authority",
|
|
2033
|
-
"isMut": false,
|
|
2034
|
-
"isSigner": true
|
|
2035
|
-
},
|
|
2036
|
-
{
|
|
2037
|
-
"name": "user",
|
|
2038
|
-
"isMut": true,
|
|
2039
|
-
"isSigner": false
|
|
2040
|
-
},
|
|
2041
|
-
{
|
|
2042
|
-
"name": "userStats",
|
|
2043
|
-
"isMut": true,
|
|
2044
|
-
"isSigner": false
|
|
2045
|
-
}
|
|
2046
|
-
],
|
|
2047
|
-
"args": []
|
|
2048
|
-
},
|
|
2049
2023
|
{
|
|
2050
2024
|
"name": "updateUserStatsReferrerStatus",
|
|
2051
2025
|
"accounts": [
|
|
@@ -4285,11 +4259,6 @@
|
|
|
4285
4259
|
"isMut": true,
|
|
4286
4260
|
"isSigner": false
|
|
4287
4261
|
},
|
|
4288
|
-
{
|
|
4289
|
-
"name": "ammCache",
|
|
4290
|
-
"isMut": true,
|
|
4291
|
-
"isSigner": false
|
|
4292
|
-
},
|
|
4293
4262
|
{
|
|
4294
4263
|
"name": "oracle",
|
|
4295
4264
|
"isMut": false,
|
|
@@ -4454,7 +4423,7 @@
|
|
|
4454
4423
|
"args": []
|
|
4455
4424
|
},
|
|
4456
4425
|
{
|
|
4457
|
-
"name": "
|
|
4426
|
+
"name": "addMarketToAmmCache",
|
|
4458
4427
|
"accounts": [
|
|
4459
4428
|
{
|
|
4460
4429
|
"name": "admin",
|
|
@@ -4471,6 +4440,11 @@
|
|
|
4471
4440
|
"isMut": true,
|
|
4472
4441
|
"isSigner": false
|
|
4473
4442
|
},
|
|
4443
|
+
{
|
|
4444
|
+
"name": "perpMarket",
|
|
4445
|
+
"isMut": false,
|
|
4446
|
+
"isSigner": false
|
|
4447
|
+
},
|
|
4474
4448
|
{
|
|
4475
4449
|
"name": "rent",
|
|
4476
4450
|
"isMut": false,
|
|
@@ -4484,6 +4458,27 @@
|
|
|
4484
4458
|
],
|
|
4485
4459
|
"args": []
|
|
4486
4460
|
},
|
|
4461
|
+
{
|
|
4462
|
+
"name": "deleteAmmCache",
|
|
4463
|
+
"accounts": [
|
|
4464
|
+
{
|
|
4465
|
+
"name": "admin",
|
|
4466
|
+
"isMut": true,
|
|
4467
|
+
"isSigner": true
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
"name": "state",
|
|
4471
|
+
"isMut": false,
|
|
4472
|
+
"isSigner": false
|
|
4473
|
+
},
|
|
4474
|
+
{
|
|
4475
|
+
"name": "ammCache",
|
|
4476
|
+
"isMut": true,
|
|
4477
|
+
"isSigner": false
|
|
4478
|
+
}
|
|
4479
|
+
],
|
|
4480
|
+
"args": []
|
|
4481
|
+
},
|
|
4487
4482
|
{
|
|
4488
4483
|
"name": "updateInitialAmmCacheInfo",
|
|
4489
4484
|
"accounts": [
|
|
@@ -6109,27 +6104,6 @@
|
|
|
6109
6104
|
}
|
|
6110
6105
|
]
|
|
6111
6106
|
},
|
|
6112
|
-
{
|
|
6113
|
-
"name": "updateLpCooldownTime",
|
|
6114
|
-
"accounts": [
|
|
6115
|
-
{
|
|
6116
|
-
"name": "admin",
|
|
6117
|
-
"isMut": false,
|
|
6118
|
-
"isSigner": true
|
|
6119
|
-
},
|
|
6120
|
-
{
|
|
6121
|
-
"name": "state",
|
|
6122
|
-
"isMut": true,
|
|
6123
|
-
"isSigner": false
|
|
6124
|
-
}
|
|
6125
|
-
],
|
|
6126
|
-
"args": [
|
|
6127
|
-
{
|
|
6128
|
-
"name": "lpCooldownTime",
|
|
6129
|
-
"type": "u64"
|
|
6130
|
-
}
|
|
6131
|
-
]
|
|
6132
|
-
},
|
|
6133
6107
|
{
|
|
6134
6108
|
"name": "updatePerpFeeStructure",
|
|
6135
6109
|
"accounts": [
|
|
@@ -6705,46 +6679,6 @@
|
|
|
6705
6679
|
}
|
|
6706
6680
|
]
|
|
6707
6681
|
},
|
|
6708
|
-
{
|
|
6709
|
-
"name": "updatePerpMarketFuel",
|
|
6710
|
-
"accounts": [
|
|
6711
|
-
{
|
|
6712
|
-
"name": "admin",
|
|
6713
|
-
"isMut": false,
|
|
6714
|
-
"isSigner": true
|
|
6715
|
-
},
|
|
6716
|
-
{
|
|
6717
|
-
"name": "state",
|
|
6718
|
-
"isMut": false,
|
|
6719
|
-
"isSigner": false
|
|
6720
|
-
},
|
|
6721
|
-
{
|
|
6722
|
-
"name": "perpMarket",
|
|
6723
|
-
"isMut": true,
|
|
6724
|
-
"isSigner": false
|
|
6725
|
-
}
|
|
6726
|
-
],
|
|
6727
|
-
"args": [
|
|
6728
|
-
{
|
|
6729
|
-
"name": "fuelBoostTaker",
|
|
6730
|
-
"type": {
|
|
6731
|
-
"option": "u8"
|
|
6732
|
-
}
|
|
6733
|
-
},
|
|
6734
|
-
{
|
|
6735
|
-
"name": "fuelBoostMaker",
|
|
6736
|
-
"type": {
|
|
6737
|
-
"option": "u8"
|
|
6738
|
-
}
|
|
6739
|
-
},
|
|
6740
|
-
{
|
|
6741
|
-
"name": "fuelBoostPosition",
|
|
6742
|
-
"type": {
|
|
6743
|
-
"option": "u8"
|
|
6744
|
-
}
|
|
6745
|
-
}
|
|
6746
|
-
]
|
|
6747
|
-
},
|
|
6748
6682
|
{
|
|
6749
6683
|
"name": "updatePerpMarketProtectedMakerParams",
|
|
6750
6684
|
"accounts": [
|
|
@@ -6865,115 +6799,6 @@
|
|
|
6865
6799
|
}
|
|
6866
6800
|
]
|
|
6867
6801
|
},
|
|
6868
|
-
{
|
|
6869
|
-
"name": "updateSpotMarketFuel",
|
|
6870
|
-
"accounts": [
|
|
6871
|
-
{
|
|
6872
|
-
"name": "admin",
|
|
6873
|
-
"isMut": false,
|
|
6874
|
-
"isSigner": true
|
|
6875
|
-
},
|
|
6876
|
-
{
|
|
6877
|
-
"name": "state",
|
|
6878
|
-
"isMut": false,
|
|
6879
|
-
"isSigner": false
|
|
6880
|
-
},
|
|
6881
|
-
{
|
|
6882
|
-
"name": "spotMarket",
|
|
6883
|
-
"isMut": true,
|
|
6884
|
-
"isSigner": false
|
|
6885
|
-
}
|
|
6886
|
-
],
|
|
6887
|
-
"args": [
|
|
6888
|
-
{
|
|
6889
|
-
"name": "fuelBoostDeposits",
|
|
6890
|
-
"type": {
|
|
6891
|
-
"option": "u8"
|
|
6892
|
-
}
|
|
6893
|
-
},
|
|
6894
|
-
{
|
|
6895
|
-
"name": "fuelBoostBorrows",
|
|
6896
|
-
"type": {
|
|
6897
|
-
"option": "u8"
|
|
6898
|
-
}
|
|
6899
|
-
},
|
|
6900
|
-
{
|
|
6901
|
-
"name": "fuelBoostTaker",
|
|
6902
|
-
"type": {
|
|
6903
|
-
"option": "u8"
|
|
6904
|
-
}
|
|
6905
|
-
},
|
|
6906
|
-
{
|
|
6907
|
-
"name": "fuelBoostMaker",
|
|
6908
|
-
"type": {
|
|
6909
|
-
"option": "u8"
|
|
6910
|
-
}
|
|
6911
|
-
},
|
|
6912
|
-
{
|
|
6913
|
-
"name": "fuelBoostInsurance",
|
|
6914
|
-
"type": {
|
|
6915
|
-
"option": "u8"
|
|
6916
|
-
}
|
|
6917
|
-
}
|
|
6918
|
-
]
|
|
6919
|
-
},
|
|
6920
|
-
{
|
|
6921
|
-
"name": "initUserFuel",
|
|
6922
|
-
"accounts": [
|
|
6923
|
-
{
|
|
6924
|
-
"name": "admin",
|
|
6925
|
-
"isMut": false,
|
|
6926
|
-
"isSigner": true
|
|
6927
|
-
},
|
|
6928
|
-
{
|
|
6929
|
-
"name": "state",
|
|
6930
|
-
"isMut": false,
|
|
6931
|
-
"isSigner": false
|
|
6932
|
-
},
|
|
6933
|
-
{
|
|
6934
|
-
"name": "user",
|
|
6935
|
-
"isMut": true,
|
|
6936
|
-
"isSigner": false
|
|
6937
|
-
},
|
|
6938
|
-
{
|
|
6939
|
-
"name": "userStats",
|
|
6940
|
-
"isMut": true,
|
|
6941
|
-
"isSigner": false
|
|
6942
|
-
}
|
|
6943
|
-
],
|
|
6944
|
-
"args": [
|
|
6945
|
-
{
|
|
6946
|
-
"name": "fuelBoostDeposits",
|
|
6947
|
-
"type": {
|
|
6948
|
-
"option": "i32"
|
|
6949
|
-
}
|
|
6950
|
-
},
|
|
6951
|
-
{
|
|
6952
|
-
"name": "fuelBoostBorrows",
|
|
6953
|
-
"type": {
|
|
6954
|
-
"option": "u32"
|
|
6955
|
-
}
|
|
6956
|
-
},
|
|
6957
|
-
{
|
|
6958
|
-
"name": "fuelBoostTaker",
|
|
6959
|
-
"type": {
|
|
6960
|
-
"option": "u32"
|
|
6961
|
-
}
|
|
6962
|
-
},
|
|
6963
|
-
{
|
|
6964
|
-
"name": "fuelBoostMaker",
|
|
6965
|
-
"type": {
|
|
6966
|
-
"option": "u32"
|
|
6967
|
-
}
|
|
6968
|
-
},
|
|
6969
|
-
{
|
|
6970
|
-
"name": "fuelBoostInsurance",
|
|
6971
|
-
"type": {
|
|
6972
|
-
"option": "u32"
|
|
6973
|
-
}
|
|
6974
|
-
}
|
|
6975
|
-
]
|
|
6976
|
-
},
|
|
6977
6802
|
{
|
|
6978
6803
|
"name": "updateAdmin",
|
|
6979
6804
|
"accounts": [
|
|
@@ -6995,27 +6820,6 @@
|
|
|
6995
6820
|
}
|
|
6996
6821
|
]
|
|
6997
6822
|
},
|
|
6998
|
-
{
|
|
6999
|
-
"name": "updateWhitelistMint",
|
|
7000
|
-
"accounts": [
|
|
7001
|
-
{
|
|
7002
|
-
"name": "admin",
|
|
7003
|
-
"isMut": false,
|
|
7004
|
-
"isSigner": true
|
|
7005
|
-
},
|
|
7006
|
-
{
|
|
7007
|
-
"name": "state",
|
|
7008
|
-
"isMut": true,
|
|
7009
|
-
"isSigner": false
|
|
7010
|
-
}
|
|
7011
|
-
],
|
|
7012
|
-
"args": [
|
|
7013
|
-
{
|
|
7014
|
-
"name": "whitelistMint",
|
|
7015
|
-
"type": "publicKey"
|
|
7016
|
-
}
|
|
7017
|
-
]
|
|
7018
|
-
},
|
|
7019
6823
|
{
|
|
7020
6824
|
"name": "updateDiscountMint",
|
|
7021
6825
|
"accounts": [
|
|
@@ -8478,32 +8282,6 @@
|
|
|
8478
8282
|
}
|
|
8479
8283
|
]
|
|
8480
8284
|
},
|
|
8481
|
-
{
|
|
8482
|
-
"name": "resetAmmCache",
|
|
8483
|
-
"accounts": [
|
|
8484
|
-
{
|
|
8485
|
-
"name": "admin",
|
|
8486
|
-
"isMut": true,
|
|
8487
|
-
"isSigner": true
|
|
8488
|
-
},
|
|
8489
|
-
{
|
|
8490
|
-
"name": "state",
|
|
8491
|
-
"isMut": false,
|
|
8492
|
-
"isSigner": false
|
|
8493
|
-
},
|
|
8494
|
-
{
|
|
8495
|
-
"name": "ammCache",
|
|
8496
|
-
"isMut": true,
|
|
8497
|
-
"isSigner": false
|
|
8498
|
-
},
|
|
8499
|
-
{
|
|
8500
|
-
"name": "systemProgram",
|
|
8501
|
-
"isMut": false,
|
|
8502
|
-
"isSigner": false
|
|
8503
|
-
}
|
|
8504
|
-
],
|
|
8505
|
-
"args": []
|
|
8506
|
-
},
|
|
8507
8285
|
{
|
|
8508
8286
|
"name": "lpPoolSwap",
|
|
8509
8287
|
"accounts": [
|
|
@@ -12267,6 +12045,10 @@
|
|
|
12267
12045
|
"name": "oracleSlot",
|
|
12268
12046
|
"type": "u64"
|
|
12269
12047
|
},
|
|
12048
|
+
{
|
|
12049
|
+
"name": "marketIndex",
|
|
12050
|
+
"type": "u16"
|
|
12051
|
+
},
|
|
12270
12052
|
{
|
|
12271
12053
|
"name": "oracleSource",
|
|
12272
12054
|
"type": "u8"
|
|
@@ -12288,7 +12070,7 @@
|
|
|
12288
12070
|
"type": {
|
|
12289
12071
|
"array": [
|
|
12290
12072
|
"u8",
|
|
12291
|
-
|
|
12073
|
+
34
|
|
12292
12074
|
]
|
|
12293
12075
|
}
|
|
12294
12076
|
}
|
|
@@ -19777,6 +19559,11 @@
|
|
|
19777
19559
|
"code": 6343,
|
|
19778
19560
|
"name": "InvalidLpPoolId",
|
|
19779
19561
|
"msg": "Invalid Lp Pool Id for Operation"
|
|
19562
|
+
},
|
|
19563
|
+
{
|
|
19564
|
+
"code": 6344,
|
|
19565
|
+
"name": "MarketIndexNotFoundAmmCache",
|
|
19566
|
+
"msg": "MarketIndexNotFoundAmmCache"
|
|
19780
19567
|
}
|
|
19781
19568
|
]
|
|
19782
19569
|
}
|
|
@@ -74,7 +74,7 @@ export declare function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, dr
|
|
|
74
74
|
price?: number;
|
|
75
75
|
}>;
|
|
76
76
|
/**
|
|
77
|
-
* Finds best
|
|
77
|
+
* Finds best swap instructions for a generic lstMint
|
|
78
78
|
*
|
|
79
79
|
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
|
|
80
80
|
*/
|
|
@@ -129,7 +129,7 @@ async function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, driftClient
|
|
|
129
129
|
}
|
|
130
130
|
exports.findBestJitoSolSuperStakeIxs = findBestJitoSolSuperStakeIxs;
|
|
131
131
|
/**
|
|
132
|
-
* Finds best
|
|
132
|
+
* Finds best swap instructions for a generic lstMint
|
|
133
133
|
*
|
|
134
134
|
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
|
|
135
135
|
*/
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { Connection, PublicKey, TransactionMessage, AddressLookupTableAccount, VersionedTransaction, TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { BN } from '@coral-xyz/anchor';
|
|
4
|
-
import { JupiterClient
|
|
5
|
-
import { TitanClient
|
|
4
|
+
import { JupiterClient } from '../jupiter/jupiterClient';
|
|
5
|
+
import { TitanClient } from '../titan/titanClient';
|
|
6
6
|
export type SwapMode = 'ExactIn' | 'ExactOut';
|
|
7
7
|
export type SwapClientType = 'jupiter' | 'titan';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Unified quote response interface that combines properties from both Jupiter and Titan
|
|
10
|
+
* This provides a consistent interface while allowing for provider-specific fields
|
|
11
|
+
*/
|
|
12
|
+
export interface UnifiedQuoteResponse {
|
|
13
|
+
inputMint: string;
|
|
14
|
+
inAmount: string;
|
|
15
|
+
outputMint: string;
|
|
16
|
+
outAmount: string;
|
|
17
|
+
swapMode: SwapMode;
|
|
18
|
+
slippageBps: number;
|
|
19
|
+
routePlan: Array<{
|
|
20
|
+
swapInfo: any;
|
|
21
|
+
percent: number;
|
|
22
|
+
}>;
|
|
23
|
+
otherAmountThreshold?: string;
|
|
24
|
+
priceImpactPct?: string;
|
|
25
|
+
platformFee?: {
|
|
26
|
+
amount?: string;
|
|
27
|
+
feeBps?: number;
|
|
28
|
+
};
|
|
29
|
+
contextSlot?: number;
|
|
30
|
+
timeTaken?: number;
|
|
31
|
+
error?: string;
|
|
32
|
+
errorCode?: string;
|
|
33
|
+
}
|
|
9
34
|
export interface SwapQuoteParams {
|
|
10
35
|
inputMint: PublicKey;
|
|
11
36
|
outputMint: PublicKey;
|
|
@@ -61,7 +61,7 @@ class UnifiedSwapClient {
|
|
|
61
61
|
async getSwap(params) {
|
|
62
62
|
if (this.clientType === 'jupiter') {
|
|
63
63
|
const jupiterClient = this.client;
|
|
64
|
-
// Cast the quote to Jupiter's QuoteResponse type
|
|
64
|
+
// Cast the quote to Jupiter's specific QuoteResponse type
|
|
65
65
|
const jupiterParams = {
|
|
66
66
|
...params,
|
|
67
67
|
quote: params.quote,
|
|
@@ -111,7 +111,7 @@ class UnifiedSwapClient {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
if (!finalQuote) {
|
|
114
|
-
throw new Error(
|
|
114
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
115
115
|
}
|
|
116
116
|
// Get swap transaction and extract instructions
|
|
117
117
|
const transaction = await jupiterClient.getSwap({
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -59,7 +59,8 @@ export declare enum PerpOperation {
|
|
|
59
59
|
FILL = 4,
|
|
60
60
|
SETTLE_PNL = 8,
|
|
61
61
|
SETTLE_PNL_WITH_POSITION = 16,
|
|
62
|
-
LIQUIDATION = 32
|
|
62
|
+
LIQUIDATION = 32,
|
|
63
|
+
SETTLE_REV_POOL = 64
|
|
63
64
|
}
|
|
64
65
|
export declare enum SpotOperation {
|
|
65
66
|
UPDATE_CUMULATIVE_INTEREST = 1,
|
|
@@ -1854,6 +1855,7 @@ export type CacheInfo = {
|
|
|
1854
1855
|
oracleValidity: number;
|
|
1855
1856
|
lpStatusForPerpMarket: number;
|
|
1856
1857
|
ammPositionScalar: number;
|
|
1858
|
+
marketIndex: number;
|
|
1857
1859
|
};
|
|
1858
1860
|
export type AmmCache = {
|
|
1859
1861
|
cache: CacheInfo[];
|
package/lib/browser/types.js
CHANGED
|
@@ -43,6 +43,7 @@ var PerpOperation;
|
|
|
43
43
|
PerpOperation[PerpOperation["SETTLE_PNL"] = 8] = "SETTLE_PNL";
|
|
44
44
|
PerpOperation[PerpOperation["SETTLE_PNL_WITH_POSITION"] = 16] = "SETTLE_PNL_WITH_POSITION";
|
|
45
45
|
PerpOperation[PerpOperation["LIQUIDATION"] = 32] = "LIQUIDATION";
|
|
46
|
+
PerpOperation[PerpOperation["SETTLE_REV_POOL"] = 64] = "SETTLE_REV_POOL";
|
|
46
47
|
})(PerpOperation || (exports.PerpOperation = PerpOperation = {}));
|
|
47
48
|
var SpotOperation;
|
|
48
49
|
(function (SpotOperation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpcMultiUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcMultiUserAccountSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,WAAW,EAEX,SAAS,EAET,qBAAqB,EACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAW,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,qBAAa,8BAA8B;IAC1C,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAA0C;IAEjE,OAAO,CAAC,QAAQ,CAA+C;IAC/D,OAAO,CAAC,SAAS,CAGb;IACJ,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,aAAa,CAAC,CAAgC;IACtD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,sBAAsB,CAA4C;IAC1E,OAAO,CAAC,WAAW,CAAc;IACjC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,OAAO,CAAC,mBAAmB,CAgBzB;gBAGD,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,SAAS,EACrB,eAAe,CAAC,EAAE,0BAA0B,CAAC,WAAW,CAAC;IAQ7C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IA0ChC,OAAO,CAAC,oBAAoB,EAAE,SAAS,GAAG,qBAAqB;
|
|
1
|
+
{"version":3,"file":"grpcMultiUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcMultiUserAccountSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,WAAW,EAEX,SAAS,EAET,qBAAqB,EACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAW,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,qBAAa,8BAA8B;IAC1C,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAA0C;IAEjE,OAAO,CAAC,QAAQ,CAA+C;IAC/D,OAAO,CAAC,SAAS,CAGb;IACJ,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,aAAa,CAAC,CAAgC;IACtD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,sBAAsB,CAA4C;IAC1E,OAAO,CAAC,WAAW,CAAc;IACjC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,OAAO,CAAC,mBAAmB,CAgBzB;gBAGD,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,SAAS,EACrB,eAAe,CAAC,EAAE,0BAA0B,CAAC,WAAW,CAAC;IAQ7C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IA0ChC,OAAO,CAAC,oBAAoB,EAAE,SAAS,GAAG,qBAAqB;IAqGtE,OAAO,CAAC,aAAa;YAOP,YAAY;CAmE1B"}
|
|
@@ -76,7 +76,10 @@ class grpcMultiUserAccountSubscriber {
|
|
|
76
76
|
this.listeners.set(key, new Set());
|
|
77
77
|
this.keyToPk.set(key, userAccountPublicKey);
|
|
78
78
|
this.pendingAddKeys.add(key);
|
|
79
|
-
this.
|
|
79
|
+
if (this.isMultiSubscribed) {
|
|
80
|
+
// only schedule flush if already subscribed to the multi-subscriber
|
|
81
|
+
this.scheduleFlush();
|
|
82
|
+
}
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
const perUser = {
|
|
@@ -110,6 +113,10 @@ class grpcMultiUserAccountSubscriber {
|
|
|
110
113
|
this.updateData(account, 0);
|
|
111
114
|
},
|
|
112
115
|
updateData(userAccount, slot) {
|
|
116
|
+
const existingData = parent.userData.get(key);
|
|
117
|
+
if (existingData && existingData.slot > slot) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
113
120
|
parent.userData.set(key, { data: userAccount, slot });
|
|
114
121
|
perUserEmitter.emit('userAccountUpdate', userAccount);
|
|
115
122
|
perUserEmitter.emit('update');
|
|
@@ -22,11 +22,11 @@ export declare class AdminClient extends DriftClient {
|
|
|
22
22
|
initializeOpenbookV2FulfillmentConfig(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionSignature>;
|
|
23
23
|
getInitializeOpenbookV2FulfillmentConfigIx(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionInstruction>;
|
|
24
24
|
initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionSignature>;
|
|
25
|
-
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number
|
|
25
|
+
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionInstruction[]>;
|
|
26
26
|
initializeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
27
27
|
getInitializeAmmCacheIx(): Promise<TransactionInstruction>;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
addMarketToAmmCache(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
29
|
+
getAddMarketToAmmCacheIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
30
30
|
deleteAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
31
31
|
getDeleteAmmCacheIx(): Promise<TransactionInstruction>;
|
|
32
32
|
updateInitialAmmCacheInfo(perpMarketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|