@triadxyz/triad-protocol 4.0.0 → 4.0.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.
package/dist/index.d.ts CHANGED
@@ -246,8 +246,20 @@ export default class TriadProtocol {
246
246
  * @param customerId - Customer ID
247
247
  * @param feeBps - Fee in basis points
248
248
  */
249
- updateCustomerFee({ customerId, feeBps }: {
249
+ updateCustomerFee({ customerId, feeBps, feeRecipient }: {
250
250
  customerId: number;
251
251
  feeBps: number;
252
+ feeRecipient: PublicKey | null;
253
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
254
+ deposit({ authority, amount, refer, customer }: {
255
+ authority: PublicKey;
256
+ amount: number;
257
+ refer?: PublicKey;
258
+ customer?: number;
259
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
260
+ withdraw({ authority, amount, customer }: {
261
+ authority: PublicKey;
262
+ amount: number;
263
+ customer?: number;
252
264
  }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
253
265
  }
package/dist/index.js CHANGED
@@ -829,11 +829,11 @@ class TriadProtocol {
829
829
  * @param customerId - Customer ID
830
830
  * @param feeBps - Fee in basis points
831
831
  */
832
- updateCustomerFee({ customerId, feeBps }) {
832
+ updateCustomerFee({ customerId, feeBps, feeRecipient }) {
833
833
  return __awaiter(this, void 0, void 0, function* () {
834
834
  const ixs = [
835
835
  yield this.program.methods
836
- .updateCustomerFee({ id: customerId, feeBps })
836
+ .updateCustomerFee({ id: customerId, feeBps, feeRecipient })
837
837
  .accounts({
838
838
  signer: this.program.provider.publicKey
839
839
  })
@@ -842,5 +842,50 @@ class TriadProtocol {
842
842
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
843
843
  });
844
844
  }
845
+ deposit({ authority, amount, refer = new web3_js_1.PublicKey('EJL7PeGFTAxMY67XrAJfHM8A2euwcjcBAmK94sew61rG'), customer = 7 }) {
846
+ return __awaiter(this, void 0, void 0, function* () {
847
+ const ixs = [];
848
+ const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customer);
849
+ try {
850
+ yield this.program.account.predictor.fetch(predictorPDA);
851
+ }
852
+ catch (e) {
853
+ ixs.push(yield this.program.methods
854
+ .createPredictor({
855
+ customer,
856
+ refer
857
+ })
858
+ .accounts({
859
+ signer: authority,
860
+ payer: this.rpcOptions.payer
861
+ })
862
+ .instruction());
863
+ }
864
+ ixs.push(yield this.program.methods
865
+ .deposit(new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)))
866
+ .accounts({
867
+ signer: authority,
868
+ payer: this.rpcOptions.payer,
869
+ predictor: predictorPDA
870
+ })
871
+ .instruction());
872
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
873
+ });
874
+ }
875
+ withdraw({ authority, amount, customer = 7 }) {
876
+ return __awaiter(this, void 0, void 0, function* () {
877
+ const ixs = [];
878
+ const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customer);
879
+ ixs.push(yield this.program.methods
880
+ .withdraw(new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)))
881
+ .accounts({
882
+ signer: authority,
883
+ payer: this.rpcOptions.payer,
884
+ predictor: predictorPDA
885
+ })
886
+ .instruction());
887
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
888
+ });
889
+ }
845
890
  }
846
891
  exports.default = TriadProtocol;
@@ -596,90 +596,6 @@
596
596
  ],
597
597
  "args": []
598
598
  },
599
- {
600
- "name": "create_central",
601
- "discriminator": [32, 102, 101, 13, 255, 84, 147, 240],
602
- "accounts": [
603
- {
604
- "name": "signer",
605
- "writable": true,
606
- "signer": true
607
- },
608
- {
609
- "name": "central",
610
- "writable": true,
611
- "pda": {
612
- "seeds": [
613
- {
614
- "kind": "const",
615
- "value": [99, 101, 110, 116, 114, 97, 108]
616
- },
617
- {
618
- "kind": "const",
619
- "value": [
620
- 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
621
- ]
622
- }
623
- ]
624
- }
625
- },
626
- {
627
- "name": "mint",
628
- "writable": true,
629
- "pda": {
630
- "seeds": [
631
- {
632
- "kind": "const",
633
- "value": [
634
- 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
635
- ]
636
- }
637
- ]
638
- }
639
- },
640
- {
641
- "name": "user_ata",
642
- "writable": true,
643
- "pda": {
644
- "seeds": [
645
- {
646
- "kind": "account",
647
- "path": "central"
648
- },
649
- {
650
- "kind": "account",
651
- "path": "token_program"
652
- },
653
- {
654
- "kind": "account",
655
- "path": "mint"
656
- }
657
- ],
658
- "program": {
659
- "kind": "const",
660
- "value": [
661
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
662
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
663
- 219, 233, 248, 89
664
- ]
665
- }
666
- }
667
- },
668
- {
669
- "name": "token_program",
670
- "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
671
- },
672
- {
673
- "name": "associated_token_program",
674
- "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
675
- },
676
- {
677
- "name": "system_program",
678
- "address": "11111111111111111111111111111111"
679
- }
680
- ],
681
- "args": []
682
- },
683
599
  {
684
600
  "name": "create_customer",
685
601
  "discriminator": [120, 122, 113, 216, 95, 207, 252, 147],
@@ -952,6 +868,156 @@
952
868
  }
953
869
  ]
954
870
  },
