@drift-labs/sdk 2.98.0-beta.9 → 2.99.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/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
- package/lib/browser/accounts/types.d.ts +14 -1
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
- package/lib/browser/addresses/pda.d.ts +1 -0
- package/lib/browser/addresses/pda.js +8 -1
- package/lib/browser/constants/perpMarkets.js +11 -0
- package/lib/browser/constants/spotMarkets.js +2 -2
- package/lib/browser/driftClient.d.ts +14 -4
- package/lib/browser/driftClient.js +58 -16
- package/lib/browser/idl/drift.json +199 -8
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.js +4 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +6 -0
- package/lib/browser/memcmp.d.ts +3 -0
- package/lib/browser/memcmp.js +28 -1
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +85 -0
- package/lib/browser/types.d.ts +4 -3
- package/lib/browser/user.js +3 -0
- package/lib/browser/userMap/referrerMap.d.ts +45 -0
- package/lib/browser/userMap/referrerMap.js +180 -0
- package/lib/browser/util/digest.d.ts +1 -0
- package/lib/browser/util/digest.js +5 -1
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
- package/lib/node/accounts/types.d.ts +14 -1
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
- package/lib/node/addresses/pda.d.ts +1 -0
- package/lib/node/addresses/pda.js +8 -1
- package/lib/node/constants/perpMarkets.js +11 -0
- package/lib/node/constants/spotMarkets.js +2 -2
- package/lib/node/driftClient.d.ts +14 -4
- package/lib/node/driftClient.js +58 -16
- package/lib/node/idl/drift.json +199 -8
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.js +4 -0
- package/lib/node/jupiter/jupiterClient.d.ts +6 -0
- package/lib/node/memcmp.d.ts +3 -0
- package/lib/node/memcmp.js +28 -1
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.js +85 -0
- package/lib/node/types.d.ts +4 -3
- package/lib/node/user.js +3 -0
- package/lib/node/userMap/referrerMap.d.ts +45 -0
- package/lib/node/userMap/referrerMap.js +180 -0
- package/lib/node/util/digest.d.ts +1 -0
- package/lib/node/util/digest.js +5 -1
- package/package.json +1 -1
- package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +189 -0
- package/src/accounts/types.ts +25 -1
- package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +131 -0
- package/src/addresses/pda.ts +13 -0
- package/src/constants/perpMarkets.ts +12 -0
- package/src/constants/spotMarkets.ts +2 -2
- package/src/driftClient.ts +122 -33
- package/src/idl/drift.json +199 -8
- package/src/index.ts +4 -0
- package/src/jupiter/jupiterClient.ts +6 -0
- package/src/memcmp.ts +27 -0
- package/src/slot/SlothashSubscriber.ts +126 -0
- package/src/types.ts +4 -3
- package/src/user.ts +4 -0
- package/src/userMap/referrerMap.ts +283 -0
- package/src/util/digest.ts +4 -0
- package/tests/ci/verifyConstants.ts +16 -2
package/lib/node/driftClient.js
CHANGED
|
@@ -186,7 +186,7 @@ class DriftClient {
|
|
|
186
186
|
if (config.env && !this.marketLookupTable) {
|
|
187
187
|
this.marketLookupTable = new web3_js_1.PublicKey(config_1.configs[config.env].MARKET_LOOKUP_TABLE);
|
|
188
188
|
}
|
|
189
|
-
const delistedMarketSetting = config.delistedMarketSetting || types_2.DelistedMarketSetting.
|
|
189
|
+
const delistedMarketSetting = config.delistedMarketSetting || types_2.DelistedMarketSetting.Unsubscribe;
|
|
190
190
|
const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
|
|
191
191
|
config.spotMarketIndexes === undefined &&
|
|
192
192
|
config.oracleInfos === undefined;
|
|
@@ -600,6 +600,28 @@ class DriftClient {
|
|
|
600
600
|
});
|
|
601
601
|
return [rfqUserAccountPublicKey, initializeUserAccountIx];
|
|
602
602
|
}
|
|
603
|
+
async initializeSwiftUserOrdersAccount(userAccountPublicKey, txParams) {
|
|
604
|
+
const initializeIxs = [];
|
|
605
|
+
const [swiftUserAccountPublicKey, initializeUserAccountIx] = await this.getInitializeSwiftUserOrdersAccountInstruction(userAccountPublicKey);
|
|
606
|
+
initializeIxs.push(initializeUserAccountIx);
|
|
607
|
+
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
608
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
609
|
+
return [txSig, swiftUserAccountPublicKey];
|
|
610
|
+
}
|
|
611
|
+
async getInitializeSwiftUserOrdersAccountInstruction(userAccountPublicKey) {
|
|
612
|
+
const swiftUserAccountPublicKey = (0, pda_1.getSwiftUserAccountPublicKey)(this.program.programId, userAccountPublicKey);
|
|
613
|
+
const initializeUserAccountIx = await this.program.instruction.initializeSwiftUserOrders({
|
|
614
|
+
accounts: {
|
|
615
|
+
swiftUserOrders: swiftUserAccountPublicKey,
|
|
616
|
+
authority: this.wallet.publicKey,
|
|
617
|
+
user: userAccountPublicKey,
|
|
618
|
+
payer: this.wallet.publicKey,
|
|
619
|
+
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
620
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
return [swiftUserAccountPublicKey, initializeUserAccountIx];
|
|
624
|
+
}
|
|
603
625
|
async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
|
|
604
626
|
const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
605
627
|
const remainingAccounts = new Array();
|
|
@@ -2993,15 +3015,12 @@ class DriftClient {
|
|
|
2993
3015
|
});
|
|
2994
3016
|
}
|
|
2995
3017
|
encodeSwiftServerMessage(message) {
|
|
2996
|
-
|
|
2997
|
-
slot: message.slot,
|
|
2998
|
-
swiftOrderSignature: message.swiftOrderSignature,
|
|
2999
|
-
};
|
|
3000
|
-
return this.program.coder.types.encode('SwiftServerMessage', messageWithBuffer);
|
|
3018
|
+
return this.program.coder.types.encode('SwiftServerMessage', message);
|
|
3001
3019
|
}
|
|
3002
3020
|
decodeSwiftServerMessage(encodedMessage) {
|
|
3003
3021
|
const decodedSwiftMessage = this.program.coder.types.decode('SwiftServerMessage', encodedMessage);
|
|
3004
3022
|
return {
|
|
3023
|
+
uuid: decodedSwiftMessage.uuid,
|
|
3005
3024
|
slot: decodedSwiftMessage.slot,
|
|
3006
3025
|
swiftOrderSignature: decodedSwiftMessage.swiftSignature,
|
|
3007
3026
|
};
|
|
@@ -3049,6 +3068,7 @@ class DriftClient {
|
|
|
3049
3068
|
state: await this.getStatePublicKey(),
|
|
3050
3069
|
user: takerInfo.taker,
|
|
3051
3070
|
userStats: takerInfo.takerStats,
|
|
3071
|
+
swiftUserOrders: (0, pda_1.getSwiftUserAccountPublicKey)(this.program.programId, takerInfo.taker),
|
|
3052
3072
|
authority: this.wallet.publicKey,
|
|
3053
3073
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3054
3074
|
},
|
|
@@ -3060,13 +3080,13 @@ class DriftClient {
|
|
|
3060
3080
|
placeTakerSwiftPerpOrderIx,
|
|
3061
3081
|
];
|
|
3062
3082
|
}
|
|
3063
|
-
async placeAndMakeSwiftPerpOrder(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature,
|
|
3064
|
-
const ixs = await this.getPlaceAndMakeSwiftPerpOrderIxs(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature,
|
|
3083
|
+
async placeAndMakeSwiftPerpOrder(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature, swiftOrderUuid, takerInfo, orderParams, referrerInfo, txParams, subAccountId) {
|
|
3084
|
+
const ixs = await this.getPlaceAndMakeSwiftPerpOrderIxs(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature, swiftOrderUuid, takerInfo, orderParams, referrerInfo, subAccountId);
|
|
3065
3085
|
const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
|
|
3066
3086
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
3067
3087
|
return txSig;
|
|
3068
3088
|
}
|
|
3069
|
-
async getPlaceAndMakeSwiftPerpOrderIxs(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature,
|
|
3089
|
+
async getPlaceAndMakeSwiftPerpOrderIxs(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature, swiftOrderUuid, takerInfo, orderParams, referrerInfo, subAccountId) {
|
|
3070
3090
|
const [swiftServerSignatureIx, swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx,] = await this.getPlaceSwiftTakerPerpOrderIxs(encodedSwiftMessage, swiftSignature, encodedSwiftOrderParamsMessage, swiftOrderParamsSignature, orderParams.marketIndex, takerInfo);
|
|
3071
3091
|
orderParams = (0, orderParams_1.getOrderParams)(orderParams, { marketType: types_1.MarketType.PERP });
|
|
3072
3092
|
const userStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
@@ -3091,7 +3111,7 @@ class DriftClient {
|
|
|
3091
3111
|
isSigner: false,
|
|
3092
3112
|
});
|
|
3093
3113
|
}
|
|
3094
|
-
const placeAndMakeIx = await this.program.instruction.
|
|
3114
|
+
const placeAndMakeIx = await this.program.instruction.placeAndMakeSwiftPerpOrder(orderParams, swiftOrderUuid, {
|
|
3095
3115
|
accounts: {
|
|
3096
3116
|
state: await this.getStatePublicKey(),
|
|
3097
3117
|
user,
|
|
@@ -3099,6 +3119,7 @@ class DriftClient {
|
|
|
3099
3119
|
taker: takerInfo.taker,
|
|
3100
3120
|
takerStats: takerInfo.takerStats,
|
|
3101
3121
|
authority: this.wallet.publicKey,
|
|
3122
|
+
takerSwiftUserOrders: (0, pda_1.getSwiftUserAccountPublicKey)(this.program.programId, takerInfo.taker),
|
|
3102
3123
|
},
|
|
3103
3124
|
remainingAccounts,
|
|
3104
3125
|
});
|
|
@@ -3880,6 +3901,10 @@ class DriftClient {
|
|
|
3880
3901
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
3881
3902
|
const isSolMarket = spotMarketAccount.mint.equals(spotMarkets_1.WRAPPED_SOL_MINT);
|
|
3882
3903
|
const createWSOLTokenAccount = isSolMarket && collateralAccountPublicKey.equals(this.wallet.publicKey);
|
|
3904
|
+
const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
3905
|
+
// create associated token account because it may not exist
|
|
3906
|
+
const associatedTokenAccountPublicKey = (0, spl_token_1.getAssociatedTokenAddressSync)(spotMarketAccount.mint, this.wallet.publicKey, true, tokenProgramId);
|
|
3907
|
+
addIfStakeIxs.push(await (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(this.wallet.publicKey, associatedTokenAccountPublicKey, this.wallet.publicKey, spotMarketAccount.mint, tokenProgramId));
|
|
3883
3908
|
let tokenAccount;
|
|
3884
3909
|
if (!(await this.checkIfAccountExists(this.getUserStatsAccountPublicKey()))) {
|
|
3885
3910
|
addIfStakeIxs.push(await this.getInitializeUserStatsIx());
|
|
@@ -3952,6 +3977,7 @@ class DriftClient {
|
|
|
3952
3977
|
const additionalSigners = [];
|
|
3953
3978
|
const isSolMarket = spotMarketAccount.mint.equals(spotMarkets_1.WRAPPED_SOL_MINT);
|
|
3954
3979
|
const createWSOLTokenAccount = isSolMarket && collateralAccountPublicKey.equals(this.wallet.publicKey);
|
|
3980
|
+
const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
3955
3981
|
let tokenAccount;
|
|
3956
3982
|
if (createWSOLTokenAccount) {
|
|
3957
3983
|
const { ixs, pubkey } = await this.getWrappedSolAccountCreationIxs(numericConstants_1.ZERO, true);
|
|
@@ -3964,7 +3990,7 @@ class DriftClient {
|
|
|
3964
3990
|
tokenAccount = collateralAccountPublicKey;
|
|
3965
3991
|
const tokenAccountExists = await this.checkIfAccountExists(tokenAccount);
|
|
3966
3992
|
if (!tokenAccountExists) {
|
|
3967
|
-
const createTokenAccountIx = await this.createAssociatedTokenAccountIdempotentInstruction(tokenAccount, this.wallet.publicKey, this.wallet.publicKey, spotMarketAccount.mint);
|
|
3993
|
+
const createTokenAccountIx = await this.createAssociatedTokenAccountIdempotentInstruction(tokenAccount, this.wallet.publicKey, this.wallet.publicKey, spotMarketAccount.mint, tokenProgramId);
|
|
3968
3994
|
removeIfStakeIxs.push(createTokenAccountIx);
|
|
3969
3995
|
}
|
|
3970
3996
|
}
|
|
@@ -4101,6 +4127,13 @@ class DriftClient {
|
|
|
4101
4127
|
});
|
|
4102
4128
|
return ix;
|
|
4103
4129
|
}
|
|
4130
|
+
/**
|
|
4131
|
+
* This ix will donate your funds to drift revenue pool. It does not deposit into your user account
|
|
4132
|
+
* @param marketIndex
|
|
4133
|
+
* @param amount
|
|
4134
|
+
* @param userTokenAccountPublicKey
|
|
4135
|
+
* @returns
|
|
4136
|
+
*/
|
|
4104
4137
|
async depositIntoSpotMarketRevenuePool(marketIndex, amount, userTokenAccountPublicKey) {
|
|
4105
4138
|
const ix = await this.getDepositIntoSpotMarketRevenuePoolIx(marketIndex, amount, userTokenAccountPublicKey);
|
|
4106
4139
|
const tx = await this.buildTransaction([ix]);
|
|
@@ -4148,7 +4181,14 @@ class DriftClient {
|
|
|
4148
4181
|
else {
|
|
4149
4182
|
marketAccount = this.getSpotMarketAccount(marketIndex);
|
|
4150
4183
|
}
|
|
4151
|
-
|
|
4184
|
+
let takeFeeAdjustment;
|
|
4185
|
+
if (user && user.isHighLeverageMode()) {
|
|
4186
|
+
takeFeeAdjustment = 100;
|
|
4187
|
+
}
|
|
4188
|
+
else {
|
|
4189
|
+
takeFeeAdjustment = marketAccount.feeAdjustment;
|
|
4190
|
+
}
|
|
4191
|
+
takerFee += (takerFee * takeFeeAdjustment) / 100;
|
|
4152
4192
|
makerFee += (makerFee * marketAccount.feeAdjustment) / 100;
|
|
4153
4193
|
}
|
|
4154
4194
|
return {
|
|
@@ -4289,7 +4329,7 @@ class DriftClient {
|
|
|
4289
4329
|
},
|
|
4290
4330
|
});
|
|
4291
4331
|
}
|
|
4292
|
-
async getPostSwitchboardOnDemandUpdateAtomicIx(feed, numSignatures = 3) {
|
|
4332
|
+
async getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures = 3) {
|
|
4293
4333
|
const program = await this.getSwitchboardOnDemandProgram();
|
|
4294
4334
|
const feedAccount = new on_demand_1.PullFeed(program, feed);
|
|
4295
4335
|
if (!this.sbProgramFeedConfigs) {
|
|
@@ -4301,14 +4341,16 @@ class DriftClient {
|
|
|
4301
4341
|
}
|
|
4302
4342
|
const [pullIx, _responses, success] = await feedAccount.fetchUpdateIx({
|
|
4303
4343
|
numSignatures,
|
|
4304
|
-
}
|
|
4344
|
+
}, recentSlothash
|
|
4345
|
+
? [[new anchor_1.BN(recentSlothash.slot), recentSlothash.hash]]
|
|
4346
|
+
: undefined);
|
|
4305
4347
|
if (!success) {
|
|
4306
4348
|
return undefined;
|
|
4307
4349
|
}
|
|
4308
4350
|
return pullIx;
|
|
4309
4351
|
}
|
|
4310
|
-
async postSwitchboardOnDemandUpdate(feed, numSignatures = 3) {
|
|
4311
|
-
const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, numSignatures);
|
|
4352
|
+
async postSwitchboardOnDemandUpdate(feed, recentSlothash, numSignatures = 3) {
|
|
4353
|
+
const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures);
|
|
4312
4354
|
if (!pullIx) {
|
|
4313
4355
|
return undefined;
|
|
4314
4356
|
}
|
package/lib/node/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.98.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -129,6 +129,42 @@
|
|
|
129
129
|
],
|
|
130
130
|
"args": []
|
|
131
131
|
},
|
|
132
|
+
{
|
|
133
|
+
"name": "initializeSwiftUserOrders",
|
|
134
|
+
"accounts": [
|
|
135
|
+
{
|
|
136
|
+
"name": "swiftUserOrders",
|
|
137
|
+
"isMut": true,
|
|
138
|
+
"isSigner": false
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "authority",
|
|
142
|
+
"isMut": false,
|
|
143
|
+
"isSigner": true
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "user",
|
|
147
|
+
"isMut": true,
|
|
148
|
+
"isSigner": false
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "payer",
|
|
152
|
+
"isMut": true,
|
|
153
|
+
"isSigner": true
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "rent",
|
|
157
|
+
"isMut": false,
|
|
158
|
+
"isSigner": false
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "systemProgram",
|
|
162
|
+
"isMut": false,
|
|
163
|
+
"isSigner": false
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"args": []
|
|
167
|
+
},
|
|
132
168
|
{
|
|
133
169
|
"name": "initializeReferrerName",
|
|
134
170
|
"accounts": [
|
|
@@ -644,6 +680,63 @@
|
|
|
644
680
|
}
|
|
645
681
|
]
|
|
646
682
|
},
|
|
683
|
+
{
|
|
684
|
+
"name": "placeAndMakeSwiftPerpOrder",
|
|
685
|
+
"accounts": [
|
|
686
|
+
{
|
|
687
|
+
"name": "state",
|
|
688
|
+
"isMut": false,
|
|
689
|
+
"isSigner": false
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
"name": "user",
|
|
693
|
+
"isMut": true,
|
|
694
|
+
"isSigner": false
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"name": "userStats",
|
|
698
|
+
"isMut": true,
|
|
699
|
+
"isSigner": false
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"name": "taker",
|
|
703
|
+
"isMut": true,
|
|
704
|
+
"isSigner": false
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"name": "takerStats",
|
|
708
|
+
"isMut": true,
|
|
709
|
+
"isSigner": false
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"name": "takerSwiftUserOrders",
|
|
713
|
+
"isMut": false,
|
|
714
|
+
"isSigner": false
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
"name": "authority",
|
|
718
|
+
"isMut": false,
|
|
719
|
+
"isSigner": true
|
|
720
|
+
}
|
|
721
|
+
],
|
|
722
|
+
"args": [
|
|
723
|
+
{
|
|
724
|
+
"name": "params",
|
|
725
|
+
"type": {
|
|
726
|
+
"defined": "OrderParams"
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
"name": "swiftOrderUuid",
|
|
731
|
+
"type": {
|
|
732
|
+
"array": [
|
|
733
|
+
"u8",
|
|
734
|
+
8
|
|
735
|
+
]
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
]
|
|
739
|
+
},
|
|
647
740
|
{
|
|
648
741
|
"name": "placeSwiftTakerOrder",
|
|
649
742
|
"accounts": [
|
|
@@ -662,6 +755,11 @@
|
|
|
662
755
|
"isMut": true,
|
|
663
756
|
"isSigner": false
|
|
664
757
|
},
|
|
758
|
+
{
|
|
759
|
+
"name": "swiftUserOrders",
|
|
760
|
+
"isMut": true,
|
|
761
|
+
"isSigner": false
|
|
762
|
+
},
|
|
665
763
|
{
|
|
666
764
|
"name": "authority",
|
|
667
765
|
"isMut": false,
|
|
@@ -7468,6 +7566,29 @@
|
|
|
7468
7566
|
]
|
|
7469
7567
|
}
|
|
7470
7568
|
},
|
|
7569
|
+
{
|
|
7570
|
+
"name": "SwiftUserOrders",
|
|
7571
|
+
"type": {
|
|
7572
|
+
"kind": "struct",
|
|
7573
|
+
"fields": [
|
|
7574
|
+
{
|
|
7575
|
+
"name": "userPubkey",
|
|
7576
|
+
"type": "publicKey"
|
|
7577
|
+
},
|
|
7578
|
+
{
|
|
7579
|
+
"name": "swiftOrderData",
|
|
7580
|
+
"type": {
|
|
7581
|
+
"array": [
|
|
7582
|
+
{
|
|
7583
|
+
"defined": "SwiftOrderId"
|
|
7584
|
+
},
|
|
7585
|
+
32
|
|
7586
|
+
]
|
|
7587
|
+
}
|
|
7588
|
+
}
|
|
7589
|
+
]
|
|
7590
|
+
}
|
|
7591
|
+
},
|
|
7471
7592
|
{
|
|
7472
7593
|
"name": "User",
|
|
7473
7594
|
"type": {
|
|
@@ -8432,6 +8553,15 @@
|
|
|
8432
8553
|
"type": {
|
|
8433
8554
|
"kind": "struct",
|
|
8434
8555
|
"fields": [
|
|
8556
|
+
{
|
|
8557
|
+
"name": "uuid",
|
|
8558
|
+
"type": {
|
|
8559
|
+
"array": [
|
|
8560
|
+
"u8",
|
|
8561
|
+
8
|
|
8562
|
+
]
|
|
8563
|
+
}
|
|
8564
|
+
},
|
|
8435
8565
|
{
|
|
8436
8566
|
"name": "swiftOrderSignature",
|
|
8437
8567
|
"type": {
|
|
@@ -8459,10 +8589,6 @@
|
|
|
8459
8589
|
"defined": "OrderParams"
|
|
8460
8590
|
}
|
|
8461
8591
|
},
|
|
8462
|
-
{
|
|
8463
|
-
"name": "expectedOrderId",
|
|
8464
|
-
"type": "i32"
|
|
8465
|
-
},
|
|
8466
8592
|
{
|
|
8467
8593
|
"name": "subAccountId",
|
|
8468
8594
|
"type": "u16"
|
|
@@ -9642,6 +9768,31 @@
|
|
|
9642
9768
|
]
|
|
9643
9769
|
}
|
|
9644
9770
|
},
|
|
9771
|
+
{
|
|
9772
|
+
"name": "SwiftOrderId",
|
|
9773
|
+
"type": {
|
|
9774
|
+
"kind": "struct",
|
|
9775
|
+
"fields": [
|
|
9776
|
+
{
|
|
9777
|
+
"name": "uuid",
|
|
9778
|
+
"type": {
|
|
9779
|
+
"array": [
|
|
9780
|
+
"u8",
|
|
9781
|
+
8
|
|
9782
|
+
]
|
|
9783
|
+
}
|
|
9784
|
+
},
|
|
9785
|
+
{
|
|
9786
|
+
"name": "maxSlot",
|
|
9787
|
+
"type": "u64"
|
|
9788
|
+
},
|
|
9789
|
+
{
|
|
9790
|
+
"name": "orderId",
|
|
9791
|
+
"type": "u32"
|
|
9792
|
+
}
|
|
9793
|
+
]
|
|
9794
|
+
}
|
|
9795
|
+
},
|
|
9645
9796
|
{
|
|
9646
9797
|
"name": "UserFees",
|
|
9647
9798
|
"type": {
|
|
@@ -11541,13 +11692,28 @@
|
|
|
11541
11692
|
"index": false
|
|
11542
11693
|
},
|
|
11543
11694
|
{
|
|
11544
|
-
"name": "
|
|
11695
|
+
"name": "userOrderId",
|
|
11696
|
+
"type": "u32",
|
|
11697
|
+
"index": false
|
|
11698
|
+
},
|
|
11699
|
+
{
|
|
11700
|
+
"name": "swiftOrderMaxSlot",
|
|
11545
11701
|
"type": "u64",
|
|
11546
11702
|
"index": false
|
|
11547
11703
|
},
|
|
11548
11704
|
{
|
|
11549
|
-
"name": "
|
|
11550
|
-
"type":
|
|
11705
|
+
"name": "swiftOrderUuid",
|
|
11706
|
+
"type": {
|
|
11707
|
+
"array": [
|
|
11708
|
+
"u8",
|
|
11709
|
+
8
|
|
11710
|
+
]
|
|
11711
|
+
},
|
|
11712
|
+
"index": false
|
|
11713
|
+
},
|
|
11714
|
+
{
|
|
11715
|
+
"name": "ts",
|
|
11716
|
+
"type": "i64",
|
|
11551
11717
|
"index": false
|
|
11552
11718
|
}
|
|
11553
11719
|
]
|
|
@@ -13671,6 +13837,31 @@
|
|
|
13671
13837
|
"code": 6296,
|
|
13672
13838
|
"name": "InvalidRFQMatch",
|
|
13673
13839
|
"msg": "RFQ matches must be valid"
|
|
13840
|
+
},
|
|
13841
|
+
{
|
|
13842
|
+
"code": 6297,
|
|
13843
|
+
"name": "InvalidSwiftUserAccount",
|
|
13844
|
+
"msg": "Invalid swift user account"
|
|
13845
|
+
},
|
|
13846
|
+
{
|
|
13847
|
+
"code": 6298,
|
|
13848
|
+
"name": "SwiftUserAccountWrongMutability",
|
|
13849
|
+
"msg": "Swift account wrong mutability"
|
|
13850
|
+
},
|
|
13851
|
+
{
|
|
13852
|
+
"code": 6299,
|
|
13853
|
+
"name": "SwiftUserOrdersAccountFull",
|
|
13854
|
+
"msg": "SwiftUserAccount has too many active orders"
|
|
13855
|
+
},
|
|
13856
|
+
{
|
|
13857
|
+
"code": 6300,
|
|
13858
|
+
"name": "SwiftOrderDoesNotExist",
|
|
13859
|
+
"msg": "Order with swift uuid does not exist"
|
|
13860
|
+
},
|
|
13861
|
+
{
|
|
13862
|
+
"code": 6301,
|
|
13863
|
+
"name": "InvalidSwiftOrderId",
|
|
13864
|
+
"msg": "Swift order id cannot be 0s"
|
|
13674
13865
|
}
|
|
13675
13866
|
],
|
|
13676
13867
|
"metadata": {
|
package/lib/node/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './constants/perpMarkets';
|
|
|
10
10
|
export * from './accounts/fetch';
|
|
11
11
|
export * from './accounts/webSocketDriftClientAccountSubscriber';
|
|
12
12
|
export * from './accounts/webSocketInsuranceFundStakeAccountSubscriber';
|
|
13
|
+
export * from './accounts/webSocketHighLeverageModeConfigAccountSubscriber';
|
|
13
14
|
export * from './accounts/bulkAccountLoader';
|
|
14
15
|
export * from './accounts/bulkUserSubscription';
|
|
15
16
|
export * from './accounts/bulkUserStatsSubscription';
|
|
@@ -19,6 +20,7 @@ export * from './accounts/pollingTokenAccountSubscriber';
|
|
|
19
20
|
export * from './accounts/pollingUserAccountSubscriber';
|
|
20
21
|
export * from './accounts/pollingUserStatsAccountSubscriber';
|
|
21
22
|
export * from './accounts/pollingInsuranceFundStakeAccountSubscriber';
|
|
23
|
+
export * from './accounts/pollingHighLeverageModeConfigAccountSubscriber';
|
|
22
24
|
export * from './accounts/basicUserAccountSubscriber';
|
|
23
25
|
export * from './accounts/oneShotUserAccountSubscriber';
|
|
24
26
|
export * from './accounts/types';
|
|
@@ -64,6 +66,7 @@ export * from './math/tiers';
|
|
|
64
66
|
export * from './marinade';
|
|
65
67
|
export * from './orderParams';
|
|
66
68
|
export * from './slot/SlotSubscriber';
|
|
69
|
+
export * from './slot/SlothashSubscriber';
|
|
67
70
|
export * from './wallet';
|
|
68
71
|
export * from './keypair';
|
|
69
72
|
export * from './types';
|
|
@@ -104,6 +107,7 @@ export * from './dlob/DLOBApiClient';
|
|
|
104
107
|
export * from './dlob/types';
|
|
105
108
|
export * from './dlob/orderBookLevels';
|
|
106
109
|
export * from './userMap/userMap';
|
|
110
|
+
export * from './userMap/referrerMap';
|
|
107
111
|
export * from './userMap/userStatsMap';
|
|
108
112
|
export * from './userMap/userMapConfig';
|
|
109
113
|
export * from './math/bankruptcy';
|
package/lib/node/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./constants/perpMarkets"), exports);
|
|
|
33
33
|
__exportStar(require("./accounts/fetch"), exports);
|
|
34
34
|
__exportStar(require("./accounts/webSocketDriftClientAccountSubscriber"), exports);
|
|
35
35
|
__exportStar(require("./accounts/webSocketInsuranceFundStakeAccountSubscriber"), exports);
|
|
36
|
+
__exportStar(require("./accounts/webSocketHighLeverageModeConfigAccountSubscriber"), exports);
|
|
36
37
|
__exportStar(require("./accounts/bulkAccountLoader"), exports);
|
|
37
38
|
__exportStar(require("./accounts/bulkUserSubscription"), exports);
|
|
38
39
|
__exportStar(require("./accounts/bulkUserStatsSubscription"), exports);
|
|
@@ -42,6 +43,7 @@ __exportStar(require("./accounts/pollingTokenAccountSubscriber"), exports);
|
|
|
42
43
|
__exportStar(require("./accounts/pollingUserAccountSubscriber"), exports);
|
|
43
44
|
__exportStar(require("./accounts/pollingUserStatsAccountSubscriber"), exports);
|
|
44
45
|
__exportStar(require("./accounts/pollingInsuranceFundStakeAccountSubscriber"), exports);
|
|
46
|
+
__exportStar(require("./accounts/pollingHighLeverageModeConfigAccountSubscriber"), exports);
|
|
45
47
|
__exportStar(require("./accounts/basicUserAccountSubscriber"), exports);
|
|
46
48
|
__exportStar(require("./accounts/oneShotUserAccountSubscriber"), exports);
|
|
47
49
|
__exportStar(require("./accounts/types"), exports);
|
|
@@ -87,6 +89,7 @@ __exportStar(require("./math/tiers"), exports);
|
|
|
87
89
|
__exportStar(require("./marinade"), exports);
|
|
88
90
|
__exportStar(require("./orderParams"), exports);
|
|
89
91
|
__exportStar(require("./slot/SlotSubscriber"), exports);
|
|
92
|
+
__exportStar(require("./slot/SlothashSubscriber"), exports);
|
|
90
93
|
__exportStar(require("./wallet"), exports);
|
|
91
94
|
__exportStar(require("./keypair"), exports);
|
|
92
95
|
__exportStar(require("./types"), exports);
|
|
@@ -127,6 +130,7 @@ __exportStar(require("./dlob/DLOBApiClient"), exports);
|
|
|
127
130
|
__exportStar(require("./dlob/types"), exports);
|
|
128
131
|
__exportStar(require("./dlob/orderBookLevels"), exports);
|
|
129
132
|
__exportStar(require("./userMap/userMap"), exports);
|
|
133
|
+
__exportStar(require("./userMap/referrerMap"), exports);
|
|
130
134
|
__exportStar(require("./userMap/userStatsMap"), exports);
|
|
131
135
|
__exportStar(require("./userMap/userMapConfig"), exports);
|
|
132
136
|
__exportStar(require("./math/bankruptcy"), exports);
|
|
@@ -201,6 +201,12 @@ export interface QuoteResponse {
|
|
|
201
201
|
* @memberof QuoteResponse
|
|
202
202
|
*/
|
|
203
203
|
error?: string;
|
|
204
|
+
/**
|
|
205
|
+
*
|
|
206
|
+
* @type {string}
|
|
207
|
+
* @memberof QuoteResponse
|
|
208
|
+
*/
|
|
209
|
+
errorCode?: string;
|
|
204
210
|
}
|
|
205
211
|
export declare class JupiterClient {
|
|
206
212
|
url: string;
|
package/lib/node/memcmp.d.ts
CHANGED
|
@@ -5,3 +5,6 @@ export declare function getUserWithOrderFilter(): MemcmpFilter;
|
|
|
5
5
|
export declare function getUserWithAuctionFilter(): MemcmpFilter;
|
|
6
6
|
export declare function getUserThatHasBeenLP(): MemcmpFilter;
|
|
7
7
|
export declare function getUserWithName(name: string): MemcmpFilter;
|
|
8
|
+
export declare function getUserStatsFilter(): MemcmpFilter;
|
|
9
|
+
export declare function getUserStatsIsReferredFilter(): MemcmpFilter;
|
|
10
|
+
export declare function getUserStatsIsReferredOrReferrerFilter(): MemcmpFilter;
|
package/lib/node/memcmp.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getUserWithName = exports.getUserThatHasBeenLP = exports.getUserWithAuctionFilter = exports.getUserWithOrderFilter = exports.getNonIdleUserFilter = exports.getUserFilter = void 0;
|
|
6
|
+
exports.getUserStatsIsReferredOrReferrerFilter = exports.getUserStatsIsReferredFilter = exports.getUserStatsFilter = exports.getUserWithName = exports.getUserThatHasBeenLP = exports.getUserWithAuctionFilter = exports.getUserWithOrderFilter = exports.getNonIdleUserFilter = exports.getUserFilter = void 0;
|
|
7
7
|
const bs58_1 = __importDefault(require("bs58"));
|
|
8
8
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
9
|
const userName_1 = require("./userName");
|
|
@@ -61,3 +61,30 @@ function getUserWithName(name) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
exports.getUserWithName = getUserWithName;
|
|
64
|
+
function getUserStatsFilter() {
|
|
65
|
+
return {
|
|
66
|
+
memcmp: {
|
|
67
|
+
offset: 0,
|
|
68
|
+
bytes: bs58_1.default.encode(anchor_1.BorshAccountsCoder.accountDiscriminator('UserStats')),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exports.getUserStatsFilter = getUserStatsFilter;
|
|
73
|
+
function getUserStatsIsReferredFilter() {
|
|
74
|
+
return {
|
|
75
|
+
memcmp: {
|
|
76
|
+
offset: 188,
|
|
77
|
+
bytes: bs58_1.default.encode(Buffer.from(Uint8Array.from([2]))),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.getUserStatsIsReferredFilter = getUserStatsIsReferredFilter;
|
|
82
|
+
function getUserStatsIsReferredOrReferrerFilter() {
|
|
83
|
+
return {
|
|
84
|
+
memcmp: {
|
|
85
|
+
offset: 188,
|
|
86
|
+
bytes: bs58_1.default.encode(Buffer.from(Uint8Array.from([3]))),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.getUserStatsIsReferredOrReferrerFilter = getUserStatsIsReferredOrReferrerFilter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Commitment, Connection } from '@solana/web3.js';
|
|
3
|
+
type SlothashSubscriberConfig = {
|
|
4
|
+
resubTimeoutMs?: number;
|
|
5
|
+
commitment?: Commitment;
|
|
6
|
+
};
|
|
7
|
+
export type Slothash = {
|
|
8
|
+
slot: number;
|
|
9
|
+
hash: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class SlothashSubscriber {
|
|
12
|
+
private connection;
|
|
13
|
+
currentSlothash: Slothash;
|
|
14
|
+
subscriptionId: number;
|
|
15
|
+
commitment: Commitment;
|
|
16
|
+
timeoutId?: NodeJS.Timeout;
|
|
17
|
+
resubTimeoutMs?: number;
|
|
18
|
+
isUnsubscribing: boolean;
|
|
19
|
+
receivingData: boolean;
|
|
20
|
+
constructor(connection: Connection, config?: SlothashSubscriberConfig);
|
|
21
|
+
subscribe(): Promise<void>;
|
|
22
|
+
private setTimeout;
|
|
23
|
+
getSlothash(): Slothash;
|
|
24
|
+
unsubscribe(onResub?: boolean): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|