@triadxyz/triad-protocol 2.9.8-beta → 3.0.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
@@ -390,7 +390,7 @@ export default class TriadProtocolClient {
390
390
  *
391
391
  * @param options - RPC options
392
392
  */
393
- placeBidOrder({ marketId, amount, direction, mint, price }: PlaceBidOrderArgs, options?: RpcOptions): Promise<string>;
393
+ placeBidOrder({ marketId, amount, direction, mint, price, isTrdPayout }: PlaceBidOrderArgs, options?: RpcOptions): Promise<string>;
394
394
  /**
395
395
  * Place Ask Order
396
396
  * @param args.marketId - The ID of the Market
package/dist/index.js CHANGED
@@ -738,7 +738,7 @@ class TriadProtocolClient {
738
738
  *
739
739
  * @param options - RPC options
740
740
  */
741
- placeBidOrder({ marketId, amount, direction, mint, price }, options) {
741
+ placeBidOrder({ marketId, amount, direction, mint, price, isTrdPayout }, options) {
742
742
  return __awaiter(this, void 0, void 0, function* () {
743
743
  const ixs = [];
744
744
  const { userTradePDA, userTradeIxs } = yield this.getUserTradeNonce(marketId, Object.keys(direction)[0]);
@@ -749,7 +749,8 @@ class TriadProtocolClient {
749
749
  .placeBidOrder({
750
750
  amount: new bn_js_1.default(amount * Math.pow(10, this.decimals)),
751
751
  price: new bn_js_1.default(price * Math.pow(10, this.decimals)),
752
- orderDirection: direction
752
+ orderDirection: direction,
753
+ isTrdPayout
753
754
  })
754
755
  .accounts({
755
756
  signer: this.program.provider.publicKey,
@@ -896,11 +897,11 @@ class TriadProtocolClient {
896
897
  let adjustedPrice = orderPrice;
897
898
  if (feeBps > 0) {
898
899
  const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
899
- const fee = (0, helpers_1.roundUp)(priceSpread
900
+ const fee = priceSpread
900
901
  .mul(orderPrice)
901
902
  .mul(new bn_js_1.default(feeBps))
902
903
  .div(new bn_js_1.default(10000))
903
- .div(new bn_js_1.default(1000000)));
904
+ .div(new bn_js_1.default(1000000));
904
905
  adjustedPrice = orderPrice.add(fee);
905
906
  }
906
907
  const maxSharesForPrice = tempRemainingUSDC
@@ -945,11 +946,11 @@ class TriadProtocolClient {
945
946
  let adjustedPrice = orderPrice;
946
947
  if (feeBps > 0) {
947
948
  const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
948
- const fee = (0, helpers_1.roundUp)(priceSpread
949
+ const fee = priceSpread
949
950
  .mul(orderPrice)
950
951
  .mul(new bn_js_1.default(feeBps))
951
952
  .div(new bn_js_1.default(10000))
952
- .div(new bn_js_1.default(1000000)));
953
+ .div(new bn_js_1.default(1000000));
953
954
  adjustedPrice = orderPrice.add(fee);
954
955
  }
955
956
  const maxSharesForPrice = remainingUSDC
@@ -1033,11 +1034,11 @@ class TriadProtocolClient {
1033
1034
  let adjustedPrice = orderPrice;
1034
1035
  if (feeBps > 0) {
1035
1036
  const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
1036
- const fee = (0, helpers_1.roundUp)(priceSpread
1037
+ const fee = priceSpread
1037
1038
  .mul(orderPrice)
1038
1039
  .mul(new bn_js_1.default(feeBps))
1039
1040
  .div(new bn_js_1.default(10000))
1040
- .div(new bn_js_1.default(1000000)));
1041
+ .div(new bn_js_1.default(1000000));
1041
1042
  adjustedPrice = orderPrice.sub(fee);
1042
1043
  }
1043
1044
  amountOfUSDC = amountOfUSDC.add(sharesToSell.mul(adjustedPrice).div(new bn_js_1.default(Math.pow(10, this.decimals))));
@@ -3646,6 +3646,10 @@
3646
3646
  "name": "OrderDirection"
3647
3647
  }
3648
3648
  }
3649
+ },
3650
+ {
3651
+ "name": "is_trd_payout",
3652
+ "type": "bool"
3649
3653
  }
3650
3654
  ]
3651
3655
  }
@@ -67,6 +67,7 @@ export type Order = {
67
67
  userNonce: string;
68
68
  authority: string;
69
69
  createdAt: string;
70
+ isTrdPayout: boolean;
70
71
  };
71
72
  export type BookOrder = {
72
73
  id: string;
@@ -115,6 +116,7 @@ export type PlaceBidOrderArgs = {
115
116
  flop: {};
116
117
  };
117
118
  mint: PublicKey;
119
+ isTrdPayout: boolean;
118
120
  };
119
121
  export type PlaceAskOrderArgs = {
120
122
  marketId: number;
@@ -4466,6 +4466,10 @@ export type TriadProtocol = {
4466
4466
  name: 'orderDirection';
4467
4467
  };
4468
4468
  };
4469
+ },
4470
+ {
4471
+ name: 'isTrdPayout';
4472
+ type: 'bool';
4469
4473
  }
4470
4474
  ];
4471
4475
  };
@@ -3,7 +3,6 @@ import { IdlAccounts } from '@coral-xyz/anchor';
3
3
  import { Stake, StakeVault, Unstake } from './../types/stake';
4
4
  import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Refer, Customer } from '../types';
5
5
  import { TriadProtocol } from '../types/triad_protocol';
6
- import { BN } from '@coral-xyz/anchor';
7
6
  export declare const encodeString: (value: string, alloc?: number) => number[];
8
7
  export declare const decodeString: (bytes: number[]) => string;
9
8
  export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
@@ -48,4 +47,3 @@ export declare const getOrderStatus: (status: {
48
47
  }) => OrderStatus;
49
48
  export declare const formatRefer: (account: IdlAccounts<TriadProtocol>['refer']) => Refer;
50
49
  export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
51
- export declare const roundUp: (value: BN) => BN;
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roundUp = exports.formatCustomer = exports.formatRefer = 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.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.formatCustomer = exports.formatRefer = 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.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const types_1 = require("../types");
7
7
  const constants_1 = require("./constants");
8
- const anchor_1 = require("@coral-xyz/anchor");
9
8
  const encodeString = (value, alloc = 32) => {
10
9
  const buffer = Buffer.alloc(alloc, 32);
11
10
  buffer.write(value);
@@ -130,7 +129,8 @@ const formatOrder = (order, authority) => {
130
129
  orderSide: (0, exports.getOrderSide)(order.orderSide),
131
130
  price: order.price.toString(),
132
131
  totalShares: order.totalShares.toString(),
133
- filledShares: order.filledShares ? order.filledShares.toString() : ''
132
+ filledShares: order.filledShares ? order.filledShares.toString() : '',
133
+ isTrdPayout: order.isTrdPayout
134
134
  };
135
135
  };
136
136
  exports.formatOrder = formatOrder;
@@ -249,9 +249,3 @@ const formatCustomer = (account, publicKey) => {
249
249
  };
250
250
  };
251
251
  exports.formatCustomer = formatCustomer;
252
- const roundUp = (value) => {
253
- let decimal = value.toNumber() / 1000000;
254
- let rounded = Math.ceil(decimal * 100) / 100;
255
- return new anchor_1.BN(rounded * 1000000);
256
- };
257
- exports.roundUp = roundUp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.9.8-beta",
3
+ "version": "3.0.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",