@drift-labs/sdk 2.86.0-beta.24 → 2.86.0-beta.26
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/addresses/pda.d.ts +1 -0
- package/lib/addresses/pda.js +8 -1
- package/lib/adminClient.d.ts +2 -0
- package/lib/adminClient.js +26 -0
- package/lib/constants/perpMarkets.js +12 -12
- package/lib/constants/spotMarkets.js +11 -10
- package/lib/driftClient.d.ts +7 -4
- package/lib/driftClient.js +102 -0
- package/lib/idl/drift.json +179 -0
- package/lib/types.d.ts +15 -0
- package/lib/user.js +1 -1
- package/package.json +1 -1
- package/src/addresses/pda.ts +15 -0
- package/src/adminClient.ts +51 -0
- package/src/constants/perpMarkets.ts +12 -12
- package/src/constants/spotMarkets.ts +12 -10
- package/src/driftClient.ts +132 -2
- package/src/idl/drift.json +179 -0
- package/src/idl/openbook.json +3854 -0
- package/src/types.ts +17 -0
- package/src/user.ts +5 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.86.0-beta.
|
|
1
|
+
2.86.0-beta.26
|
package/lib/addresses/pda.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare function getSerumOpenOrdersPublicKey(programId: PublicKey, market
|
|
|
17
17
|
export declare function getSerumSignerPublicKey(programId: PublicKey, market: PublicKey, nonce: BN): PublicKey;
|
|
18
18
|
export declare function getSerumFulfillmentConfigPublicKey(programId: PublicKey, market: PublicKey): PublicKey;
|
|
19
19
|
export declare function getPhoenixFulfillmentConfigPublicKey(programId: PublicKey, market: PublicKey): PublicKey;
|
|
20
|
+
export declare function getOpenbookV2FulfillmentConfigPublicKey(programId: PublicKey, market: PublicKey): PublicKey;
|
|
20
21
|
export declare function getReferrerNamePublicKeySync(programId: PublicKey, nameBuffer: number[]): PublicKey;
|
|
21
22
|
export declare function getProtocolIfSharesTransferConfigPublicKey(programId: PublicKey): PublicKey;
|
|
22
23
|
export declare function getPrelaunchOraclePublicKey(programId: PublicKey, marketIndex: number): PublicKey;
|
package/lib/addresses/pda.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
|
|
26
|
+
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.getSpotMarketPublicKey = exports.getPerpMarketPublicKey = 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
29
|
async function getDriftStateAccountPublicKeyAndNonce(programId) {
|
|
@@ -126,6 +126,13 @@ function getPhoenixFulfillmentConfigPublicKey(programId, market) {
|
|
|
126
126
|
], programId)[0];
|
|
127
127
|
}
|
|
128
128
|
exports.getPhoenixFulfillmentConfigPublicKey = getPhoenixFulfillmentConfigPublicKey;
|
|
129
|
+
function getOpenbookV2FulfillmentConfigPublicKey(programId, market) {
|
|
130
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
131
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('openbook_v2_fulfillment_config')),
|
|
132
|
+
market.toBuffer(),
|
|
133
|
+
], programId)[0];
|
|
134
|
+
}
|
|
135
|
+
exports.getOpenbookV2FulfillmentConfigPublicKey = getOpenbookV2FulfillmentConfigPublicKey;
|
|
129
136
|
function getReferrerNamePublicKeySync(programId, nameBuffer) {
|
|
130
137
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
131
138
|
Buffer.from(anchor.utils.bytes.utf8.encode('referrer_name')),
|
package/lib/adminClient.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
17
17
|
getInitializeSerumFulfillmentConfigIx(marketIndex: number, serumMarket: PublicKey, serumProgram: PublicKey): Promise<TransactionInstruction>;
|
|
18
18
|
initializePhoenixFulfillmentConfig(marketIndex: number, phoenixMarket: PublicKey): Promise<TransactionSignature>;
|
|
19
19
|
getInitializePhoenixFulfillmentConfigIx(marketIndex: number, phoenixMarket: PublicKey): Promise<TransactionInstruction>;
|
|
20
|
+
initializeOpenbookV2FulfillmentConfig(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionSignature>;
|
|
21
|
+
getInitializeOpenbookV2FulfillmentConfigIx(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionInstruction>;
|
|
20
22
|
initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string): Promise<TransactionSignature>;
|
|
21
23
|
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string): Promise<TransactionInstruction>;
|
|
22
24
|
deleteInitializedPerpMarket(marketIndex: number): Promise<TransactionSignature>;
|
package/lib/adminClient.js
CHANGED
|
@@ -39,6 +39,7 @@ const amm_1 = require("./math/amm");
|
|
|
39
39
|
const phoenix_sdk_1 = require("@ellipsis-labs/phoenix-sdk");
|
|
40
40
|
const config_1 = require("./config");
|
|
41
41
|
const pythPullOracleUtils_1 = require("./util/pythPullOracleUtils");
|
|
42
|
+
const OPENBOOK_PROGRAM_ID = new web3_js_1.PublicKey('opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb');
|
|
42
43
|
class AdminClient extends driftClient_1.DriftClient {
|
|
43
44
|
async initialize(usdcMint, _adminControlsPrices) {
|
|
44
45
|
const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(await this.getStatePublicKey());
|
|
@@ -177,6 +178,31 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
177
178
|
},
|
|
178
179
|
});
|
|
179
180
|
}
|
|
181
|
+
async initializeOpenbookV2FulfillmentConfig(marketIndex, openbookMarket) {
|
|
182
|
+
const initializeIx = await this.getInitializeOpenbookV2FulfillmentConfigIx(marketIndex, openbookMarket);
|
|
183
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
184
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
185
|
+
return txSig;
|
|
186
|
+
}
|
|
187
|
+
async getInitializeOpenbookV2FulfillmentConfigIx(marketIndex, openbookMarket) {
|
|
188
|
+
const openbookFulfillmentConfig = (0, pda_1.getOpenbookV2FulfillmentConfigPublicKey)(this.program.programId, openbookMarket);
|
|
189
|
+
return this.program.instruction.initializeOpenbookV2FulfillmentConfig(marketIndex, {
|
|
190
|
+
accounts: {
|
|
191
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
192
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
193
|
+
state: await this.getStatePublicKey(),
|
|
194
|
+
openbookV2Program: OPENBOOK_PROGRAM_ID,
|
|
195
|
+
openbookV2Market: openbookMarket,
|
|
196
|
+
driftSigner: this.getSignerPublicKey(),
|
|
197
|
+
openbookV2FulfillmentConfig: openbookFulfillmentConfig,
|
|
198
|
+
admin: this.isSubscribed
|
|
199
|
+
? this.getStateAccount().admin
|
|
200
|
+
: this.wallet.publicKey,
|
|
201
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
202
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
180
206
|
async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
181
207
|
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
182
208
|
const initializeMarketIx = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name);
|
|
@@ -496,9 +496,9 @@ exports.MainnetPerpMarkets = [
|
|
|
496
496
|
symbol: 'PYTH-PERP',
|
|
497
497
|
baseAssetSymbol: 'PYTH',
|
|
498
498
|
marketIndex: 18,
|
|
499
|
-
oracle: new web3_js_1.PublicKey('
|
|
499
|
+
oracle: new web3_js_1.PublicKey('GqkCu7CbsPVz1H6W6AAHuReqbJckYG59TXz7Y5HDV7hr'),
|
|
500
500
|
launchTs: 1700542800000,
|
|
501
|
-
oracleSource: __1.OracleSource.
|
|
501
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
502
502
|
pythFeedId: '0x0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff',
|
|
503
503
|
},
|
|
504
504
|
{
|
|
@@ -507,9 +507,9 @@ exports.MainnetPerpMarkets = [
|
|
|
507
507
|
symbol: 'TIA-PERP',
|
|
508
508
|
baseAssetSymbol: 'TIA',
|
|
509
509
|
marketIndex: 19,
|
|
510
|
-
oracle: new web3_js_1.PublicKey('
|
|
510
|
+
oracle: new web3_js_1.PublicKey('C6LHPUrgjrgo5eNUitC8raNEdEttfoRhmqdJ3BHVBJhi'),
|
|
511
511
|
launchTs: 1701880540000,
|
|
512
|
-
oracleSource: __1.OracleSource.
|
|
512
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
513
513
|
pythFeedId: '0x09f7c1d7dfbb7df2b8fe3d3d87ee94a2259d212da4f30c1f0540d066dfa44723',
|
|
514
514
|
},
|
|
515
515
|
{
|
|
@@ -551,9 +551,9 @@ exports.MainnetPerpMarkets = [
|
|
|
551
551
|
symbol: 'WIF-PERP',
|
|
552
552
|
baseAssetSymbol: 'WIF',
|
|
553
553
|
marketIndex: 23,
|
|
554
|
-
oracle: new web3_js_1.PublicKey('
|
|
554
|
+
oracle: new web3_js_1.PublicKey('6x6KfE7nY2xoLCRSMPT1u83wQ5fpGXoKNBqFjrCwzsCQ'),
|
|
555
555
|
launchTs: 1706219971000,
|
|
556
|
-
oracleSource: __1.OracleSource.
|
|
556
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
557
557
|
pythFeedId: '0x4ca4beeca86f0d164160323817a4e42b10010a724c2217c6ee41b54cd4cc61fc',
|
|
558
558
|
},
|
|
559
559
|
{
|
|
@@ -562,9 +562,9 @@ exports.MainnetPerpMarkets = [
|
|
|
562
562
|
symbol: 'JUP-PERP',
|
|
563
563
|
baseAssetSymbol: 'JUP',
|
|
564
564
|
marketIndex: 24,
|
|
565
|
-
oracle: new web3_js_1.PublicKey('
|
|
565
|
+
oracle: new web3_js_1.PublicKey('AwqRpfJ36jnSZQykyL1jYY35mhMteeEAjh7o8LveRQin'),
|
|
566
566
|
launchTs: 1706713201000,
|
|
567
|
-
oracleSource: __1.OracleSource.
|
|
567
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
568
568
|
pythFeedId: '0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996',
|
|
569
569
|
},
|
|
570
570
|
{
|
|
@@ -628,9 +628,9 @@ exports.MainnetPerpMarkets = [
|
|
|
628
628
|
symbol: 'DRIFT-PERP',
|
|
629
629
|
baseAssetSymbol: 'DRIFT',
|
|
630
630
|
marketIndex: 30,
|
|
631
|
-
oracle: new web3_js_1.PublicKey('
|
|
631
|
+
oracle: new web3_js_1.PublicKey('23KmX7SNikmUr2axSCy6Zer7XPBnvmVcASALnDGqBVRR'),
|
|
632
632
|
launchTs: 1716595200000,
|
|
633
|
-
oracleSource: __1.OracleSource.
|
|
633
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
634
634
|
pythFeedId: '0x5c1690b27bb02446db17cdda13ccc2c1d609ad6d2ef5bf4983a85ea8b6f19d07',
|
|
635
635
|
},
|
|
636
636
|
{
|
|
@@ -671,9 +671,9 @@ exports.MainnetPerpMarkets = [
|
|
|
671
671
|
symbol: 'POPCAT-PERP',
|
|
672
672
|
baseAssetSymbol: 'POPCAT',
|
|
673
673
|
marketIndex: 34,
|
|
674
|
-
oracle: new web3_js_1.PublicKey('
|
|
674
|
+
oracle: new web3_js_1.PublicKey('H3pn43tkNvsG5z3qzmERguSvKoyHZvvY6VPmNrJqiW5X'),
|
|
675
675
|
launchTs: 1720013054000,
|
|
676
|
-
oracleSource: __1.OracleSource.
|
|
676
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
677
677
|
pythFeedId: '0xb9312a7ee50e189ef045aa3c7842e099b061bd9bdc99ac645956c3b660dc8cce',
|
|
678
678
|
},
|
|
679
679
|
{
|
|
@@ -123,8 +123,8 @@ exports.MainnetSpotMarkets = [
|
|
|
123
123
|
{
|
|
124
124
|
symbol: 'PYTH',
|
|
125
125
|
marketIndex: 7,
|
|
126
|
-
oracle: new web3_js_1.PublicKey('
|
|
127
|
-
oracleSource: __1.OracleSource.
|
|
126
|
+
oracle: new web3_js_1.PublicKey('GqkCu7CbsPVz1H6W6AAHuReqbJckYG59TXz7Y5HDV7hr'),
|
|
127
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
128
128
|
mint: new web3_js_1.PublicKey('HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3'),
|
|
129
129
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
130
130
|
precisionExp: numericConstants_1.SIX,
|
|
@@ -158,8 +158,8 @@ exports.MainnetSpotMarkets = [
|
|
|
158
158
|
{
|
|
159
159
|
symbol: 'WIF',
|
|
160
160
|
marketIndex: 10,
|
|
161
|
-
oracle: new web3_js_1.PublicKey('
|
|
162
|
-
oracleSource: __1.OracleSource.
|
|
161
|
+
oracle: new web3_js_1.PublicKey('6x6KfE7nY2xoLCRSMPT1u83wQ5fpGXoKNBqFjrCwzsCQ'),
|
|
162
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
163
163
|
mint: new web3_js_1.PublicKey('EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'),
|
|
164
164
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
165
165
|
precisionExp: numericConstants_1.SIX,
|
|
@@ -170,8 +170,8 @@ exports.MainnetSpotMarkets = [
|
|
|
170
170
|
{
|
|
171
171
|
symbol: 'JUP',
|
|
172
172
|
marketIndex: 11,
|
|
173
|
-
oracle: new web3_js_1.PublicKey('
|
|
174
|
-
oracleSource: __1.OracleSource.
|
|
173
|
+
oracle: new web3_js_1.PublicKey('AwqRpfJ36jnSZQykyL1jYY35mhMteeEAjh7o8LveRQin'),
|
|
174
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
175
175
|
mint: new web3_js_1.PublicKey('JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN'),
|
|
176
176
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
177
177
|
precisionExp: numericConstants_1.SIX,
|
|
@@ -218,8 +218,8 @@ exports.MainnetSpotMarkets = [
|
|
|
218
218
|
{
|
|
219
219
|
symbol: 'DRIFT',
|
|
220
220
|
marketIndex: 15,
|
|
221
|
-
oracle: new web3_js_1.PublicKey('
|
|
222
|
-
oracleSource: __1.OracleSource.
|
|
221
|
+
oracle: new web3_js_1.PublicKey('23KmX7SNikmUr2axSCy6Zer7XPBnvmVcASALnDGqBVRR'),
|
|
222
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
223
223
|
mint: new web3_js_1.PublicKey('DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7'),
|
|
224
224
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
225
225
|
precisionExp: numericConstants_1.SIX,
|
|
@@ -272,13 +272,14 @@ exports.MainnetSpotMarkets = [
|
|
|
272
272
|
{
|
|
273
273
|
symbol: 'POPCAT',
|
|
274
274
|
marketIndex: 20,
|
|
275
|
-
oracle: new web3_js_1.PublicKey('
|
|
276
|
-
oracleSource: __1.OracleSource.
|
|
275
|
+
oracle: new web3_js_1.PublicKey('H3pn43tkNvsG5z3qzmERguSvKoyHZvvY6VPmNrJqiW5X'),
|
|
276
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
277
277
|
mint: new web3_js_1.PublicKey('7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr'),
|
|
278
278
|
precision: new __1.BN(10).pow(numericConstants_1.NINE),
|
|
279
279
|
precisionExp: numericConstants_1.NINE,
|
|
280
280
|
launchTs: 1720013054000,
|
|
281
281
|
phoenixMarket: new web3_js_1.PublicKey('31XgvAQ1HgFQEk31KdszbPkVXKaQqB1bgYZPoDrFpSR2'),
|
|
282
|
+
pythFeedId: '0xb9312a7ee50e189ef045aa3c7842e099b061bd9bdc99ac645956c3b660dc8cce',
|
|
282
283
|
},
|
|
283
284
|
];
|
|
284
285
|
exports.SpotMarkets = {
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="bn.js" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
5
|
-
import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, TxParams, SerumV3FulfillmentConfigAccount, ReferrerNameAccount, OrderTriggerCondition, PerpMarketExtendedInfo, UserStatsAccount, PhoenixV1FulfillmentConfigAccount, ModifyOrderPolicy, SwapReduceOnly, SettlePnlMode, SignedTxData, MappedRecord } from './types';
|
|
5
|
+
import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, TxParams, SerumV3FulfillmentConfigAccount, ReferrerNameAccount, OrderTriggerCondition, PerpMarketExtendedInfo, UserStatsAccount, PhoenixV1FulfillmentConfigAccount, ModifyOrderPolicy, SwapReduceOnly, SettlePnlMode, SignedTxData, MappedRecord, OpenbookV2FulfillmentConfigAccount } from './types';
|
|
6
6
|
import * as anchor from '@coral-xyz/anchor';
|
|
7
7
|
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta, Signer, AddressLookupTableAccount, TransactionVersion, VersionedTransaction, BlockhashWithExpiryBlockHeight } from '@solana/web3.js';
|
|
8
8
|
import { TokenFaucet } from './tokenFaucet';
|
|
@@ -107,6 +107,8 @@ export declare class DriftClient {
|
|
|
107
107
|
getSerumV3FulfillmentConfigs(): Promise<SerumV3FulfillmentConfigAccount[]>;
|
|
108
108
|
getPhoenixV1FulfillmentConfig(phoenixMarket: PublicKey): Promise<PhoenixV1FulfillmentConfigAccount>;
|
|
109
109
|
getPhoenixV1FulfillmentConfigs(): Promise<PhoenixV1FulfillmentConfigAccount[]>;
|
|
110
|
+
getOpenbookV2FulfillmentConfig(openbookMarket: PublicKey): Promise<OpenbookV2FulfillmentConfigAccount>;
|
|
111
|
+
getOpenbookV2FulfillmentConfigs(): Promise<OpenbookV2FulfillmentConfigAccount[]>;
|
|
110
112
|
fetchMarketLookupTableAccount(): Promise<AddressLookupTableAccount>;
|
|
111
113
|
/**
|
|
112
114
|
* Update the wallet to use for drift transactions and linked user account
|
|
@@ -357,11 +359,12 @@ export declare class DriftClient {
|
|
|
357
359
|
placeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
358
360
|
}>;
|
|
359
361
|
getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise<TransactionInstruction>;
|
|
360
|
-
fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
361
|
-
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
362
|
-
addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount): void;
|
|
362
|
+
fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
363
|
+
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
364
|
+
addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount): void;
|
|
363
365
|
addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void;
|
|
364
366
|
addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): void;
|
|
367
|
+
addOpenbookRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: OpenbookV2FulfillmentConfigAccount): void;
|
|
365
368
|
/**
|
|
366
369
|
* Swap tokens in drift account using jupiter
|
|
367
370
|
* @param jupiterClient jupiter client to find routes and jupiter instructions
|
package/lib/driftClient.js
CHANGED
|
@@ -324,6 +324,14 @@ class DriftClient {
|
|
|
324
324
|
const accounts = await this.program.account.phoenixV1FulfillmentConfig.all();
|
|
325
325
|
return accounts.map((account) => account.account);
|
|
326
326
|
}
|
|
327
|
+
async getOpenbookV2FulfillmentConfig(openbookMarket) {
|
|
328
|
+
const address = (0, pda_1.getOpenbookV2FulfillmentConfigPublicKey)(this.program.programId, openbookMarket);
|
|
329
|
+
return (await this.program.account.openbookV2FulfillmentConfig.fetch(address));
|
|
330
|
+
}
|
|
331
|
+
async getOpenbookV2FulfillmentConfigs() {
|
|
332
|
+
const accounts = await this.program.account.openbookV2FulfillmentConfig.all();
|
|
333
|
+
return accounts.map((account) => account.account);
|
|
334
|
+
}
|
|
327
335
|
async fetchMarketLookupTableAccount() {
|
|
328
336
|
if (this.lookupTableAccount)
|
|
329
337
|
return this.lookupTableAccount;
|
|
@@ -2010,6 +2018,9 @@ class DriftClient {
|
|
|
2010
2018
|
else if ('phoenixProgramId' in fulfillmentConfig) {
|
|
2011
2019
|
this.addPhoenixRemainingAccounts(marketIndex, remainingAccounts, fulfillmentConfig);
|
|
2012
2020
|
}
|
|
2021
|
+
else if ('openbookV2ProgramId' in fulfillmentConfig) {
|
|
2022
|
+
this.addOpenbookRemainingAccounts(marketIndex, remainingAccounts, fulfillmentConfig);
|
|
2023
|
+
}
|
|
2013
2024
|
else {
|
|
2014
2025
|
throw Error('Invalid fulfillment config type');
|
|
2015
2026
|
}
|
|
@@ -2161,6 +2172,97 @@ class DriftClient {
|
|
|
2161
2172
|
isSigner: false,
|
|
2162
2173
|
});
|
|
2163
2174
|
}
|
|
2175
|
+
addOpenbookRemainingAccounts(marketIndex, remainingAccounts, fulfillmentConfig) {
|
|
2176
|
+
remainingAccounts.push({
|
|
2177
|
+
pubkey: fulfillmentConfig.pubkey,
|
|
2178
|
+
isWritable: false,
|
|
2179
|
+
isSigner: false,
|
|
2180
|
+
});
|
|
2181
|
+
remainingAccounts.push({
|
|
2182
|
+
pubkey: this.getSignerPublicKey(),
|
|
2183
|
+
isWritable: true,
|
|
2184
|
+
isSigner: false,
|
|
2185
|
+
});
|
|
2186
|
+
remainingAccounts.push({
|
|
2187
|
+
pubkey: fulfillmentConfig.openbookV2ProgramId,
|
|
2188
|
+
isWritable: false,
|
|
2189
|
+
isSigner: false,
|
|
2190
|
+
});
|
|
2191
|
+
remainingAccounts.push({
|
|
2192
|
+
pubkey: fulfillmentConfig.openbookV2Market,
|
|
2193
|
+
isWritable: true,
|
|
2194
|
+
isSigner: false,
|
|
2195
|
+
});
|
|
2196
|
+
remainingAccounts.push({
|
|
2197
|
+
pubkey: fulfillmentConfig.openbookV2MarketAuthority,
|
|
2198
|
+
isWritable: false,
|
|
2199
|
+
isSigner: false,
|
|
2200
|
+
});
|
|
2201
|
+
remainingAccounts.push({
|
|
2202
|
+
pubkey: fulfillmentConfig.openbookV2EventHeap,
|
|
2203
|
+
isWritable: true,
|
|
2204
|
+
isSigner: false,
|
|
2205
|
+
});
|
|
2206
|
+
remainingAccounts.push({
|
|
2207
|
+
pubkey: fulfillmentConfig.openbookV2Bids,
|
|
2208
|
+
isWritable: true,
|
|
2209
|
+
isSigner: false,
|
|
2210
|
+
});
|
|
2211
|
+
remainingAccounts.push({
|
|
2212
|
+
pubkey: fulfillmentConfig.openbookV2Asks,
|
|
2213
|
+
isWritable: true,
|
|
2214
|
+
isSigner: false,
|
|
2215
|
+
});
|
|
2216
|
+
remainingAccounts.push({
|
|
2217
|
+
pubkey: fulfillmentConfig.openbookV2BaseVault,
|
|
2218
|
+
isWritable: true,
|
|
2219
|
+
isSigner: false,
|
|
2220
|
+
});
|
|
2221
|
+
remainingAccounts.push({
|
|
2222
|
+
pubkey: fulfillmentConfig.openbookV2QuoteVault,
|
|
2223
|
+
isWritable: true,
|
|
2224
|
+
isSigner: false,
|
|
2225
|
+
});
|
|
2226
|
+
remainingAccounts.push({
|
|
2227
|
+
pubkey: this.getSpotMarketAccount(marketIndex).vault,
|
|
2228
|
+
isWritable: true,
|
|
2229
|
+
isSigner: false,
|
|
2230
|
+
});
|
|
2231
|
+
remainingAccounts.push({
|
|
2232
|
+
pubkey: this.getQuoteSpotMarketAccount().vault,
|
|
2233
|
+
isWritable: true,
|
|
2234
|
+
isSigner: false,
|
|
2235
|
+
});
|
|
2236
|
+
remainingAccounts.push({
|
|
2237
|
+
pubkey: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2238
|
+
isWritable: false,
|
|
2239
|
+
isSigner: false,
|
|
2240
|
+
});
|
|
2241
|
+
remainingAccounts.push({
|
|
2242
|
+
pubkey: web3_js_1.SystemProgram.programId,
|
|
2243
|
+
isWritable: false,
|
|
2244
|
+
isSigner: false,
|
|
2245
|
+
});
|
|
2246
|
+
remainingAccounts.push({
|
|
2247
|
+
pubkey: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
2248
|
+
isWritable: true,
|
|
2249
|
+
isSigner: false,
|
|
2250
|
+
});
|
|
2251
|
+
remainingAccounts.push({
|
|
2252
|
+
pubkey: this.getQuoteSpotMarketAccount().pubkey,
|
|
2253
|
+
isWritable: true,
|
|
2254
|
+
isSigner: false,
|
|
2255
|
+
});
|
|
2256
|
+
if (fulfillmentConfig.remainingAccounts) {
|
|
2257
|
+
for (const remainingAccount of fulfillmentConfig.remainingAccounts) {
|
|
2258
|
+
remainingAccounts.push({
|
|
2259
|
+
pubkey: remainingAccount,
|
|
2260
|
+
isWritable: true,
|
|
2261
|
+
isSigner: false,
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2164
2266
|
/**
|
|
2165
2267
|
* Swap tokens in drift account using jupiter
|
|
2166
2268
|
* @param jupiterClient jupiter client to find routes and jupiter instructions
|
package/lib/idl/drift.json
CHANGED
|
@@ -3017,6 +3017,95 @@
|
|
|
3017
3017
|
}
|
|
3018
3018
|
]
|
|
3019
3019
|
},
|
|
3020
|
+
{
|
|
3021
|
+
"name": "initializeOpenbookV2FulfillmentConfig",
|
|
3022
|
+
"accounts": [
|
|
3023
|
+
{
|
|
3024
|
+
"name": "baseSpotMarket",
|
|
3025
|
+
"isMut": false,
|
|
3026
|
+
"isSigner": false
|
|
3027
|
+
},
|
|
3028
|
+
{
|
|
3029
|
+
"name": "quoteSpotMarket",
|
|
3030
|
+
"isMut": false,
|
|
3031
|
+
"isSigner": false
|
|
3032
|
+
},
|
|
3033
|
+
{
|
|
3034
|
+
"name": "state",
|
|
3035
|
+
"isMut": true,
|
|
3036
|
+
"isSigner": false
|
|
3037
|
+
},
|
|
3038
|
+
{
|
|
3039
|
+
"name": "openbookV2Program",
|
|
3040
|
+
"isMut": false,
|
|
3041
|
+
"isSigner": false
|
|
3042
|
+
},
|
|
3043
|
+
{
|
|
3044
|
+
"name": "openbookV2Market",
|
|
3045
|
+
"isMut": false,
|
|
3046
|
+
"isSigner": false
|
|
3047
|
+
},
|
|
3048
|
+
{
|
|
3049
|
+
"name": "driftSigner",
|
|
3050
|
+
"isMut": false,
|
|
3051
|
+
"isSigner": false
|
|
3052
|
+
},
|
|
3053
|
+
{
|
|
3054
|
+
"name": "openbookV2FulfillmentConfig",
|
|
3055
|
+
"isMut": true,
|
|
3056
|
+
"isSigner": false
|
|
3057
|
+
},
|
|
3058
|
+
{
|
|
3059
|
+
"name": "admin",
|
|
3060
|
+
"isMut": true,
|
|
3061
|
+
"isSigner": true
|
|
3062
|
+
},
|
|
3063
|
+
{
|
|
3064
|
+
"name": "rent",
|
|
3065
|
+
"isMut": false,
|
|
3066
|
+
"isSigner": false
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
"name": "systemProgram",
|
|
3070
|
+
"isMut": false,
|
|
3071
|
+
"isSigner": false
|
|
3072
|
+
}
|
|
3073
|
+
],
|
|
3074
|
+
"args": [
|
|
3075
|
+
{
|
|
3076
|
+
"name": "marketIndex",
|
|
3077
|
+
"type": "u16"
|
|
3078
|
+
}
|
|
3079
|
+
]
|
|
3080
|
+
},
|
|
3081
|
+
{
|
|
3082
|
+
"name": "openbookV2FulfillmentConfigStatus",
|
|
3083
|
+
"accounts": [
|
|
3084
|
+
{
|
|
3085
|
+
"name": "state",
|
|
3086
|
+
"isMut": false,
|
|
3087
|
+
"isSigner": false
|
|
3088
|
+
},
|
|
3089
|
+
{
|
|
3090
|
+
"name": "openbookV2FulfillmentConfig",
|
|
3091
|
+
"isMut": true,
|
|
3092
|
+
"isSigner": false
|
|
3093
|
+
},
|
|
3094
|
+
{
|
|
3095
|
+
"name": "admin",
|
|
3096
|
+
"isMut": true,
|
|
3097
|
+
"isSigner": true
|
|
3098
|
+
}
|
|
3099
|
+
],
|
|
3100
|
+
"args": [
|
|
3101
|
+
{
|
|
3102
|
+
"name": "status",
|
|
3103
|
+
"type": {
|
|
3104
|
+
"defined": "SpotFulfillmentConfigStatus"
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
]
|
|
3108
|
+
},
|
|
3020
3109
|
{
|
|
3021
3110
|
"name": "initializePhoenixFulfillmentConfig",
|
|
3022
3111
|
"accounts": [
|
|
@@ -5631,6 +5720,75 @@
|
|
|
5631
5720
|
}
|
|
5632
5721
|
],
|
|
5633
5722
|
"accounts": [
|
|
5723
|
+
{
|
|
5724
|
+
"name": "OpenbookV2FulfillmentConfig",
|
|
5725
|
+
"type": {
|
|
5726
|
+
"kind": "struct",
|
|
5727
|
+
"fields": [
|
|
5728
|
+
{
|
|
5729
|
+
"name": "pubkey",
|
|
5730
|
+
"type": "publicKey"
|
|
5731
|
+
},
|
|
5732
|
+
{
|
|
5733
|
+
"name": "openbookV2ProgramId",
|
|
5734
|
+
"type": "publicKey"
|
|
5735
|
+
},
|
|
5736
|
+
{
|
|
5737
|
+
"name": "openbookV2Market",
|
|
5738
|
+
"type": "publicKey"
|
|
5739
|
+
},
|
|
5740
|
+
{
|
|
5741
|
+
"name": "openbookV2MarketAuthority",
|
|
5742
|
+
"type": "publicKey"
|
|
5743
|
+
},
|
|
5744
|
+
{
|
|
5745
|
+
"name": "openbookV2EventHeap",
|
|
5746
|
+
"type": "publicKey"
|
|
5747
|
+
},
|
|
5748
|
+
{
|
|
5749
|
+
"name": "openbookV2Bids",
|
|
5750
|
+
"type": "publicKey"
|
|
5751
|
+
},
|
|
5752
|
+
{
|
|
5753
|
+
"name": "openbookV2Asks",
|
|
5754
|
+
"type": "publicKey"
|
|
5755
|
+
},
|
|
5756
|
+
{
|
|
5757
|
+
"name": "openbookV2BaseVault",
|
|
5758
|
+
"type": "publicKey"
|
|
5759
|
+
},
|
|
5760
|
+
{
|
|
5761
|
+
"name": "openbookV2QuoteVault",
|
|
5762
|
+
"type": "publicKey"
|
|
5763
|
+
},
|
|
5764
|
+
{
|
|
5765
|
+
"name": "marketIndex",
|
|
5766
|
+
"type": "u16"
|
|
5767
|
+
},
|
|
5768
|
+
{
|
|
5769
|
+
"name": "fulfillmentType",
|
|
5770
|
+
"type": {
|
|
5771
|
+
"defined": "SpotFulfillmentType"
|
|
5772
|
+
}
|
|
5773
|
+
},
|
|
5774
|
+
{
|
|
5775
|
+
"name": "status",
|
|
5776
|
+
"type": {
|
|
5777
|
+
"defined": "SpotFulfillmentConfigStatus"
|
|
5778
|
+
}
|
|
5779
|
+
},
|
|
5780
|
+
{
|
|
5781
|
+
"name": "padding",
|
|
5782
|
+
"type": {
|
|
5783
|
+
"array": [
|
|
5784
|
+
"u8",
|
|
5785
|
+
4
|
|
5786
|
+
]
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5789
|
+
]
|
|
5790
|
+
}
|
|
5791
|
+
},
|
|
5634
5792
|
{
|
|
5635
5793
|
"name": "PhoenixV1FulfillmentConfig",
|
|
5636
5794
|
"type": {
|
|
@@ -9269,6 +9427,9 @@
|
|
|
9269
9427
|
},
|
|
9270
9428
|
{
|
|
9271
9429
|
"name": "PhoenixV1"
|
|
9430
|
+
},
|
|
9431
|
+
{
|
|
9432
|
+
"name": "OpenbookV2"
|
|
9272
9433
|
}
|
|
9273
9434
|
]
|
|
9274
9435
|
}
|
|
@@ -9540,6 +9701,9 @@
|
|
|
9540
9701
|
},
|
|
9541
9702
|
{
|
|
9542
9703
|
"name": "DeriskLp"
|
|
9704
|
+
},
|
|
9705
|
+
{
|
|
9706
|
+
"name": "OrderFilledWithOpenbookV2"
|
|
9543
9707
|
}
|
|
9544
9708
|
]
|
|
9545
9709
|
}
|
|
@@ -12553,6 +12717,21 @@
|
|
|
12553
12717
|
"code": 6278,
|
|
12554
12718
|
"name": "OracleBadRemainingAccountPublicKey",
|
|
12555
12719
|
"msg": "Remaining account passed is not a valid pda"
|
|
12720
|
+
},
|
|
12721
|
+
{
|
|
12722
|
+
"code": 6279,
|
|
12723
|
+
"name": "FailedOpenbookV2CPI",
|
|
12724
|
+
"msg": "FailedOpenbookV2CPI"
|
|
12725
|
+
},
|
|
12726
|
+
{
|
|
12727
|
+
"code": 6280,
|
|
12728
|
+
"name": "InvalidOpenbookV2Program",
|
|
12729
|
+
"msg": "InvalidOpenbookV2Program"
|
|
12730
|
+
},
|
|
12731
|
+
{
|
|
12732
|
+
"code": 6281,
|
|
12733
|
+
"name": "InvalidOpenbookV2Market",
|
|
12734
|
+
"msg": "InvalidOpenbookV2Market"
|
|
12556
12735
|
}
|
|
12557
12736
|
],
|
|
12558
12737
|
"metadata": {
|
package/lib/types.d.ts
CHANGED
|
@@ -1202,6 +1202,21 @@ export type PhoenixV1FulfillmentConfigAccount = {
|
|
|
1202
1202
|
fulfillmentType: SpotFulfillmentType;
|
|
1203
1203
|
status: SpotFulfillmentStatus;
|
|
1204
1204
|
};
|
|
1205
|
+
export type OpenbookV2FulfillmentConfigAccount = {
|
|
1206
|
+
pubkey: PublicKey;
|
|
1207
|
+
openbookV2ProgramId: PublicKey;
|
|
1208
|
+
openbookV2Market: PublicKey;
|
|
1209
|
+
openbookV2MarketAuthority: PublicKey;
|
|
1210
|
+
openbookV2EventHeap: PublicKey;
|
|
1211
|
+
openbookV2Bids: PublicKey;
|
|
1212
|
+
openbookV2Asks: PublicKey;
|
|
1213
|
+
openbookV2BaseVault: PublicKey;
|
|
1214
|
+
openbookV2QuoteVault: PublicKey;
|
|
1215
|
+
marketIndex: number;
|
|
1216
|
+
fulfillmentType: SpotFulfillmentType;
|
|
1217
|
+
status: SpotFulfillmentStatus;
|
|
1218
|
+
remainingAccounts?: PublicKey[];
|
|
1219
|
+
};
|
|
1205
1220
|
export type ReferrerNameAccount = {
|
|
1206
1221
|
name: number[];
|
|
1207
1222
|
user: PublicKey;
|
package/lib/user.js
CHANGED
|
@@ -592,7 +592,7 @@ class User {
|
|
|
592
592
|
// todo: get real time ifStakedGovTokenAmount using ifStakeAccount
|
|
593
593
|
if (userStats.ifStakedGovTokenAmount.gt(numericConstants_1.ZERO)) {
|
|
594
594
|
const spotMarketAccount = this.driftClient.getSpotMarketAccount(numericConstants_1.GOV_SPOT_MARKET_INDEX);
|
|
595
|
-
const fuelBonusNumeratorUserStats = now.sub(_1.BN.max(new _1.BN(userStats.lastFuelIfBonusUpdateTs), numericConstants_1.FUEL_START_TS));
|
|
595
|
+
const fuelBonusNumeratorUserStats = _1.BN.max(now.sub(_1.BN.max(new _1.BN(userStats.lastFuelIfBonusUpdateTs), numericConstants_1.FUEL_START_TS)), numericConstants_1.ZERO);
|
|
596
596
|
result.insuranceFuel = result.insuranceFuel.add((0, fuel_1.calculateInsuranceFuelBonus)(spotMarketAccount, userStats.ifStakedGovTokenAmount, fuelBonusNumeratorUserStats));
|
|
597
597
|
}
|
|
598
598
|
if (userStats.ifStakedQuoteAssetAmount.gt(numericConstants_1.ZERO)) {
|
package/package.json
CHANGED
package/src/addresses/pda.ts
CHANGED
|
@@ -202,6 +202,21 @@ export function getPhoenixFulfillmentConfigPublicKey(
|
|
|
202
202
|
)[0];
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
export function getOpenbookV2FulfillmentConfigPublicKey(
|
|
206
|
+
programId: PublicKey,
|
|
207
|
+
market: PublicKey
|
|
208
|
+
): PublicKey {
|
|
209
|
+
return PublicKey.findProgramAddressSync(
|
|
210
|
+
[
|
|
211
|
+
Buffer.from(
|
|
212
|
+
anchor.utils.bytes.utf8.encode('openbook_v2_fulfillment_config')
|
|
213
|
+
),
|
|
214
|
+
market.toBuffer(),
|
|
215
|
+
],
|
|
216
|
+
programId
|
|
217
|
+
)[0];
|
|
218
|
+
}
|
|
219
|
+
|
|
205
220
|
export function getReferrerNamePublicKeySync(
|
|
206
221
|
programId: PublicKey,
|
|
207
222
|
nameBuffer: number[]
|