@drift-labs/sdk 2.110.0-beta.10 → 2.110.0-beta.11
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 +0 -1
- package/lib/browser/addresses/pda.js +1 -8
- package/lib/browser/driftClient.d.ts +1 -6
- package/lib/browser/driftClient.js +0 -77
- package/lib/browser/types.d.ts +0 -20
- package/lib/node/addresses/pda.d.ts +0 -1
- package/lib/node/addresses/pda.js +1 -8
- package/lib/node/driftClient.d.ts +1 -6
- package/lib/node/driftClient.js +0 -77
- package/lib/node/types.d.ts +0 -20
- package/package.json +1 -1
- package/src/addresses/pda.ts +0 -13
- package/src/driftClient.ts +0 -126
- package/src/types.ts +0 -23
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.110.0-beta.
|
|
1
|
+
2.110.0-beta.11
|
|
@@ -9,7 +9,6 @@ export declare function getUserAccountPublicKey(programId: PublicKey, authority:
|
|
|
9
9
|
export declare function getUserAccountPublicKeySync(programId: PublicKey, authority: PublicKey, subAccountId?: number): PublicKey;
|
|
10
10
|
export declare function getUserStatsAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
|
|
11
11
|
export declare function getFuelOverflowAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
|
|
12
|
-
export declare function getRFQUserAccountPublicKey(programId: PublicKey, userAccountPublicKey: PublicKey): PublicKey;
|
|
13
12
|
export declare function getSwiftUserAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
|
|
14
13
|
export declare function getPerpMarketPublicKey(programId: PublicKey, marketIndex: number): Promise<PublicKey>;
|
|
15
14
|
export declare function getPerpMarketPublicKeySync(programId: PublicKey, marketIndex: number): PublicKey;
|
|
@@ -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.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.getSwiftUserAccountPublicKey = exports.
|
|
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.getSwiftUserAccountPublicKey = 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
29
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -69,13 +69,6 @@ function getFuelOverflowAccountPublicKey(programId, authority) {
|
|
|
69
69
|
], programId)[0];
|
|
70
70
|
}
|
|
71
71
|
exports.getFuelOverflowAccountPublicKey = getFuelOverflowAccountPublicKey;
|
|
72
|
-
function getRFQUserAccountPublicKey(programId, userAccountPublicKey) {
|
|
73
|
-
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
74
|
-
Buffer.from(anchor.utils.bytes.utf8.encode('RFQ')),
|
|
75
|
-
userAccountPublicKey.toBuffer(),
|
|
76
|
-
], programId)[0];
|
|
77
|
-
}
|
|
78
|
-
exports.getRFQUserAccountPublicKey = getRFQUserAccountPublicKey;
|
|
79
72
|
function getSwiftUserAccountPublicKey(programId, authority) {
|
|
80
73
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
81
74
|
Buffer.from(anchor.utils.bytes.utf8.encode('SWIFT')),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as anchor from '@coral-xyz/anchor';
|
|
6
6
|
import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
7
7
|
import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
|
|
8
|
-
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount,
|
|
8
|
+
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SwiftOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount } from './types';
|
|
9
9
|
import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
10
10
|
import { TokenFaucet } from './tokenFaucet';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
@@ -148,8 +148,6 @@ export declare class DriftClient {
|
|
|
148
148
|
addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
|
|
149
149
|
initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
150
150
|
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
151
|
-
initializeRFQUser(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
152
|
-
getInitializeRFQUserInstruction(userAccountPublicKey: PublicKey): Promise<[PublicKey, TransactionInstruction]>;
|
|
153
151
|
initializeSwiftUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
154
152
|
getInitializeSwiftUserOrdersAccountIx(authority: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>;
|
|
155
153
|
resizeSwiftUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
@@ -580,9 +578,6 @@ export declare class DriftClient {
|
|
|
580
578
|
takerUserAccount: UserAccount;
|
|
581
579
|
signingAuthority: PublicKey;
|
|
582
580
|
}, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
|
|
583
|
-
encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
|
|
584
|
-
placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
585
|
-
getPlaceAndMatchRFQOrdersIxs(rfqMatches: RFQMatch[]): Promise<TransactionInstruction[]>;
|
|
586
581
|
preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{
|
|
587
582
|
placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
588
583
|
}>;
|
|
@@ -603,28 +603,6 @@ class DriftClient {
|
|
|
603
603
|
},
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
async initializeRFQUser(userAccountPublicKey, txParams) {
|
|
607
|
-
const initializeIxs = [];
|
|
608
|
-
const [rfqUserAccountPublicKey, initializeUserAccountIx] = await this.getInitializeRFQUserInstruction(userAccountPublicKey);
|
|
609
|
-
initializeIxs.push(initializeUserAccountIx);
|
|
610
|
-
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
611
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
612
|
-
return [txSig, rfqUserAccountPublicKey];
|
|
613
|
-
}
|
|
614
|
-
async getInitializeRFQUserInstruction(userAccountPublicKey) {
|
|
615
|
-
const rfqUserAccountPublicKey = (0, pda_1.getRFQUserAccountPublicKey)(this.program.programId, userAccountPublicKey);
|
|
616
|
-
const initializeUserAccountIx = await this.program.instruction.initializeRfqUser({
|
|
617
|
-
accounts: {
|
|
618
|
-
rfqUser: rfqUserAccountPublicKey,
|
|
619
|
-
authority: this.wallet.publicKey,
|
|
620
|
-
user: userAccountPublicKey,
|
|
621
|
-
payer: this.wallet.publicKey,
|
|
622
|
-
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
623
|
-
systemProgram: anchor.web3.SystemProgram.programId,
|
|
624
|
-
},
|
|
625
|
-
});
|
|
626
|
-
return [rfqUserAccountPublicKey, initializeUserAccountIx];
|
|
627
|
-
}
|
|
628
606
|
async initializeSwiftUserOrders(authority, numOrders, txParams) {
|
|
629
607
|
const initializeIxs = [];
|
|
630
608
|
const [swiftUserAccountPublicKey, initializeUserAccountIx] = await this.getInitializeSwiftUserOrdersAccountIx(authority, numOrders);
|
|
@@ -3347,61 +3325,6 @@ class DriftClient {
|
|
|
3347
3325
|
});
|
|
3348
3326
|
return [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx, placeAndMakeIx];
|
|
3349
3327
|
}
|
|
3350
|
-
encodeRFQMakerOrderParams(message) {
|
|
3351
|
-
return this.program.coder.types.encode('RFQMakerOrderParams', message);
|
|
3352
|
-
}
|
|
3353
|
-
async placeAndMatchRFQOrders(rfqMatches, txParams) {
|
|
3354
|
-
const ixs = await this.getPlaceAndMatchRFQOrdersIxs(rfqMatches);
|
|
3355
|
-
const { txSig } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
|
|
3356
|
-
return txSig;
|
|
3357
|
-
}
|
|
3358
|
-
async getPlaceAndMatchRFQOrdersIxs(rfqMatches) {
|
|
3359
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
3360
|
-
userAccounts: [this.getUserAccount()],
|
|
3361
|
-
useMarketLastSlotCache: true,
|
|
3362
|
-
writablePerpMarketIndexes: [rfqMatches[0].makerOrderParams.marketIndex],
|
|
3363
|
-
});
|
|
3364
|
-
const makerAccountMetas = [];
|
|
3365
|
-
const verifyIxs = [];
|
|
3366
|
-
for (const match of rfqMatches) {
|
|
3367
|
-
const verifyIx = web3_js_1.Ed25519Program.createInstructionWithPublicKey({
|
|
3368
|
-
publicKey: match.makerOrderParams.authority.toBytes(),
|
|
3369
|
-
signature: match.makerSignature,
|
|
3370
|
-
message: Uint8Array.from(this.encodeRFQMakerOrderParams(match.makerOrderParams)),
|
|
3371
|
-
});
|
|
3372
|
-
verifyIxs.push(verifyIx);
|
|
3373
|
-
const userAccountPubkey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, match.makerOrderParams.authority, match.makerOrderParams.subAccountId);
|
|
3374
|
-
makerAccountMetas.push({
|
|
3375
|
-
pubkey: userAccountPubkey,
|
|
3376
|
-
isWritable: true,
|
|
3377
|
-
isSigner: false,
|
|
3378
|
-
});
|
|
3379
|
-
makerAccountMetas.push({
|
|
3380
|
-
pubkey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, match.makerOrderParams.authority),
|
|
3381
|
-
isWritable: true,
|
|
3382
|
-
isSigner: false,
|
|
3383
|
-
});
|
|
3384
|
-
makerAccountMetas.push({
|
|
3385
|
-
pubkey: (0, pda_1.getRFQUserAccountPublicKey)(this.program.programId, userAccountPubkey),
|
|
3386
|
-
isWritable: true,
|
|
3387
|
-
isSigner: false,
|
|
3388
|
-
});
|
|
3389
|
-
}
|
|
3390
|
-
remainingAccounts.push(...makerAccountMetas);
|
|
3391
|
-
const userStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
3392
|
-
const user = await this.getUserAccountPublicKey();
|
|
3393
|
-
const placeAndMatchRFQOrdersIx = await this.program.instruction.placeAndMatchRfqOrders(rfqMatches, {
|
|
3394
|
-
accounts: {
|
|
3395
|
-
state: await this.getStatePublicKey(),
|
|
3396
|
-
user,
|
|
3397
|
-
userStats: userStatsPublicKey,
|
|
3398
|
-
authority: this.wallet.publicKey,
|
|
3399
|
-
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3400
|
-
},
|
|
3401
|
-
remainingAccounts,
|
|
3402
|
-
});
|
|
3403
|
-
return [...verifyIxs, placeAndMatchRFQOrdersIx];
|
|
3404
|
-
}
|
|
3405
3328
|
async preparePlaceAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams, subAccountId) {
|
|
3406
3329
|
const tx = await this.buildTransaction(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo, subAccountId), txParams);
|
|
3407
3330
|
return {
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -1179,26 +1179,6 @@ export type SwiftTriggerOrderParams = {
|
|
|
1179
1179
|
triggerPrice: BN;
|
|
1180
1180
|
baseAssetAmount: BN;
|
|
1181
1181
|
};
|
|
1182
|
-
export type RFQMakerOrderParams = {
|
|
1183
|
-
uuid: Uint8Array;
|
|
1184
|
-
authority: PublicKey;
|
|
1185
|
-
subAccountId: number;
|
|
1186
|
-
marketIndex: number;
|
|
1187
|
-
marketType: MarketType;
|
|
1188
|
-
baseAssetAmount: BN;
|
|
1189
|
-
price: BN;
|
|
1190
|
-
direction: PositionDirection;
|
|
1191
|
-
maxTs: BN;
|
|
1192
|
-
};
|
|
1193
|
-
export type RFQMakerMessage = {
|
|
1194
|
-
orderParams: RFQMakerOrderParams;
|
|
1195
|
-
signature: Uint8Array;
|
|
1196
|
-
};
|
|
1197
|
-
export type RFQMatch = {
|
|
1198
|
-
baseAssetAmount: BN;
|
|
1199
|
-
makerOrderParams: RFQMakerOrderParams;
|
|
1200
|
-
makerSignature: Uint8Array;
|
|
1201
|
-
};
|
|
1202
1182
|
export type MakerInfo = {
|
|
1203
1183
|
maker: PublicKey;
|
|
1204
1184
|
makerStats: PublicKey;
|
|
@@ -9,7 +9,6 @@ export declare function getUserAccountPublicKey(programId: PublicKey, authority:
|
|
|
9
9
|
export declare function getUserAccountPublicKeySync(programId: PublicKey, authority: PublicKey, subAccountId?: number): PublicKey;
|
|
10
10
|
export declare function getUserStatsAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
|
|
11
11
|
export declare function getFuelOverflowAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
|
|
12
|
-
export declare function getRFQUserAccountPublicKey(programId: PublicKey, userAccountPublicKey: PublicKey): PublicKey;
|
|
13
12
|
export declare function getSwiftUserAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
|
|
14
13
|
export declare function getPerpMarketPublicKey(programId: PublicKey, marketIndex: number): Promise<PublicKey>;
|
|
15
14
|
export declare function getPerpMarketPublicKeySync(programId: PublicKey, marketIndex: number): PublicKey;
|
|
@@ -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.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.getSwiftUserAccountPublicKey = exports.
|
|
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.getSwiftUserAccountPublicKey = 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
29
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -69,13 +69,6 @@ function getFuelOverflowAccountPublicKey(programId, authority) {
|
|
|
69
69
|
], programId)[0];
|
|
70
70
|
}
|
|
71
71
|
exports.getFuelOverflowAccountPublicKey = getFuelOverflowAccountPublicKey;
|
|
72
|
-
function getRFQUserAccountPublicKey(programId, userAccountPublicKey) {
|
|
73
|
-
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
74
|
-
Buffer.from(anchor.utils.bytes.utf8.encode('RFQ')),
|
|
75
|
-
userAccountPublicKey.toBuffer(),
|
|
76
|
-
], programId)[0];
|
|
77
|
-
}
|
|
78
|
-
exports.getRFQUserAccountPublicKey = getRFQUserAccountPublicKey;
|
|
79
72
|
function getSwiftUserAccountPublicKey(programId, authority) {
|
|
80
73
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
81
74
|
Buffer.from(anchor.utils.bytes.utf8.encode('SWIFT')),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as anchor from '@coral-xyz/anchor';
|
|
6
6
|
import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
7
7
|
import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
|
|
8
|
-
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount,
|
|
8
|
+
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SwiftOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount } from './types';
|
|
9
9
|
import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
10
10
|
import { TokenFaucet } from './tokenFaucet';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
@@ -148,8 +148,6 @@ export declare class DriftClient {
|
|
|
148
148
|
addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
|
|
149
149
|
initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
150
150
|
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
151
|
-
initializeRFQUser(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
152
|
-
getInitializeRFQUserInstruction(userAccountPublicKey: PublicKey): Promise<[PublicKey, TransactionInstruction]>;
|
|
153
151
|
initializeSwiftUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
154
152
|
getInitializeSwiftUserOrdersAccountIx(authority: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>;
|
|
155
153
|
resizeSwiftUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
@@ -580,9 +578,6 @@ export declare class DriftClient {
|
|
|
580
578
|
takerUserAccount: UserAccount;
|
|
581
579
|
signingAuthority: PublicKey;
|
|
582
580
|
}, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): Promise<TransactionInstruction[]>;
|
|
583
|
-
encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
|
|
584
|
-
placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
585
|
-
getPlaceAndMatchRFQOrdersIxs(rfqMatches: RFQMatch[]): Promise<TransactionInstruction[]>;
|
|
586
581
|
preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{
|
|
587
582
|
placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
588
583
|
}>;
|
package/lib/node/driftClient.js
CHANGED
|
@@ -603,28 +603,6 @@ class DriftClient {
|
|
|
603
603
|
},
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
async initializeRFQUser(userAccountPublicKey, txParams) {
|
|
607
|
-
const initializeIxs = [];
|
|
608
|
-
const [rfqUserAccountPublicKey, initializeUserAccountIx] = await this.getInitializeRFQUserInstruction(userAccountPublicKey);
|
|
609
|
-
initializeIxs.push(initializeUserAccountIx);
|
|
610
|
-
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
611
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
612
|
-
return [txSig, rfqUserAccountPublicKey];
|
|
613
|
-
}
|
|
614
|
-
async getInitializeRFQUserInstruction(userAccountPublicKey) {
|
|
615
|
-
const rfqUserAccountPublicKey = (0, pda_1.getRFQUserAccountPublicKey)(this.program.programId, userAccountPublicKey);
|
|
616
|
-
const initializeUserAccountIx = await this.program.instruction.initializeRfqUser({
|
|
617
|
-
accounts: {
|
|
618
|
-
rfqUser: rfqUserAccountPublicKey,
|
|
619
|
-
authority: this.wallet.publicKey,
|
|
620
|
-
user: userAccountPublicKey,
|
|
621
|
-
payer: this.wallet.publicKey,
|
|
622
|
-
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
623
|
-
systemProgram: anchor.web3.SystemProgram.programId,
|
|
624
|
-
},
|
|
625
|
-
});
|
|
626
|
-
return [rfqUserAccountPublicKey, initializeUserAccountIx];
|
|
627
|
-
}
|
|
628
606
|
async initializeSwiftUserOrders(authority, numOrders, txParams) {
|
|
629
607
|
const initializeIxs = [];
|
|
630
608
|
const [swiftUserAccountPublicKey, initializeUserAccountIx] = await this.getInitializeSwiftUserOrdersAccountIx(authority, numOrders);
|
|
@@ -3347,61 +3325,6 @@ class DriftClient {
|
|
|
3347
3325
|
});
|
|
3348
3326
|
return [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx, placeAndMakeIx];
|
|
3349
3327
|
}
|
|
3350
|
-
encodeRFQMakerOrderParams(message) {
|
|
3351
|
-
return this.program.coder.types.encode('RFQMakerOrderParams', message);
|
|
3352
|
-
}
|
|
3353
|
-
async placeAndMatchRFQOrders(rfqMatches, txParams) {
|
|
3354
|
-
const ixs = await this.getPlaceAndMatchRFQOrdersIxs(rfqMatches);
|
|
3355
|
-
const { txSig } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
|
|
3356
|
-
return txSig;
|
|
3357
|
-
}
|
|
3358
|
-
async getPlaceAndMatchRFQOrdersIxs(rfqMatches) {
|
|
3359
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
3360
|
-
userAccounts: [this.getUserAccount()],
|
|
3361
|
-
useMarketLastSlotCache: true,
|
|
3362
|
-
writablePerpMarketIndexes: [rfqMatches[0].makerOrderParams.marketIndex],
|
|
3363
|
-
});
|
|
3364
|
-
const makerAccountMetas = [];
|
|
3365
|
-
const verifyIxs = [];
|
|
3366
|
-
for (const match of rfqMatches) {
|
|
3367
|
-
const verifyIx = web3_js_1.Ed25519Program.createInstructionWithPublicKey({
|
|
3368
|
-
publicKey: match.makerOrderParams.authority.toBytes(),
|
|
3369
|
-
signature: match.makerSignature,
|
|
3370
|
-
message: Uint8Array.from(this.encodeRFQMakerOrderParams(match.makerOrderParams)),
|
|
3371
|
-
});
|
|
3372
|
-
verifyIxs.push(verifyIx);
|
|
3373
|
-
const userAccountPubkey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, match.makerOrderParams.authority, match.makerOrderParams.subAccountId);
|
|
3374
|
-
makerAccountMetas.push({
|
|
3375
|
-
pubkey: userAccountPubkey,
|
|
3376
|
-
isWritable: true,
|
|
3377
|
-
isSigner: false,
|
|
3378
|
-
});
|
|
3379
|
-
makerAccountMetas.push({
|
|
3380
|
-
pubkey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, match.makerOrderParams.authority),
|
|
3381
|
-
isWritable: true,
|
|
3382
|
-
isSigner: false,
|
|
3383
|
-
});
|
|
3384
|
-
makerAccountMetas.push({
|
|
3385
|
-
pubkey: (0, pda_1.getRFQUserAccountPublicKey)(this.program.programId, userAccountPubkey),
|
|
3386
|
-
isWritable: true,
|
|
3387
|
-
isSigner: false,
|
|
3388
|
-
});
|
|
3389
|
-
}
|
|
3390
|
-
remainingAccounts.push(...makerAccountMetas);
|
|
3391
|
-
const userStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
3392
|
-
const user = await this.getUserAccountPublicKey();
|
|
3393
|
-
const placeAndMatchRFQOrdersIx = await this.program.instruction.placeAndMatchRfqOrders(rfqMatches, {
|
|
3394
|
-
accounts: {
|
|
3395
|
-
state: await this.getStatePublicKey(),
|
|
3396
|
-
user,
|
|
3397
|
-
userStats: userStatsPublicKey,
|
|
3398
|
-
authority: this.wallet.publicKey,
|
|
3399
|
-
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3400
|
-
},
|
|
3401
|
-
remainingAccounts,
|
|
3402
|
-
});
|
|
3403
|
-
return [...verifyIxs, placeAndMatchRFQOrdersIx];
|
|
3404
|
-
}
|
|
3405
3328
|
async preparePlaceAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams, subAccountId) {
|
|
3406
3329
|
const tx = await this.buildTransaction(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo, subAccountId), txParams);
|
|
3407
3330
|
return {
|
package/lib/node/types.d.ts
CHANGED
|
@@ -1179,26 +1179,6 @@ export type SwiftTriggerOrderParams = {
|
|
|
1179
1179
|
triggerPrice: BN;
|
|
1180
1180
|
baseAssetAmount: BN;
|
|
1181
1181
|
};
|
|
1182
|
-
export type RFQMakerOrderParams = {
|
|
1183
|
-
uuid: Uint8Array;
|
|
1184
|
-
authority: PublicKey;
|
|
1185
|
-
subAccountId: number;
|
|
1186
|
-
marketIndex: number;
|
|
1187
|
-
marketType: MarketType;
|
|
1188
|
-
baseAssetAmount: BN;
|
|
1189
|
-
price: BN;
|
|
1190
|
-
direction: PositionDirection;
|
|
1191
|
-
maxTs: BN;
|
|
1192
|
-
};
|
|
1193
|
-
export type RFQMakerMessage = {
|
|
1194
|
-
orderParams: RFQMakerOrderParams;
|
|
1195
|
-
signature: Uint8Array;
|
|
1196
|
-
};
|
|
1197
|
-
export type RFQMatch = {
|
|
1198
|
-
baseAssetAmount: BN;
|
|
1199
|
-
makerOrderParams: RFQMakerOrderParams;
|
|
1200
|
-
makerSignature: Uint8Array;
|
|
1201
|
-
};
|
|
1202
1182
|
export type MakerInfo = {
|
|
1203
1183
|
maker: PublicKey;
|
|
1204
1184
|
makerStats: PublicKey;
|
package/package.json
CHANGED
package/src/addresses/pda.ts
CHANGED
|
@@ -85,19 +85,6 @@ export function getFuelOverflowAccountPublicKey(
|
|
|
85
85
|
)[0];
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function getRFQUserAccountPublicKey(
|
|
89
|
-
programId: PublicKey,
|
|
90
|
-
userAccountPublicKey: PublicKey
|
|
91
|
-
): PublicKey {
|
|
92
|
-
return PublicKey.findProgramAddressSync(
|
|
93
|
-
[
|
|
94
|
-
Buffer.from(anchor.utils.bytes.utf8.encode('RFQ')),
|
|
95
|
-
userAccountPublicKey.toBuffer(),
|
|
96
|
-
],
|
|
97
|
-
programId
|
|
98
|
-
)[0];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
88
|
export function getSwiftUserAccountPublicKey(
|
|
102
89
|
programId: PublicKey,
|
|
103
90
|
authority: PublicKey
|
package/src/driftClient.ts
CHANGED
|
@@ -43,8 +43,6 @@ import {
|
|
|
43
43
|
PositionDirection,
|
|
44
44
|
ReferrerInfo,
|
|
45
45
|
ReferrerNameAccount,
|
|
46
|
-
RFQMakerOrderParams,
|
|
47
|
-
RFQMatch,
|
|
48
46
|
SerumV3FulfillmentConfigAccount,
|
|
49
47
|
SettlePnlMode,
|
|
50
48
|
SignedTxData,
|
|
@@ -67,7 +65,6 @@ import {
|
|
|
67
65
|
BlockhashWithExpiryBlockHeight,
|
|
68
66
|
ConfirmOptions,
|
|
69
67
|
Connection,
|
|
70
|
-
Ed25519Program,
|
|
71
68
|
Keypair,
|
|
72
69
|
LAMPORTS_PER_SOL,
|
|
73
70
|
PublicKey,
|
|
@@ -97,7 +94,6 @@ import {
|
|
|
97
94
|
getPythLazerOraclePublicKey,
|
|
98
95
|
getPythPullOraclePublicKey,
|
|
99
96
|
getReferrerNamePublicKeySync,
|
|
100
|
-
getRFQUserAccountPublicKey,
|
|
101
97
|
getSerumFulfillmentConfigPublicKey,
|
|
102
98
|
getSerumSignerPublicKey,
|
|
103
99
|
getSpotMarketPublicKey,
|
|
@@ -1049,43 +1045,6 @@ export class DriftClient {
|
|
|
1049
1045
|
});
|
|
1050
1046
|
}
|
|
1051
1047
|
|
|
1052
|
-
public async initializeRFQUser(
|
|
1053
|
-
userAccountPublicKey: PublicKey,
|
|
1054
|
-
txParams?: TxParams
|
|
1055
|
-
): Promise<[TransactionSignature, PublicKey]> {
|
|
1056
|
-
const initializeIxs = [];
|
|
1057
|
-
|
|
1058
|
-
const [rfqUserAccountPublicKey, initializeUserAccountIx] =
|
|
1059
|
-
await this.getInitializeRFQUserInstruction(userAccountPublicKey);
|
|
1060
|
-
initializeIxs.push(initializeUserAccountIx);
|
|
1061
|
-
const tx = await this.buildTransaction(initializeIxs, txParams);
|
|
1062
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1063
|
-
|
|
1064
|
-
return [txSig, rfqUserAccountPublicKey];
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
async getInitializeRFQUserInstruction(
|
|
1068
|
-
userAccountPublicKey: PublicKey
|
|
1069
|
-
): Promise<[PublicKey, TransactionInstruction]> {
|
|
1070
|
-
const rfqUserAccountPublicKey = getRFQUserAccountPublicKey(
|
|
1071
|
-
this.program.programId,
|
|
1072
|
-
userAccountPublicKey
|
|
1073
|
-
);
|
|
1074
|
-
const initializeUserAccountIx =
|
|
1075
|
-
await this.program.instruction.initializeRfqUser({
|
|
1076
|
-
accounts: {
|
|
1077
|
-
rfqUser: rfqUserAccountPublicKey,
|
|
1078
|
-
authority: this.wallet.publicKey,
|
|
1079
|
-
user: userAccountPublicKey,
|
|
1080
|
-
payer: this.wallet.publicKey,
|
|
1081
|
-
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
|
|
1082
|
-
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1083
|
-
},
|
|
1084
|
-
});
|
|
1085
|
-
|
|
1086
|
-
return [rfqUserAccountPublicKey, initializeUserAccountIx];
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
1048
|
public async initializeSwiftUserOrders(
|
|
1090
1049
|
authority: PublicKey,
|
|
1091
1050
|
numOrders: number,
|
|
@@ -6252,91 +6211,6 @@ export class DriftClient {
|
|
|
6252
6211
|
return [swiftOrderSignatureIx, placeTakerSwiftPerpOrderIx, placeAndMakeIx];
|
|
6253
6212
|
}
|
|
6254
6213
|
|
|
6255
|
-
public encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer {
|
|
6256
|
-
return this.program.coder.types.encode('RFQMakerOrderParams', message);
|
|
6257
|
-
}
|
|
6258
|
-
|
|
6259
|
-
public async placeAndMatchRFQOrders(
|
|
6260
|
-
rfqMatches: RFQMatch[],
|
|
6261
|
-
txParams?: TxParams
|
|
6262
|
-
): Promise<TransactionSignature> {
|
|
6263
|
-
const ixs = await this.getPlaceAndMatchRFQOrdersIxs(rfqMatches);
|
|
6264
|
-
const { txSig } = await this.sendTransaction(
|
|
6265
|
-
await this.buildTransaction(ixs, txParams),
|
|
6266
|
-
[],
|
|
6267
|
-
this.opts
|
|
6268
|
-
);
|
|
6269
|
-
return txSig;
|
|
6270
|
-
}
|
|
6271
|
-
|
|
6272
|
-
public async getPlaceAndMatchRFQOrdersIxs(
|
|
6273
|
-
rfqMatches: RFQMatch[]
|
|
6274
|
-
): Promise<TransactionInstruction[]> {
|
|
6275
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
6276
|
-
userAccounts: [this.getUserAccount()],
|
|
6277
|
-
useMarketLastSlotCache: true,
|
|
6278
|
-
writablePerpMarketIndexes: [rfqMatches[0].makerOrderParams.marketIndex],
|
|
6279
|
-
});
|
|
6280
|
-
|
|
6281
|
-
const makerAccountMetas = [];
|
|
6282
|
-
const verifyIxs = [];
|
|
6283
|
-
for (const match of rfqMatches) {
|
|
6284
|
-
const verifyIx = Ed25519Program.createInstructionWithPublicKey({
|
|
6285
|
-
publicKey: match.makerOrderParams.authority.toBytes(),
|
|
6286
|
-
signature: match.makerSignature,
|
|
6287
|
-
message: Uint8Array.from(
|
|
6288
|
-
this.encodeRFQMakerOrderParams(match.makerOrderParams)
|
|
6289
|
-
),
|
|
6290
|
-
});
|
|
6291
|
-
verifyIxs.push(verifyIx);
|
|
6292
|
-
|
|
6293
|
-
const userAccountPubkey = await getUserAccountPublicKey(
|
|
6294
|
-
this.program.programId,
|
|
6295
|
-
match.makerOrderParams.authority,
|
|
6296
|
-
match.makerOrderParams.subAccountId
|
|
6297
|
-
);
|
|
6298
|
-
makerAccountMetas.push({
|
|
6299
|
-
pubkey: userAccountPubkey,
|
|
6300
|
-
isWritable: true,
|
|
6301
|
-
isSigner: false,
|
|
6302
|
-
});
|
|
6303
|
-
|
|
6304
|
-
makerAccountMetas.push({
|
|
6305
|
-
pubkey: getUserStatsAccountPublicKey(
|
|
6306
|
-
this.program.programId,
|
|
6307
|
-
match.makerOrderParams.authority
|
|
6308
|
-
),
|
|
6309
|
-
isWritable: true,
|
|
6310
|
-
isSigner: false,
|
|
6311
|
-
});
|
|
6312
|
-
|
|
6313
|
-
makerAccountMetas.push({
|
|
6314
|
-
pubkey: getRFQUserAccountPublicKey(
|
|
6315
|
-
this.program.programId,
|
|
6316
|
-
userAccountPubkey
|
|
6317
|
-
),
|
|
6318
|
-
isWritable: true,
|
|
6319
|
-
isSigner: false,
|
|
6320
|
-
});
|
|
6321
|
-
}
|
|
6322
|
-
remainingAccounts.push(...makerAccountMetas);
|
|
6323
|
-
|
|
6324
|
-
const userStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
6325
|
-
const user = await this.getUserAccountPublicKey();
|
|
6326
|
-
const placeAndMatchRFQOrdersIx =
|
|
6327
|
-
await this.program.instruction.placeAndMatchRfqOrders(rfqMatches, {
|
|
6328
|
-
accounts: {
|
|
6329
|
-
state: await this.getStatePublicKey(),
|
|
6330
|
-
user,
|
|
6331
|
-
userStats: userStatsPublicKey,
|
|
6332
|
-
authority: this.wallet.publicKey,
|
|
6333
|
-
ixSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6334
|
-
},
|
|
6335
|
-
remainingAccounts,
|
|
6336
|
-
});
|
|
6337
|
-
return [...verifyIxs, placeAndMatchRFQOrdersIx];
|
|
6338
|
-
}
|
|
6339
|
-
|
|
6340
6214
|
public async preparePlaceAndTakeSpotOrder(
|
|
6341
6215
|
orderParams: OptionalOrderParams,
|
|
6342
6216
|
fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
|
package/src/types.ts
CHANGED
|
@@ -1139,29 +1139,6 @@ export type SwiftTriggerOrderParams = {
|
|
|
1139
1139
|
baseAssetAmount: BN;
|
|
1140
1140
|
};
|
|
1141
1141
|
|
|
1142
|
-
export type RFQMakerOrderParams = {
|
|
1143
|
-
uuid: Uint8Array; // From buffer of standard UUID string
|
|
1144
|
-
authority: PublicKey;
|
|
1145
|
-
subAccountId: number;
|
|
1146
|
-
marketIndex: number;
|
|
1147
|
-
marketType: MarketType;
|
|
1148
|
-
baseAssetAmount: BN;
|
|
1149
|
-
price: BN;
|
|
1150
|
-
direction: PositionDirection;
|
|
1151
|
-
maxTs: BN;
|
|
1152
|
-
};
|
|
1153
|
-
|
|
1154
|
-
export type RFQMakerMessage = {
|
|
1155
|
-
orderParams: RFQMakerOrderParams;
|
|
1156
|
-
signature: Uint8Array;
|
|
1157
|
-
};
|
|
1158
|
-
|
|
1159
|
-
export type RFQMatch = {
|
|
1160
|
-
baseAssetAmount: BN;
|
|
1161
|
-
makerOrderParams: RFQMakerOrderParams;
|
|
1162
|
-
makerSignature: Uint8Array;
|
|
1163
|
-
};
|
|
1164
|
-
|
|
1165
1142
|
export type MakerInfo = {
|
|
1166
1143
|
maker: PublicKey;
|
|
1167
1144
|
makerStats: PublicKey;
|