@triadxyz/triad-protocol 2.3.8-beta → 2.4.0-beta

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/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
2
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
3
3
  import BN from 'bn.js';
4
4
  import { TriadProtocol } from './types/triad_protocol';
5
- import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions } from './types';
5
+ import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, CollectMarketFeeArgs } from './types';
6
6
  import Stake from './stake';
7
7
  import Poseidon from './poseidon';
8
8
  export default class TriadProtocolClient {
@@ -409,5 +409,5 @@ export default class TriadProtocolClient {
409
409
  *
410
410
  * @param options - RPC options
411
411
  */
412
- collectMarketFee(marketId: number, options?: RpcOptions): Promise<string>;
412
+ collectMarketFee({ marketId, feeRecipient }: CollectMarketFeeArgs, options?: RpcOptions): Promise<string>;
413
413
  }
package/dist/index.js CHANGED
@@ -871,6 +871,8 @@ class TriadProtocolClient {
871
871
  data.spreadToReward = orderBook.spreadToReward.toString();
872
872
  const processOrders = (orders, side) => {
873
873
  for (const order of orders) {
874
+ if (order.price.eq(new bn_js_1.default(0)))
875
+ continue;
874
876
  if ((0, helpers_1.getOrderSideFromNumber)(order.orderSide) === types_1.OrderSide.BID) {
875
877
  data[side].bid.push((0, helpers_1.formatBookOrder)(order));
876
878
  }
@@ -890,7 +892,7 @@ class TriadProtocolClient {
890
892
  *
891
893
  * @param options - RPC options
892
894
  */
893
- collectMarketFee(marketId, options) {
895
+ collectMarketFee({ marketId, feeRecipient }, options) {
894
896
  return __awaiter(this, void 0, void 0, function* () {
895
897
  const ixs = [];
896
898
  ixs.push(yield this.program.methods
@@ -898,6 +900,7 @@ class TriadProtocolClient {
898
900
  .accounts({
899
901
  signer: this.program.provider.publicKey,
900
902
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
903
+ feeRecipient,
901
904
  mint: constants_1.TRD_MINT
902
905
  })
903
906
  .instruction());
@@ -404,9 +404,8 @@
404
404
  "signer": true
405
405
  },
406
406
  {
407
- "name": "squads",
408
- "writable": true,
409
- "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
407
+ "name": "fee_recipient",
408
+ "writable": true
410
409
  },
411
410
  {
412
411
  "name": "market",
@@ -451,7 +450,7 @@
451
450
  "seeds": [
452
451
  {
453
452
  "kind": "account",
454
- "path": "squads"
453
+ "path": "fee_recipient"
455
454
  },
456
455
  {
457
456
  "kind": "account",
@@ -77,6 +77,7 @@ export type BookOrder = {
77
77
  orderDirection: OrderDirection;
78
78
  orderSide: OrderSide;
79
79
  userNonce: string;
80
+ linkedBookOrderId: string;
80
81
  };
81
82
  export declare enum WinningDirection {
82
83
  HYPE = "Hype",
@@ -228,3 +229,7 @@ export type MarketAskOrderArgs = {
228
229
  };
229
230
  mint: PublicKey;
230
231
  };
232
+ export type CollectMarketFeeArgs = {
233
+ marketId: number;
234
+ feeRecipient: PublicKey;
235
+ };
@@ -596,9 +596,8 @@ export type TriadProtocol = {
596
596
  signer: true;
597
597
  },
598
598
  {
599
- name: 'squads';
599
+ name: 'feeRecipient';
600
600
  writable: true;
601
- address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
602
601
  },
603
602
  {
604
603
  name: 'market';
@@ -672,7 +671,7 @@ export type TriadProtocol = {
672
671
  seeds: [
673
672
  {
674
673
  kind: 'account';
675
- path: 'squads';
674
+ path: 'feeRecipient';
676
675
  },
677
676
  {
678
677
  kind: 'account';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatBookOrder = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
4
5
  const spl_token_1 = require("@solana/spl-token");
5
6
  const types_1 = require("../types");
6
7
  const constants_1 = require("./constants");
@@ -134,11 +135,12 @@ const formatBookOrder = (order) => {
134
135
  id: order.id.toString(),
135
136
  price: order.price.toString(),
136
137
  totalShares: order.totalShares.toString(),
137
- authority: order.authority.toString(),
138
+ authority: new web3_js_1.PublicKey(order.authority).toString(),
138
139
  filledShares: order.filledShares.toString(),
139
140
  orderDirection: (0, exports.getOrderDirectionFromNumber)(order.orderDirection),
140
141
  orderSide: (0, exports.getOrderSideFromNumber)(order.orderSide),
141
- userNonce: order.userNonce.toString()
142
+ userNonce: order.userNonce.toString(),
143
+ linkedBookOrderId: order.linkedBookOrderId.toString()
142
144
  };
143
145
  };
144
146
  exports.formatBookOrder = formatBookOrder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.3.8-beta",
3
+ "version": "2.4.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",