@drift-labs/sdk 2.124.0-beta.9 → 2.125.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/addresses/pda.d.ts +1 -0
- package/lib/browser/addresses/pda.js +10 -1
- package/lib/browser/adminClient.d.ts +5 -1
- package/lib/browser/adminClient.js +55 -12
- package/lib/browser/driftClient.d.ts +10 -0
- package/lib/browser/driftClient.js +40 -0
- package/lib/browser/events/types.d.ts +4 -2
- package/lib/browser/events/types.js +2 -0
- package/lib/browser/idl/drift.json +590 -3
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +1 -0
- package/lib/browser/math/amm.js +1 -1
- package/lib/browser/types.d.ts +58 -0
- package/lib/browser/user.d.ts +1 -1
- package/lib/browser/user.js +3 -39
- package/lib/node/addresses/pda.d.ts +1 -0
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +10 -1
- package/lib/node/adminClient.d.ts +5 -1
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +55 -12
- package/lib/node/driftClient.d.ts +10 -0
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +40 -0
- package/lib/node/events/types.d.ts +4 -2
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +2 -0
- package/lib/node/idl/drift.json +590 -3
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/math/amm.js +1 -1
- package/lib/node/types.d.ts +58 -0
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +1 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +3 -39
- package/package.json +1 -1
- package/src/addresses/pda.ts +15 -0
- package/src/adminClient.ts +105 -12
- package/src/driftClient.ts +75 -0
- package/src/events/types.ts +9 -1
- package/src/idl/drift.json +590 -3
- package/src/index.ts +1 -0
- package/src/math/amm.ts +1 -1
- package/src/types.ts +62 -0
- package/src/user.ts +18 -66
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.125.0-beta.0
|
|
@@ -32,3 +32,4 @@ export declare function getPythLazerOraclePublicKey(progarmId: PublicKey, feedId
|
|
|
32
32
|
export declare function getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
33
33
|
export declare function getHighLeverageModeConfigPublicKey(programId: PublicKey): PublicKey;
|
|
34
34
|
export declare function getProtectedMakerModeConfigPublicKey(programId: PublicKey): PublicKey;
|
|
35
|
+
export declare function getIfRebalanceConfigPublicKey(programId: PublicKey, inMarketIndex: number, outMarketIndex: number): PublicKey;
|
|
@@ -23,9 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getProtectedMakerModeConfigPublicKey = exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSignedMsgWsDelegatesAccountPublicKey = exports.getSignedMsgUserAccountPublicKey = exports.getFuelOverflowAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
26
|
+
exports.getIfRebalanceConfigPublicKey = exports.getProtectedMakerModeConfigPublicKey = exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSignedMsgWsDelegatesAccountPublicKey = exports.getSignedMsgUserAccountPublicKey = exports.getFuelOverflowAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
27
27
|
const web3_js_1 = require("@solana/web3.js");
|
|
28
28
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
29
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
29
30
|
const spl_token_1 = require("@solana/spl-token");
|
|
30
31
|
async function getDriftStateAccountPublicKeyAndNonce(programId) {
|
|
31
32
|
return web3_js_1.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('drift_state'))], programId);
|
|
@@ -222,3 +223,11 @@ function getProtectedMakerModeConfigPublicKey(programId) {
|
|
|
222
223
|
], programId)[0];
|
|
223
224
|
}
|
|
224
225
|
exports.getProtectedMakerModeConfigPublicKey = getProtectedMakerModeConfigPublicKey;
|
|
226
|
+
function getIfRebalanceConfigPublicKey(programId, inMarketIndex, outMarketIndex) {
|
|
227
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
228
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('if_rebalance_config')),
|
|
229
|
+
new anchor_1.BN(inMarketIndex).toArrayLike(Buffer, 'le', 2),
|
|
230
|
+
new anchor_1.BN(outMarketIndex).toArrayLike(Buffer, 'le', 2),
|
|
231
|
+
], programId)[0];
|
|
232
|
+
}
|
|
233
|
+
exports.getIfRebalanceConfigPublicKey = getIfRebalanceConfigPublicKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
|
|
3
|
-
import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus } from './types';
|
|
3
|
+
import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus, IfRebalanceConfigParams } from './types';
|
|
4
4
|
import { BN } from '@coral-xyz/anchor';
|
|
5
5
|
import { DriftClient } from './driftClient';
|
|
6
6
|
export declare class AdminClient extends DriftClient {
|
|
@@ -183,6 +183,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
183
183
|
getInitializeProtocolIfSharesTransferConfigIx(): Promise<TransactionInstruction>;
|
|
184
184
|
updateProtocolIfSharesTransferConfig(whitelistedSigners?: PublicKey[], maxTransferPerEpoch?: BN): Promise<TransactionSignature>;
|
|
185
185
|
getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners?: PublicKey[], maxTransferPerEpoch?: BN): Promise<TransactionInstruction>;
|
|
186
|
+
transferProtocolIfSharesToRevenuePool(outMarketIndex: number, inMarketIndex: number, amount: BN): Promise<TransactionSignature>;
|
|
187
|
+
getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex: number, inMarketIndex: number, amount: BN): Promise<TransactionInstruction>;
|
|
186
188
|
initializePrelaunchOracle(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionSignature>;
|
|
187
189
|
getInitializePrelaunchOracleIx(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionInstruction>;
|
|
188
190
|
updatePrelaunchOracleParams(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionSignature>;
|
|
@@ -199,6 +201,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
199
201
|
getUpdatePerpMarketAmmSpreadAdjustmentIx(perpMarketIndex: number, ammSpreadAdjustment: number): Promise<TransactionInstruction>;
|
|
200
202
|
updatePerpMarketProtectedMakerParams(perpMarketIndex: number, protectedMakerLimitPriceDivisor?: number, protectedMakerDynamicDivisor?: number): Promise<TransactionSignature>;
|
|
201
203
|
getUpdatePerpMarketProtectedMakerParamsIx(perpMarketIndex: number, protectedMakerLimitPriceDivisor?: number, protectedMakerDynamicDivisor?: number): Promise<TransactionInstruction>;
|
|
204
|
+
initializeIfRebalanceConfig(params: IfRebalanceConfigParams): Promise<TransactionSignature>;
|
|
205
|
+
getInitializeIfRebalanceConfigIx(params: IfRebalanceConfigParams): Promise<TransactionInstruction>;
|
|
202
206
|
initUserFuel(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionSignature>;
|
|
203
207
|
getInitUserFuelIx(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionInstruction>;
|
|
204
208
|
/**
|
|
@@ -501,9 +501,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
501
501
|
async getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity) {
|
|
502
502
|
return await this.program.instruction.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
|
|
503
503
|
accounts: {
|
|
504
|
-
admin: this.
|
|
505
|
-
? this.
|
|
506
|
-
: this.
|
|
504
|
+
admin: this.useHotWalletAdmin
|
|
505
|
+
? this.wallet.publicKey
|
|
506
|
+
: this.getStateAccount().admin,
|
|
507
507
|
state: await this.getStatePublicKey(),
|
|
508
508
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
509
509
|
},
|
|
@@ -627,9 +627,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
627
627
|
async getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity) {
|
|
628
628
|
return await this.program.instruction.updateAmmJitIntensity(ammJitIntensity, {
|
|
629
629
|
accounts: {
|
|
630
|
-
admin: this.
|
|
631
|
-
? this.
|
|
632
|
-
: this.
|
|
630
|
+
admin: this.useHotWalletAdmin
|
|
631
|
+
? this.wallet.publicKey
|
|
632
|
+
: this.getStateAccount().admin,
|
|
633
633
|
state: await this.getStatePublicKey(),
|
|
634
634
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
635
635
|
},
|
|
@@ -1666,6 +1666,30 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1666
1666
|
},
|
|
1667
1667
|
});
|
|
1668
1668
|
}
|
|
1669
|
+
async transferProtocolIfSharesToRevenuePool(outMarketIndex, inMarketIndex, amount) {
|
|
1670
|
+
const transferProtocolIfSharesToRevenuePoolIx = await this.getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex, inMarketIndex, amount);
|
|
1671
|
+
const tx = await this.buildTransaction(transferProtocolIfSharesToRevenuePoolIx);
|
|
1672
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1673
|
+
return txSig;
|
|
1674
|
+
}
|
|
1675
|
+
async getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex, inMarketIndex, amount) {
|
|
1676
|
+
const remainingAccounts = await this.getRemainingAccounts({
|
|
1677
|
+
userAccounts: [],
|
|
1678
|
+
writableSpotMarketIndexes: [outMarketIndex],
|
|
1679
|
+
});
|
|
1680
|
+
return await this.program.instruction.transferProtocolIfSharesToRevenuePool(outMarketIndex, amount, {
|
|
1681
|
+
accounts: {
|
|
1682
|
+
authority: this.wallet.publicKey,
|
|
1683
|
+
state: await this.getStatePublicKey(),
|
|
1684
|
+
insuranceFundVault: await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, outMarketIndex),
|
|
1685
|
+
spotMarketVault: await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, outMarketIndex),
|
|
1686
|
+
ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, inMarketIndex, outMarketIndex),
|
|
1687
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1688
|
+
driftSigner: this.getStateAccount().signer,
|
|
1689
|
+
},
|
|
1690
|
+
remainingAccounts,
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1669
1693
|
async initializePrelaunchOracle(perpMarketIndex, price, maxPrice) {
|
|
1670
1694
|
const initializePrelaunchOracleIx = await this.getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice);
|
|
1671
1695
|
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
@@ -1784,9 +1808,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1784
1808
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1785
1809
|
return await this.program.instruction.updatePerpMarketTakerSpeedBumpOverride(takerSpeedBumpOverride, {
|
|
1786
1810
|
accounts: {
|
|
1787
|
-
admin: this.
|
|
1788
|
-
? this.
|
|
1789
|
-
: this.
|
|
1811
|
+
admin: this.useHotWalletAdmin
|
|
1812
|
+
? this.wallet.publicKey
|
|
1813
|
+
: this.getStateAccount().admin,
|
|
1790
1814
|
state: await this.getStatePublicKey(),
|
|
1791
1815
|
perpMarket: perpMarketPublicKey,
|
|
1792
1816
|
},
|
|
@@ -1802,9 +1826,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1802
1826
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1803
1827
|
return await this.program.instruction.updatePerpMarketAmmSpreadAdjustment(ammSpreadAdjustment, {
|
|
1804
1828
|
accounts: {
|
|
1805
|
-
admin: this.
|
|
1806
|
-
? this.
|
|
1807
|
-
: this.
|
|
1829
|
+
admin: this.useHotWalletAdmin
|
|
1830
|
+
? this.wallet.publicKey
|
|
1831
|
+
: this.getStateAccount().admin,
|
|
1808
1832
|
state: await this.getStatePublicKey(),
|
|
1809
1833
|
perpMarket: perpMarketPublicKey,
|
|
1810
1834
|
},
|
|
@@ -1828,6 +1852,25 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1828
1852
|
},
|
|
1829
1853
|
});
|
|
1830
1854
|
}
|
|
1855
|
+
async initializeIfRebalanceConfig(params) {
|
|
1856
|
+
const initializeIfRebalanceConfigIx = await this.getInitializeIfRebalanceConfigIx(params);
|
|
1857
|
+
const tx = await this.buildTransaction(initializeIfRebalanceConfigIx);
|
|
1858
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1859
|
+
return txSig;
|
|
1860
|
+
}
|
|
1861
|
+
async getInitializeIfRebalanceConfigIx(params) {
|
|
1862
|
+
return await this.program.instruction.initializeIfRebalanceConfig(params, {
|
|
1863
|
+
accounts: {
|
|
1864
|
+
admin: this.isSubscribed
|
|
1865
|
+
? this.getStateAccount().admin
|
|
1866
|
+
: this.wallet.publicKey,
|
|
1867
|
+
state: await this.getStatePublicKey(),
|
|
1868
|
+
ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, params.inMarketIndex, params.outMarketIndex),
|
|
1869
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1870
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1871
|
+
},
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1831
1874
|
async initUserFuel(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance) {
|
|
1832
1875
|
const updatePerpMarketFuelIx = await this.getInitUserFuelIx(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance);
|
|
1833
1876
|
const tx = await this.buildTransaction(updatePerpMarketFuelIx);
|
|
@@ -795,6 +795,16 @@ export declare class DriftClient {
|
|
|
795
795
|
beginSwapIx: TransactionInstruction;
|
|
796
796
|
endSwapIx: TransactionInstruction;
|
|
797
797
|
}>;
|
|
798
|
+
getInsuranceFundSwapIx({ inMarketIndex, outMarketIndex, amountIn, inTokenAccount, outTokenAccount, }: {
|
|
799
|
+
inMarketIndex: number;
|
|
800
|
+
outMarketIndex: number;
|
|
801
|
+
amountIn: BN;
|
|
802
|
+
inTokenAccount: PublicKey;
|
|
803
|
+
outTokenAccount: PublicKey;
|
|
804
|
+
}): Promise<{
|
|
805
|
+
beginSwapIx: TransactionInstruction;
|
|
806
|
+
endSwapIx: TransactionInstruction;
|
|
807
|
+
}>;
|
|
798
808
|
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
799
809
|
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
800
810
|
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
@@ -4101,6 +4101,46 @@ class DriftClient {
|
|
|
4101
4101
|
});
|
|
4102
4102
|
return { beginSwapIx, endSwapIx };
|
|
4103
4103
|
}
|
|
4104
|
+
async getInsuranceFundSwapIx({ inMarketIndex, outMarketIndex, amountIn, inTokenAccount, outTokenAccount, }) {
|
|
4105
|
+
const remainingAccounts = await this.getRemainingAccounts({
|
|
4106
|
+
userAccounts: [],
|
|
4107
|
+
writableSpotMarketIndexes: [inMarketIndex, outMarketIndex],
|
|
4108
|
+
});
|
|
4109
|
+
const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
|
|
4110
|
+
const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
|
|
4111
|
+
const ifRebalanceConfig = (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, inMarketIndex, outMarketIndex);
|
|
4112
|
+
const beginSwapIx = await this.program.instruction.beginInsuranceFundSwap(inMarketIndex, outMarketIndex, amountIn, {
|
|
4113
|
+
accounts: {
|
|
4114
|
+
state: await this.getStatePublicKey(),
|
|
4115
|
+
authority: this.wallet.publicKey,
|
|
4116
|
+
outInsuranceFundVault: outSpotMarket.insuranceFund.vault,
|
|
4117
|
+
inInsuranceFundVault: inSpotMarket.insuranceFund.vault,
|
|
4118
|
+
outTokenAccount,
|
|
4119
|
+
inTokenAccount,
|
|
4120
|
+
ifRebalanceConfig: ifRebalanceConfig,
|
|
4121
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4122
|
+
driftSigner: this.getStateAccount().signer,
|
|
4123
|
+
instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4124
|
+
},
|
|
4125
|
+
remainingAccounts,
|
|
4126
|
+
});
|
|
4127
|
+
const endSwapIx = await this.program.instruction.endInsuranceFundSwap(inMarketIndex, outMarketIndex, {
|
|
4128
|
+
accounts: {
|
|
4129
|
+
state: await this.getStatePublicKey(),
|
|
4130
|
+
authority: this.wallet.publicKey,
|
|
4131
|
+
outInsuranceFundVault: outSpotMarket.insuranceFund.vault,
|
|
4132
|
+
inInsuranceFundVault: inSpotMarket.insuranceFund.vault,
|
|
4133
|
+
outTokenAccount,
|
|
4134
|
+
inTokenAccount,
|
|
4135
|
+
ifRebalanceConfig: ifRebalanceConfig,
|
|
4136
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4137
|
+
driftSigner: this.getStateAccount().signer,
|
|
4138
|
+
instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4139
|
+
},
|
|
4140
|
+
remainingAccounts,
|
|
4141
|
+
});
|
|
4142
|
+
return { beginSwapIx, endSwapIx };
|
|
4143
|
+
}
|
|
4104
4144
|
async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams, liquidatorSubAccountId) {
|
|
4105
4145
|
const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, liquidatorSubAccountId), txParams), [], this.opts);
|
|
4106
4146
|
this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Commitment, PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
|
-
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord, SwapRecord, SpotMarketVaultDepositRecord, SignedMsgOrderRecord, DeleteUserRecord, FuelSweepRecord, FuelSeasonRecord } from '../index';
|
|
3
|
+
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord, SwapRecord, SpotMarketVaultDepositRecord, SignedMsgOrderRecord, DeleteUserRecord, FuelSweepRecord, FuelSeasonRecord, InsuranceFundSwapRecord, TransferProtocolIfSharesToRevenuePoolRecord } from '../index';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
export type EventSubscriptionOptions = {
|
|
6
6
|
address?: PublicKey;
|
|
@@ -45,9 +45,11 @@ export type EventMap = {
|
|
|
45
45
|
DeleteUserRecord: Event<DeleteUserRecord>;
|
|
46
46
|
FuelSweepRecord: Event<FuelSweepRecord>;
|
|
47
47
|
FuelSeasonRecord: Event<FuelSeasonRecord>;
|
|
48
|
+
InsuranceFundSwapRecord: Event<InsuranceFundSwapRecord>;
|
|
49
|
+
TransferProtocolIfSharesToRevenuePoolRecord: Event<TransferProtocolIfSharesToRevenuePoolRecord>;
|
|
48
50
|
};
|
|
49
51
|
export type EventType = keyof EventMap;
|
|
50
|
-
export type DriftEvent = Event<DepositRecord> | Event<FundingPaymentRecord> | Event<LiquidationRecord> | Event<FundingRateRecord> | Event<OrderRecord> | Event<OrderActionRecord> | Event<SettlePnlRecord> | Event<NewUserRecord> | Event<LPRecord> | Event<InsuranceFundRecord> | Event<SpotInterestRecord> | Event<InsuranceFundStakeRecord> | Event<CurveRecord> | Event<SwapRecord> | Event<SpotMarketVaultDepositRecord> | Event<SignedMsgOrderRecord> | Event<DeleteUserRecord> | Event<FuelSweepRecord> | Event<FuelSeasonRecord>;
|
|
52
|
+
export type DriftEvent = Event<DepositRecord> | Event<FundingPaymentRecord> | Event<LiquidationRecord> | Event<FundingRateRecord> | Event<OrderRecord> | Event<OrderActionRecord> | Event<SettlePnlRecord> | Event<NewUserRecord> | Event<LPRecord> | Event<InsuranceFundRecord> | Event<SpotInterestRecord> | Event<InsuranceFundStakeRecord> | Event<CurveRecord> | Event<SwapRecord> | Event<SpotMarketVaultDepositRecord> | Event<SignedMsgOrderRecord> | Event<DeleteUserRecord> | Event<FuelSweepRecord> | Event<FuelSeasonRecord> | Event<InsuranceFundSwapRecord> | Event<TransferProtocolIfSharesToRevenuePoolRecord>;
|
|
51
53
|
export interface EventSubscriberEvents {
|
|
52
54
|
newEvent: (event: WrappedEvent<EventType>) => void;
|
|
53
55
|
}
|