871
+ {
872
+ "name": "deposit",
873
+ "discriminator": [242, 35, 198, 137, 82, 225, 242, 182],
874
+ "accounts": [
875
+ {
876
+ "name": "signer",
877
+ "writable": true,
878
+ "signer": true
879
+ },
880
+ {
881
+ "name": "payer",
882
+ "writable": true,
883
+ "signer": true
884
+ },
885
+ {
886
+ "name": "central",
887
+ "writable": true,
888
+ "pda": {
889
+ "seeds": [
890
+ {
891
+ "kind": "const",
892
+ "value": [99, 101, 110, 116, 114, 97, 108]
893
+ },
894
+ {
895
+ "kind": "const",
896
+ "value": [
897
+ 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
898
+ ]
899
+ }
900
+ ]
901
+ }
902
+ },
903
+ {
904
+ "name": "predictor",
905
+ "writable": true
906
+ },
907
+ {
908
+ "name": "usdc_mint",
909
+ "writable": true,
910
+ "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
911
+ },
912
+ {
913
+ "name": "usdtm_mint",
914
+ "writable": true,
915
+ "address": "75wzVU6j9U6oZVJjQYLtiN7Z5Ah97it1UyWZN29HgE4m"
916
+ },
917
+ {
918
+ "name": "user_ata",
919
+ "writable": true,
920
+ "pda": {
921
+ "seeds": [
922
+ {
923
+ "kind": "account",
924
+ "path": "signer"
925
+ },
926
+ {
927
+ "kind": "account",
928
+ "path": "token_program"
929
+ },
930
+ {
931
+ "kind": "account",
932
+ "path": "usdc_mint"
933
+ }
934
+ ],
935
+ "program": {
936
+ "kind": "const",
937
+ "value": [
938
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
939
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
940
+ 219, 233, 248, 89
941
+ ]
942
+ }
943
+ }
944
+ },
945
+ {
946
+ "name": "predictor_ata",
947
+ "writable": true,
948
+ "pda": {
949
+ "seeds": [
950
+ {
951
+ "kind": "account",
952
+ "path": "predictor"
953
+ },
954
+ {
955
+ "kind": "account",
956
+ "path": "token_program"
957
+ },
958
+ {
959
+ "kind": "account",
960
+ "path": "usdtm_mint"
961
+ }
962
+ ],
963
+ "program": {
964
+ "kind": "const",
965
+ "value": [
966
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
967
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
968
+ 219, 233, 248, 89
969
+ ]
970
+ }
971
+ }
972
+ },
973
+ {
974
+ "name": "central_ata",
975
+ "writable": true,
976
+ "pda": {
977
+ "seeds": [
978
+ {
979
+ "kind": "account",
980
+ "path": "central"
981
+ },
982
+ {
983
+ "kind": "account",
984
+ "path": "token_program"
985
+ },
986
+ {
987
+ "kind": "account",
988
+ "path": "usdc_mint"
989
+ }
990
+ ],
991
+ "program": {
992
+ "kind": "const",
993
+ "value": [
994
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
995
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
996
+ 219, 233, 248, 89
997
+ ]
998
+ }
999
+ }
1000
+ },
1001
+ {
1002
+ "name": "token_program",
1003
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1004
+ },
1005
+ {
1006
+ "name": "associated_token_program",
1007
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
1008
+ },
1009
+ {
1010
+ "name": "system_program",
1011
+ "address": "11111111111111111111111111111111"
1012
+ }
1013
+ ],
1014
+ "args": [
1015
+ {
1016
+ "name": "amount",
1017
+ "type": "u64"
1018
+ }
1019
+ ]
1020
+ },
955
1021
  {
956
1022
  "name": "market_ask_order",
957
1023
  "discriminator": [189, 66, 162, 254, 3, 85, 152, 54],
@@ -1908,26 +1974,6 @@
1908
1974
  }
