@drift-labs/sdk 2.97.0-beta.21 → 2.97.0-beta.22

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 CHANGED
@@ -1 +1 @@
1
- 2.97.0-beta.21
1
+ 2.97.0-beta.22
@@ -8,6 +8,7 @@ export declare function getUserAccountPublicKeyAndNonce(programId: PublicKey, au
8
8
  export declare function getUserAccountPublicKey(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<PublicKey>;
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
+ export declare function getRFQUserAccountPublicKey(programId: PublicKey, userAccountPublicKey: PublicKey): PublicKey;
11
12
  export declare function getPerpMarketPublicKey(programId: PublicKey, marketIndex: number): Promise<PublicKey>;
12
13
  export declare function getPerpMarketPublicKeySync(programId: PublicKey, marketIndex: number): PublicKey;
13
14
  export declare function getSpotMarketPublicKey(programId: PublicKey, marketIndex: number): Promise<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.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = 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.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
26
+ exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = 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.getRFQUserAccountPublicKey = 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");
@@ -62,6 +62,13 @@ function getUserStatsAccountPublicKey(programId, authority) {
62
62
  ], programId)[0];
63
63
  }
64
64
  exports.getUserStatsAccountPublicKey = getUserStatsAccountPublicKey;
65
+ function getRFQUserAccountPublicKey(programId, userAccountPublicKey) {
66
+ return web3_js_1.PublicKey.findProgramAddressSync([
67
+ Buffer.from(anchor.utils.bytes.utf8.encode('RFQ')),
68
+ userAccountPublicKey.toBuffer(),
69
+ ], programId)[0];
70
+ }
71
+ exports.getRFQUserAccountPublicKey = getRFQUserAccountPublicKey;
65
72
  async function getPerpMarketPublicKey(programId, marketIndex) {
66
73
  return (await web3_js_1.PublicKey.findProgramAddress([
67
74
  Buffer.from(anchor.utils.bytes.utf8.encode('perp_market')),
@@ -4,7 +4,7 @@
4
4
  import * as anchor from '@coral-xyz/anchor';
5
5
  import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
6
6
  import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
7
- import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SwiftOrderParamsMessage, SwiftServerMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount } from './types';
7
+ import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, RFQMakerOrderParams, RFQMatch, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SwiftOrderParamsMessage, SwiftServerMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount } from './types';
8
8
  import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
9
9
  import { TokenFaucet } from './tokenFaucet';
10
10
  import { EventEmitter } from 'events';
@@ -136,8 +136,10 @@ export declare class DriftClient {
136
136
  */
137
137
  addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
138
138
  initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
139
- getInitializeUserInstructions(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
140
139
  getInitializeUserStatsIx(): Promise<TransactionInstruction>;
140
+ initializeRFQUser(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
141
+ getInitializeRFQUserInstruction(userAccountPublicKey: PublicKey): Promise<[PublicKey, TransactionInstruction]>;
142
+ getInitializeUserInstructions(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
141
143
  getNextSubAccountId(): Promise<number>;
142
144
  initializeReferrerName(name: string): Promise<TransactionSignature>;
143
145
  updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
@@ -513,11 +515,11 @@ export declare class DriftClient {
513
515
  getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
514
516
  encodeSwiftServerMessage(message: SwiftServerMessage): Buffer;
515
517
  decodeSwiftServerMessage(encodedMessage: Buffer): SwiftServerMessage;
516
- signSwiftServerMessage(message: SwiftServerMessage): Promise<Buffer>;
517
- signSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Promise<Buffer>;
518
+ signSwiftServerMessage(message: SwiftServerMessage): Buffer;
519
+ signSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
518
520
  encodeSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
519
521
  decodeSwiftOrderParamsMessage(encodedMessage: Buffer): SwiftOrderParamsMessage;
520
- signMessage(message: Uint8Array, keypair?: Keypair): Promise<Buffer>;
522
+ signMessage(message: Uint8Array, keypair?: Keypair): Buffer;
521
523
  placeSwiftTakerOrder(swiftServerMessage: Buffer, swiftSignature: Buffer, swiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, marketIndex: number, takerInfo: {
522
524
  taker: PublicKey;
523
525
  takerStats: PublicKey;
@@ -538,6 +540,9 @@ export declare class DriftClient {
538
540
  takerStats: PublicKey;
539
541
  takerUserAccount: UserAccount;
540
542
  }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction[]>;
543
+ encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
544
+ placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
545
+ getPlaceAndMatchRFQOrdersIxs(rfqMatches: RFQMatch[]): Promise<TransactionInstruction[]>;
541
546
  preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{
542
547
  placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
543
548
  }>;
@@ -67,7 +67,7 @@ const pythPullOracleUtils_1 = require("./util/pythPullOracleUtils");
67
67
  const utils_2 = require("./tx/utils");
68
68
  const pyth_solana_receiver_json_1 = __importDefault(require("./idl/pyth_solana_receiver.json"));
69
69
  const on_demand_1 = require("@switchboard-xyz/on-demand");
70
- const ed = __importStar(require("@noble/ed25519"));
70
+ const tweetnacl_1 = __importDefault(require("tweetnacl"));
71
71
  /**
72
72
  * # DriftClient
73
73
  * This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
@@ -544,6 +544,40 @@ class DriftClient {
544
544
  await this.addUser(subAccountId);
545
545
  return [txSig, userAccountPublicKey];
546
546
  }
547
+ async getInitializeUserStatsIx() {
548
+ return await this.program.instruction.initializeUserStats({
549
+ accounts: {
550
+ userStats: this.getUserStatsAccountPublicKey(),
551
+ authority: this.wallet.publicKey,
552
+ payer: this.wallet.publicKey,
553
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
554
+ systemProgram: anchor.web3.SystemProgram.programId,
555
+ state: await this.getStatePublicKey(),
556
+ },
557
+ });
558
+ }
559
+ async initializeRFQUser(userAccountPublicKey, txParams) {
560
+ const initializeIxs = [];
561
+ const [rfqUserAccountPublicKey, initializeUserAccountIx] = await this.getInitializeRFQUserInstruction(userAccountPublicKey);
562
+ initializeIxs.push(initializeUserAccountIx);
563
+ const tx = await this.buildTransaction(initializeIxs, txParams);
564
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
565
+ return [txSig, rfqUserAccountPublicKey];
566
+ }
567
+ async getInitializeRFQUserInstruction(userAccountPublicKey) {
568
+ const rfqUserAccountPublicKey = (0, pda_1.getRFQUserAccountPublicKey)(this.program.programId, userAccountPublicKey);
569
+ const initializeUserAccountIx = await this.program.instruction.initializeRfqUser({
570
+ accounts: {
571
+ rfqUser: rfqUserAccountPublicKey,
572
+ authority: this.wallet.publicKey,
573
+ user: userAccountPublicKey,
574
+ payer: this.wallet.publicKey,
575
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
576
+ systemProgram: anchor.web3.SystemProgram.programId,
577
+ },
578
+ });
579
+ return [rfqUserAccountPublicKey, initializeUserAccountIx];
580
+ }
547
581
  async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
548
582
  const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
549
583
  const remainingAccounts = new Array();
@@ -591,18 +625,6 @@ class DriftClient {
591
625
  });
592
626
  return [userAccountPublicKey, initializeUserAccountIx];
593
627
  }
594
- async getInitializeUserStatsIx() {
595
- return await this.program.instruction.initializeUserStats({
596
- accounts: {
597
- userStats: this.getUserStatsAccountPublicKey(),
598
- authority: this.wallet.publicKey,
599
- payer: this.wallet.publicKey,
600
- rent: anchor.web3.SYSVAR_RENT_PUBKEY,
601
- systemProgram: anchor.web3.SystemProgram.programId,
602
- state: await this.getStatePublicKey(),
603
- },
604
- });
605
- }
606
628
  async getNextSubAccountId() {
607
629
  const userStats = this.getUserStats();
608
630
  let userStatsAccount;
@@ -2962,13 +2984,13 @@ class DriftClient {
2962
2984
  swiftOrderSignature: decodedSwiftMessage.swiftSignature,
2963
2985
  };
2964
2986
  }
2965
- async signSwiftServerMessage(message) {
2987
+ signSwiftServerMessage(message) {
2966
2988
  const swiftServerMessage = Uint8Array.from(this.encodeSwiftServerMessage(message));
2967
- return await this.signMessage(swiftServerMessage);
2989
+ return this.signMessage(swiftServerMessage);
2968
2990
  }
2969
- async signSwiftOrderParamsMessage(orderParamsMessage) {
2991
+ signSwiftOrderParamsMessage(orderParamsMessage) {
2970
2992
  const takerOrderParamsMessage = Uint8Array.from(this.encodeSwiftOrderParamsMessage(orderParamsMessage));
2971
- return await this.signMessage(takerOrderParamsMessage);
2993
+ return this.signMessage(takerOrderParamsMessage);
2972
2994
  }
2973
2995
  encodeSwiftOrderParamsMessage(orderParamsMessage) {
2974
2996
  return this.program.coder.types.encode('SwiftOrderParamsMessage', orderParamsMessage);
@@ -2976,8 +2998,8 @@ class DriftClient {
2976
2998
  decodeSwiftOrderParamsMessage(encodedMessage) {
2977
2999
  return this.program.coder.types.decode('SwiftOrderParamsMessage', encodedMessage);
2978
3000
  }
2979
- async signMessage(message, keypair = this.wallet.payer) {
2980
- return Buffer.from(await ed.sign(message, keypair.secretKey.slice(0, 32)));
3001
+ signMessage(message, keypair = this.wallet.payer) {
3002
+ return Buffer.from(tweetnacl_1.default.sign.detached(message, keypair.secretKey));
2981
3003
  }
2982
3004
  async placeSwiftTakerOrder(swiftServerMessage, swiftSignature, swiftOrderParamsMessage, swiftOrderParamsSignature, marketIndex, takerInfo, txParams) {
2983
3005
  const ixs = await this.getPlaceSwiftTakerPerpOrderIxs(swiftServerMessage, swiftSignature, swiftOrderParamsMessage, swiftOrderParamsSignature, marketIndex, takerInfo);
@@ -3065,6 +3087,61 @@ class DriftClient {
3065
3087
  placeAndMakeIx,
3066
3088
  ];
3067
3089
  }
3090
+ encodeRFQMakerOrderParams(message) {
3091
+ return this.program.coder.types.encode('RFQMakerOrderParams', message);
3092
+ }
3093
+ async placeAndMatchRFQOrders(rfqMatches, txParams) {
3094
+ const ixs = await this.getPlaceAndMatchRFQOrdersIxs(rfqMatches);
3095
+ const { txSig } = await this.sendTransaction(await this.buildTransaction(ixs, txParams), [], this.opts);
3096
+ return txSig;
3097
+ }
3098
+ async getPlaceAndMatchRFQOrdersIxs(rfqMatches) {
3099
+ const remainingAccounts = this.getRemainingAccounts({
3100
+ userAccounts: [this.getUserAccount()],
3101
+ useMarketLastSlotCache: true,
3102
+ writablePerpMarketIndexes: [rfqMatches[0].makerOrderParams.marketIndex],
3103
+ });
3104
+ const makerAccountMetas = [];
3105
+ const verifyIxs = [];
3106
+ for (const match of rfqMatches) {
3107
+ const verifyIx = web3_js_1.Ed25519Program.createInstructionWithPublicKey({
3108
+ publicKey: match.makerOrderParams.authority.toBytes(),
3109
+ signature: match.makerSignature,
3110
+ message: Uint8Array.from(this.encodeRFQMakerOrderParams(match.makerOrderParams)),
3111
+ });
3112
+ verifyIxs.push(verifyIx);
3113
+ const userAccountPubkey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, match.makerOrderParams.authority, match.makerOrderParams.subAccountId);
3114
+ makerAccountMetas.push({
3115
+ pubkey: userAccountPubkey,
3116
+ isWritable: true,
3117
+ isSigner: false,
3118
+ });
3119
+ makerAccountMetas.push({
3120
+ pubkey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, match.makerOrderParams.authority),
3121
+ isWritable: true,
3122
+ isSigner: false,
3123
+ });
3124
+ makerAccountMetas.push({
3125
+ pubkey: (0, pda_1.getRFQUserAccountPublicKey)(this.program.programId, userAccountPubkey),
3126
+ isWritable: true,
3127
+ isSigner: false,
3128
+ });
3129
+ }
3130
+ remainingAccounts.push(...makerAccountMetas);
3131
+ const userStatsPublicKey = this.getUserStatsAccountPublicKey();
3132
+ const user = await this.getUserAccountPublicKey();
3133
+ const placeAndMatchRFQOrdersIx = await this.program.instruction.placeAndMatchRfqOrders(rfqMatches, {
3134
+ accounts: {
3135
+ state: await this.getStatePublicKey(),
3136
+ user,
3137
+ userStats: userStatsPublicKey,
3138
+ authority: this.wallet.publicKey,
3139
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
3140
+ },
3141
+ remainingAccounts,
3142
+ });
3143
+ return [...verifyIxs, placeAndMatchRFQOrdersIx];
3144
+ }
3068
3145
  async preparePlaceAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams, subAccountId) {
3069
3146
  const tx = await this.buildTransaction(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo, subAccountId), txParams);
3070
3147
  return {
@@ -93,6 +93,42 @@
93
93
  ],
94
94
  "args": []
95
95
  },
96
+ {
97
+ "name": "initializeRfqUser",
98
+ "accounts": [
99
+ {
100
+ "name": "rfqUser",
101
+ "isMut": true,
102
+ "isSigner": false
103
+ },
104
+ {
105
+ "name": "authority",
106
+ "isMut": false,
107
+ "isSigner": true
108
+ },
109
+ {
110
+ "name": "user",
111
+ "isMut": true,
112
+ "isSigner": false
113
+ },
114
+ {
115
+ "name": "payer",
116
+ "isMut": true,
117
+ "isSigner": true
118
+ },
119
+ {
120
+ "name": "rent",
121
+ "isMut": false,
122
+ "isSigner": false
123
+ },
124
+ {
125
+ "name": "systemProgram",
126
+ "isMut": false,
127
+ "isSigner": false
128
+ }
129
+ ],
130
+ "args": []
131
+ },
96
132
  {
97
133
  "name": "initializeReferrerName",
98
134
  "accounts": [
@@ -662,6 +698,51 @@
662
698
  }
663
699
  ]
664
700
  },
701
+ {
702
+ "name": "placeAndMatchRfqOrders",
703
+ "accounts": [
704
+ {
705
+ "name": "state",
706
+ "isMut": false,
707
+ "isSigner": false
708
+ },
709
+ {
710
+ "name": "user",
711
+ "isMut": true,
712
+ "isSigner": false
713
+ },
714
+ {
715
+ "name": "userStats",
716
+ "isMut": true,
717
+ "isSigner": false
718
+ },
719
+ {
720
+ "name": "authority",
721
+ "isMut": false,
722
+ "isSigner": true
723
+ },
724
+ {
725
+ "name": "ixSysvar",
726
+ "isMut": false,
727
+ "isSigner": false,
728
+ "docs": [
729
+ "the supplied Sysvar could be anything else.",
730
+ "The Instruction Sysvar has not been implemented",
731
+ "in the Anchor framework yet, so this is the safe approach."
732
+ ]
733
+ }
734
+ ],
735
+ "args": [
736
+ {
737
+ "name": "rfqMatches",
738
+ "type": {
739
+ "vec": {
740
+ "defined": "RFQMatch"
741
+ }
742
+ }
743
+ }
744
+ ]
745
+ },
665
746
  {
666
747
  "name": "placeSpotOrder",
667
748
  "accounts": [
@@ -6752,6 +6833,29 @@
6752
6833
  ]
6753
6834
  }
6754
6835
  },
6836
+ {
6837
+ "name": "RFQUser",
6838
+ "type": {
6839
+ "kind": "struct",
6840
+ "fields": [
6841
+ {
6842
+ "name": "userPubkey",
6843
+ "type": "publicKey"
6844
+ },
6845
+ {
6846
+ "name": "rfqOrderData",
6847
+ "type": {
6848
+ "array": [
6849
+ {
6850
+ "defined": "RFQOrderId"
6851
+ },
6852
+ 32
6853
+ ]
6854
+ }
6855
+ }
6856
+ ]
6857
+ }
6858
+ },
6755
6859
  {
6756
6860
  "name": "SpotMarket",
6757
6861
  "type": {
@@ -8407,6 +8511,109 @@
8407
8511
  ]
8408
8512
  }
8409
8513
  },
8514
+ {
8515
+ "name": "RFQMakerOrderParams",
8516
+ "type": {
8517
+ "kind": "struct",
8518
+ "fields": [
8519
+ {
8520
+ "name": "uuid",
8521
+ "type": {
8522
+ "array": [
8523
+ "u8",
8524
+ 8
8525
+ ]
8526
+ }
8527
+ },
8528
+ {
8529
+ "name": "authority",
8530
+ "type": "publicKey"
8531
+ },
8532
+ {
8533
+ "name": "subAccountId",
8534
+ "type": "u16"
8535
+ },
8536
+ {
8537
+ "name": "marketIndex",
8538
+ "type": "u16"
8539
+ },
8540
+ {
8541
+ "name": "marketType",
8542
+ "type": {
8543
+ "defined": "MarketType"
8544
+ }
8545
+ },
8546
+ {
8547
+ "name": "baseAssetAmount",
8548
+ "type": "u64"
8549
+ },
8550
+ {
8551
+ "name": "price",
8552
+ "type": "u64"
8553
+ },
8554
+ {
8555
+ "name": "direction",
8556
+ "type": {
8557
+ "defined": "PositionDirection"
8558
+ }
8559
+ },
8560
+ {
8561
+ "name": "maxTs",
8562
+ "type": "i64"
8563
+ }
8564
+ ]
8565
+ }
8566
+ },
8567
+ {
8568
+ "name": "RFQMakerMessage",
8569
+ "type": {
8570
+ "kind": "struct",
8571
+ "fields": [
8572
+ {
8573
+ "name": "orderParams",
8574
+ "type": {
8575
+ "defined": "RFQMakerOrderParams"
8576
+ }
8577
+ },
8578
+ {
8579
+ "name": "signature",
8580
+ "type": {
8581
+ "array": [
8582
+ "u8",
8583
+ 64
8584
+ ]
8585
+ }
8586
+ }
8587
+ ]
8588
+ }
8589
+ },
8590
+ {
8591
+ "name": "RFQMatch",
8592
+ "type": {
8593
+ "kind": "struct",
8594
+ "fields": [
8595
+ {
8596
+ "name": "baseAssetAmount",
8597
+ "type": "u64"
8598
+ },
8599
+ {
8600
+ "name": "makerOrderParams",
8601
+ "type": {
8602
+ "defined": "RFQMakerOrderParams"
8603
+ }
8604
+ },
8605
+ {
8606
+ "name": "makerSignature",
8607
+ "type": {
8608
+ "array": [
8609
+ "u8",
8610
+ 64
8611
+ ]
8612
+ }
8613
+ }
8614
+ ]
8615
+ }
8616
+ },
8410
8617
  {
8411
8618
  "name": "ModifyOrderParams",
8412
8619
  "type": {
@@ -9226,6 +9433,27 @@
9226
9433
  ]
9227
9434
  }
9228
9435
  },
9436
+ {
9437
+ "name": "RFQOrderId",
9438
+ "type": {
9439
+ "kind": "struct",
9440
+ "fields": [
9441
+ {
9442
+ "name": "uuid",
9443
+ "type": {
9444
+ "array": [
9445
+ "u8",
9446
+ 8
9447
+ ]
9448
+ }
9449
+ },
9450
+ {
9451
+ "name": "maxTs",
9452
+ "type": "i64"
9453
+ }
9454
+ ]
9455
+ }
9456
+ },
9229
9457
  {
9230
9458
  "name": "InsuranceFund",
9231
9459
  "type": {
@@ -10326,6 +10554,9 @@
10326
10554
  },
10327
10555
  {
10328
10556
  "name": "Liquidation"
10557
+ },
10558
+ {
10559
+ "name": "RFQ"
10329
10560
  }
10330
10561
  ]
10331
10562
  }
@@ -13387,6 +13618,31 @@
13387
13618
  "code": 6290,
13388
13619
  "name": "InvalidHighLeverageModeConfig",
13389
13620
  "msg": "Invalid High Leverage Mode Config"
13621
+ },
13622
+ {
13623
+ "code": 6291,
13624
+ "name": "InvalidRFQUserAccount",
13625
+ "msg": "Invalid RFQ User Account"
13626
+ },
13627
+ {
13628
+ "code": 6292,
13629
+ "name": "RFQUserAccountWrongMutability",
13630
+ "msg": "RFQUserAccount should be mutable"
13631
+ },
13632
+ {
13633
+ "code": 6293,
13634
+ "name": "RFQUserAccountFull",
13635
+ "msg": "RFQUserAccount has too many active RFQs"
13636
+ },
13637
+ {
13638
+ "code": 6294,
13639
+ "name": "RFQOrderNotFilled",
13640
+ "msg": "RFQ order not filled as expected"
13641
+ },
13642
+ {
13643
+ "code": 6295,
13644
+ "name": "InvalidRFQOrder",
13645
+ "msg": "RFQ orders must be jit makers"
13390
13646
  }
13391
13647
  ],
13392
13648
  "metadata": {
package/lib/types.d.ts CHANGED
@@ -1122,6 +1122,26 @@ export type SwiftTriggerOrderParams = {
1122
1122
  triggerPrice: BN;
1123
1123
  baseAssetAmount: BN;
1124
1124
  };
1125
+ export type RFQMakerOrderParams = {
1126
+ uuid: Uint8Array;
1127
+ authority: PublicKey;
1128
+ subAccountId: number;
1129
+ marketIndex: number;
1130
+ marketType: MarketType;
1131
+ baseAssetAmount: BN;
1132
+ price: BN;
1133
+ direction: PositionDirection;
1134
+ maxTs: BN;
1135
+ };
1136
+ export type RFQMakerMessage = {
1137
+ orderParams: RFQMakerOrderParams;
1138
+ signature: Uint8Array;
1139
+ };
1140
+ export type RFQMatch = {
1141
+ baseAssetAmount: BN;
1142
+ makerOrderParams: RFQMakerOrderParams;
1143
+ makerSignature: Uint8Array;
1144
+ };
1125
1145
  export type MakerInfo = {
1126
1146
  maker: PublicKey;
1127
1147
  makerStats: PublicKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.97.0-beta.21",
3
+ "version": "2.97.0-beta.22",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -50,6 +50,7 @@
50
50
  "rpc-websockets": "7.5.1",
51
51
  "solana-bankrun": "^0.3.0",
52
52
  "strict-event-emitter-types": "^2.0.0",
53
+ "tweetnacl": "1.0.3",
53
54
  "uuid": "^8.3.2",
54
55
  "zstddec": "^0.1.0"
55
56
  },
@@ -72,6 +72,19 @@ export function getUserStatsAccountPublicKey(
72
72
  )[0];
73
73
  }
74
74
 
75
+ export function getRFQUserAccountPublicKey(
76
+ programId: PublicKey,
77
+ userAccountPublicKey: PublicKey
78
+ ): PublicKey {
79
+ return PublicKey.findProgramAddressSync(
80
+ [
81
+ Buffer.from(anchor.utils.bytes.utf8.encode('RFQ')),
82
+ userAccountPublicKey.toBuffer(),
83
+ ],
84
+ programId
85
+ )[0];
86
+ }
87
+
75
88
  export async function getPerpMarketPublicKey(
76
89
  programId: PublicKey,
77
90
  marketIndex: number
@@ -40,6 +40,8 @@ import {
40
40
  PositionDirection,
41
41
  ReferrerInfo,
42
42
  ReferrerNameAccount,
43
+ RFQMakerOrderParams,
44
+ RFQMatch,
43
45
  SerumV3FulfillmentConfigAccount,
44
46
  SettlePnlMode,
45
47
  SignedTxData,
@@ -90,6 +92,7 @@ import {
90
92
  getPhoenixFulfillmentConfigPublicKey,
91
93
  getPythPullOraclePublicKey,
92
94
  getReferrerNamePublicKeySync,
95
+ getRFQUserAccountPublicKey,
93
96
  getSerumFulfillmentConfigPublicKey,
94
97
  getSerumSignerPublicKey,
95
98
  getSpotMarketPublicKey,
@@ -164,7 +167,7 @@ import { getFeedIdUint8Array, trimFeedId } from './util/pythPullOracleUtils';
164
167
  import { isVersionedTransaction } from './tx/utils';
165
168
  import pythSolanaReceiverIdl from './idl/pyth_solana_receiver.json';
166
169
  import { asV0Tx, PullFeed } from '@switchboard-xyz/on-demand';
167
- import * as ed from '@noble/ed25519';
170
+ import nacl from 'tweetnacl';
168
171
 
169
172
  type RemainingAccountParams = {
170
173
  userAccounts: UserAccount[];
@@ -940,6 +943,56 @@ export class DriftClient {
940
943
  return [txSig, userAccountPublicKey];
941
944
  }
942
945
 
946
+ async getInitializeUserStatsIx(): Promise<TransactionInstruction> {
947
+ return await this.program.instruction.initializeUserStats({
948
+ accounts: {
949
+ userStats: this.getUserStatsAccountPublicKey(),
950
+ authority: this.wallet.publicKey,
951
+ payer: this.wallet.publicKey,
952
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
953
+ systemProgram: anchor.web3.SystemProgram.programId,
954
+ state: await this.getStatePublicKey(),
955
+ },
956
+ });
957
+ }
958
+
959
+ public async initializeRFQUser(
960
+ userAccountPublicKey: PublicKey,
961
+ txParams?: TxParams
962
+ ): Promise<[TransactionSignature, PublicKey]> {
963
+ const initializeIxs = [];
964
+
965
+ const [rfqUserAccountPublicKey, initializeUserAccountIx] =
966
+ await this.getInitializeRFQUserInstruction(userAccountPublicKey);
967
+ initializeIxs.push(initializeUserAccountIx);
968
+ const tx = await this.buildTransaction(initializeIxs, txParams);
969
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
970
+
971
+ return [txSig, rfqUserAccountPublicKey];
972
+ }
973
+
974
+ async getInitializeRFQUserInstruction(
975
+ userAccountPublicKey: PublicKey
976
+ ): Promise<[PublicKey, TransactionInstruction]> {
977
+ const rfqUserAccountPublicKey = getRFQUserAccountPublicKey(
978
+ this.program.programId,
979
+ userAccountPublicKey
980
+ );
981
+ const initializeUserAccountIx =
982
+ await this.program.instruction.initializeRfqUser({
983
+ accounts: {
984
+ rfqUser: rfqUserAccountPublicKey,
985
+ authority: this.wallet.publicKey,
986
+ user: userAccountPublicKey,
987
+ payer: this.wallet.publicKey,
988
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
989
+ systemProgram: anchor.web3.SystemProgram.programId,
990
+ },
991
+ });
992
+
993
+ return [rfqUserAccountPublicKey, initializeUserAccountIx];
994
+ }
995
+
943
996
  async getInitializeUserInstructions(
944
997
  subAccountId = 0,
945
998
  name?: string,
@@ -1004,19 +1057,6 @@ export class DriftClient {
1004
1057
  return [userAccountPublicKey, initializeUserAccountIx];
1005
1058
  }
1006
1059
 
1007
- async getInitializeUserStatsIx(): Promise<TransactionInstruction> {
1008
- return await this.program.instruction.initializeUserStats({
1009
- accounts: {
1010
- userStats: this.getUserStatsAccountPublicKey(),
1011
- authority: this.wallet.publicKey,
1012
- payer: this.wallet.publicKey,
1013
- rent: anchor.web3.SYSVAR_RENT_PUBKEY,
1014
- systemProgram: anchor.web3.SystemProgram.programId,
1015
- state: await this.getStatePublicKey(),
1016
- },
1017
- });
1018
- }
1019
-
1020
1060
  async getNextSubAccountId(): Promise<number> {
1021
1061
  const userStats = this.getUserStats();
1022
1062
  let userStatsAccount: UserStatsAccount;
@@ -5475,22 +5515,20 @@ export class DriftClient {
5475
5515
  };
5476
5516
  }
5477
5517
 
5478
- public async signSwiftServerMessage(
5479
- message: SwiftServerMessage
5480
- ): Promise<Buffer> {
5518
+ public signSwiftServerMessage(message: SwiftServerMessage): Buffer {
5481
5519
  const swiftServerMessage = Uint8Array.from(
5482
5520
  this.encodeSwiftServerMessage(message)
5483
5521
  );
5484
- return await this.signMessage(swiftServerMessage);
5522
+ return this.signMessage(swiftServerMessage);
5485
5523
  }
5486
5524
 
5487
- public async signSwiftOrderParamsMessage(
5525
+ public signSwiftOrderParamsMessage(
5488
5526
  orderParamsMessage: SwiftOrderParamsMessage
5489
- ): Promise<Buffer> {
5527
+ ): Buffer {
5490
5528
  const takerOrderParamsMessage = Uint8Array.from(
5491
5529
  this.encodeSwiftOrderParamsMessage(orderParamsMessage)
5492
5530
  );
5493
- return await this.signMessage(takerOrderParamsMessage);
5531
+ return this.signMessage(takerOrderParamsMessage);
5494
5532
  }
5495
5533
 
5496
5534
  public encodeSwiftOrderParamsMessage(
@@ -5511,11 +5549,11 @@ export class DriftClient {
5511
5549
  );
5512
5550
  }
5513
5551
 
5514
- public async signMessage(
5552
+ public signMessage(
5515
5553
  message: Uint8Array,
5516
5554
  keypair: Keypair = this.wallet.payer
5517
- ): Promise<Buffer> {
5518
- return Buffer.from(await ed.sign(message, keypair.secretKey.slice(0, 32)));
5555
+ ): Buffer {
5556
+ return Buffer.from(nacl.sign.detached(message, keypair.secretKey));
5519
5557
  }
5520
5558
 
5521
5559
  public async placeSwiftTakerOrder(
@@ -5718,6 +5756,91 @@ export class DriftClient {
5718
5756
  ];
5719
5757
  }
5720
5758
 
5759
+ public encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer {
5760
+ return this.program.coder.types.encode('RFQMakerOrderParams', message);
5761
+ }
5762
+
5763
+ public async placeAndMatchRFQOrders(
5764
+ rfqMatches: RFQMatch[],
5765
+ txParams?: TxParams
5766
+ ): Promise<TransactionSignature> {
5767
+ const ixs = await this.getPlaceAndMatchRFQOrdersIxs(rfqMatches);
5768
+ const { txSig } = await this.sendTransaction(
5769
+ await this.buildTransaction(ixs, txParams),
5770
+ [],
5771
+ this.opts
5772
+ );
5773
+ return txSig;
5774
+ }
5775
+
5776
+ public async getPlaceAndMatchRFQOrdersIxs(
5777
+ rfqMatches: RFQMatch[]
5778
+ ): Promise<TransactionInstruction[]> {
5779
+ const remainingAccounts = this.getRemainingAccounts({
5780
+ userAccounts: [this.getUserAccount()],
5781
+ useMarketLastSlotCache: true,
5782
+ writablePerpMarketIndexes: [rfqMatches[0].makerOrderParams.marketIndex],
5783
+ });
5784
+
5785
+ const makerAccountMetas = [];
5786
+ const verifyIxs = [];
5787
+ for (const match of rfqMatches) {
5788
+ const verifyIx = Ed25519Program.createInstructionWithPublicKey({
5789
+ publicKey: match.makerOrderParams.authority.toBytes(),
5790
+ signature: match.makerSignature,
5791
+ message: Uint8Array.from(
5792
+ this.encodeRFQMakerOrderParams(match.makerOrderParams)
5793
+ ),
5794
+ });
5795
+ verifyIxs.push(verifyIx);
5796
+
5797
+ const userAccountPubkey = await getUserAccountPublicKey(
5798
+ this.program.programId,
5799
+ match.makerOrderParams.authority,
5800
+ match.makerOrderParams.subAccountId
5801
+ );
5802
+ makerAccountMetas.push({
5803
+ pubkey: userAccountPubkey,
5804
+ isWritable: true,
5805
+ isSigner: false,
5806
+ });
5807
+
5808
+ makerAccountMetas.push({
5809
+ pubkey: getUserStatsAccountPublicKey(
5810
+ this.program.programId,
5811
+ match.makerOrderParams.authority
5812
+ ),
5813
+ isWritable: true,
5814
+ isSigner: false,
5815
+ });
5816
+
5817
+ makerAccountMetas.push({
5818
+ pubkey: getRFQUserAccountPublicKey(
5819
+ this.program.programId,
5820
+ userAccountPubkey
5821
+ ),
5822
+ isWritable: true,
5823
+ isSigner: false,
5824
+ });
5825
+ }
5826
+ remainingAccounts.push(...makerAccountMetas);
5827
+
5828
+ const userStatsPublicKey = this.getUserStatsAccountPublicKey();
5829
+ const user = await this.getUserAccountPublicKey();
5830
+ const placeAndMatchRFQOrdersIx =
5831
+ await this.program.instruction.placeAndMatchRfqOrders(rfqMatches, {
5832
+ accounts: {
5833
+ state: await this.getStatePublicKey(),
5834
+ user,
5835
+ userStats: userStatsPublicKey,
5836
+ authority: this.wallet.publicKey,
5837
+ ixSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
5838
+ },
5839
+ remainingAccounts,
5840
+ });
5841
+ return [...verifyIxs, placeAndMatchRFQOrdersIx];
5842
+ }
5843
+
5721
5844
  public async preparePlaceAndTakeSpotOrder(
5722
5845
  orderParams: OptionalOrderParams,
5723
5846
  fulfillmentConfig?: SerumV3FulfillmentConfigAccount,
@@ -93,6 +93,42 @@
93
93
  ],
94
94
  "args": []
95
95
  },
96
+ {
97
+ "name": "initializeRfqUser",
98
+ "accounts": [
99
+ {
100
+ "name": "rfqUser",
101
+ "isMut": true,
102
+ "isSigner": false
103
+ },
104
+ {
105
+ "name": "authority",
106
+ "isMut": false,
107
+ "isSigner": true
108
+ },
109
+ {
110
+ "name": "user",
111
+ "isMut": true,
112
+ "isSigner": false
113
+ },
114
+ {
115
+ "name": "payer",
116
+ "isMut": true,
117
+ "isSigner": true
118
+ },
119
+ {
120
+ "name": "rent",
121
+ "isMut": false,
122
+ "isSigner": false
123
+ },
124
+ {
125
+ "name": "systemProgram",
126
+ "isMut": false,
127
+ "isSigner": false
128
+ }
129
+ ],
130
+ "args": []
131
+ },
96
132
  {
97
133
  "name": "initializeReferrerName",
98
134
  "accounts": [
@@ -662,6 +698,51 @@
662
698
  }
663
699
  ]
664
700
  },
701
+ {
702
+ "name": "placeAndMatchRfqOrders",
703
+ "accounts": [
704
+ {
705
+ "name": "state",
706
+ "isMut": false,
707
+ "isSigner": false
708
+ },
709
+ {
710
+ "name": "user",
711
+ "isMut": true,
712
+ "isSigner": false
713
+ },
714
+ {
715
+ "name": "userStats",
716
+ "isMut": true,
717
+ "isSigner": false
718
+ },
719
+ {
720
+ "name": "authority",
721
+ "isMut": false,
722
+ "isSigner": true
723
+ },
724
+ {
725
+ "name": "ixSysvar",
726
+ "isMut": false,
727
+ "isSigner": false,
728
+ "docs": [
729
+ "the supplied Sysvar could be anything else.",
730
+ "The Instruction Sysvar has not been implemented",
731
+ "in the Anchor framework yet, so this is the safe approach."
732
+ ]
733
+ }
734
+ ],
735
+ "args": [
736
+ {
737
+ "name": "rfqMatches",
738
+ "type": {
739
+ "vec": {
740
+ "defined": "RFQMatch"
741
+ }
742
+ }
743
+ }
744
+ ]
745
+ },
665
746
  {
666
747
  "name": "placeSpotOrder",
667
748
  "accounts": [
@@ -6752,6 +6833,29 @@
6752
6833
  ]
6753
6834
  }
6754
6835
  },
6836
+ {
6837
+ "name": "RFQUser",
6838
+ "type": {
6839
+ "kind": "struct",
6840
+ "fields": [
6841
+ {
6842
+ "name": "userPubkey",
6843
+ "type": "publicKey"
6844
+ },
6845
+ {
6846
+ "name": "rfqOrderData",
6847
+ "type": {
6848
+ "array": [
6849
+ {
6850
+ "defined": "RFQOrderId"
6851
+ },
6852
+ 32
6853
+ ]
6854
+ }
6855
+ }
6856
+ ]
6857
+ }
6858
+ },
6755
6859
  {
6756
6860
  "name": "SpotMarket",
6757
6861
  "type": {
@@ -8407,6 +8511,109 @@
8407
8511
  ]
8408
8512
  }
8409
8513
  },
8514
+ {
8515
+ "name": "RFQMakerOrderParams",
8516
+ "type": {
8517
+ "kind": "struct",
8518
+ "fields": [
8519
+ {
8520
+ "name": "uuid",
8521
+ "type": {
8522
+ "array": [
8523
+ "u8",
8524
+ 8
8525
+ ]
8526
+ }
8527
+ },
8528
+ {
8529
+ "name": "authority",
8530
+ "type": "publicKey"
8531
+ },
8532
+ {
8533
+ "name": "subAccountId",
8534
+ "type": "u16"
8535
+ },
8536
+ {
8537
+ "name": "marketIndex",
8538
+ "type": "u16"
8539
+ },
8540
+ {
8541
+ "name": "marketType",
8542
+ "type": {
8543
+ "defined": "MarketType"
8544
+ }
8545
+ },
8546
+ {
8547
+ "name": "baseAssetAmount",
8548
+ "type": "u64"
8549
+ },
8550
+ {
8551
+ "name": "price",
8552
+ "type": "u64"
8553
+ },
8554
+ {
8555
+ "name": "direction",
8556
+ "type": {
8557
+ "defined": "PositionDirection"
8558
+ }
8559
+ },
8560
+ {
8561
+ "name": "maxTs",
8562
+ "type": "i64"
8563
+ }
8564
+ ]
8565
+ }
8566
+ },
8567
+ {
8568
+ "name": "RFQMakerMessage",
8569
+ "type": {
8570
+ "kind": "struct",
8571
+ "fields": [
8572
+ {
8573
+ "name": "orderParams",
8574
+ "type": {
8575
+ "defined": "RFQMakerOrderParams"
8576
+ }
8577
+ },
8578
+ {
8579
+ "name": "signature",
8580
+ "type": {
8581
+ "array": [
8582
+ "u8",
8583
+ 64
8584
+ ]
8585
+ }
8586
+ }
8587
+ ]
8588
+ }
8589
+ },
8590
+ {
8591
+ "name": "RFQMatch",
8592
+ "type": {
8593
+ "kind": "struct",
8594
+ "fields": [
8595
+ {
8596
+ "name": "baseAssetAmount",
8597
+ "type": "u64"
8598
+ },
8599
+ {
8600
+ "name": "makerOrderParams",
8601
+ "type": {
8602
+ "defined": "RFQMakerOrderParams"
8603
+ }
8604
+ },
8605
+ {
8606
+ "name": "makerSignature",
8607
+ "type": {
8608
+ "array": [
8609
+ "u8",
8610
+ 64
8611
+ ]
8612
+ }
8613
+ }
8614
+ ]
8615
+ }
8616
+ },
8410
8617
  {
8411
8618
  "name": "ModifyOrderParams",
8412
8619
  "type": {
@@ -9226,6 +9433,27 @@
9226
9433
  ]
9227
9434
  }
9228
9435
  },
9436
+ {
9437
+ "name": "RFQOrderId",
9438
+ "type": {
9439
+ "kind": "struct",
9440
+ "fields": [
9441
+ {
9442
+ "name": "uuid",
9443
+ "type": {
9444
+ "array": [
9445
+ "u8",
9446
+ 8
9447
+ ]
9448
+ }
9449
+ },
9450
+ {
9451
+ "name": "maxTs",
9452
+ "type": "i64"
9453
+ }
9454
+ ]
9455
+ }
9456
+ },
9229
9457
  {
9230
9458
  "name": "InsuranceFund",
9231
9459
  "type": {
@@ -10326,6 +10554,9 @@
10326
10554
  },
10327
10555
  {
10328
10556
  "name": "Liquidation"
10557
+ },
10558
+ {
10559
+ "name": "RFQ"
10329
10560
  }
10330
10561
  ]
10331
10562
  }
@@ -13387,6 +13618,31 @@
13387
13618
  "code": 6290,
13388
13619
  "name": "InvalidHighLeverageModeConfig",
13389
13620
  "msg": "Invalid High Leverage Mode Config"
13621
+ },
13622
+ {
13623
+ "code": 6291,
13624
+ "name": "InvalidRFQUserAccount",
13625
+ "msg": "Invalid RFQ User Account"
13626
+ },
13627
+ {
13628
+ "code": 6292,
13629
+ "name": "RFQUserAccountWrongMutability",
13630
+ "msg": "RFQUserAccount should be mutable"
13631
+ },
13632
+ {
13633
+ "code": 6293,
13634
+ "name": "RFQUserAccountFull",
13635
+ "msg": "RFQUserAccount has too many active RFQs"
13636
+ },
13637
+ {
13638
+ "code": 6294,
13639
+ "name": "RFQOrderNotFilled",
13640
+ "msg": "RFQ order not filled as expected"
13641
+ },
13642
+ {
13643
+ "code": 6295,
13644
+ "name": "InvalidRFQOrder",
13645
+ "msg": "RFQ orders must be jit makers"
13390
13646
  }
13391
13647
  ],
13392
13648
  "metadata": {
package/src/types.ts CHANGED
@@ -1083,6 +1083,29 @@ export type SwiftTriggerOrderParams = {
1083
1083
  baseAssetAmount: BN;
1084
1084
  };
1085
1085
 
1086
+ export type RFQMakerOrderParams = {
1087
+ uuid: Uint8Array; // From buffer of standard UUID string
1088
+ authority: PublicKey;
1089
+ subAccountId: number;
1090
+ marketIndex: number;
1091
+ marketType: MarketType;
1092
+ baseAssetAmount: BN;
1093
+ price: BN;
1094
+ direction: PositionDirection;
1095
+ maxTs: BN;
1096
+ };
1097
+
1098
+ export type RFQMakerMessage = {
1099
+ orderParams: RFQMakerOrderParams;
1100
+ signature: Uint8Array;
1101
+ };
1102
+
1103
+ export type RFQMatch = {
1104
+ baseAssetAmount: BN;
1105
+ makerOrderParams: RFQMakerOrderParams;
1106
+ makerSignature: Uint8Array;
1107
+ };
1108
+
1086
1109
  export type MakerInfo = {
1087
1110
  maker: PublicKey;
1088
1111
  makerStats: PublicKey;