@drift-labs/sdk 2.112.0-beta.11 → 2.112.0-beta.12
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/driftClient.d.ts +2 -2
- package/lib/browser/driftClient.js +9 -6
- package/lib/node/driftClient.d.ts +2 -2
- package/lib/node/driftClient.js +9 -6
- package/package.json +1 -1
- package/src/driftClient.ts +15 -6
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.112.0-beta.
|
|
1
|
+
2.112.0-beta.12
|
|
@@ -154,7 +154,7 @@ export declare class DriftClient {
|
|
|
154
154
|
* @param referrerInfo
|
|
155
155
|
* @returns [instructions, userAccountPublicKey]
|
|
156
156
|
*/
|
|
157
|
-
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionInstruction[], PublicKey]>;
|
|
157
|
+
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, poolId?: number): Promise<[TransactionInstruction[], PublicKey]>;
|
|
158
158
|
/**
|
|
159
159
|
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
160
160
|
* @param subAccountId
|
|
@@ -361,7 +361,7 @@ export declare class DriftClient {
|
|
|
361
361
|
transferDeposit(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
362
362
|
getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
363
363
|
transferPools(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
364
|
-
getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
364
|
+
getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, isToNewSubAccount?: boolean): Promise<TransactionInstruction>;
|
|
365
365
|
updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
366
366
|
updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
367
367
|
settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
@@ -588,7 +588,7 @@ class DriftClient {
|
|
|
588
588
|
* @param referrerInfo
|
|
589
589
|
* @returns [instructions, userAccountPublicKey]
|
|
590
590
|
*/
|
|
591
|
-
async getInitializeUserAccountIxs(subAccountId = 0, name, referrerInfo) {
|
|
591
|
+
async getInitializeUserAccountIxs(subAccountId = 0, name, referrerInfo, poolId) {
|
|
592
592
|
const initializeIxs = [];
|
|
593
593
|
const [userAccountPublicKey, initializeUserAccountIx] = await this.getInitializeUserInstructions(subAccountId, name, referrerInfo);
|
|
594
594
|
if (subAccountId === 0) {
|
|
@@ -597,6 +597,9 @@ class DriftClient {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
initializeIxs.push(initializeUserAccountIx);
|
|
600
|
+
if (poolId) {
|
|
601
|
+
initializeIxs.push(await this.getUpdateUserPoolIdIx(poolId, subAccountId));
|
|
602
|
+
}
|
|
600
603
|
return [initializeIxs, userAccountPublicKey];
|
|
601
604
|
}
|
|
602
605
|
/**
|
|
@@ -1749,13 +1752,13 @@ class DriftClient {
|
|
|
1749
1752
|
}
|
|
1750
1753
|
return txSig;
|
|
1751
1754
|
}
|
|
1752
|
-
async getTransferPoolsIx(depositFromMarketIndex, depositToMarketIndex, borrowFromMarketIndex, borrowToMarketIndex, depositAmount, borrowAmount, fromSubAccountId, toSubAccountId) {
|
|
1755
|
+
async getTransferPoolsIx(depositFromMarketIndex, depositToMarketIndex, borrowFromMarketIndex, borrowToMarketIndex, depositAmount, borrowAmount, fromSubAccountId, toSubAccountId, isToNewSubAccount) {
|
|
1753
1756
|
const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
|
|
1754
1757
|
const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
|
|
1755
|
-
const userAccounts = [
|
|
1756
|
-
|
|
1757
|
-
this.getUserAccount(toSubAccountId)
|
|
1758
|
-
|
|
1758
|
+
const userAccounts = [this.getUserAccount(fromSubAccountId)];
|
|
1759
|
+
if (!isToNewSubAccount) {
|
|
1760
|
+
userAccounts.push(this.getUserAccount(toSubAccountId));
|
|
1761
|
+
}
|
|
1759
1762
|
const remainingAccounts = this.getRemainingAccounts({
|
|
1760
1763
|
userAccounts,
|
|
1761
1764
|
useMarketLastSlotCache: true,
|
|
@@ -154,7 +154,7 @@ export declare class DriftClient {
|
|
|
154
154
|
* @param referrerInfo
|
|
155
155
|
* @returns [instructions, userAccountPublicKey]
|
|
156
156
|
*/
|
|
157
|
-
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionInstruction[], PublicKey]>;
|
|
157
|
+
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, poolId?: number): Promise<[TransactionInstruction[], PublicKey]>;
|
|
158
158
|
/**
|
|
159
159
|
* Initializes a user account and returns the transaction signature and the public key of the user account.
|
|
160
160
|
* @param subAccountId
|
|
@@ -361,7 +361,7 @@ export declare class DriftClient {
|
|
|
361
361
|
transferDeposit(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
362
362
|
getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
363
363
|
transferPools(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
364
|
-
getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
364
|
+
getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, isToNewSubAccount?: boolean): Promise<TransactionInstruction>;
|
|
365
365
|
updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
366
366
|
updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
367
367
|
settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
package/lib/node/driftClient.js
CHANGED
|
@@ -588,7 +588,7 @@ class DriftClient {
|
|
|
588
588
|
* @param referrerInfo
|
|
589
589
|
* @returns [instructions, userAccountPublicKey]
|
|
590
590
|
*/
|
|
591
|
-
async getInitializeUserAccountIxs(subAccountId = 0, name, referrerInfo) {
|
|
591
|
+
async getInitializeUserAccountIxs(subAccountId = 0, name, referrerInfo, poolId) {
|
|
592
592
|
const initializeIxs = [];
|
|
593
593
|
const [userAccountPublicKey, initializeUserAccountIx] = await this.getInitializeUserInstructions(subAccountId, name, referrerInfo);
|
|
594
594
|
if (subAccountId === 0) {
|
|
@@ -597,6 +597,9 @@ class DriftClient {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
initializeIxs.push(initializeUserAccountIx);
|
|
600
|
+
if (poolId) {
|
|
601
|
+
initializeIxs.push(await this.getUpdateUserPoolIdIx(poolId, subAccountId));
|
|
602
|
+
}
|
|
600
603
|
return [initializeIxs, userAccountPublicKey];
|
|
601
604
|
}
|
|
602
605
|
/**
|
|
@@ -1749,13 +1752,13 @@ class DriftClient {
|
|
|
1749
1752
|
}
|
|
1750
1753
|
return txSig;
|
|
1751
1754
|
}
|
|
1752
|
-
async getTransferPoolsIx(depositFromMarketIndex, depositToMarketIndex, borrowFromMarketIndex, borrowToMarketIndex, depositAmount, borrowAmount, fromSubAccountId, toSubAccountId) {
|
|
1755
|
+
async getTransferPoolsIx(depositFromMarketIndex, depositToMarketIndex, borrowFromMarketIndex, borrowToMarketIndex, depositAmount, borrowAmount, fromSubAccountId, toSubAccountId, isToNewSubAccount) {
|
|
1753
1756
|
const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
|
|
1754
1757
|
const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
|
|
1755
|
-
const userAccounts = [
|
|
1756
|
-
|
|
1757
|
-
this.getUserAccount(toSubAccountId)
|
|
1758
|
-
|
|
1758
|
+
const userAccounts = [this.getUserAccount(fromSubAccountId)];
|
|
1759
|
+
if (!isToNewSubAccount) {
|
|
1760
|
+
userAccounts.push(this.getUserAccount(toSubAccountId));
|
|
1761
|
+
}
|
|
1759
1762
|
const remainingAccounts = this.getRemainingAccounts({
|
|
1760
1763
|
userAccounts,
|
|
1761
1764
|
useMarketLastSlotCache: true,
|
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -1012,7 +1012,8 @@ export class DriftClient {
|
|
|
1012
1012
|
public async getInitializeUserAccountIxs(
|
|
1013
1013
|
subAccountId = 0,
|
|
1014
1014
|
name?: string,
|
|
1015
|
-
referrerInfo?: ReferrerInfo
|
|
1015
|
+
referrerInfo?: ReferrerInfo,
|
|
1016
|
+
poolId?: number
|
|
1016
1017
|
): Promise<[TransactionInstruction[], PublicKey]> {
|
|
1017
1018
|
const initializeIxs: TransactionInstruction[] = [];
|
|
1018
1019
|
|
|
@@ -1033,6 +1034,12 @@ export class DriftClient {
|
|
|
1033
1034
|
|
|
1034
1035
|
initializeIxs.push(initializeUserAccountIx);
|
|
1035
1036
|
|
|
1037
|
+
if (poolId) {
|
|
1038
|
+
initializeIxs.push(
|
|
1039
|
+
await this.getUpdateUserPoolIdIx(poolId, subAccountId)
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1036
1043
|
return [initializeIxs, userAccountPublicKey];
|
|
1037
1044
|
}
|
|
1038
1045
|
|
|
@@ -3236,7 +3243,8 @@ export class DriftClient {
|
|
|
3236
3243
|
depositAmount: BN | undefined,
|
|
3237
3244
|
borrowAmount: BN | undefined,
|
|
3238
3245
|
fromSubAccountId: number,
|
|
3239
|
-
toSubAccountId: number
|
|
3246
|
+
toSubAccountId: number,
|
|
3247
|
+
isToNewSubAccount?: boolean
|
|
3240
3248
|
): Promise<TransactionInstruction> {
|
|
3241
3249
|
const fromUser = await getUserAccountPublicKey(
|
|
3242
3250
|
this.program.programId,
|
|
@@ -3249,10 +3257,11 @@ export class DriftClient {
|
|
|
3249
3257
|
toSubAccountId
|
|
3250
3258
|
);
|
|
3251
3259
|
|
|
3252
|
-
const userAccounts = [
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3260
|
+
const userAccounts = [this.getUserAccount(fromSubAccountId)];
|
|
3261
|
+
|
|
3262
|
+
if (!isToNewSubAccount) {
|
|
3263
|
+
userAccounts.push(this.getUserAccount(toSubAccountId));
|
|
3264
|
+
}
|
|
3256
3265
|
|
|
3257
3266
|
const remainingAccounts = this.getRemainingAccounts({
|
|
3258
3267
|
userAccounts,
|