@triadxyz/triad-protocol 4.3.0 → 4.3.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.
@@ -2,7 +2,7 @@ import { PublicKey } from '@solana/web3.js';
2
2
  import { Program } from '@coral-xyz/anchor';
3
3
  import { TriadProtocol } from './types/triad_protocol';
4
4
  import { RpcOptions } from './types';
5
- import { DepositArgs, DepositExtArgs, WithdrawArgs, WithdrawExtArgs, CollectRewardsArgs, Predictor as PredictorType } from './types/predictor';
5
+ import { DepositArgs, DepositExtArgs, WithdrawArgs, CollectRewardsArgs, Predictor as PredictorType } from './types/predictor';
6
6
  export default class Predictor {
7
7
  private program;
8
8
  private rpcOptions;
@@ -53,10 +53,11 @@ export default class Predictor {
53
53
  /**
54
54
  * Withdraw
55
55
  * @param args.authority - Authority of the withdraw
56
+ * @param args.recipient - Recipient of the withdraw
56
57
  * @param args.amount - Amount to deposit
57
58
  * @param args.customerId - Customer ID
58
59
  */
59
- withdraw({ authority, amount, customerId }: WithdrawArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
60
+ withdraw({ authority, recipient, amount, customerId }: WithdrawArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
60
61
  /**
61
62
  * Deposit Ext
62
63
  * Idempotent deposit with an optional external deposit record.
@@ -67,16 +68,6 @@ export default class Predictor {
67
68
  * @param args.depositId - Optional 12-byte deposit ID used as idempotency key
68
69
  */
69
70
  depositExt({ authority, amount, refer, customerId, depositId }: DepositExtArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
70
- /**
71
- * Withdraw Ext
72
- * Withdraws to an external ATA owned by the caller-provided account.
73
- * @param args.authority - Authority of the withdraw
74
- * @param args.amount - Amount to withdraw
75
- * @param args.customerId - Customer ID
76
- * @param args.key - External withdraw key (idempotency / off-chain reference)
77
- * @param args.extAta - External ATA destination
78
- */
79
- withdrawExt({ authority, amount, customerId, key, extAta }: WithdrawExtArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
80
71
  /**
81
72
  * Collect Rewards
82
73
  * Claims accumulated TRIAD token rewards for the predictor.
package/dist/predictor.js CHANGED
@@ -162,10 +162,11 @@ class Predictor {
162
162
  /**
163
163
  * Withdraw
164
164
  * @param args.authority - Authority of the withdraw
165
+ * @param args.recipient - Recipient of the withdraw
165
166
  * @param args.amount - Amount to deposit
166
167
  * @param args.customerId - Customer ID
167
168
  */
168
- withdraw({ authority, amount, customerId }) {
169
+ withdraw({ authority, recipient, amount, customerId }) {
169
170
  return __awaiter(this, void 0, void 0, function* () {
170
171
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
171
172
  const ixs = [
@@ -174,6 +175,7 @@ class Predictor {
174
175
  .accounts({
175
176
  signer: authority,
176
177
  payer: this.rpcOptions.payer,
178
+ recipient,
177
179
  predictor: predictorPDA
178
180
  })
179
181
  .instruction()
@@ -223,34 +225,6 @@ class Predictor {
223
225
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
224
226
  });
225
227
  }
226
- /**
227
- * Withdraw Ext
228
- * Withdraws to an external ATA owned by the caller-provided account.
229
- * @param args.authority - Authority of the withdraw
230
- * @param args.amount - Amount to withdraw
231
- * @param args.customerId - Customer ID
232
- * @param args.key - External withdraw key (idempotency / off-chain reference)
233
- * @param args.extAta - External ATA destination
234
- */
235
- withdrawExt({ authority, amount, customerId, key, extAta }) {
236
- return __awaiter(this, void 0, void 0, function* () {
237
- const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
238
- const ixs = [
239
- yield this.program.methods
240
- .withdrawExt({
241
- amount: new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)),
242
- key
243
- })
244
- .accounts({
245
- signer: authority,
246
- predictor: predictorPDA,
247
- extAta
248
- })
249
- .instruction()
250
- ];
251
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
252
- });
253
- }
254
228
  /**
255
229
  * Collect Rewards
256
230
  * Claims accumulated TRIAD token rewards for the predictor.
@@ -1873,6 +1873,10 @@
1873
1873
  "writable": true,
1874
1874
  "signer": true
1875
1875
  },
1876
+ {
1877
+ "name": "recipient",
1878
+ "writable": true
1879
+ },
1876
1880
  {
1877
1881
  "name": "central",
1878
1882
  "writable": true,
@@ -1924,7 +1928,7 @@
1924
1928
  "seeds": [
1925
1929
  {
1926
1930
  "kind": "account",
1927
- "path": "signer"
1931
+ "path": "recipient"
1928
1932
  },
1929
1933
  {
1930
1934
  "kind": "account",
@@ -1993,115 +1997,6 @@
1993
1997
  }
1994
1998
  ]
1995
1999
  },
1996
- {
1997
- "name": "withdraw_ext",
1998
- "discriminator": [244, 65, 141, 53, 29, 13, 232, 64],
1999
- "accounts": [
2000
- {
2001
- "name": "signer",
2002
- "writable": true,
2003
- "signer": true
2004
- },
2005
- {
2006
- "name": "central",
2007
- "writable": true,
2008
- "pda": {
2009
- "seeds": [
2010
- {
2011
- "kind": "const",
2012
- "value": [99, 101, 110, 116, 114, 97, 108]
2013
- },
2014
- {
2015
- "kind": "const",
2016
- "value": [
2017
- 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
2018
- ]
2019
- }
2020
- ]
2021
- }
2022
- },
2023
- {
2024
- "name": "customer",
2025
- "writable": true,
2026
- "pda": {
2027
- "seeds": [
2028
- {
2029
- "kind": "const",
2030
- "value": [99, 117, 115, 116, 111, 109, 101, 114]
2031
- },
2032
- {
2033
- "kind": "account",
2034
- "path": "predictor.customer_id",
2035
- "account": "Predictor"
2036
- }
2037
- ]
2038
- }
2039
- },
2040
- {
2041
- "name": "predictor",
2042
- "writable": true
2043
- },
2044
- {
2045
- "name": "mint",
2046
- "writable": true,
2047
- "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
2048
- },
2049
- {
2050
- "name": "ext_ata",
2051
- "writable": true
2052
- },
2053
- {
2054
- "name": "central_ata",
2055
- "writable": true,
2056
- "pda": {
2057
- "seeds": [
2058
- {
2059
- "kind": "account",
2060
- "path": "central"
2061
- },
2062
- {
2063
- "kind": "account",
2064
- "path": "token_program"
2065
- },
2066
- {
2067
- "kind": "account",
2068
- "path": "mint"
2069
- }
2070
- ],
2071
- "program": {
2072
- "kind": "const",
2073
- "value": [
2074
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
2075
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
2076
- 219, 233, 248, 89
2077
- ]
2078
- }
2079
- }
2080
- },
2081
- {
2082
- "name": "token_program",
2083
- "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
2084
- },
2085
- {
2086
- "name": "associated_token_program",
2087
- "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
2088
- },
2089
- {
2090
- "name": "system_program",
2091
- "address": "11111111111111111111111111111111"
2092
- }
2093
- ],
2094
- "args": [
2095
- {
2096
- "name": "args",
2097
- "type": {
2098
- "defined": {
2099
- "name": "WithdrawExtArgs"
2100
- }
2101
- }
2102
- }
2103
- ]
2104
- },
2105
2000
  {
2106
2001
  "name": "withdraw_poseidon",
2107
2002
  "discriminator": [63, 55, 48, 174, 44, 202, 11, 227],
@@ -4286,14 +4181,12 @@
4286
4181
  "type": "pubkey"
4287
4182
  },
4288
4183
  {
4289
- "name": "customer_id",
4290
- "type": "u16"
4184
+ "name": "recipient",
4185
+ "type": "pubkey"
4291
4186
  },
4292
4187
  {
4293
- "name": "key",
4294
- "type": {
4295
- "option": "string"
4296
- }
4188
+ "name": "customer_id",
4189
+ "type": "u16"
4297
4190
  },
4298
4191
  {
4299
4192
  "name": "amount",
@@ -4309,22 +4202,6 @@
4309
4202
  }
4310
4203
  ]
4311
4204
  }
4312
- },
4313
- {
4314
- "name": "WithdrawExtArgs",
4315
- "type": {
4316
- "kind": "struct",
4317
- "fields": [
4318
- {
4319
- "name": "amount",
4320
- "type": "u64"
4321
- },
4322
- {
4323
- "name": "key",
4324
- "type": "string"
4325
- }
4326
- ]
4327
- }
4328
4205
  }
4329
4206
  ]
4330
4207
  }
@@ -16,6 +16,7 @@ export type DepositArgs = {
16
16
  };
17
17
  export type WithdrawArgs = {
18
18
  authority: PublicKey;
19
+ recipient: PublicKey;
19
20
  amount: number;
20
21
  customerId: number;
21
22
  };
@@ -2370,6 +2370,10 @@ export type TriadProtocol = {
2370
2370
  writable: true;
2371
2371
  signer: true;
2372
2372
  },
2373
+ {
2374
+ name: 'recipient';
2375
+ writable: true;
2376
+ },
2373
2377
  {
2374
2378
  name: 'central';
2375
2379
  writable: true;
@@ -2432,7 +2436,7 @@ export type TriadProtocol = {
2432
2436
  seeds: [
2433
2437
  {
2434
2438
  kind: 'account';
2435
- path: 'signer';
2439
+ path: 'recipient';
2436
2440
  },
2437
2441
  {
2438
2442
  kind: 'account';
@@ -2559,155 +2563,6 @@ export type TriadProtocol = {
2559
2563
  }
2560
2564
  ];
2561
2565
  },
2562
- {
2563
- name: 'withdrawExt';
2564
- discriminator: [244, 65, 141, 53, 29, 13, 232, 64];
2565
- accounts: [
2566
- {
2567
- name: 'signer';
2568
- writable: true;
2569
- signer: true;
2570
- },
2571
- {
2572
- name: 'central';
2573
- writable: true;
2574
- pda: {
2575
- seeds: [
2576
- {
2577
- kind: 'const';
2578
- value: [99, 101, 110, 116, 114, 97, 108];
2579
- },
2580
- {
2581
- kind: 'const';
2582
- value: [
2583
- 116,
2584
- 114,
2585
- 105,
2586
- 97,
2587
- 100,
2588
- 109,
2589
- 97,
2590
- 114,
2591
- 107,
2592
- 101,
2593
- 116,
2594
- 115
2595
- ];
2596
- }
2597
- ];
2598
- };
2599
- },
2600
- {
2601
- name: 'customer';
2602
- writable: true;
2603
- pda: {
2604
- seeds: [
2605
- {
2606
- kind: 'const';
2607
- value: [99, 117, 115, 116, 111, 109, 101, 114];
2608
- },
2609
- {
2610
- kind: 'account';
2611
- path: 'predictor.customer_id';
2612
- account: 'predictor';
2613
- }
2614
- ];
2615
- };
2616
- },
2617
- {
2618
- name: 'predictor';
2619
- writable: true;
2620
- },
2621
- {
2622
- name: 'mint';
2623
- writable: true;
2624
- address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
2625
- },
2626
- {
2627
- name: 'extAta';
2628
- writable: true;
2629
- },
2630
- {
2631
- name: 'centralAta';
2632
- writable: true;
2633
- pda: {
2634
- seeds: [
2635
- {
2636
- kind: 'account';
2637
- path: 'central';
2638
- },
2639
- {
2640
- kind: 'account';
2641
- path: 'tokenProgram';
2642
- },
2643
- {
2644
- kind: 'account';
2645
- path: 'mint';
2646
- }
2647
- ];
2648
- program: {
2649
- kind: 'const';
2650
- value: [
2651
- 140,
2652
- 151,
2653
- 37,
2654
- 143,
2655
- 78,
2656
- 36,
2657
- 137,
2658
- 241,
2659
- 187,
2660
- 61,
2661
- 16,
2662
- 41,
2663
- 20,
2664
- 142,
2665
- 13,
2666
- 131,
2667
- 11,
2668
- 90,
2669
- 19,
2670
- 153,
2671
- 218,
2672
- 255,
2673
- 16,
2674
- 132,
2675
- 4,
2676
- 142,
2677
- 123,
2678
- 216,
2679
- 219,
2680
- 233,
2681
- 248,
2682
- 89
2683
- ];
2684
- };
2685
- };
2686
- },
2687
- {
2688
- name: 'tokenProgram';
2689
- address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
2690
- },
2691
- {
2692
- name: 'associatedTokenProgram';
2693
- address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
2694
- },
2695
- {
2696
- name: 'systemProgram';
2697
- address: '11111111111111111111111111111111';
2698
- }
2699
- ];
2700
- args: [
2701
- {
2702
- name: 'args';
2703
- type: {
2704
- defined: {
2705
- name: 'withdrawExtArgs';
2706
- };
2707
- };
2708
- }
2709
- ];
2710
- },
2711
2566
  {
2712
2567
  name: 'withdrawPoseidon';
2713
2568
  discriminator: [63, 55, 48, 174, 44, 202, 11, 227];
@@ -4892,14 +4747,12 @@ export type TriadProtocol = {
4892
4747
  type: 'pubkey';
4893
4748
  },
4894
4749
  {
4895
- name: 'customerId';
4896
- type: 'u16';
4750
+ name: 'recipient';
4751
+ type: 'pubkey';
4897
4752
  },
4898
4753
  {
4899
- name: 'key';
4900
- type: {
4901
- option: 'string';
4902
- };
4754
+ name: 'customerId';
4755
+ type: 'u16';
4903
4756
  },
4904
4757
  {
4905
4758
  name: 'amount';
@@ -4915,22 +4768,6 @@ export type TriadProtocol = {
4915
4768
  }
4916
4769
  ];
4917
4770
  };
4918
- },
4919
- {
4920
- name: 'withdrawExtArgs';
4921
- type: {
4922
- kind: 'struct';
4923
- fields: [
4924
- {
4925
- name: 'amount';
4926
- type: 'u64';
4927
- },
4928
- {
4929
- name: 'key';
4930
- type: 'string';
4931
- }
4932
- ];
4933
- };
4934
4771
  }
4935
4772
  ];
4936
4773
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",