@triadxyz/triad-protocol 4.2.0 → 4.2.1

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.
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- import { BN, IdlAccounts, Program } from '@coral-xyz/anchor';
2
+ import { IdlAccounts, Program } from '@coral-xyz/anchor';
3
3
  import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, OrderDirectionEncoded, OrderTypeEncoded, OrderSideEncoded, OrderStatusEncoded, Pool, BookOrder } from '../types';
4
4
  import { Stake, StakeVault, Unstake } from '../types/stake';
5
5
  import { Customer } from '../types/customer';
@@ -26,7 +26,7 @@ export declare const getOrderStatus: (status: OrderStatusEncoded) => OrderStatus
26
26
  export declare const getOrderDirectionEncoded: (orderDirection: OrderDirection) => OrderDirectionEncoded;
27
27
  export declare const getOppositeOrderDirection: (orderDirection: OrderDirection) => OrderDirection;
28
28
  export declare const getOppositeOrderDirectionEncoded: (orderDirection: OrderDirectionEncoded) => OrderDirectionEncoded;
29
- export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey, balance: BN) => Predictor;
29
+ export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey) => Predictor;
30
30
  export declare const getPriceFeedAccountForProgram: (priceFeedId: string) => PublicKey;
31
31
  export declare const getFeedIdFromHex: (input?: string) => PublicKey | null;
32
32
  export declare const getCustomerById: (program: Program<TriadProtocol>, customerId: number) => Promise<Customer>;
@@ -103,10 +103,7 @@ const formatMarket = (account, address) => {
103
103
  marketStart: account.marketStart.toString(),
104
104
  marketEnd: account.marketEnd.toString(),
105
105
  question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
106
- payoutFeeAvailable: account.payoutFeeAvailable.toString(),
107
- payoutFeeClaimed: account.payoutFeeClaimed.toString(),
108
- marketFeeAvailable: account.marketFeeAvailable.toString(),
109
- marketFeeClaimed: account.marketFeeClaimed.toString(),
106
+ feeGenerated: account.feeGenerated.toString(),
110
107
  winningDirection: types_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()],
111
108
  marketLiquidityAtStart: account.marketLiquidityAtStart.toNumber() > 0
112
109
  ? account.marketLiquidityAtStart.toString()
@@ -262,13 +259,15 @@ const getOppositeOrderDirectionEncoded = (orderDirection) => {
262
259
  return { hype: {} };
263
260
  };
264
261
  exports.getOppositeOrderDirectionEncoded = getOppositeOrderDirectionEncoded;
265
- const formatPredictor = (account, publicKey, balance) => {
262
+ const formatPredictor = (account, publicKey) => {
266
263
  return {
267
264
  address: publicKey.toBase58(),
268
- authority: publicKey.toString(),
265
+ authority: account.authority.toString(),
269
266
  refer: account.refer.toString(),
270
267
  customerId: account.customerId,
271
- balance: balance.toNumber() / 1e6
268
+ balance: account.balance.toNumber() / 1e6,
269
+ rewardsAvailable: account.rewardsAvailable.toNumber() / 1e6,
270
+ rewardsClaimed: account.rewardsClaimed.toNumber() / 1e6
272
271
  };
273
272
  };
274
273
  exports.formatPredictor = formatPredictor;
@@ -8,12 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  const web3_js_1 = require("@solana/web3.js");
16
- const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
17
13
  const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccounts) => __awaiter(void 0, void 0, void 0, function* () {
18
14
  var _a;
19
15
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
@@ -21,13 +17,9 @@ const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccou
21
17
  microLamports: options.microLamports
22
18
  }));
23
19
  }
24
- if (!(options === null || options === void 0 ? void 0 : options.microLamports)) {
25
- const priorityFee = yield (0, getPriorityFee_1.default)();
26
- ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
27
- microLamports: priorityFee
28
- }));
29
- }
30
- const { blockhash } = yield program.provider.connection.getLatestBlockhash();
20
+ const { blockhash } = yield program.provider.connection.getLatestBlockhash({
21
+ commitment: 'confirmed'
22
+ });
31
23
  if (program.provider.publicKey.toBase58() !== ((_a = options === null || options === void 0 ? void 0 : options.payer) === null || _a === void 0 ? void 0 : _a.toBase58())) {
32
24
  return new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
33
25
  instructions: ixs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",