@drift-labs/sdk 2.152.0-beta.2 → 2.153.0-beta.1
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/build-browser.js +58 -0
- package/bun.lock +182 -1
- package/esbuild-shims.js +12 -0
- package/lib/browser/constants/perpMarkets.js +12 -0
- package/lib/browser/driftClient.d.ts +7 -0
- package/lib/browser/driftClient.js +96 -0
- package/lib/browser/idl/drift.json +207 -18
- package/lib/browser/swap/UnifiedSwapClient.js +2 -0
- package/lib/browser/titan/titanClient.d.ts +3 -0
- package/lib/browser/titan/titanClient.js +58 -60
- package/lib/browser/user.d.ts +1 -1
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +12 -0
- package/lib/node/driftClient.d.ts +7 -0
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +96 -0
- package/lib/node/idl/drift.json +207 -18
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +2 -0
- package/lib/node/titan/titanClient.d.ts +3 -0
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.js +58 -60
- package/lib/node/user.d.ts +1 -1
- package/lib/node/user.d.ts.map +1 -1
- package/package.json +10 -2
- package/src/constants/perpMarkets.ts +13 -0
- package/src/driftClient.ts +213 -0
- package/src/idl/drift.json +207 -18
- package/src/swap/UnifiedSwapClient.ts +2 -0
- package/src/titan/titanClient.ts +88 -72
- package/src/user.ts +1 -1
|
@@ -1439,6 +1439,19 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
1439
1439
|
oracleSource: OracleSource.PYTH_LAZER_1K,
|
|
1440
1440
|
pythLazerId: 2396,
|
|
1441
1441
|
},
|
|
1442
|
+
{
|
|
1443
|
+
fullName: 'Lighter',
|
|
1444
|
+
category: ['DEX'],
|
|
1445
|
+
symbol: 'LIT-PERP',
|
|
1446
|
+
baseAssetSymbol: 'LIT',
|
|
1447
|
+
marketIndex: 84,
|
|
1448
|
+
oracle: new PublicKey('HsfwxaJdpY5Dvd3ttrrY7YL635T7D9W443XdTwE2Dvbh'),
|
|
1449
|
+
launchTs: 1767621600000,
|
|
1450
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
1451
|
+
pythFeedId:
|
|
1452
|
+
'0xc0c83f00c39165892d55dcd17ade2191e289697e2ac132d9ab721e20834e2a9e',
|
|
1453
|
+
pythLazerId: 2921,
|
|
1454
|
+
},
|
|
1442
1455
|
];
|
|
1443
1456
|
|
|
1444
1457
|
export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
|
package/src/driftClient.ts
CHANGED
|
@@ -2469,6 +2469,15 @@ export class DriftClient {
|
|
|
2469
2469
|
return this.getTokenAmount(QUOTE_SPOT_MARKET_INDEX);
|
|
2470
2470
|
}
|
|
2471
2471
|
|
|
2472
|
+
public getIsolatedPerpPositionTokenAmount(
|
|
2473
|
+
perpMarketIndex: number,
|
|
2474
|
+
subAccountId?: number
|
|
2475
|
+
): BN {
|
|
2476
|
+
return this.getUser(subAccountId).getIsolatePerpPositionTokenAmount(
|
|
2477
|
+
perpMarketIndex
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2472
2481
|
/**
|
|
2473
2482
|
* Returns the token amount for a given market. The spot market precision is based on the token mint decimals.
|
|
2474
2483
|
* Positive if it is a deposit, negative if it is a borrow.
|
|
@@ -3367,6 +3376,25 @@ export class DriftClient {
|
|
|
3367
3376
|
ixs.push(...startIxs);
|
|
3368
3377
|
}
|
|
3369
3378
|
|
|
3379
|
+
// For Token2022 tokens, check if the user's token account exists and create it if it doesn't
|
|
3380
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
3381
|
+
if (
|
|
3382
|
+
!isSolMarket &&
|
|
3383
|
+
!isFromSubaccount &&
|
|
3384
|
+
!tokenProgram.equals(TOKEN_PROGRAM_ID)
|
|
3385
|
+
) {
|
|
3386
|
+
const accountExists = await this.checkIfAccountExists(userTokenAccount);
|
|
3387
|
+
|
|
3388
|
+
if (!accountExists) {
|
|
3389
|
+
const createAtaIx = this.getAssociatedTokenAccountCreationIx(
|
|
3390
|
+
spotMarket.mint,
|
|
3391
|
+
userTokenAccount,
|
|
3392
|
+
tokenProgram
|
|
3393
|
+
);
|
|
3394
|
+
ixs.push(createAtaIx);
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3370
3398
|
const depositCollateralIx = isFromSubaccount
|
|
3371
3399
|
? await this.getTransferDepositIx(
|
|
3372
3400
|
amount,
|
|
@@ -4082,6 +4110,191 @@ export class DriftClient {
|
|
|
4082
4110
|
);
|
|
4083
4111
|
}
|
|
4084
4112
|
|
|
4113
|
+
async depositIntoIsolatedPerpPosition(
|
|
4114
|
+
amount: BN,
|
|
4115
|
+
perpMarketIndex: number,
|
|
4116
|
+
userTokenAccount: PublicKey,
|
|
4117
|
+
subAccountId?: number,
|
|
4118
|
+
txParams?: TxParams
|
|
4119
|
+
): Promise<TransactionSignature> {
|
|
4120
|
+
const { txSig } = await this.sendTransaction(
|
|
4121
|
+
await this.buildTransaction(
|
|
4122
|
+
await this.getDepositIntoIsolatedPerpPositionIx(
|
|
4123
|
+
amount,
|
|
4124
|
+
perpMarketIndex,
|
|
4125
|
+
userTokenAccount,
|
|
4126
|
+
subAccountId
|
|
4127
|
+
),
|
|
4128
|
+
txParams
|
|
4129
|
+
),
|
|
4130
|
+
[],
|
|
4131
|
+
this.opts
|
|
4132
|
+
);
|
|
4133
|
+
return txSig;
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
async getDepositIntoIsolatedPerpPositionIx(
|
|
4137
|
+
amount: BN,
|
|
4138
|
+
perpMarketIndex: number,
|
|
4139
|
+
userTokenAccount: PublicKey,
|
|
4140
|
+
subAccountId?: number
|
|
4141
|
+
): Promise<TransactionInstruction> {
|
|
4142
|
+
const userAccountPublicKey = await getUserAccountPublicKey(
|
|
4143
|
+
this.program.programId,
|
|
4144
|
+
this.authority,
|
|
4145
|
+
subAccountId ?? this.activeSubAccountId
|
|
4146
|
+
);
|
|
4147
|
+
|
|
4148
|
+
const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
|
|
4149
|
+
const spotMarketIndex = perpMarketAccount.quoteSpotMarketIndex;
|
|
4150
|
+
const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
|
|
4151
|
+
|
|
4152
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
4153
|
+
userAccounts: [],
|
|
4154
|
+
writableSpotMarketIndexes: [spotMarketIndex],
|
|
4155
|
+
readablePerpMarketIndex: [perpMarketIndex],
|
|
4156
|
+
});
|
|
4157
|
+
|
|
4158
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
4159
|
+
return await this.program.instruction.depositIntoIsolatedPerpPosition(
|
|
4160
|
+
spotMarketIndex,
|
|
4161
|
+
perpMarketIndex,
|
|
4162
|
+
amount,
|
|
4163
|
+
{
|
|
4164
|
+
accounts: {
|
|
4165
|
+
state: await this.getStatePublicKey(),
|
|
4166
|
+
spotMarketVault: spotMarketAccount.vault,
|
|
4167
|
+
user: userAccountPublicKey,
|
|
4168
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
4169
|
+
userTokenAccount: userTokenAccount,
|
|
4170
|
+
authority: this.wallet.publicKey,
|
|
4171
|
+
tokenProgram,
|
|
4172
|
+
},
|
|
4173
|
+
remainingAccounts,
|
|
4174
|
+
}
|
|
4175
|
+
);
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
public async transferIsolatedPerpPositionDeposit(
|
|
4179
|
+
amount: BN,
|
|
4180
|
+
perpMarketIndex: number,
|
|
4181
|
+
subAccountId?: number,
|
|
4182
|
+
txParams?: TxParams
|
|
4183
|
+
): Promise<TransactionSignature> {
|
|
4184
|
+
const { txSig } = await this.sendTransaction(
|
|
4185
|
+
await this.buildTransaction(
|
|
4186
|
+
await this.getTransferIsolatedPerpPositionDepositIx(
|
|
4187
|
+
amount,
|
|
4188
|
+
perpMarketIndex,
|
|
4189
|
+
subAccountId
|
|
4190
|
+
),
|
|
4191
|
+
txParams
|
|
4192
|
+
),
|
|
4193
|
+
[],
|
|
4194
|
+
this.opts
|
|
4195
|
+
);
|
|
4196
|
+
return txSig;
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
public async getTransferIsolatedPerpPositionDepositIx(
|
|
4200
|
+
amount: BN,
|
|
4201
|
+
perpMarketIndex: number,
|
|
4202
|
+
subAccountId?: number
|
|
4203
|
+
): Promise<TransactionInstruction> {
|
|
4204
|
+
const userAccountPublicKey = await getUserAccountPublicKey(
|
|
4205
|
+
this.program.programId,
|
|
4206
|
+
this.authority,
|
|
4207
|
+
subAccountId ?? this.activeSubAccountId
|
|
4208
|
+
);
|
|
4209
|
+
|
|
4210
|
+
const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
|
|
4211
|
+
const spotMarketIndex = perpMarketAccount.quoteSpotMarketIndex;
|
|
4212
|
+
const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
|
|
4213
|
+
const user = await this.getUserAccount(subAccountId);
|
|
4214
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
4215
|
+
userAccounts: [user],
|
|
4216
|
+
writableSpotMarketIndexes: [spotMarketIndex],
|
|
4217
|
+
readablePerpMarketIndex: [perpMarketIndex],
|
|
4218
|
+
});
|
|
4219
|
+
|
|
4220
|
+
return await this.program.instruction.transferIsolatedPerpPositionDeposit(
|
|
4221
|
+
spotMarketIndex,
|
|
4222
|
+
perpMarketIndex,
|
|
4223
|
+
amount,
|
|
4224
|
+
{
|
|
4225
|
+
accounts: {
|
|
4226
|
+
state: await this.getStatePublicKey(),
|
|
4227
|
+
spotMarketVault: spotMarketAccount.vault,
|
|
4228
|
+
user: userAccountPublicKey,
|
|
4229
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
4230
|
+
authority: this.wallet.publicKey,
|
|
4231
|
+
},
|
|
4232
|
+
remainingAccounts,
|
|
4233
|
+
}
|
|
4234
|
+
);
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
public async withdrawFromIsolatedPerpPosition(
|
|
4238
|
+
amount: BN,
|
|
4239
|
+
perpMarketIndex: number,
|
|
4240
|
+
userTokenAccount: PublicKey,
|
|
4241
|
+
subAccountId?: number,
|
|
4242
|
+
txParams?: TxParams
|
|
4243
|
+
): Promise<TransactionSignature> {
|
|
4244
|
+
const { txSig } = await this.sendTransaction(
|
|
4245
|
+
await this.buildTransaction(
|
|
4246
|
+
await this.getWithdrawFromIsolatedPerpPositionIx(
|
|
4247
|
+
amount,
|
|
4248
|
+
perpMarketIndex,
|
|
4249
|
+
userTokenAccount,
|
|
4250
|
+
subAccountId
|
|
4251
|
+
),
|
|
4252
|
+
txParams
|
|
4253
|
+
)
|
|
4254
|
+
);
|
|
4255
|
+
return txSig;
|
|
4256
|
+
}
|
|
4257
|
+
|
|
4258
|
+
public async getWithdrawFromIsolatedPerpPositionIx(
|
|
4259
|
+
amount: BN,
|
|
4260
|
+
perpMarketIndex: number,
|
|
4261
|
+
userTokenAccount: PublicKey,
|
|
4262
|
+
subAccountId?: number
|
|
4263
|
+
): Promise<TransactionInstruction> {
|
|
4264
|
+
const userAccountPublicKey = await getUserAccountPublicKey(
|
|
4265
|
+
this.program.programId,
|
|
4266
|
+
this.authority,
|
|
4267
|
+
subAccountId ?? this.activeSubAccountId
|
|
4268
|
+
);
|
|
4269
|
+
const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
|
|
4270
|
+
const spotMarketIndex = perpMarketAccount.quoteSpotMarketIndex;
|
|
4271
|
+
const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
|
|
4272
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
4273
|
+
userAccounts: [this.getUserAccount(subAccountId)],
|
|
4274
|
+
writableSpotMarketIndexes: [spotMarketIndex],
|
|
4275
|
+
readablePerpMarketIndex: [perpMarketIndex],
|
|
4276
|
+
});
|
|
4277
|
+
|
|
4278
|
+
return await this.program.instruction.withdrawFromIsolatedPerpPosition(
|
|
4279
|
+
spotMarketIndex,
|
|
4280
|
+
perpMarketIndex,
|
|
4281
|
+
amount,
|
|
4282
|
+
{
|
|
4283
|
+
accounts: {
|
|
4284
|
+
state: await this.getStatePublicKey(),
|
|
4285
|
+
spotMarketVault: spotMarketAccount.vault,
|
|
4286
|
+
user: userAccountPublicKey,
|
|
4287
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
4288
|
+
authority: this.wallet.publicKey,
|
|
4289
|
+
userTokenAccount: userTokenAccount,
|
|
4290
|
+
tokenProgram: this.getTokenProgramForSpotMarket(spotMarketAccount),
|
|
4291
|
+
driftSigner: this.getSignerPublicKey(),
|
|
4292
|
+
},
|
|
4293
|
+
remainingAccounts,
|
|
4294
|
+
}
|
|
4295
|
+
);
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4085
4298
|
public async updateSpotMarketCumulativeInterest(
|
|
4086
4299
|
marketIndex: number,
|
|
4087
4300
|
txParams?: TxParams
|
package/src/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.152.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
{
|
|
24
24
|
"name": "authority",
|
|
25
25
|
"isMut": false,
|
|
26
|
-
"isSigner":
|
|
26
|
+
"isSigner": false
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"name": "payer",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
{
|
|
74
74
|
"name": "authority",
|
|
75
75
|
"isMut": false,
|
|
76
|
-
"isSigner":
|
|
76
|
+
"isSigner": false
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
"name": "payer",
|
|
@@ -652,6 +652,163 @@
|
|
|
652
652
|
}
|
|
653
653
|
]
|
|
654
654
|
},
|
|
655
|
+
{
|
|
656
|
+
"name": "depositIntoIsolatedPerpPosition",
|
|
657
|
+
"accounts": [
|
|
658
|
+
{
|
|
659
|
+
"name": "state",
|
|
660
|
+
"isMut": false,
|
|
661
|
+
"isSigner": false
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"name": "user",
|
|
665
|
+
"isMut": true,
|
|
666
|
+
"isSigner": false
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
"name": "userStats",
|
|
670
|
+
"isMut": true,
|
|
671
|
+
"isSigner": false
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
"name": "authority",
|
|
675
|
+
"isMut": false,
|
|
676
|
+
"isSigner": true
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
"name": "spotMarketVault",
|
|
680
|
+
"isMut": true,
|
|
681
|
+
"isSigner": false
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"name": "userTokenAccount",
|
|
685
|
+
"isMut": true,
|
|
686
|
+
"isSigner": false
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"name": "tokenProgram",
|
|
690
|
+
"isMut": false,
|
|
691
|
+
"isSigner": false
|
|
692
|
+
}
|
|
693
|
+
],
|
|
694
|
+
"args": [
|
|
695
|
+
{
|
|
696
|
+
"name": "spotMarketIndex",
|
|
697
|
+
"type": "u16"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
"name": "perpMarketIndex",
|
|
701
|
+
"type": "u16"
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"name": "amount",
|
|
705
|
+
"type": "u64"
|
|
706
|
+
}
|
|
707
|
+
]
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
"name": "transferIsolatedPerpPositionDeposit",
|
|
711
|
+
"accounts": [
|
|
712
|
+
{
|
|
713
|
+
"name": "user",
|
|
714
|
+
"isMut": true,
|
|
715
|
+
"isSigner": false
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
"name": "userStats",
|
|
719
|
+
"isMut": true,
|
|
720
|
+
"isSigner": false
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
"name": "authority",
|
|
724
|
+
"isMut": false,
|
|
725
|
+
"isSigner": true
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"name": "state",
|
|
729
|
+
"isMut": false,
|
|
730
|
+
"isSigner": false
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
"name": "spotMarketVault",
|
|
734
|
+
"isMut": false,
|
|
735
|
+
"isSigner": false
|
|
736
|
+
}
|
|
737
|
+
],
|
|
738
|
+
"args": [
|
|
739
|
+
{
|
|
740
|
+
"name": "spotMarketIndex",
|
|
741
|
+
"type": "u16"
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
"name": "perpMarketIndex",
|
|
745
|
+
"type": "u16"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
"name": "amount",
|
|
749
|
+
"type": "i64"
|
|
750
|
+
}
|
|
751
|
+
]
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
"name": "withdrawFromIsolatedPerpPosition",
|
|
755
|
+
"accounts": [
|
|
756
|
+
{
|
|
757
|
+
"name": "state",
|
|
758
|
+
"isMut": false,
|
|
759
|
+
"isSigner": false
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"name": "user",
|
|
763
|
+
"isMut": true,
|
|
764
|
+
"isSigner": false
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
"name": "userStats",
|
|
768
|
+
"isMut": true,
|
|
769
|
+
"isSigner": false
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
"name": "authority",
|
|
773
|
+
"isMut": false,
|
|
774
|
+
"isSigner": true
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
"name": "spotMarketVault",
|
|
778
|
+
"isMut": true,
|
|
779
|
+
"isSigner": false
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"name": "driftSigner",
|
|
783
|
+
"isMut": false,
|
|
784
|
+
"isSigner": false
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"name": "userTokenAccount",
|
|
788
|
+
"isMut": true,
|
|
789
|
+
"isSigner": false
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
"name": "tokenProgram",
|
|
793
|
+
"isMut": false,
|
|
794
|
+
"isSigner": false
|
|
795
|
+
}
|
|
796
|
+
],
|
|
797
|
+
"args": [
|
|
798
|
+
{
|
|
799
|
+
"name": "spotMarketIndex",
|
|
800
|
+
"type": "u16"
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
"name": "perpMarketIndex",
|
|
804
|
+
"type": "u16"
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"name": "amount",
|
|
808
|
+
"type": "u64"
|
|
809
|
+
}
|
|
810
|
+
]
|
|
811
|
+
},
|
|
655
812
|
{
|
|
656
813
|
"name": "placePerpOrder",
|
|
657
814
|
"accounts": [
|
|
@@ -11584,7 +11741,7 @@
|
|
|
11584
11741
|
},
|
|
11585
11742
|
{
|
|
11586
11743
|
"name": "disableUpdatePerpBidAskTwap",
|
|
11587
|
-
"type": "
|
|
11744
|
+
"type": "u8"
|
|
11588
11745
|
},
|
|
11589
11746
|
{
|
|
11590
11747
|
"name": "pausedOperations",
|
|
@@ -14407,13 +14564,13 @@
|
|
|
14407
14564
|
"type": "u64"
|
|
14408
14565
|
},
|
|
14409
14566
|
{
|
|
14410
|
-
"name": "
|
|
14567
|
+
"name": "isolatedPositionScaledBalance",
|
|
14411
14568
|
"docs": [
|
|
14412
14569
|
"The last base asset amount per lp the amm had",
|
|
14413
14570
|
"Used to settle the users lp position",
|
|
14414
|
-
"precision:
|
|
14571
|
+
"precision: SPOT_BALANCE_PRECISION"
|
|
14415
14572
|
],
|
|
14416
|
-
"type": "
|
|
14573
|
+
"type": "u64"
|
|
14417
14574
|
},
|
|
14418
14575
|
{
|
|
14419
14576
|
"name": "lastQuoteAssetAmountPerLp",
|
|
@@ -14452,8 +14609,8 @@
|
|
|
14452
14609
|
"type": "u8"
|
|
14453
14610
|
},
|
|
14454
14611
|
{
|
|
14455
|
-
"name": "
|
|
14456
|
-
"type": "
|
|
14612
|
+
"name": "positionFlag",
|
|
14613
|
+
"type": "u8"
|
|
14457
14614
|
}
|
|
14458
14615
|
]
|
|
14459
14616
|
}
|
|
@@ -15133,6 +15290,17 @@
|
|
|
15133
15290
|
]
|
|
15134
15291
|
}
|
|
15135
15292
|
},
|
|
15293
|
+
{
|
|
15294
|
+
"name": "LiquidationBitFlag",
|
|
15295
|
+
"type": {
|
|
15296
|
+
"kind": "enum",
|
|
15297
|
+
"variants": [
|
|
15298
|
+
{
|
|
15299
|
+
"name": "IsolatedPosition"
|
|
15300
|
+
}
|
|
15301
|
+
]
|
|
15302
|
+
}
|
|
15303
|
+
},
|
|
15136
15304
|
{
|
|
15137
15305
|
"name": "SettlePnlExplanation",
|
|
15138
15306
|
"type": {
|
|
@@ -15262,13 +15430,7 @@
|
|
|
15262
15430
|
"kind": "enum",
|
|
15263
15431
|
"variants": [
|
|
15264
15432
|
{
|
|
15265
|
-
"name": "Standard"
|
|
15266
|
-
"fields": [
|
|
15267
|
-
{
|
|
15268
|
-
"name": "trackOpenOrdersFraction",
|
|
15269
|
-
"type": "bool"
|
|
15270
|
-
}
|
|
15271
|
-
]
|
|
15433
|
+
"name": "Standard"
|
|
15272
15434
|
},
|
|
15273
15435
|
{
|
|
15274
15436
|
"name": "Liquidation",
|
|
@@ -15910,6 +16072,23 @@
|
|
|
15910
16072
|
]
|
|
15911
16073
|
}
|
|
15912
16074
|
},
|
|
16075
|
+
{
|
|
16076
|
+
"name": "PositionFlag",
|
|
16077
|
+
"type": {
|
|
16078
|
+
"kind": "enum",
|
|
16079
|
+
"variants": [
|
|
16080
|
+
{
|
|
16081
|
+
"name": "IsolatedPosition"
|
|
16082
|
+
},
|
|
16083
|
+
{
|
|
16084
|
+
"name": "BeingLiquidated"
|
|
16085
|
+
},
|
|
16086
|
+
{
|
|
16087
|
+
"name": "Bankrupt"
|
|
16088
|
+
}
|
|
16089
|
+
]
|
|
16090
|
+
}
|
|
16091
|
+
},
|
|
15913
16092
|
{
|
|
15914
16093
|
"name": "ReferrerStatus",
|
|
15915
16094
|
"type": {
|
|
@@ -16903,6 +17082,11 @@
|
|
|
16903
17082
|
"defined": "SpotBankruptcyRecord"
|
|
16904
17083
|
},
|
|
16905
17084
|
"index": false
|
|
17085
|
+
},
|
|
17086
|
+
{
|
|
17087
|
+
"name": "bitFlags",
|
|
17088
|
+
"type": "u8",
|
|
17089
|
+
"index": false
|
|
16906
17090
|
}
|
|
16907
17091
|
]
|
|
16908
17092
|
},
|
|
@@ -18339,8 +18523,8 @@
|
|
|
18339
18523
|
},
|
|
18340
18524
|
{
|
|
18341
18525
|
"code": 6094,
|
|
18342
|
-
"name": "
|
|
18343
|
-
"msg": "
|
|
18526
|
+
"name": "CantUpdateSpotBalanceType",
|
|
18527
|
+
"msg": "CantUpdateSpotBalanceType"
|
|
18344
18528
|
},
|
|
18345
18529
|
{
|
|
18346
18530
|
"code": 6095,
|
|
@@ -19591,6 +19775,11 @@
|
|
|
19591
19775
|
"code": 6344,
|
|
19592
19776
|
"name": "MarketIndexNotFoundAmmCache",
|
|
19593
19777
|
"msg": "MarketIndexNotFoundAmmCache"
|
|
19778
|
+
},
|
|
19779
|
+
{
|
|
19780
|
+
"code": 6345,
|
|
19781
|
+
"name": "InvalidIsolatedPerpMarket",
|
|
19782
|
+
"msg": "Invalid Isolated Perp Market"
|
|
19594
19783
|
}
|
|
19595
19784
|
],
|
|
19596
19785
|
"metadata": {
|
|
@@ -143,6 +143,7 @@ export class UnifiedSwapClient {
|
|
|
143
143
|
...titanParams,
|
|
144
144
|
userPublicKey: titanParams.userPublicKey,
|
|
145
145
|
swapMode: titanParams.swapMode as string, // Titan expects string
|
|
146
|
+
sizeConstraint: titanParams.sizeConstraint || 1280 - 375, // Use same default as getSwapInstructions
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
return await titanClient.getQuote(titanParamsWithUser);
|
|
@@ -177,6 +178,7 @@ export class UnifiedSwapClient {
|
|
|
177
178
|
userPublicKey,
|
|
178
179
|
slippageBps: slippageBps || titanQuote.slippageBps,
|
|
179
180
|
swapMode: titanQuote.swapMode,
|
|
181
|
+
sizeConstraint: 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for drift instructions
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
return {
|