@triadxyz/triad-protocol 2.0.8-beta → 2.1.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
@@ -1,5 +1,5 @@
1
1
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
2
- import { Connection, Keypair, PublicKey } from '@solana/web3.js';
2
+ import { Connection, PublicKey } from '@solana/web3.js';
3
3
  import { TriadProtocol } from './types/triad_protocol';
4
4
  import Trade from './trade';
5
5
  import Stake from './stake';
@@ -15,12 +15,11 @@ export default class TriadProtocolClient {
15
15
  * @param args.poseidonAsset - Poseidon Asset
16
16
  * @param args.ticketAsset - Ticket Asset
17
17
  * @param args.ticketNumber - Ticket Number
18
- * @param verifier - Verifier
19
18
  *
20
19
  * @param options - RPC options
21
20
  *
22
21
  */
23
- transferPoseidon(args: TransferPoseidonArgs[], verifier: Keypair, options?: RpcOptions): Promise<string>;
22
+ transferPoseidon(args: TransferPoseidonArgs[], options?: RpcOptions): Promise<string>;
24
23
  /**
25
24
  * Withdraw Poseidon
26
25
  * @param args.poseidonAsset - Poseidon Asset - CORE PublicKey
package/dist/index.js CHANGED
@@ -35,12 +35,11 @@ class TriadProtocolClient {
35
35
  * @param args.poseidonAsset - Poseidon Asset
36
36
  * @param args.ticketAsset - Ticket Asset
37
37
  * @param args.ticketNumber - Ticket Number
38
- * @param verifier - Verifier
39
38
  *
40
39
  * @param options - RPC options
41
40
  *
42
41
  */
43
- transferPoseidon(args, verifier, options) {
42
+ transferPoseidon(args, options) {
44
43
  return __awaiter(this, void 0, void 0, function* () {
45
44
  const ixs = [];
46
45
  for (const arg of args) {
@@ -51,7 +50,6 @@ class TriadProtocolClient {
51
50
  nft: (0, poseidon_1.getNftPDA)(this.program.programId, arg.ticketNumber),
52
51
  poseidonAsset: arg.poseidonAsset,
53
52
  ticketAsset: arg.ticketAsset,
54
- verifier: constants_1.VERIFIER,
55
53
  poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
56
54
  ticketCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.TICKET_COLLECTION_SYMBOL),
57
55
  coreTicketCollection: constants_1.TICKET_CORE_COLLECTION,
@@ -59,7 +57,7 @@ class TriadProtocolClient {
59
57
  })
60
58
  .instruction());
61
59
  }
62
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, [], verifier);
60
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
63
61
  });
64
62
  }
