@drift-labs/sdk 2.97.0-beta.20 → 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.20
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>;
@@ -493,6 +495,8 @@ export declare class DriftClient {
493
495
  getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
494
496
  updateUserFuelBonus(userAccountPublicKey: PublicKey, user: UserAccount, userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
495
497
  getUpdateUserFuelBonusIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, userAuthority: PublicKey): Promise<TransactionInstruction>;
498
+ updateUserStatsReferrerInfo(userStatsAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
499
+ getUpdateUserStatsReferrerInfoIx(userStatsAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
496
500
  updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
497
501
  getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
498
502
  placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
@@ -511,11 +515,11 @@ export declare class DriftClient {
511
515
  getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
512
516
  encodeSwiftServerMessage(message: SwiftServerMessage): Buffer;
513
517
  decodeSwiftServerMessage(encodedMessage: Buffer): SwiftServerMessage;
514
- signSwiftServerMessage(message: SwiftServerMessage): Promise<Buffer>;
515
- signSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Promise<Buffer>;
518
+ signSwiftServerMessage(message: SwiftServerMessage): Buffer;
519
+ signSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
516
520
  encodeSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
517
521
  decodeSwiftOrderParamsMessage(encodedMessage: Buffer): SwiftOrderParamsMessage;
518
- signMessage(message: Uint8Array, keypair?: Keypair): Promise<Buffer>;
522
+ signMessage(message: Uint8Array, keypair?: Keypair): Buffer;
519
523
  placeSwiftTakerOrder(swiftServerMessage: Buffer, swiftSignature: Buffer, swiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, marketIndex: number, takerInfo: {
520
524
  taker: PublicKey;
521
525
  takerStats: PublicKey;
@@ -536,6 +540,9 @@ export declare class DriftClient {
536
540
  takerStats: PublicKey;
537
541
  takerUserAccount: UserAccount;
538
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[]>;
539
546
  preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{
540
547
  placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
541
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;
@@ -2731,6 +2753,19 @@ class DriftClient {
2731
2753
  remainingAccounts,
2732
2754
  });
2733
2755
  }
2756
+ async updateUserStatsReferrerInfo(userStatsAccountPublicKey, txParams) {
2757
+ const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getUpdateUserStatsReferrerInfoIx(userStatsAccountPublicKey), txParams), [], this.opts);
2758
+ return txSig;
2759
+ }
2760
+ async getUpdateUserStatsReferrerInfoIx(userStatsAccountPublicKey) {
2761
+ return await this.program.instruction.updateUserStatsReferrerInfo({
2762
+ accounts: {
2763
+ state: await this.getStatePublicKey(),
2764
+ userStats: userStatsAccountPublicKey,
2765
+ authority: this.wallet.publicKey,
2766
+ },
2767
+ });
2768
+ }
2734
2769
  async updateUserOpenOrdersCount(userAccountPublicKey, user, txParams, fillerPublicKey) {
2735
2770
  const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getUpdateUserOpenOrdersCountIx(userAccountPublicKey, user, fillerPublicKey), txParams), [], this.opts);
2736
2771
  return txSig;
@@ -2949,13 +2984,13 @@ class DriftClient {
2949
2984
  swiftOrderSignature: decodedSwiftMessage.swiftSignature,
2950
2985
  };
2951
2986
  }
2952
- async signSwiftServerMessage(message) {
2987
+ signSwiftServerMessage(message) {
2953
2988
  const swiftServerMessage = Uint8Array.from(this.encodeSwiftServerMessage(message));
2954
- return await this.signMessage(swiftServerMessage);
2989
+ return this.signMessage(swiftServerMessage);
2955
2990
  }
2956
- async signSwiftOrderParamsMessage(orderParamsMessage) {
2991
+ signSwiftOrderParamsMessage(orderParamsMessage) {
2957
2992
  const takerOrderParamsMessage = Uint8Array.from(this.encodeSwiftOrderParamsMessage(orderParamsMessage));
2958
- return await this.signMessage(takerOrderParamsMessage);
2993
+ return this.signMessage(takerOrderParamsMessage);
2959
2994
  }
2960
2995
  encodeSwiftOrderParamsMessage(orderParamsMessage) {
2961
2996
  return this.program.coder.types.encode('SwiftOrderParamsMessage', orderParamsMessage);
@@ -2963,8 +2998,8 @@ class DriftClient {
2963
2998
  decodeSwiftOrderParamsMessage(encodedMessage) {
2964
2999
  return this.program.coder.types.decode('SwiftOrderParamsMessage', encodedMessage);
2965
3000
  }
2966
- async signMessage(message, keypair = this.wallet.payer) {
2967
- 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));
2968
3003
  }
2969
3004
  async placeSwiftTakerOrder(swiftServerMessage, swiftSignature, swiftOrderParamsMessage, swiftOrderParamsSignature, marketIndex, takerInfo, txParams) {
2970
3005
  const ixs = await this.getPlaceSwiftTakerPerpOrderIxs(swiftServerMessage, swiftSignature, swiftOrderParamsMessage, swiftOrderParamsSignature, marketIndex, takerInfo);
@@ -3052,6 +3087,61 @@ class DriftClient {
3052
3087
  placeAndMakeIx,
3053
3088
  ];
3054
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
+ }
3055
3145
  async preparePlaceAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams, subAccountId) {
3056
3146
  const tx = await this.buildTransaction(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo, subAccountId), txParams);
3057
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": {
@@ -7730,11 +7834,13 @@
7730
7834
  "type": "u16"
7731
7835
  },
7732
7836
  {
7733
- "name": "isReferrer",
7837
+ "name": "referrerStatus",
7734
7838
  "docs": [
7735
- "Whether the user is a referrer. Sub account 0 can not be deleted if user is a referrer"
7839
+ "Flags for referrer status:",
7840
+ "First bit (LSB): 1 if user is a referrer, 0 otherwise",
7841
+ "Second bit: 1 if user was referred, 0 otherwise"
7736
7842
  ],
7737
- "type": "bool"
7843
+ "type": "u8"
7738
7844
  },
7739
7845
  {
7740
7846
  "name": "disableUpdatePerpBidAskTwap",
@@ -8405,6 +8511,109 @@
8405
8511
  ]
8406
8512
  }
8407
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
+ },
8408
8617
  {
8409
8618
  "name": "ModifyOrderParams",
8410
8619
  "type": {
@@ -9224,6 +9433,27 @@
9224
9433
  ]
9225
9434
  }