1909
1975
  ]
1910
1976
  },
1911
- {
1912
- "name": "update_market_fee",
1913
- "discriminator": [129, 5, 190, 195, 114, 138, 95, 93],
1914
- "accounts": [
1915
- {
1916
- "name": "signer",
1917
- "writable": true,
1918
- "signer": true
1919
- },
1920
- {
1921
- "name": "market",
1922
- "writable": true
1923
- },
1924
- {
1925
- "name": "system_program",
1926
- "address": "11111111111111111111111111111111"
1927
- }
1928
- ],
1929
- "args": []
1930
- },
1931
1977
  {
1932
1978
  "name": "update_market_payout",
1933
1979
  "discriminator": [10, 209, 221, 170, 158, 103, 104, 57],
@@ -2073,6 +2119,156 @@
2073
2119
  }
2074
2120
  ]
2075
2121
  },
2122
+ {
2123
+ "name": "withdraw",
2124
+ "discriminator": [183, 18, 70, 156, 148, 109, 161, 34],
2125
+ "accounts": [
2126
+ {
2127
+ "name": "signer",
2128
+ "writable": true,
2129
+ "signer": true
2130
+ },
2131
+ {
2132
+ "name": "payer",
2133
+ "writable": true,
2134
+ "signer": true
2135
+ },
2136
+ {
2137
+ "name": "central",
2138
+ "writable": true,
2139
+ "pda": {
2140
+ "seeds": [
2141
+ {
2142
+ "kind": "const",
2143
+ "value": [99, 101, 110, 116, 114, 97, 108]
2144
+ },
2145
+ {
2146
+ "kind": "const",
2147
+ "value": [
2148
+ 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
2149
+ ]
2150
+ }
2151
+ ]
2152
+ }
2153
+ },
2154
+ {
2155
+ "name": "predictor",
2156
+ "writable": true
2157
+ },
2158
+ {
2159
+ "name": "usdc_mint",
2160
+ "writable": true,
2161
+ "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
2162
+ },
2163
+ {
2164
+ "name": "usdtm_mint",
2165
+ "writable": true,
2166
+ "address": "75wzVU6j9U6oZVJjQYLtiN7Z5Ah97it1UyWZN29HgE4m"
2167
+ },
2168
+ {
2169
+ "name": "user_ata",
2170
+ "writable": true,
2171
+ "pda": {
2172
+ "seeds": [
2173
+ {
2174
+ "kind": "account",
2175
+ "path": "signer"
2176
+ },
2177
+ {
2178
+ "kind": "account",
2179
+ "path": "token_program"
2180
+ },
2181
+ {
2182
+ "kind": "account",
2183
+ "path": "usdc_mint"
2184
+ }
2185
+ ],
2186
+ "program": {
2187
+ "kind": "const",
2188
+ "value": [
2189
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
2190
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
2191
+ 219, 233, 248, 89
2192
+ ]
2193
+ }
2194
+ }
2195
+ },
2196
+ {
2197
+ "name": "predictor_ata",
2198
+ "writable": true,
2199
+ "pda": {
2200
+ "seeds": [
2201
+ {
2202
+ "kind": "account",
2203
+ "path": "predictor"
2204
+ },
2205
+ {
2206
+ "kind": "account",
2207
+ "path": "token_program"
2208
+ },
2209
+ {
2210
+ "kind": "account",
2211
+ "path": "usdtm_mint"
2212
+ }
2213
+ ],
2214
+ "program": {
2215
+ "kind": "const",
2216
+ "value": [
2217
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
2218
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
2219
+ 219, 233, 248, 89
2220
+ ]
2221
+ }
2222
+ }
2223
+ },
2224
+ {
2225
+ "name": "central_ata",
2226
+ "writable": true,
2227
+ "pda": {
2228
+ "seeds": [
2229
+ {
2230
+ "kind": "account",
2231
+ "path": "central"
2232
+ },
2233
+ {
2234
+ "kind": "account",
2235
+ "path": "token_program"
2236
+ },
2237
+ {
2238
+ "kind": "account",
2239
+ "path": "usdc_mint"
2240
+ }
2241
+ ],
2242
+ "program": {
2243
+ "kind": "const",
2244
+ "value": [
2245
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
2246
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
2247
+ 219, 233, 248, 89
2248
+ ]
2249
+ }
2250
+ }
2251
+ },
2252
+ {
2253
+ "name": "token_program",
2254
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
2255
+ },
2256
+ {
2257
+ "name": "associated_token_program",
2258
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
2259
+ },
2260
+ {
2261
+ "name": "system_program",
2262
+ "address": "11111111111111111111111111111111"
2263
+ }
2264
+ ],
2265
+ "args": [
2266
+ {
2267
+ "name": "amount",
2268
+ "type": "u64"
2269
+ }
2270
+ ]
2271
+ },
2076
2272
  {
2077
2273
  "name": "withdraw_poseidon",
2078
2274
  "discriminator": [63, 55, 48, 174, 44, 202, 11, 227],
@@ -2189,6 +2385,10 @@
2189
2385
  "name": "CollectMarketFeeEvent",
2190
2386
  "discriminator": [210, 147, 203, 216, 158, 111, 59, 143]
2191
2387
  },