65
63
  /**
package/dist/stake.d.ts CHANGED
@@ -69,9 +69,6 @@ export default class Stake {
69
69
  /**
70
70
  * Claim Stake Rewards
71
71
  * @param args.wallet - User wallet
72
- * @param args.collections - NFT collections
73
- * @param args.ranks - Tensor ranks
74
- * @param args.verifier - Verifier
75
72
  *
76
73
  * @param options - RPC options
77
74
  *
package/dist/stake.js CHANGED
@@ -152,9 +152,6 @@ class Stake {
152
152
  /**
153
153
  * Claim Stake Rewards
154
154
  * @param args.wallet - User wallet
155
- * @param args.collections - NFT collections
156
- * @param args.ranks - Tensor ranks
157
- * @param args.verifier - Verifier
158
155
  *
159
156
  * @param options - RPC options
160
157
  *
package/dist/trade.js CHANGED
@@ -440,7 +440,7 @@ class Trade {
440
440
  .accounts({
441
441
  signer: this.program.provider.publicKey,
442
442
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
443
- userTrade: userTradePDA,
443
+ bidUserTrade: userTradePDA,
444
444
  mint,
445
445
  tokenProgram: (0, helpers_1.getTokenProgram)(mint)
446
446
  })
@@ -557,16 +557,16 @@ class Trade {
557
557
  const ixs = [];
558
558
  const { userTradePDA: buyerTrade, ixs: userTradeIxs } = yield this.getUserTradeIxs();
559
559
  const orderBook = yield this.getOrderBook(marketId);
560
- let remainingUSDC = amount * Math.pow(10, this.decimals);
560
+ let remainingUSDC = new bn_js_1.default(amount * Math.pow(10, this.decimals));
561
561
  const orders = Object.keys(direction)[0] === 'hype'
562
562
  ? orderBook.hype.ask
563
563
  : orderBook.flop.ask;
564
564
  const sortedOrders = orders.sort((a, b) => Number(a.price) - Number(b.price));
565
565
  for (const order of sortedOrders) {
566
- if (remainingUSDC <= 0)
566
+ if (remainingUSDC.div(new bn_js_1.default(Math.pow(10, this.decimals))).toString() === '0')
567
567
  break;
568
568
  if (order.authority === this.program.provider.publicKey.toBase58()) {
569
- continue;
569
+ return;
570
570
  }
571
571
  let linkedSellerBidTradePDA = null;
572
572
  if (order.linkedBidOrderId !== '0') {
@@ -582,11 +582,17 @@ class Trade {
582
582
  linkedSellerBidTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
583
583
  }
584
584
  }
585
- const orderPrice = Number(order.price);
586
- const maxSharesForPrice = remainingUSDC / orderPrice;
587
- const availableShares = Number(order.totalShares);
588
- const sharesToBuy = Math.min(maxSharesForPrice, availableShares);
589
- const usdcAmount = sharesToBuy * orderPrice;
585
+ const orderPrice = new bn_js_1.default(order.price);
586
+ const availableShares = new bn_js_1.default(order.totalShares);
587
+ const maxSharesForPrice = remainingUSDC
588
+ .mul(new bn_js_1.default(Math.pow(10, this.decimals)))
589
+ .div(orderPrice);
590
+ const sharesToBuy = bn_js_1.default.min(maxSharesForPrice, availableShares);
591
+ if (sharesToBuy.lten(0))
592
+ continue;
593
+ const usdcAmount = sharesToBuy
594
+ .mul(orderPrice)
595
+ .div(new bn_js_1.default(Math.pow(10, this.decimals)));
590
596
  let sellerTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority));
591
597
  if (order.userNonce !== '0') {
592
598
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), Number(order.userNonce));
@@ -612,7 +618,7 @@ class Trade {
612
618
  linkedSellerBidTrade: linkedSellerBidTradePDA
613
619
  })
614
620
  .instruction());
615
- remainingUSDC -= usdcAmount;
621
+ remainingUSDC = remainingUSDC.sub(usdcAmount);
616
622
  }
617
623
  if (userTradeIxs.length > 0) {
618
624
  ixs.unshift(...userTradeIxs);
@@ -1116,9 +1116,8 @@
1116
1116
  "signer": true
1117
1117
  },
1118
1118
  {
1119
- "name": "squads",
1120
- "writable": true,
1121
- "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
1119
+ "name": "market",
1120
+ "writable": true
1122
1121
  },
1123
1122
  {
1124
1123
  "name": "ask_user_trade",
@@ -1128,10 +1127,6 @@
1128
1127
  "name": "bid_user_trade",
1129
1128
  "writable": true
1130
1129
  },
1131
- {
1132
- "name": "market",
1133
- "writable": true
1134
- },
1135
1130
  {
1136
1131
  "name": "system_program",
1137
1132
  "address": "11111111111111111111111111111111"
@@ -1158,16 +1153,11 @@
1158
1153
  "signer": true
1159
1154
  },
1160
1155
  {
1161
- "name": "squads",
1162
- "writable": true,
1163
- "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
1164
- },
1165
- {
1166
- "name": "user_trade",
1156
+ "name": "market",
1167
1157
  "writable": true
1168
1158
  },
1169
1159
  {
1170
- "name": "market",
1160
+ "name": "bid_user_trade",
1171
1161
  "writable": true
1172
1162
  },
1173
1163
  {
@@ -1175,7 +1165,7 @@
1175
1165
  "writable": true
1176
1166
  },
1177
1167
  {
1178
- "name": "user_from_ata",
1168
+ "name": "user_ata",
1179
1169
  "writable": true,
1180
1170
  "pda": {
1181
1171
  "seeds": [
@@ -1203,7 +1193,7 @@
1203
1193
  }
1204
1194
  },
1205
1195
  {
1206
- "name": "market_to_ata",
1196
+ "name": "market_ata",
1207
1197
  "writable": true,
1208
1198
  "pda": {
1209
1199
  "seeds": [
@@ -1451,9 +1441,9 @@
1451
1441
  "signer": true
1452
1442
  },
1453
1443
  {
1454
- "name": "verifier",
1444
+ "name": "squads",
1455
1445
  "writable": true,
1456
- "signer": true
1446
+ "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
1457
1447
  },
1458
1448
  {
1459
1449
  "name": "nft",
@@ -1972,6 +1962,11 @@
1972
1962
  "code": 6026,
1973
1963
  "name": "Overflow",
1974
1964
  "msg": "Overflow"
1965
+ },
1966
+ {
1967
+ "code": 6027,
1968
+ "name": "LinkedBidOrderNotFound",
1969
+ "msg": "Linked bid order not found"
1975
1970
  }
1976
1971
  ],
1977
1972
  "types": [
@@ -1569,9 +1569,8 @@ export type TriadProtocol = {
1569
1569
  signer: true;
1570
1570
  },
1571
1571
  {
1572
- name: 'squads';
1572
+ name: 'market';
1573
1573
  writable: true;
1574
- address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
1575
1574
  },
1576
1575
  {
1577
1576
  name: 'askUserTrade';
@@ -1581,10 +1580,6 @@ export type TriadProtocol = {
1581
1580
  name: 'bidUserTrade';
1582
1581
  writable: true;
1583
1582
  },
1584
- {
1585
- name: 'market';
1586
- writable: true;
1587
- },
1588
1583
  {
1589
1584
  name: 'systemProgram';
1590
1585
  address: '11111111111111111111111111111111';
@@ -1611,16 +1606,11 @@ export type TriadProtocol = {
1611
1606
  signer: true;
1612
1607
  },
1613
1608
  {
1614
- name: 'squads';
1615
- writable: true;
1616
- address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
1617
- },
1618
- {
1619
- name: 'userTrade';
1609
+ name: 'market';
1620
1610
  writable: true;
1621
1611
  },
1622
1612
  {
1623
- name: 'market';
1613
+ name: 'bidUserTrade';
1624
1614
  writable: true;
1625
1615
  },
1626
1616
  {
@@ -1628,7 +1618,7 @@ export type TriadProtocol = {
1628
1618
  writable: true;
1629
1619
  },
1630
1620
  {
1631
- name: 'userFromAta';
1621
+ name: 'userAta';
1632
1622
  writable: true;
1633
1623
  pda: {
1634
1624
  seeds: [
@@ -1685,7 +1675,7 @@ export type TriadProtocol = {
1685
1675
  };
1686
1676
  },
1687
1677
  {
1688
- name: 'marketToAta';
1678
+ name: 'marketAta';
1689
1679
  writable: true;
1690
1680
  pda: {
1691
1681
  seeds: [
@@ -2032,9 +2022,9 @@ export type TriadProtocol = {
2032
2022
  signer: true;
2033
2023
  },
2034
2024
  {
2035
- name: 'verifier';
2025
+ name: 'squads';
2036
2026
  writable: true;
2037
- signer: true;
2027
+ address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
2038
2028
  },
2039
2029
  {
2040
2030
  name: 'nft';
@@ -2693,6 +2683,11 @@ export type TriadProtocol = {
2693
2683
  code: 6026;
2694
2684
  name: 'overflow';
2695
2685
  msg: 'overflow';
2686
+ },
2687
+ {
2688
+ code: 6027;
2689
+ name: 'linkedBidOrderNotFound';
2690
+ msg: 'Linked bid order not found';
2696
2691
  }
2697
2692
  ];
2698
2693
  types: [
@@ -1,6 +1,5 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
2
  export declare const TRD_DECIMALS = 6;
3
- export declare const VERIFIER: PublicKey;
4
3
  export declare const TRD_MINT: PublicKey;
5
4
  export declare const TRIAD_ADMIN: PublicKey;
6
5
  export declare const SOL_MINT: PublicKey;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = void 0;
3
+ exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.TRD_DECIMALS = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.TRD_DECIMALS = 6;
6
- exports.VERIFIER = new web3_js_1.PublicKey('42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1Rt5w2a919');
7
6
  exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
8
7
  exports.TRIAD_ADMIN = new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR');
9
8
  exports.SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
@@ -2,7 +2,6 @@ import { TransactionInstruction } from '@solana/web3.js';
2
2
  import { RpcOptions } from '../types';
3
3
  import { AddressLookupTableAccount } from '@solana/web3.js';
4
4
  import { Program } from '@coral-xyz/anchor';
5
- import { Keypair } from '@solana/web3.js';
6
5
  import { TriadProtocol } from '../types/triad_protocol';
7
- declare const sendVersionedTransaction: (program: Program<TriadProtocol>, ixs: TransactionInstruction[], options?: RpcOptions, addressLookupTableAccounts?: AddressLookupTableAccount[], verifier?: Keypair) => Promise<string>;
6
+ declare const sendVersionedTransaction: (program: Program<TriadProtocol>, ixs: TransactionInstruction[], options?: RpcOptions, addressLookupTableAccounts?: AddressLookupTableAccount[]) => Promise<string>;
8
7
  export default sendVersionedTransaction;
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const web3_js_1 = require("@solana/web3.js");
16
16
  const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
17
- const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccounts, verifier) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccounts) => __awaiter(void 0, void 0, void 0, function* () {
18
18
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
19
19
  ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
20
20
  microLamports: options.microLamports
@@ -32,12 +32,7 @@ const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccou
32
32
  recentBlockhash: blockhash,
33
33
  payerKey: program.provider.publicKey
34
34
  }).compileToV0Message(addressLookupTableAccounts));
35
- let signers = [];
36
- if (verifier) {
37
- tx.sign([verifier]);
38
- signers.push(verifier);
39
- }
40
- return program.provider.sendAndConfirm(tx, signers, {
35
+ return program.provider.sendAndConfirm(tx, [], {
41
36
  skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
42
37
  commitment: 'confirmed'
43
38
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.0.8-beta",
3
+ "version": "2.1.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",