@drift-labs/sdk 2.146.0-beta.9 → 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 -1
- 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 -1
- 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 -3
- 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
package/src/driftClient.ts
CHANGED
|
@@ -172,7 +172,7 @@ import { calculateMarketMaxAvailableInsurance } from './math/market';
|
|
|
172
172
|
import { fetchUserStatsAccount } from './accounts/fetch';
|
|
173
173
|
import { castNumberToSpotPrecision } from './math/spotMarket';
|
|
174
174
|
import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
175
|
-
import { SwapMode } from './swap/UnifiedSwapClient';
|
|
175
|
+
import { SwapMode, UnifiedQuoteResponse } from './swap/UnifiedSwapClient';
|
|
176
176
|
import { getNonIdleUserFilter } from './memcmp';
|
|
177
177
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
178
178
|
import { getMarinadeDepositIx, getMarinadeFinanceProgram } from './marinade';
|
|
@@ -1776,15 +1776,24 @@ export class DriftClient {
|
|
|
1776
1776
|
public async getUpdateUserPerpPositionCustomMarginRatioIx(
|
|
1777
1777
|
perpMarketIndex: number,
|
|
1778
1778
|
marginRatio: number,
|
|
1779
|
-
subAccountId = 0
|
|
1779
|
+
subAccountId = 0,
|
|
1780
|
+
overrides?: {
|
|
1781
|
+
userAccountPublicKey?: PublicKey;
|
|
1782
|
+
authority?: PublicKey;
|
|
1783
|
+
signingAuthority?: PublicKey;
|
|
1784
|
+
}
|
|
1780
1785
|
): Promise<TransactionInstruction> {
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
+
let userAccountPublicKey = overrides?.userAccountPublicKey;
|
|
1787
|
+
if (!userAccountPublicKey) {
|
|
1788
|
+
userAccountPublicKey = getUserAccountPublicKeySync(
|
|
1789
|
+
this.program.programId,
|
|
1790
|
+
overrides?.authority ?? this.authority,
|
|
1791
|
+
subAccountId
|
|
1792
|
+
);
|
|
1793
|
+
}
|
|
1786
1794
|
|
|
1787
|
-
|
|
1795
|
+
const signingAuthority =
|
|
1796
|
+
overrides?.signingAuthority ?? this.wallet.publicKey;
|
|
1788
1797
|
|
|
1789
1798
|
const ix = this.program.instruction.updateUserPerpPositionCustomMarginRatio(
|
|
1790
1799
|
subAccountId,
|
|
@@ -1793,7 +1802,7 @@ export class DriftClient {
|
|
|
1793
1802
|
{
|
|
1794
1803
|
accounts: {
|
|
1795
1804
|
user: userAccountPublicKey,
|
|
1796
|
-
authority:
|
|
1805
|
+
authority: signingAuthority,
|
|
1797
1806
|
},
|
|
1798
1807
|
}
|
|
1799
1808
|
);
|
|
@@ -5756,21 +5765,23 @@ export class DriftClient {
|
|
|
5756
5765
|
/**
|
|
5757
5766
|
* Swap tokens in drift account using titan or jupiter
|
|
5758
5767
|
* @param swapClient swap client to find routes and instructions (Titan or Jupiter)
|
|
5768
|
+
* @param jupiterClient @deprecated Use swapClient instead. Legacy parameter for backward compatibility
|
|
5759
5769
|
* @param outMarketIndex the market index of the token you're buying
|
|
5760
5770
|
* @param inMarketIndex the market index of the token you're selling
|
|
5761
|
-
* @param outAssociatedTokenAccount the token account to receive the token being sold on
|
|
5771
|
+
* @param outAssociatedTokenAccount the token account to receive the token being sold on the swap provider
|
|
5762
5772
|
* @param inAssociatedTokenAccount the token account to
|
|
5763
5773
|
* @param amount the amount of TokenIn, regardless of swapMode
|
|
5764
|
-
* @param slippageBps the max slippage passed to
|
|
5765
|
-
* @param swapMode
|
|
5766
|
-
* @param route the
|
|
5774
|
+
* @param slippageBps the max slippage passed to the swap provider api
|
|
5775
|
+
* @param swapMode swap provider swapMode (ExactIn or ExactOut), default is ExactIn
|
|
5776
|
+
* @param route the swap provider route to use for the swap
|
|
5767
5777
|
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
|
|
5768
|
-
* @param v6 pass in the quote response from
|
|
5769
|
-
* @param quote pass in the quote response from
|
|
5778
|
+
* @param v6 pass in the quote response from swap provider quote's API (deprecated, use quote instead)
|
|
5779
|
+
* @param quote pass in the quote response from swap provider quote's API
|
|
5770
5780
|
* @param txParams
|
|
5771
5781
|
*/
|
|
5772
5782
|
public async swap({
|
|
5773
5783
|
swapClient,
|
|
5784
|
+
jupiterClient,
|
|
5774
5785
|
outMarketIndex,
|
|
5775
5786
|
inMarketIndex,
|
|
5776
5787
|
outAssociatedTokenAccount,
|
|
@@ -5784,7 +5795,9 @@ export class DriftClient {
|
|
|
5784
5795
|
quote,
|
|
5785
5796
|
onlyDirectRoutes = false,
|
|
5786
5797
|
}: {
|
|
5787
|
-
swapClient
|
|
5798
|
+
swapClient?: UnifiedSwapClient | SwapClient;
|
|
5799
|
+
/** @deprecated Use swapClient instead. Legacy parameter for backward compatibility */
|
|
5800
|
+
jupiterClient?: JupiterClient;
|
|
5788
5801
|
outMarketIndex: number;
|
|
5789
5802
|
inMarketIndex: number;
|
|
5790
5803
|
outAssociatedTokenAccount?: PublicKey;
|
|
@@ -5798,17 +5811,24 @@ export class DriftClient {
|
|
|
5798
5811
|
v6?: {
|
|
5799
5812
|
quote?: QuoteResponse;
|
|
5800
5813
|
};
|
|
5801
|
-
quote?:
|
|
5814
|
+
quote?: UnifiedQuoteResponse;
|
|
5802
5815
|
}): Promise<TransactionSignature> {
|
|
5816
|
+
// Handle backward compatibility: use jupiterClient if swapClient is not provided
|
|
5817
|
+
const clientToUse = swapClient || jupiterClient;
|
|
5818
|
+
|
|
5819
|
+
if (!clientToUse) {
|
|
5820
|
+
throw new Error('Either swapClient or jupiterClient must be provided');
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5803
5823
|
let res: {
|
|
5804
5824
|
ixs: TransactionInstruction[];
|
|
5805
5825
|
lookupTables: AddressLookupTableAccount[];
|
|
5806
5826
|
};
|
|
5807
5827
|
|
|
5808
5828
|
// Use unified SwapClient if available
|
|
5809
|
-
if (
|
|
5829
|
+
if (clientToUse instanceof UnifiedSwapClient) {
|
|
5810
5830
|
res = await this.getSwapIxV2({
|
|
5811
|
-
swapClient,
|
|
5831
|
+
swapClient: clientToUse,
|
|
5812
5832
|
outMarketIndex,
|
|
5813
5833
|
inMarketIndex,
|
|
5814
5834
|
outAssociatedTokenAccount,
|
|
@@ -5821,9 +5841,9 @@ export class DriftClient {
|
|
|
5821
5841
|
quote,
|
|
5822
5842
|
v6,
|
|
5823
5843
|
});
|
|
5824
|
-
} else if (
|
|
5844
|
+
} else if (clientToUse instanceof TitanClient) {
|
|
5825
5845
|
res = await this.getTitanSwapIx({
|
|
5826
|
-
titanClient:
|
|
5846
|
+
titanClient: clientToUse,
|
|
5827
5847
|
outMarketIndex,
|
|
5828
5848
|
inMarketIndex,
|
|
5829
5849
|
outAssociatedTokenAccount,
|
|
@@ -5834,10 +5854,10 @@ export class DriftClient {
|
|
|
5834
5854
|
onlyDirectRoutes,
|
|
5835
5855
|
reduceOnly,
|
|
5836
5856
|
});
|
|
5837
|
-
} else if (
|
|
5857
|
+
} else if (clientToUse instanceof JupiterClient) {
|
|
5838
5858
|
const quoteToUse = quote ?? v6?.quote;
|
|
5839
5859
|
res = await this.getJupiterSwapIxV6({
|
|
5840
|
-
jupiterClient:
|
|
5860
|
+
jupiterClient: clientToUse,
|
|
5841
5861
|
outMarketIndex,
|
|
5842
5862
|
inMarketIndex,
|
|
5843
5863
|
outAssociatedTokenAccount,
|
|
@@ -5845,7 +5865,7 @@ export class DriftClient {
|
|
|
5845
5865
|
amount,
|
|
5846
5866
|
slippageBps,
|
|
5847
5867
|
swapMode,
|
|
5848
|
-
quote: quoteToUse,
|
|
5868
|
+
quote: quoteToUse as QuoteResponse,
|
|
5849
5869
|
reduceOnly,
|
|
5850
5870
|
onlyDirectRoutes,
|
|
5851
5871
|
});
|
|
@@ -6039,7 +6059,7 @@ export class DriftClient {
|
|
|
6039
6059
|
}
|
|
6040
6060
|
|
|
6041
6061
|
if (!quote) {
|
|
6042
|
-
throw new Error(
|
|
6062
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
6043
6063
|
}
|
|
6044
6064
|
|
|
6045
6065
|
const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
|
|
@@ -6295,7 +6315,7 @@ export class DriftClient {
|
|
|
6295
6315
|
swapMode?: SwapMode;
|
|
6296
6316
|
onlyDirectRoutes?: boolean;
|
|
6297
6317
|
reduceOnly?: SwapReduceOnly;
|
|
6298
|
-
quote?:
|
|
6318
|
+
quote?: UnifiedQuoteResponse;
|
|
6299
6319
|
v6?: {
|
|
6300
6320
|
quote?: QuoteResponse;
|
|
6301
6321
|
};
|
|
@@ -8890,7 +8910,7 @@ export class DriftClient {
|
|
|
8890
8910
|
}
|
|
8891
8911
|
|
|
8892
8912
|
if (!quote) {
|
|
8893
|
-
throw new Error(
|
|
8913
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
8894
8914
|
}
|
|
8895
8915
|
|
|
8896
8916
|
const amountIn = new BN(quote.inAmount);
|
|
@@ -10969,14 +10989,27 @@ export class DriftClient {
|
|
|
10969
10989
|
isMakingNewAccount: boolean;
|
|
10970
10990
|
depositMarketIndex: number;
|
|
10971
10991
|
orderMarketIndex: number;
|
|
10992
|
+
},
|
|
10993
|
+
overrides?: {
|
|
10994
|
+
user?: User;
|
|
10995
|
+
signingAuthority?: PublicKey;
|
|
10972
10996
|
}
|
|
10973
10997
|
): Promise<TransactionInstruction> {
|
|
10974
10998
|
const isDepositToTradeTx = depositToTradeArgs !== undefined;
|
|
10999
|
+
const userAccountPublicKey =
|
|
11000
|
+
overrides?.user?.getUserAccountPublicKey() ??
|
|
11001
|
+
getUserAccountPublicKeySync(
|
|
11002
|
+
this.program.programId,
|
|
11003
|
+
this.wallet.publicKey,
|
|
11004
|
+
subAccountId
|
|
11005
|
+
);
|
|
11006
|
+
const signingAuthority =
|
|
11007
|
+
overrides?.signingAuthority ?? this.wallet.publicKey;
|
|
11008
|
+
const userAccount =
|
|
11009
|
+
overrides?.user.getUserAccount() ?? this.getUserAccount(subAccountId);
|
|
10975
11010
|
|
|
10976
11011
|
const remainingAccounts = this.getRemainingAccounts({
|
|
10977
|
-
userAccounts: depositToTradeArgs?.isMakingNewAccount
|
|
10978
|
-
? []
|
|
10979
|
-
: [this.getUserAccount(subAccountId)],
|
|
11012
|
+
userAccounts: depositToTradeArgs?.isMakingNewAccount ? [] : [userAccount],
|
|
10980
11013
|
useMarketLastSlotCache: false,
|
|
10981
11014
|
readablePerpMarketIndex: depositToTradeArgs?.orderMarketIndex,
|
|
10982
11015
|
readableSpotMarketIndexes: isDepositToTradeTx
|
|
@@ -10989,12 +11022,8 @@ export class DriftClient {
|
|
|
10989
11022
|
{
|
|
10990
11023
|
accounts: {
|
|
10991
11024
|
state: await this.getStatePublicKey(),
|
|
10992
|
-
user:
|
|
10993
|
-
|
|
10994
|
-
this.wallet.publicKey,
|
|
10995
|
-
subAccountId
|
|
10996
|
-
),
|
|
10997
|
-
authority: this.wallet.publicKey,
|
|
11025
|
+
user: userAccountPublicKey,
|
|
11026
|
+
authority: signingAuthority,
|
|
10998
11027
|
highLeverageModeConfig: getHighLeverageModeConfigPublicKey(
|
|
10999
11028
|
this.program.programId
|
|
11000
11029
|
),
|
package/src/idl/drift.json
CHANGED
|
@@ -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
|
+
}
|
package/src/math/superStake.ts
CHANGED
|
@@ -223,7 +223,7 @@ export async function findBestJitoSolSuperStakeIxs({
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
* Finds best
|
|
226
|
+
* Finds best swap instructions for a generic lstMint
|
|
227
227
|
*
|
|
228
228
|
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
|
|
229
229
|
*/
|
|
@@ -20,7 +20,29 @@ import {
|
|
|
20
20
|
export type SwapMode = 'ExactIn' | 'ExactOut';
|
|
21
21
|
export type SwapClientType = 'jupiter' | 'titan';
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Unified quote response interface that combines properties from both Jupiter and Titan
|
|
25
|
+
* This provides a consistent interface while allowing for provider-specific fields
|
|
26
|
+
*/
|
|
27
|
+
export interface UnifiedQuoteResponse {
|
|
28
|
+
// Core properties available in both providers
|
|
29
|
+
inputMint: string;
|
|
30
|
+
inAmount: string;
|
|
31
|
+
outputMint: string;
|
|
32
|
+
outAmount: string;
|
|
33
|
+
swapMode: SwapMode;
|
|
34
|
+
slippageBps: number;
|
|
35
|
+
routePlan: Array<{ swapInfo: any; percent: number }>;
|
|
36
|
+
|
|
37
|
+
// Optional properties that may not be available in all providers
|
|
38
|
+
otherAmountThreshold?: string; // Jupiter has this, Titan doesn't
|
|
39
|
+
priceImpactPct?: string; // Jupiter provides this, Titan doesn't (we calculate it)
|
|
40
|
+
platformFee?: { amount?: string; feeBps?: number }; // Format varies between providers
|
|
41
|
+
contextSlot?: number;
|
|
42
|
+
timeTaken?: number;
|
|
43
|
+
error?: string;
|
|
44
|
+
errorCode?: string;
|
|
45
|
+
}
|
|
24
46
|
|
|
25
47
|
export interface SwapQuoteParams {
|
|
26
48
|
inputMint: PublicKey;
|
|
@@ -135,7 +157,7 @@ export class UnifiedSwapClient {
|
|
|
135
157
|
): Promise<SwapTransactionResult> {
|
|
136
158
|
if (this.clientType === 'jupiter') {
|
|
137
159
|
const jupiterClient = this.client as JupiterClient;
|
|
138
|
-
// Cast the quote to Jupiter's QuoteResponse type
|
|
160
|
+
// Cast the quote to Jupiter's specific QuoteResponse type
|
|
139
161
|
const jupiterParams = {
|
|
140
162
|
...params,
|
|
141
163
|
quote: params.quote as JupiterQuoteResponse,
|
|
@@ -213,7 +235,7 @@ export class UnifiedSwapClient {
|
|
|
213
235
|
}
|
|
214
236
|
|
|
215
237
|
if (!finalQuote) {
|
|
216
|
-
throw new Error(
|
|
238
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
217
239
|
}
|
|
218
240
|
|
|
219
241
|
// Get swap transaction and extract instructions
|
package/src/types.ts
CHANGED
|
@@ -54,6 +54,7 @@ export enum PerpOperation {
|
|
|
54
54
|
SETTLE_PNL = 8,
|
|
55
55
|
SETTLE_PNL_WITH_POSITION = 16,
|
|
56
56
|
LIQUIDATION = 32,
|
|
57
|
+
SETTLE_REV_POOL = 64,
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export enum SpotOperation {
|
|
@@ -1891,6 +1892,7 @@ export type CacheInfo = {
|
|
|
1891
1892
|
oracleValidity: number;
|
|
1892
1893
|
lpStatusForPerpMarket: number;
|
|
1893
1894
|
ammPositionScalar: number;
|
|
1895
|
+
marketIndex: number;
|
|
1894
1896
|
};
|
|
1895
1897
|
|
|
1896
1898
|
export type AmmCache = {
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -672,9 +672,9 @@ export class MockUserMap implements UserMapInterface {
|
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
674
|
|
|
675
|
-
public async subscribe(): Promise<void> {
|
|
675
|
+
public async subscribe(): Promise<void> {}
|
|
676
676
|
|
|
677
|
-
public async unsubscribe(): Promise<void> {
|
|
677
|
+
public async unsubscribe(): Promise<void> {}
|
|
678
678
|
|
|
679
679
|
public async addPubkey(userAccountPublicKey: PublicKey): Promise<void> {
|
|
680
680
|
const user = new User({
|
|
@@ -733,7 +733,7 @@ export class MockUserMap implements UserMapInterface {
|
|
|
733
733
|
);
|
|
734
734
|
}
|
|
735
735
|
|
|
736
|
-
public async updateWithOrderRecord(_record: OrderRecord): Promise<void> {
|
|
736
|
+
public async updateWithOrderRecord(_record: OrderRecord): Promise<void> {}
|
|
737
737
|
|
|
738
738
|
public values(): IterableIterator<User> {
|
|
739
739
|
return this.userMap.values();
|