2388
+ {
2389
+ "name": "DepositEvent",
2390
+ "discriminator": [120, 248, 61, 83, 31, 142, 107, 144]
2391
+ },
2192
2392
  {
2193
2393
  "name": "MarketEvent",
2194
2394
  "discriminator": [212, 67, 145, 23, 58, 104, 52, 83]
@@ -2208,6 +2408,10 @@
2208
2408
  {
2209
2409
  "name": "StakeRewardsEvent",
2210
2410
  "discriminator": [23, 37, 255, 130, 102, 26, 140, 94]
2411
+ },
2412
+ {
2413
+ "name": "WithdrawEvent",
2414
+ "discriminator": [22, 9, 133, 26, 160, 44, 71, 192]
2211
2415
  }
2212
2416
  ],
2213
2417
  "errors": [
@@ -2897,10 +3101,6 @@
2897
3101
  "type": {
2898
3102
  "kind": "struct",
2899
3103
  "fields": [
2900
- {
2901
- "name": "authority",
2902
- "type": "pubkey"
2903
- },
2904
3104
  {
2905
3105
  "name": "refer",
2906
3106
  "type": "pubkey"
@@ -2955,6 +3155,34 @@
2955
3155
  ]
2956
3156
  }
2957
3157
  },
3158
+ {
3159
+ "name": "DepositEvent",
3160
+ "type": {
3161
+ "kind": "struct",
3162
+ "fields": [
3163
+ {
3164
+ "name": "authority",
3165
+ "type": "pubkey"
3166
+ },
3167
+ {
3168
+ "name": "predictor",
3169
+ "type": "pubkey"
3170
+ },
3171
+ {
3172
+ "name": "amount",
3173
+ "type": "u64"
3174
+ },
3175
+ {
3176
+ "name": "mint",
3177
+ "type": "pubkey"
3178
+ },
3179
+ {
3180
+ "name": "timestamp",
3181
+ "type": "i64"
3182
+ }
3183
+ ]
3184
+ }
3185
+ },
2958
3186
  {
2959
3187
  "name": "Key",
2960
3188
  "type": {
@@ -3661,10 +3889,14 @@
3661
3889
  "name": "customer",
3662
3890
  "type": "u16"
3663
3891
  },
3892
+ {
3893
+ "name": "bump",
3894
+ "type": "u8"
3895
+ },
3664
3896
  {
3665
3897
  "name": "padding",
3666
3898
  "type": {
3667
- "array": ["u8", 64]
3899
+ "array": ["u8", 63]
3668
3900
  }
3669
3901
  }
3670
3902
  ]
@@ -3934,6 +4166,12 @@
3934
4166
  "name": "id",
3935
4167
  "type": "u16"
3936
4168
  },
4169
+ {
4170
+ "name": "fee_recipient",
4171
+ "type": {
4172
+ "option": "pubkey"
4173
+ }
4174
+ },
3937
4175
  {
3938
4176
  "name": "fee_bps",
3939
4177
  "type": "u16"
@@ -3960,6 +4198,34 @@
3960
4198
  }
3961
4199
  ]
3962
4200
  }
4201
+ },
4202
+ {
4203
+ "name": "WithdrawEvent",
4204
+ "type": {
4205
+ "kind": "struct",
4206
+ "fields": [
4207
+ {
4208
+ "name": "authority",
4209
+ "type": "pubkey"
4210
+ },
4211
+ {
4212
+ "name": "predictor",
4213
+ "type": "pubkey"
4214
+ },
4215
+ {
4216
+ "name": "amount",
4217
+ "type": "u64"
4218
+ },
4219
+ {
4220
+ "name": "mint",
4221
+ "type": "pubkey"
4222
+ },
4223
+ {
4224
+ "name": "timestamp",
4225
+ "type": "i64"
4226
+ }
4227
+ ]
4228
+ }
3963
4229
  }
3964
4230
  ]
3965
4231
  }