@triadxyz/triad-protocol 4.3.1 → 4.3.3

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, CollectRewardsArgs, Predictor as PredictorType } from './types/predictor';
5
+ import { DepositArgs, WithdrawArgs, CollectRewardsArgs, Predictor as PredictorType } from './types/predictor';
6
6
  export default class Predictor {
7
7
  private program;
8
8
  private rpcOptions;
@@ -48,8 +48,9 @@ export default class Predictor {
48
48
  * @param args.amount - Amount to deposit
49
49
  * @param args.refer - Referral public key
50
50
  * @param args.customerId - Customer ID
51
+ * @param args.depositId - Deposit ID
51
52
  */
52
- deposit({ authority, amount, refer, customerId }: DepositArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
53
+ deposit({ authority, amount, refer, customerId, depositId }: DepositArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
53
54
  /**
54
55
  * Withdraw
55
56
  * @param args.authority - Authority of the withdraw
@@ -58,16 +59,6 @@ export default class Predictor {
58
59
  * @param args.customerId - Customer ID
59
60
  */
60
61
  withdraw({ authority, recipient, amount, customerId }: WithdrawArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
61
- /**
62
- * Deposit Ext
63
- * Idempotent deposit with an optional external deposit record.
64
- * @param args.authority - Authority of the deposit
65
- * @param args.amount - Amount to deposit
66
- * @param args.refer - Referral public key (used only when creating the predictor)
67
- * @param args.customerId - Customer ID
68
- * @param args.depositId - Optional 12-byte deposit ID used as idempotency key
69
- */
70
- depositExt({ authority, amount, refer, customerId, depositId }: DepositExtArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
71
62
  /**
72
63
  * Collect Rewards
73
64
  * Claims accumulated TRIAD token rewards for the predictor.
package/dist/predictor.js CHANGED
@@ -129,8 +129,9 @@ class Predictor {
129
129
  * @param args.amount - Amount to deposit
130
130
  * @param args.refer - Referral public key
131
131
  * @param args.customerId - Customer ID
132
+ * @param args.depositId - Deposit ID
132
133
  */
133
- deposit({ authority, amount, refer, customerId }) {
134
+ deposit({ authority, amount, refer, customerId, depositId }) {
134
135
  return __awaiter(this, void 0, void 0, function* () {
135
136
  const ixs = [];
136
137
  const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
@@ -150,10 +151,18 @@ class Predictor {
150
151
  .instruction());
151
152
  }
152
153
  ixs.push(yield this.program.methods
153
- .deposit(new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)))
154
+ .deposit({
155
+ amount: new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)),
156
+ depositId: depositId
157
+ ? Array.from(Buffer.from(depositId, 'hex'))
158
+ : null
159
+ })
154
160
  .accounts({
155
161
  signer: authority,
156
- predictor: predictorPDA
162
+ predictor: predictorPDA,
163
+ predictorDeposit: depositId
164
+ ? (0, pda_1.getPredictorDepositPDA)(this.program.programId, depositId)
165
+ : null
157
166
  })
158
167
  .instruction());
159
168
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
@@ -183,48 +192,6 @@ class Predictor {
183
192
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
184
193
  });
185
194
  }
186
- /**
187
- * Deposit Ext
188
- * Idempotent deposit with an optional external deposit record.
189
- * @param args.authority - Authority of the deposit
190
- * @param args.amount - Amount to deposit
191
- * @param args.refer - Referral public key (used only when creating the predictor)
192
- * @param args.customerId - Customer ID
193
- * @param args.depositId - Optional 12-byte deposit ID used as idempotency key
194
- */
195
- depositExt({ authority, amount, refer, customerId, depositId }) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- const ixs = [];
198
- const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, authority, customerId);
199
- try {
200
- yield this.program.account.predictor.fetch(predictorPDA);
201
- }
202
- catch (e) {
203
- ixs.push(yield this.program.methods
204
- .createPredictor({
205
- customerId,
206
- refer
207
- })
208
- .accounts({
209
- signer: authority,
210
- payer: this.rpcOptions.payer
211
- })
212
- .instruction());
213
- }
214
- ixs.push(yield this.program.methods
215
- .depositExt({
216
- amount: new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)),
217
- depositId: Array.from(Buffer.from(depositId, 'hex'))
218
- })
219
- .accounts({
220
- signer: authority,
221
- predictor: predictorPDA,
222
- predictorDeposit: (0, pda_1.getPredictorDepositPDA)(this.program.programId, depositId)
223
- })
224
- .instruction());
225
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
226
- });
227
- }
228
195
  /**
229
196
  * Collect Rewards
230
197
  * Claims accumulated TRIAD token rewards for the predictor.
@@ -11,6 +11,7 @@ export type Customer = {
11
11
  payoutFeeBps: number;
12
12
  feeAvailable: number;
13
13
  feeClaimed: number;
14
+ netCash: number;
14
15
  };
15
16
  export type CreateCustomerArgs = {
16
17
  id: number;
@@ -866,135 +866,6 @@
866
866
  {
867
867
  "name": "deposit",
868
868
  "discriminator": [242, 35, 198, 137, 82, 225, 242, 182],
869
- "accounts": [
870
- {
871
- "name": "signer",
872
- "writable": true,
873
- "signer": true
874
- },
875
- {
876
- "name": "central",
877
- "writable": true,
878
- "pda": {
879
- "seeds": [
880
- {
881
- "kind": "const",
882
- "value": [99, 101, 110, 116, 114, 97, 108]
883
- },
884
- {
885
- "kind": "const",
886
- "value": [
887
- 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
888
- ]
889
- }
890
- ]
891
- }
892
- },
893
- {
894
- "name": "customer",
895
- "writable": true,
896
- "pda": {
897
- "seeds": [
898
- {
899
- "kind": "const",
900
- "value": [99, 117, 115, 116, 111, 109, 101, 114]
901
- },
902
- {
903
- "kind": "account",
904
- "path": "predictor.customer_id",
905
- "account": "Predictor"
906
- }
907
- ]
908
- }
909
- },
910
- {
911
- "name": "predictor",
912
- "writable": true
913
- },
914
- {
915
- "name": "mint",
916
- "writable": true,
917
- "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
918
- },
919
- {
920
- "name": "user_ata",
921
- "writable": true,
922
- "pda": {
923
- "seeds": [
924
- {
925
- "kind": "account",
926
- "path": "signer"
927
- },
928
- {
929
- "kind": "account",
930
- "path": "token_program"
931
- },
932
- {
933
- "kind": "account",
934
- "path": "mint"
935
- }
936
- ],
937
- "program": {
938
- "kind": "const",
939
- "value": [
940
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
941
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
942
- 219, 233, 248, 89
943
- ]
944
- }
945
- }
946
- },
947
- {
948
- "name": "central_ata",
949
- "writable": true,
950
- "pda": {
951
- "seeds": [
952
- {
953
- "kind": "account",
954
- "path": "central"
955
- },
956
- {
957
- "kind": "account",
958
- "path": "token_program"
959
- },
960
- {
961
- "kind": "account",
962
- "path": "mint"
963
- }
964
- ],
965
- "program": {
966
- "kind": "const",
967
- "value": [
968
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
969
- 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
970
- 219, 233, 248, 89
971
- ]
972
- }
973
- }
974
- },
975
- {
976
- "name": "token_program",
977
- "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
978
- },
979
- {
980
- "name": "associated_token_program",
981
- "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
982
- },
983
- {
984
- "name": "system_program",
985
- "address": "11111111111111111111111111111111"
986
- }
987
- ],
988
- "args": [
989
- {
990
- "name": "amount",
991
- "type": "u64"
992
- }
993
- ]
994
- },
995
- {
996
- "name": "deposit_ext",
997
- "discriminator": [80, 29, 27, 89, 96, 75, 249, 174],
998
869
  "accounts": [
999
870
  {
1000
871
  "name": "signer",
@@ -1042,7 +913,9 @@
1042
913
  },
1043
914
  {
1044
915
  "name": "predictor_deposit",
1045
- "writable": true
916
+ "writable": true,
917
+ "signer": true,
918
+ "optional": true
1046
919
  },
1047
920
  {
1048
921
  "name": "mint",
@@ -1123,7 +996,7 @@
1123
996
  "name": "args",
1124
997
  "type": {
1125
998
  "defined": {
1126
- "name": "DepositExtArgs"
999
+ "name": "DepositArgs"
1127
1000
  }
1128
1001
  }
1129
1002
  }
@@ -2928,6 +2801,26 @@
2928
2801
  ]
2929
2802
  }
2930
2803
  },
2804
+ {
2805
+ "name": "DepositArgs",
2806
+ "type": {
2807
+ "kind": "struct",
2808
+ "fields": [
2809
+ {
2810
+ "name": "amount",
2811
+ "type": "u64"
2812
+ },
2813
+ {
2814
+ "name": "deposit_id",
2815
+ "type": {
2816
+ "option": {
2817
+ "array": ["u8", 12]
2818
+ }
2819
+ }
2820
+ }
2821
+ ]
2822
+ }
2823
+ },
2931
2824
  {
2932
2825
  "name": "DepositEvent",
2933
2826
  "type": {
@@ -2968,24 +2861,6 @@
2968
2861
  ]
2969
2862
  }
2970
2863
  },
2971
- {
2972
- "name": "DepositExtArgs",
2973
- "type": {
2974
- "kind": "struct",
2975
- "fields": [
2976
- {
2977
- "name": "amount",
2978
- "type": "u64"
2979
- },
2980
- {
2981
- "name": "deposit_id",
2982
- "type": {
2983
- "array": ["u8", 12]
2984
- }
2985
- }
2986
- ]
2987
- }
2988
- },
2989
2864
  {
2990
2865
  "name": "Key",
2991
2866
  "type": {
@@ -13,6 +13,7 @@ export type DepositArgs = {
13
13
  amount: number;
14
14
  refer: PublicKey;
15
15
  customerId: number;
16
+ depositId?: string;
16
17
  };
17
18
  export type WithdrawArgs = {
18
19
  authority: PublicKey;
@@ -27,13 +28,6 @@ export type DepositExtArgs = {
27
28
  customerId: number;
28
29
  depositId: string;
29
30
  };
30
- export type WithdrawExtArgs = {
31
- authority: PublicKey;
32
- amount: number;
33
- customerId: number;
34
- key: string;
35
- extAta: PublicKey;
36
- };
37
31
  export type CollectRewardsArgs = {
38
32
  authority: PublicKey;
39
33
  customerId: number;
@@ -1069,204 +1069,6 @@ export type TriadProtocol = {
1069
1069
  {
1070
1070
  name: 'deposit';
1071
1071
  discriminator: [242, 35, 198, 137, 82, 225, 242, 182];
1072
- accounts: [
1073
- {
1074
- name: 'signer';
1075
- writable: true;
1076
- signer: true;
1077
- },
1078
- {
1079
- name: 'central';
1080
- writable: true;
1081
- pda: {
1082
- seeds: [
1083
- {
1084
- kind: 'const';
1085
- value: [99, 101, 110, 116, 114, 97, 108];
1086
- },
1087
- {
1088
- kind: 'const';
1089
- value: [
1090
- 116,
1091
- 114,
1092
- 105,
1093
- 97,
1094
- 100,
1095
- 109,
1096
- 97,
1097
- 114,
1098
- 107,
1099
- 101,
1100
- 116,
1101
- 115
1102
- ];
1103
- }
1104
- ];
1105
- };
1106
- },
1107
- {
1108
- name: 'customer';
1109
- writable: true;
1110
- pda: {
1111
- seeds: [
1112
- {
1113
- kind: 'const';
1114
- value: [99, 117, 115, 116, 111, 109, 101, 114];
1115
- },
1116
- {
1117
- kind: 'account';
1118
- path: 'predictor.customer_id';
1119
- account: 'predictor';
1120
- }
1121
- ];
1122
- };
1123
- },
1124
- {
1125
- name: 'predictor';
1126
- writable: true;
1127
- },
1128
- {
1129
- name: 'mint';
1130
- writable: true;
1131
- address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
1132
- },
1133
- {
1134
- name: 'userAta';
1135
- writable: true;
1136
- pda: {
1137
- seeds: [
1138
- {
1139
- kind: 'account';
1140
- path: 'signer';
1141
- },
1142
- {
1143
- kind: 'account';
1144
- path: 'tokenProgram';
1145
- },
1146
- {
1147
- kind: 'account';
1148
- path: 'mint';
1149
- }
1150
- ];
1151
- program: {
1152
- kind: 'const';
1153
- value: [
1154
- 140,
1155
- 151,
1156
- 37,
1157
- 143,
1158
- 78,
1159
- 36,
1160
- 137,
1161
- 241,
1162
- 187,
1163
- 61,
1164
- 16,
1165
- 41,
1166
- 20,
1167
- 142,
1168
- 13,
1169
- 131,
1170
- 11,
1171
- 90,
1172
- 19,
1173
- 153,
1174
- 218,
1175
- 255,
1176
- 16,
1177
- 132,
1178
- 4,
1179
- 142,
1180
- 123,
1181
- 216,
1182
- 219,
1183
- 233,
1184
- 248,
1185
- 89
1186
- ];
1187
- };
1188
- };
1189
- },
1190
- {
1191
- name: 'centralAta';
1192
- writable: true;
1193
- pda: {
1194
- seeds: [
1195
- {
1196
- kind: 'account';
1197
- path: 'central';
1198
- },
1199
- {
1200
- kind: 'account';
1201
- path: 'tokenProgram';
1202
- },
1203
- {
1204
- kind: 'account';
1205
- path: 'mint';
1206
- }
1207
- ];
1208
- program: {
1209
- kind: 'const';
1210
- value: [
1211
- 140,
1212
- 151,
1213
- 37,
1214
- 143,
1215
- 78,
1216
- 36,
1217
- 137,
1218
- 241,
1219
- 187,
1220
- 61,
1221
- 16,
1222
- 41,
1223
- 20,
1224
- 142,
1225
- 13,
1226
- 131,
1227
- 11,
1228
- 90,
1229
- 19,
1230
- 153,
1231
- 218,
1232
- 255,
1233
- 16,
1234
- 132,
1235
- 4,
1236
- 142,
1237
- 123,
1238
- 216,
1239
- 219,
1240
- 233,
1241
- 248,
1242
- 89
1243
- ];
1244
- };
1245
- };
1246
- },
1247
- {
1248
- name: 'tokenProgram';
1249
- address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
1250
- },
1251
- {
1252
- name: 'associatedTokenProgram';
1253
- address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
1254
- },
1255
- {
1256
- name: 'systemProgram';
1257
- address: '11111111111111111111111111111111';
1258
- }
1259
- ];
1260
- args: [
1261
- {
1262
- name: 'amount';
1263
- type: 'u64';
1264
- }
1265
- ];
1266
- },
1267
- {
1268
- name: 'depositExt';
1269
- discriminator: [80, 29, 27, 89, 96, 75, 249, 174];
1270
1072
  accounts: [
1271
1073
  {
1272
1074
  name: 'signer';
@@ -1326,6 +1128,8 @@ export type TriadProtocol = {
1326
1128
  {
1327
1129
  name: 'predictorDeposit';
1328
1130
  writable: true;
1131
+ signer: true;
1132
+ optional: true;
1329
1133
  },
1330
1134
  {
1331
1135
  name: 'mint';
@@ -1464,7 +1268,7 @@ export type TriadProtocol = {
1464
1268
  name: 'args';
1465
1269
  type: {
1466
1270
  defined: {
1467
- name: 'depositExtArgs';
1271
+ name: 'depositArgs';
1468
1272
  };
1469
1273
  };
1470
1274
  }
@@ -3494,6 +3298,26 @@ export type TriadProtocol = {
3494
3298
  ];
3495
3299
  };
3496
3300
  },
3301
+ {
3302
+ name: 'depositArgs';
3303
+ type: {
3304
+ kind: 'struct';
3305
+ fields: [
3306
+ {
3307
+ name: 'amount';
3308
+ type: 'u64';
3309
+ },
3310
+ {
3311
+ name: 'depositId';
3312
+ type: {
3313
+ option: {
3314
+ array: ['u8', 12];
3315
+ };
3316
+ };
3317
+ }
3318
+ ];
3319
+ };
3320
+ },
3497
3321
  {
3498
3322
  name: 'depositEvent';
3499
3323
  type: {
@@ -3534,24 +3358,6 @@ export type TriadProtocol = {
3534
3358
  ];
3535
3359
  };
3536
3360
  },
3537
- {
3538
- name: 'depositExtArgs';
3539
- type: {
3540
- kind: 'struct';
3541
- fields: [
3542
- {
3543
- name: 'amount';
3544
- type: 'u64';
3545
- },
3546
- {
3547
- name: 'depositId';
3548
- type: {
3549
- array: ['u8', 12];
3550
- };
3551
- }
3552
- ];
3553
- };
3554
- },
3555
3361
  {
3556
3362
  name: 'key';
3557
3363
  type: {
@@ -155,7 +155,8 @@ const formatCustomer = (account, publicKey) => {
155
155
  isVerified: account.isVerified,
156
156
  address: publicKey.toString(),
157
157
  feeAvailable: account.feeAvailable.toNumber() / Math.pow(10, 6),
158
- feeClaimed: account.feeClaimed.toNumber() / Math.pow(10, 6)
158
+ feeClaimed: account.feeClaimed.toNumber() / Math.pow(10, 6),
159
+ netCash: account.netCash.toNumber() / Math.pow(10, 6)
159
160
  };
160
161
  };
161
162
  exports.formatCustomer = formatCustomer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",