9226
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
+ },
9227
9457
  {
9228
9458
  "name": "InsuranceFund",
9229
9459
  "type": {
@@ -10324,6 +10554,9 @@
10324
10554
  },
10325
10555
  {
10326
10556
  "name": "Liquidation"
10557
+ },
10558
+ {
10559
+ "name": "RFQ"
10327
10560
  }
10328
10561
  ]
10329
10562
  }
@@ -10860,6 +11093,20 @@
10860
11093
  ]
10861
11094
  }
10862
11095
  },
11096
+ {
11097
+ "name": "ReferrerStatus",
11098
+ "type": {
11099
+ "kind": "enum",
11100
+ "variants": [
11101
+ {
11102
+ "name": "IsReferrer"
11103
+ },
11104
+ {
11105
+ "name": "IsReferred"
11106
+ }
11107
+ ]
11108
+ }
11109
+ },
10863
11110
  {
10864
11111
  "name": "MarginMode",
10865
11112
  "type": {
@@ -13371,6 +13618,31 @@
13371
13618
  "code": 6290,
13372
13619
  "name": "InvalidHighLeverageModeConfig",
13373
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"
13374
13646
  }
13375
13647
  ],
13376
13648
  "metadata": {
package/lib/types.d.ts CHANGED
@@ -974,7 +974,7 @@ export type UserStatsAccount = {
974
974
  current_epoch_referrer_reward: BN;
975
975
  };
976
976
  referrer: PublicKey;
977
- isReferrer: boolean;
977
+ referrerStatus: boolean;
978
978
  authority: PublicKey;
979
979
  ifStakedQuoteAssetAmount: BN;
980
980
  lastFuelIfBonusUpdateTs: number;
@@ -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;
@@ -1138,6 +1158,10 @@ export type ReferrerInfo = {
1138
1158
  referrer: PublicKey;
1139
1159
  referrerStats: PublicKey;
1140
1160
  };
1161
+ export declare enum ReferrerStatus {
1162
+ IsReferrer = 1,
1163
+ IsReferred = 2
1164
+ }
1141
1165
  export declare enum PlaceAndTakeOrderSuccessCondition {
1142
1166
  PartialFill = 1,
1143
1167
  FullFill = 2