@triadxyz/triad-protocol 1.5.4-beta → 1.5.5-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/trade.d.ts CHANGED
@@ -13,6 +13,12 @@ export default class Trade {
13
13
  *
14
14
  */
15
15
  getAllMarkets(): Promise<import("./types/trade").Market[]>;
16
+ /**
17
+ * Get All User Trades
18
+ * @param user - User PublicKey
19
+ *
20
+ */
21
+ getAllUserTrade(user: PublicKey): Promise<import("./types/trade").UserTrade[]>;
16
22
  /**
17
23
  * Get Market By ID
18
24
  * @param marketId - The ID of the market
@@ -98,8 +104,11 @@ export default class Trade {
98
104
  } & {
99
105
  flop: Record<string, never>;
100
106
  });
107
+ userNonce: number;
101
108
  padding: number[];
102
109
  }[];
110
+ nonce: number;
111
+ isSubUser: boolean;
103
112
  padding: number[];
104
113
  }>;
105
114
  /**
@@ -172,20 +181,6 @@ export default class Trade {
172
181
  marketToAddLiquidity: OrderDirection;
173
182
  amount: number;
174
183
  }, options?: RpcOptions): Promise<string>;
175
- /**
176
- * Settle an Order for a V1 Market
177
- * @param args.marketId - The ID of the Market
178
- * @param args.orderId - The ID of the Order to Settle
179
- * @param args.user - The user to settle the order for
180
- *
181
- * @param options - RPC options
182
- *
183
- */
184
- settleOrder({ marketId, orderId, user }: {
185
- marketId: number;
186
- orderId: number;
187
- user: PublicKey;
188
- }, options?: RpcOptions): Promise<string>;
189
184
  /**
190
185
  * Add Liquidity
191
186
  * @param marketId - The ID of the market
package/dist/trade.js CHANGED
@@ -34,6 +34,24 @@ class Trade {
34
34
  return marketV2.map(({ account, publicKey }) => (0, helpers_1.formatMarket)(account, publicKey));
35
35
  });
36
36
  }
37
+ /**
38
+ * Get All User Trades
39
+ * @param user - User PublicKey
40
+ *
41
+ */
42
+ getAllUserTrade(user) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const response = yield this.program.account.userTrade.all([
45
+ {
46
+ memcmp: {
47
+ offset: 8 + 1,
48
+ bytes: user.toBase58()
49
+ }
50
+ }
51
+ ]);
52
+ return response.map(({ account, publicKey }) => (0, helpers_1.formatUserTrade)(account, publicKey));
53
+ });
54
+ }
37
55
  /**
38
56
  * Get Market By ID
39
57
  * @param marketId - The ID of the market
@@ -229,28 +247,6 @@ class Trade {
229
247
  return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
230
248
  });
231
249
  }
232
- /**
233
- * Settle an Order for a V1 Market
234
- * @param args.marketId - The ID of the Market
235
- * @param args.orderId - The ID of the Order to Settle
236
- * @param args.user - The user to settle the order for
237
- *
238
- * @param options - RPC options
239
- *
240
- */
241
- settleOrder({ marketId, orderId, user }, options) {
242
- return __awaiter(this, void 0, void 0, function* () {
243
- const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
244
- const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, user);
245
- return (0, sendTransactionWithOptions_1.default)(this.program.methods.settleOrder(new bn_js_1.default(orderId)).accounts({
246
- signer: this.provider.publicKey,
247
- user: user,
248
- userTrade: userTradePDA,
249
- market: marketPDA,
250
- mint: constants_1.TRD_MINT
251
- }), options);
252
- });
253
- }
254
250
  /**
255
251
  * Add Liquidity
256
252
  * @param marketId - The ID of the market
@@ -451,6 +451,54 @@
451
451
  ],
452
452
  "args": []
453
453
  },
454
+ {
455
+ "name": "create_sub_user_trade",
456
+ "discriminator": [77, 201, 111, 73, 47, 229, 244, 161],
457
+ "accounts": [
458
+ {
459
+ "name": "signer",
460
+ "writable": true,
461
+ "signer": true
462
+ },
463
+ {
464
+ "name": "user_trade",
465
+ "writable": true,
466
+ "pda": {
467
+ "seeds": [
468
+ {
469
+ "kind": "const",
470
+ "value": [117, 115, 101, 114, 95, 116, 114, 97, 100, 101]
471
+ },
472
+ {
473
+ "kind": "account",
474
+ "path": "signer"
475
+ }
476
+ ]
477
+ }
478
+ },
479
+ {
480
+ "name": "sub_user_trade",
481
+ "writable": true,
482
+ "pda": {
483
+ "seeds": [
484
+ {
485
+ "kind": "const",
486
+ "value": [117, 115, 101, 114, 95, 116, 114, 97, 100, 101]
487
+ },
488
+ {
489
+ "kind": "arg",
490
+ "path": "sub_user_key"
491
+ }
492
+ ]
493
+ }
494
+ },
495
+ {
496
+ "name": "system_program",
497
+ "address": "11111111111111111111111111111111"
498
+ }
499
+ ],
500
+ "args": []
501
+ },
454
502
  {
455
503
  "name": "create_user_trade",
456
504
  "discriminator": [232, 235, 58, 194, 135, 248, 153, 1],
@@ -849,140 +897,6 @@
849
897
  }
850
898
  ]
851
899
  },
852
- {
853
- "name": "settle_order",
854
- "discriminator": [80, 74, 204, 34, 12, 183, 66, 66],
855
- "accounts": [
856
- {
857
- "name": "signer",
858
- "writable": true,
859
- "signer": true
860
- },
861
- {
862
- "name": "squads",
863
- "writable": true,
864
- "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
865
- },
866
- {
867
- "name": "user",
868
- "writable": true
869
- },
870
- {
871
- "name": "user_trade",
872
- "writable": true
873
- },
874
- {
875
- "name": "market",
876
- "writable": true
877
- },
878
- {
879
- "name": "mint",
880
- "writable": true
881
- },
882
- {
883
- "name": "user_ata",
884
- "writable": true,
885
- "pda": {
886
- "seeds": [
887
- {
888
- "kind": "account",
889
- "path": "user"
890
- },
891
- {
892
- "kind": "account",
893
- "path": "token_program"
894
- },
895
- {
896
- "kind": "account",
897
- "path": "mint"
898
- }
899
- ],
900
- "program": {
901
- "kind": "const",
902
- "value": [
903
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
904
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
905
- 219, 233, 248, 89
906
- ]
907
- }
908
- }
909
- },
910
- {
911
- "name": "market_ata",
912
- "writable": true,
913
- "pda": {
914
- "seeds": [
915
- {
916
- "kind": "account",
917
- "path": "market"
918
- },
919
- {
920
- "kind": "account",
921
- "path": "token_program"
922
- },
923
- {
924
- "kind": "account",
925
- "path": "mint"
926
- }
927
- ],
928
- "program": {
929
- "kind": "const",
930
- "value": [
931
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
932
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
933
- 219, 233, 248, 89
934
- ]
935
- }
936
- }
937
- },
938
- {
939
- "name": "squads_ata",
940
- "writable": true,
941
- "pda": {
942
- "seeds": [
943
- {
944
- "kind": "account",
945
- "path": "squads"
946
- },
947
- {
948
- "kind": "account",
949
- "path": "token_program"
950
- },
951
- {
952
- "kind": "account",
953
- "path": "mint"
954
- }
955
- ],
956
- "program": {
957
- "kind": "const",
958
- "value": [
959
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
960
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
961
- 219, 233, 248, 89
962
- ]
963
- }
964
- }
965
- },
966
- {
967
- "name": "token_program",
968
- "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
969
- },
970
- {
971
- "name": "associated_token_program",
972
- "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
973
- },
974
- {
975
- "name": "system_program",
976
- "address": "11111111111111111111111111111111"
977
- }
978
- ],
979
- "args": [
980
- {
981
- "name": "order_id",
982
- "type": "u64"
983
- }
984
- ]
985
- },
986
900
  {
987
901
  "name": "stake_token",
988
902
  "discriminator": [191, 127, 193, 101, 37, 96, 87, 211],
@@ -1425,10 +1339,6 @@
1425
1339
  "name": "Collection",
1426
1340
  "discriminator": [48, 160, 232, 205, 191, 207, 26, 141]
1427
1341
  },
1428
- {
1429
- "name": "Market",
1430
- "discriminator": [219, 190, 213, 55, 0, 227, 198, 154]
1431
- },
1432
1342
  {
1433
1343
  "name": "MarketV2",
1434
1344
  "discriminator": [27, 60, 50, 75, 191, 193, 86, 227]
@@ -1759,157 +1669,6 @@
1759
1669
  ]
1760
1670
  }
1761
1671
  },
1762
- {
1763
- "name": "Market",
1764
- "type": {
1765
- "kind": "struct",
1766
- "fields": [
1767
- {
1768
- "name": "bump",
1769
- "type": "u8"
1770
- },
1771
- {
1772
- "name": "authority",
1773
- "type": "pubkey"
1774
- },
1775
- {
1776
- "name": "market_id",
1777
- "docs": ["Unique identifier for the market"],
1778
- "type": "u64"
1779
- },
1780
- {
1781
- "name": "name",
1782
- "docs": ["The event being predicted (e.g., \"tJUP/TRD\")"],
1783
- "type": "string"
1784
- },
1785
- {
1786
- "name": "hype_price",
1787
- "docs": [
1788
- "Current price for Hype outcome (0-1000000, representing 0 to 1 TRD)",
1789
- "1000000 = 1 TRD, 500000 = 0.5 TRD, etc."
1790
- ],
1791
- "type": "u64"
1792
- },
1793
- {
1794
- "name": "flop_price",
1795
- "docs": [
1796
- "Current price for Flop outcome (0-1000000, representing 0 to 1 TRD)"
1797
- ],
1798
- "type": "u64"
1799
- },
1800
- {
1801
- "name": "hype_liquidity",
1802
- "docs": ["Total liquidity for Hype (in TRD)"],
1803
- "type": "u64"
1804
- },
1805
- {
1806
- "name": "flop_liquidity",
1807
- "docs": ["Total liquidity for Flop (in TRD)"],
1808
- "type": "u64"
1809
- },
1810
- {
1811
- "name": "total_hype_shares",
1812
- "docs": ["Total number of Hype shares issued"],
1813
- "type": "u64"
1814
- },
1815
- {
1816
- "name": "total_flop_shares",
1817
- "docs": ["Total number of Flop shares issued"],
1818
- "type": "u64"
1819
- },
1820
- {
1821
- "name": "total_volume",
1822
- "docs": ["Total trading volume (in TRD) for all resolutions"],
1823
- "type": "u64"
1824
- },
1825
- {
1826
- "name": "mint",
1827
- "docs": ["Mint $TRD token"],
1828
- "type": "pubkey"
1829
- },
1830
- {
1831
- "name": "ts",
1832
- "docs": ["Timestamp of the init"],
1833
- "type": "i64"
1834
- },
1835
- {
1836
- "name": "update_ts",
1837
- "type": "i64"
1838
- },
1839
- {
1840
- "name": "open_orders_count",
1841
- "docs": ["Total number of open orders in this market"],
1842
- "type": "u64"
1843
- },
1844
- {
1845
- "name": "next_order_id",
1846
- "docs": ["Next available order ID"],
1847
- "type": "u64"
1848
- },
1849
- {
1850
- "name": "fee_bps",
1851
- "docs": [
1852
- "Fees applied to trades (in basis points, e.g., 2.131% fee)"
1853
- ],
1854
- "type": "u16"
1855
- },
1856
- {
1857
- "name": "fee_vault",
1858
- "docs": ["Vault to Receive fees"],
1859
- "type": "pubkey"
1860
- },
1861
- {
1862
- "name": "is_active",
1863
- "docs": ["Whether the market is currently active for trading"],
1864
- "type": "bool"
1865
- },
1866
- {
1867
- "name": "market_price",
1868
- "type": "u64"
1869
- },
1870
- {
1871
- "name": "previous_resolved_question",
1872
- "type": {
1873
- "defined": {
1874
- "name": "ResolvedQuestion"
1875
- }
1876
- }
1877
- },
1878
- {
1879
- "name": "current_question_id",
1880
- "docs": [
1881
- "Index of the current week in the weekly_results array initialized with default values"
1882
- ],
1883
- "type": "u64"
1884
- },
1885
- {
1886
- "name": "current_question_start",
1887
- "type": "i64"
1888
- },
1889
- {
1890
- "name": "current_question_end",
1891
- "type": "i64"
1892
- },
1893
- {
1894
- "name": "current_question",
1895
- "docs": ["The question or prediction topic for the current week"],
1896
- "type": {
1897
- "array": ["u8", 80]
1898
- }
1899
- },
1900
- {
1901
- "name": "liquidity",
1902
- "type": "u64"
1903
- },
1904
- {
1905
- "name": "padding",
1906
- "type": {
1907
- "array": ["u8", 200]
1908
- }
1909
- }
1910
- ]
1911
- }
1912
- },
1913
1672
  {
1914
1673
  "name": "MarketAllowedToPayoutEvent",
1915
1674
  "type": {
@@ -2213,10 +1972,14 @@
2213
1972
  }
2214
1973
  }
2215
1974
  },
1975
+ {
1976
+ "name": "user_nonce",
1977
+ "type": "u32"
1978
+ },
2216
1979
  {
2217
1980
  "name": "padding",
2218
1981
  "type": {
2219
- "array": ["u8", 32]
1982
+ "array": ["u8", 28]
2220
1983
  }
2221
1984
  }
2222
1985
  ]
@@ -2385,84 +2148,6 @@
2385
2148
  ]
2386
2149
  }
2387
2150
  },
2388
- {
2389
- "name": "ResolvedQuestion",
2390
- "type": {
2391
- "kind": "struct",
2392
- "fields": [
2393
- {
2394
- "name": "question_id",
2395
- "type": "u64"
2396
- },
2397
- {
2398
- "name": "question",
2399
- "docs": ["The question or prediction topic for this week"],
2400
- "type": {
2401
- "array": ["u8", 80]
2402
- }
2403
- },
2404
- {
2405
- "name": "start_time",
2406
- "docs": ["Start timestamp of the week"],
2407
- "type": "i64"
2408
- },
2409
- {
2410
- "name": "end_time",
2411
- "docs": ["End timestamp of the week"],
2412
- "type": "i64"
2413
- },
2414
- {
2415
- "name": "hype_liquidity",
2416
- "docs": ["Total liquidity for Hype (in TRD)"],
2417
- "type": "u64"
2418
- },
2419
- {
2420
- "name": "flop_liquidity",
2421
- "docs": ["Total liquidity for Flop (in TRD)"],
2422
- "type": "u64"
2423
- },
2424
- {
2425
- "name": "winning_direction",
2426
- "docs": ["The winning direction (Hype, Flop or None)"],
2427
- "type": {
2428
- "defined": {
2429
- "name": "WinningDirection"
2430
- }
2431
- }
2432
- },
2433
- {
2434
- "name": "market_price",
2435
- "type": "u64"
2436
- },
2437
- {
2438
- "name": "final_hype_price",
2439
- "docs": ["Final price for Hype outcome at the end of the week"],
2440
- "type": "u64"
2441
- },
2442
- {
2443
- "name": "final_flop_price",
2444
- "docs": ["Final price for Flop outcome at the end of the week"],
2445
- "type": "u64"
2446
- },
2447
- {
2448
- "name": "total_hype_shares",
2449
- "docs": ["Total number of Hype shares issued"],
2450
- "type": "u64"
2451
- },
2452
- {
2453
- "name": "total_flop_shares",
2454
- "docs": ["Total number of Flop shares issued"],
2455
- "type": "u64"
2456
- },
2457
- {
2458
- "name": "padding",
2459
- "type": {
2460
- "array": ["u8", 40]
2461
- }
2462
- }
2463
- ]
2464
- }
2465
- },
2466
2151
  {
2467
2152
  "name": "StakeRewardsEvent",
2468
2153
  "type": {
@@ -2773,10 +2458,18 @@
2773
2458
  ]
2774
2459
  }
2775
2460
  },
2461
+ {
2462
+ "name": "nonce",
2463
+ "type": "u32"
2464
+ },
2465
+ {
2466
+ "name": "is_sub_user",
2467
+ "type": "bool"
2468
+ },
2776
2469
  {
2777
2470
  "name": "padding",
2778
2471
  "type": {
2779
- "array": ["u8", 32]
2472
+ "array": ["u8", 27]
2780
2473
  }
2781
2474
  }
2782
2475
  ]
@@ -26,6 +26,28 @@ export type Market = {
26
26
  winningDirection: WinningDirection;
27
27
  marketLiquidityAtStart: string;
28
28
  };
29
+ export type UserTrade = {
30
+ user: string;
31
+ totalDeposits: string;
32
+ totalWithdraws: string;
33
+ openedOrders: string;
34
+ orders: Order[];
35
+ nonce: string;
36
+ isSubUser: boolean;
37
+ };
38
+ export type Order = {
39
+ ts: string;
40
+ orderId: string;
41
+ questionId: string;
42
+ marketId: string;
43
+ status: OrderStatus;
44
+ price: string;
45
+ totalAmount: string;
46
+ totalShares: string;
47
+ orderType: OrderType;
48
+ direction: OrderDirection;
49
+ userNonce: string;
50
+ };
29
51
  export declare enum WinningDirection {
30
52
  HYPE = "Hype",
31
53
  FLOP = "Flop",