@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 +9 -14
- package/dist/trade.js +18 -22
- package/dist/types/idl_triad_protocol.json +62 -369
- package/dist/types/trade.d.ts +22 -0
- package/dist/types/triad_protocol.d.ts +62 -454
- package/dist/utils/helpers.d.ts +3 -2
- package/dist/utils/helpers.js +26 -31
- package/dist/utils/pda/trade.d.ts +1 -0
- package/dist/utils/pda/trade.js +9 -1
- package/package.json +1 -1
- package/dist/local-test.d.ts +0 -1
- package/dist/local-test.js +0 -619
|
@@ -689,6 +689,54 @@ export type TriadProtocol = {
|
|
|
689
689
|
];
|
|
690
690
|
args: [];
|
|
691
691
|
},
|
|
692
|
+
{
|
|
693
|
+
name: 'createSubUserTrade';
|
|
694
|
+
discriminator: [77, 201, 111, 73, 47, 229, 244, 161];
|
|
695
|
+
accounts: [
|
|
696
|
+
{
|
|
697
|
+
name: 'signer';
|
|
698
|
+
writable: true;
|
|
699
|
+
signer: true;
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
name: 'userTrade';
|
|
703
|
+
writable: true;
|
|
704
|
+
pda: {
|
|
705
|
+
seeds: [
|
|
706
|
+
{
|
|
707
|
+
kind: 'const';
|
|
708
|
+
value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
kind: 'account';
|
|
712
|
+
path: 'signer';
|
|
713
|
+
}
|
|
714
|
+
];
|
|
715
|
+
};
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
name: 'subUserTrade';
|
|
719
|
+
writable: true;
|
|
720
|
+
pda: {
|
|
721
|
+
seeds: [
|
|
722
|
+
{
|
|
723
|
+
kind: 'const';
|
|
724
|
+
value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
kind: 'arg';
|
|
728
|
+
path: 'subUserKey';
|
|
729
|
+
}
|
|
730
|
+
];
|
|
731
|
+
};
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
name: 'systemProgram';
|
|
735
|
+
address: '11111111111111111111111111111111';
|
|
736
|
+
}
|
|
737
|
+
];
|
|
738
|
+
args: [];
|
|
739
|
+
},
|
|
692
740
|
{
|
|
693
741
|
name: 'createUserTrade';
|
|
694
742
|
discriminator: [232, 235, 58, 194, 135, 248, 153, 1];
|
|
@@ -1232,227 +1280,6 @@ export type TriadProtocol = {
|
|
|
1232
1280
|
}
|
|
1233
1281
|
];
|
|
1234
1282
|
},
|
|
1235
|
-
{
|
|
1236
|
-
name: 'settleOrder';
|
|
1237
|
-
discriminator: [80, 74, 204, 34, 12, 183, 66, 66];
|
|
1238
|
-
accounts: [
|
|
1239
|
-
{
|
|
1240
|
-
name: 'signer';
|
|
1241
|
-
writable: true;
|
|
1242
|
-
signer: true;
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
name: 'squads';
|
|
1246
|
-
writable: true;
|
|
1247
|
-
address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
|
|
1248
|
-
},
|
|
1249
|
-
{
|
|
1250
|
-
name: 'user';
|
|
1251
|
-
writable: true;
|
|
1252
|
-
},
|
|
1253
|
-
{
|
|
1254
|
-
name: 'userTrade';
|
|
1255
|
-
writable: true;
|
|
1256
|
-
},
|
|
1257
|
-
{
|
|
1258
|
-
name: 'market';
|
|
1259
|
-
writable: true;
|
|
1260
|
-
},
|
|
1261
|
-
{
|
|
1262
|
-
name: 'mint';
|
|
1263
|
-
writable: true;
|
|
1264
|
-
},
|
|
1265
|
-
{
|
|
1266
|
-
name: 'userAta';
|
|
1267
|
-
writable: true;
|
|
1268
|
-
pda: {
|
|
1269
|
-
seeds: [
|
|
1270
|
-
{
|
|
1271
|
-
kind: 'account';
|
|
1272
|
-
path: 'user';
|
|
1273
|
-
},
|
|
1274
|
-
{
|
|
1275
|
-
kind: 'account';
|
|
1276
|
-
path: 'tokenProgram';
|
|
1277
|
-
},
|
|
1278
|
-
{
|
|
1279
|
-
kind: 'account';
|
|
1280
|
-
path: 'mint';
|
|
1281
|
-
}
|
|
1282
|
-
];
|
|
1283
|
-
program: {
|
|
1284
|
-
kind: 'const';
|
|
1285
|
-
value: [
|
|
1286
|
-
140,
|
|
1287
|
-
151,
|
|
1288
|
-
37,
|
|
1289
|
-
143,
|
|
1290
|
-
78,
|
|
1291
|
-
36,
|
|
1292
|
-
137,
|
|
1293
|
-
241,
|
|
1294
|
-
187,
|
|
1295
|
-
61,
|
|
1296
|
-
16,
|
|
1297
|
-
41,
|
|
1298
|
-
20,
|
|
1299
|
-
142,
|
|
1300
|
-
13,
|
|
1301
|
-
131,
|
|
1302
|
-
11,
|
|
1303
|
-
90,
|
|
1304
|
-
19,
|
|
1305
|
-
153,
|
|
1306
|
-
218,
|
|
1307
|
-
255,
|
|
1308
|
-
16,
|
|
1309
|
-
132,
|
|
1310
|
-
4,
|
|
1311
|
-
142,
|
|
1312
|
-
123,
|
|
1313
|
-
216,
|
|
1314
|
-
219,
|
|
1315
|
-
233,
|
|
1316
|
-
248,
|
|
1317
|
-
89
|
|
1318
|
-
];
|
|
1319
|
-
};
|
|
1320
|
-
};
|
|
1321
|
-
},
|
|
1322
|
-
{
|
|
1323
|
-
name: 'marketAta';
|
|
1324
|
-
writable: true;
|
|
1325
|
-
pda: {
|
|
1326
|
-
seeds: [
|
|
1327
|
-
{
|
|
1328
|
-
kind: 'account';
|
|
1329
|
-
path: 'market';
|
|
1330
|
-
},
|
|
1331
|
-
{
|
|
1332
|
-
kind: 'account';
|
|
1333
|
-
path: 'tokenProgram';
|
|
1334
|
-
},
|
|
1335
|
-
{
|
|
1336
|
-
kind: 'account';
|
|
1337
|
-
path: 'mint';
|
|
1338
|
-
}
|
|
1339
|
-
];
|
|
1340
|
-
program: {
|
|
1341
|
-
kind: 'const';
|
|
1342
|
-
value: [
|
|
1343
|
-
140,
|
|
1344
|
-
151,
|
|
1345
|
-
37,
|
|
1346
|
-
143,
|
|
1347
|
-
78,
|
|
1348
|
-
36,
|
|
1349
|
-
137,
|
|
1350
|
-
241,
|
|
1351
|
-
187,
|
|
1352
|
-
61,
|
|
1353
|
-
16,
|
|
1354
|
-
41,
|
|
1355
|
-
20,
|
|
1356
|
-
142,
|
|
1357
|
-
13,
|
|
1358
|
-
131,
|
|
1359
|
-
11,
|
|
1360
|
-
90,
|
|
1361
|
-
19,
|
|
1362
|
-
153,
|
|
1363
|
-
218,
|
|
1364
|
-
255,
|
|
1365
|
-
16,
|
|
1366
|
-
132,
|
|
1367
|
-
4,
|
|
1368
|
-
142,
|
|
1369
|
-
123,
|
|
1370
|
-
216,
|
|
1371
|
-
219,
|
|
1372
|
-
233,
|
|
1373
|
-
248,
|
|
1374
|
-
89
|
|
1375
|
-
];
|
|
1376
|
-
};
|
|
1377
|
-
};
|
|
1378
|
-
},
|
|
1379
|
-
{
|
|
1380
|
-
name: 'squadsAta';
|
|
1381
|
-
writable: true;
|
|
1382
|
-
pda: {
|
|
1383
|
-
seeds: [
|
|
1384
|
-
{
|
|
1385
|
-
kind: 'account';
|
|
1386
|
-
path: 'squads';
|
|
1387
|
-
},
|
|
1388
|
-
{
|
|
1389
|
-
kind: 'account';
|
|
1390
|
-
path: 'tokenProgram';
|
|
1391
|
-
},
|
|
1392
|
-
{
|
|
1393
|
-
kind: 'account';
|
|
1394
|
-
path: 'mint';
|
|
1395
|
-
}
|
|
1396
|
-
];
|
|
1397
|
-
program: {
|
|
1398
|
-
kind: 'const';
|
|
1399
|
-
value: [
|
|
1400
|
-
140,
|
|
1401
|
-
151,
|
|
1402
|
-
37,
|
|
1403
|
-
143,
|
|
1404
|
-
78,
|
|
1405
|
-
36,
|
|
1406
|
-
137,
|
|
1407
|
-
241,
|
|
1408
|
-
187,
|
|
1409
|
-
61,
|
|
1410
|
-
16,
|
|
1411
|
-
41,
|
|
1412
|
-
20,
|
|
1413
|
-
142,
|
|
1414
|
-
13,
|
|
1415
|
-
131,
|
|
1416
|
-
11,
|
|
1417
|
-
90,
|
|
1418
|
-
19,
|
|
1419
|
-
153,
|
|
1420
|
-
218,
|
|
1421
|
-
255,
|
|
1422
|
-
16,
|
|
1423
|
-
132,
|
|
1424
|
-
4,
|
|
1425
|
-
142,
|
|
1426
|
-
123,
|
|
1427
|
-
216,
|
|
1428
|
-
219,
|
|
1429
|
-
233,
|
|
1430
|
-
248,
|
|
1431
|
-
89
|
|
1432
|
-
];
|
|
1433
|
-
};
|
|
1434
|
-
};
|
|
1435
|
-
},
|
|
1436
|
-
{
|
|
1437
|
-
name: 'tokenProgram';
|
|
1438
|
-
address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
|
|
1439
|
-
},
|
|
1440
|
-
{
|
|
1441
|
-
name: 'associatedTokenProgram';
|
|
1442
|
-
address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
1443
|
-
},
|
|
1444
|
-
{
|
|
1445
|
-
name: 'systemProgram';
|
|
1446
|
-
address: '11111111111111111111111111111111';
|
|
1447
|
-
}
|
|
1448
|
-
];
|
|
1449
|
-
args: [
|
|
1450
|
-
{
|
|
1451
|
-
name: 'orderId';
|
|
1452
|
-
type: 'u64';
|
|
1453
|
-
}
|
|
1454
|
-
];
|
|
1455
|
-
},
|
|
1456
1283
|
{
|
|
1457
1284
|
name: 'stakeToken';
|
|
1458
1285
|
discriminator: [191, 127, 193, 101, 37, 96, 87, 211];
|
|
@@ -2069,10 +1896,6 @@ export type TriadProtocol = {
|
|
|
2069
1896
|
name: 'collection';
|
|
2070
1897
|
discriminator: [48, 160, 232, 205, 191, 207, 26, 141];
|
|
2071
1898
|
},
|
|
2072
|
-
{
|
|
2073
|
-
name: 'market';
|
|
2074
|
-
discriminator: [219, 190, 213, 55, 0, 227, 198, 154];
|
|
2075
|
-
},
|
|
2076
1899
|
{
|
|
2077
1900
|
name: 'marketV2';
|
|
2078
1901
|
discriminator: [27, 60, 50, 75, 191, 193, 86, 227];
|
|
@@ -2403,155 +2226,6 @@ export type TriadProtocol = {
|
|
|
2403
2226
|
];
|
|
2404
2227
|
};
|
|
2405
2228
|
},
|
|
2406
|
-
{
|
|
2407
|
-
name: 'market';
|
|
2408
|
-
type: {
|
|
2409
|
-
kind: 'struct';
|
|
2410
|
-
fields: [
|
|
2411
|
-
{
|
|
2412
|
-
name: 'bump';
|
|
2413
|
-
type: 'u8';
|
|
2414
|
-
},
|
|
2415
|
-
{
|
|
2416
|
-
name: 'authority';
|
|
2417
|
-
type: 'pubkey';
|
|
2418
|
-
},
|
|
2419
|
-
{
|
|
2420
|
-
name: 'marketId';
|
|
2421
|
-
docs: ['Unique identifier for the market'];
|
|
2422
|
-
type: 'u64';
|
|
2423
|
-
},
|
|
2424
|
-
{
|
|
2425
|
-
name: 'name';
|
|
2426
|
-
docs: ['The event being predicted (e.g., "tJUP/TRD")'];
|
|
2427
|
-
type: 'string';
|
|
2428
|
-
},
|
|
2429
|
-
{
|
|
2430
|
-
name: 'hypePrice';
|
|
2431
|
-
docs: [
|
|
2432
|
-
'Current price for Hype outcome (0-1000000, representing 0 to 1 TRD)',
|
|
2433
|
-
'1000000 = 1 TRD, 500000 = 0.5 TRD, etc.'
|
|
2434
|
-
];
|
|
2435
|
-
type: 'u64';
|
|
2436
|
-
},
|
|
2437
|
-
{
|
|
2438
|
-
name: 'flopPrice';
|
|
2439
|
-
docs: [
|
|
2440
|
-
'Current price for Flop outcome (0-1000000, representing 0 to 1 TRD)'
|
|
2441
|
-
];
|
|
2442
|
-
type: 'u64';
|
|
2443
|
-
},
|
|
2444
|
-
{
|
|
2445
|
-
name: 'hypeLiquidity';
|
|
2446
|
-
docs: ['Total liquidity for Hype (in TRD)'];
|
|
2447
|
-
type: 'u64';
|
|
2448
|
-
},
|
|
2449
|
-
{
|
|
2450
|
-
name: 'flopLiquidity';
|
|
2451
|
-
docs: ['Total liquidity for Flop (in TRD)'];
|
|
2452
|
-
type: 'u64';
|
|
2453
|
-
},
|
|
2454
|
-
{
|
|
2455
|
-
name: 'totalHypeShares';
|
|
2456
|
-
docs: ['Total number of Hype shares issued'];
|
|
2457
|
-
type: 'u64';
|
|
2458
|
-
},
|
|
2459
|
-
{
|
|
2460
|
-
name: 'totalFlopShares';
|
|
2461
|
-
docs: ['Total number of Flop shares issued'];
|
|
2462
|
-
type: 'u64';
|
|
2463
|
-
},
|
|
2464
|
-
{
|
|
2465
|
-
name: 'totalVolume';
|
|
2466
|
-
docs: ['Total trading volume (in TRD) for all resolutions'];
|
|
2467
|
-
type: 'u64';
|
|
2468
|
-
},
|
|
2469
|
-
{
|
|
2470
|
-
name: 'mint';
|
|
2471
|
-
docs: ['Mint $TRD token'];
|
|
2472
|
-
type: 'pubkey';
|
|
2473
|
-
},
|
|
2474
|
-
{
|
|
2475
|
-
name: 'ts';
|
|
2476
|
-
docs: ['Timestamp of the init'];
|
|
2477
|
-
type: 'i64';
|
|
2478
|
-
},
|
|
2479
|
-
{
|
|
2480
|
-
name: 'updateTs';
|
|
2481
|
-
type: 'i64';
|
|
2482
|
-
},
|
|
2483
|
-
{
|
|
2484
|
-
name: 'openOrdersCount';
|
|
2485
|
-
docs: ['Total number of open orders in this market'];
|
|
2486
|
-
type: 'u64';
|
|
2487
|
-
},
|
|
2488
|
-
{
|
|
2489
|
-
name: 'nextOrderId';
|
|
2490
|
-
docs: ['Next available order ID'];
|
|
2491
|
-
type: 'u64';
|
|
2492
|
-
},
|
|
2493
|
-
{
|
|
2494
|
-
name: 'feeBps';
|
|
2495
|
-
docs: ['Fees applied to trades (in basis points, e.g., 2.131% fee)'];
|
|
2496
|
-
type: 'u16';
|
|
2497
|
-
},
|
|
2498
|
-
{
|
|
2499
|
-
name: 'feeVault';
|
|
2500
|
-
docs: ['Vault to Receive fees'];
|
|
2501
|
-
type: 'pubkey';
|
|
2502
|
-
},
|
|
2503
|
-
{
|
|
2504
|
-
name: 'isActive';
|
|
2505
|
-
docs: ['Whether the market is currently active for trading'];
|
|
2506
|
-
type: 'bool';
|
|
2507
|
-
},
|
|
2508
|
-
{
|
|
2509
|
-
name: 'marketPrice';
|
|
2510
|
-
type: 'u64';
|
|
2511
|
-
},
|
|
2512
|
-
{
|
|
2513
|
-
name: 'previousResolvedQuestion';
|
|
2514
|
-
type: {
|
|
2515
|
-
defined: {
|
|
2516
|
-
name: 'resolvedQuestion';
|
|
2517
|
-
};
|
|
2518
|
-
};
|
|
2519
|
-
},
|
|
2520
|
-
{
|
|
2521
|
-
name: 'currentQuestionId';
|
|
2522
|
-
docs: [
|
|
2523
|
-
'Index of the current week in the weekly_results array initialized with default values'
|
|
2524
|
-
];
|
|
2525
|
-
type: 'u64';
|
|
2526
|
-
},
|
|
2527
|
-
{
|
|
2528
|
-
name: 'currentQuestionStart';
|
|
2529
|
-
type: 'i64';
|
|
2530
|
-
},
|
|
2531
|
-
{
|
|
2532
|
-
name: 'currentQuestionEnd';
|
|
2533
|
-
type: 'i64';
|
|
2534
|
-
},
|
|
2535
|
-
{
|
|
2536
|
-
name: 'currentQuestion';
|
|
2537
|
-
docs: ['The question or prediction topic for the current week'];
|
|
2538
|
-
type: {
|
|
2539
|
-
array: ['u8', 80];
|
|
2540
|
-
};
|
|
2541
|
-
},
|
|
2542
|
-
{
|
|
2543
|
-
name: 'liquidity';
|
|
2544
|
-
type: 'u64';
|
|
2545
|
-
},
|
|
2546
|
-
{
|
|
2547
|
-
name: 'padding';
|
|
2548
|
-
type: {
|
|
2549
|
-
array: ['u8', 200];
|
|
2550
|
-
};
|
|
2551
|
-
}
|
|
2552
|
-
];
|
|
2553
|
-
};
|
|
2554
|
-
},
|
|
2555
2229
|
{
|
|
2556
2230
|
name: 'marketAllowedToPayoutEvent';
|
|
2557
2231
|
type: {
|
|
@@ -2855,10 +2529,14 @@ export type TriadProtocol = {
|
|
|
2855
2529
|
};
|
|
2856
2530
|
};
|
|
2857
2531
|
},
|
|
2532
|
+
{
|
|
2533
|
+
name: 'userNonce';
|
|
2534
|
+
type: 'u32';
|
|
2535
|
+
},
|
|
2858
2536
|
{
|
|
2859
2537
|
name: 'padding';
|
|
2860
2538
|
type: {
|
|
2861
|
-
array: ['u8',
|
|
2539
|
+
array: ['u8', 28];
|
|
2862
2540
|
};
|
|
2863
2541
|
}
|
|
2864
2542
|
];
|
|
@@ -3027,84 +2705,6 @@ export type TriadProtocol = {
|
|
|
3027
2705
|
];
|
|
3028
2706
|
};
|
|
3029
2707
|
},
|
|
3030
|
-
{
|
|
3031
|
-
name: 'resolvedQuestion';
|
|
3032
|
-
type: {
|
|
3033
|
-
kind: 'struct';
|
|
3034
|
-
fields: [
|
|
3035
|
-
{
|
|
3036
|
-
name: 'questionId';
|
|
3037
|
-
type: 'u64';
|
|
3038
|
-
},
|
|
3039
|
-
{
|
|
3040
|
-
name: 'question';
|
|
3041
|
-
docs: ['The question or prediction topic for this week'];
|
|
3042
|
-
type: {
|
|
3043
|
-
array: ['u8', 80];
|
|
3044
|
-
};
|
|
3045
|
-
},
|
|
3046
|
-
{
|
|
3047
|
-
name: 'startTime';
|
|
3048
|
-
docs: ['Start timestamp of the week'];
|
|
3049
|
-
type: 'i64';
|
|
3050
|
-
},
|
|
3051
|
-
{
|
|
3052
|
-
name: 'endTime';
|
|
3053
|
-
docs: ['End timestamp of the week'];
|
|
3054
|
-
type: 'i64';
|
|
3055
|
-
},
|
|
3056
|
-
{
|
|
3057
|
-
name: 'hypeLiquidity';
|
|
3058
|
-
docs: ['Total liquidity for Hype (in TRD)'];
|
|
3059
|
-
type: 'u64';
|
|
3060
|
-
},
|
|
3061
|
-
{
|
|
3062
|
-
name: 'flopLiquidity';
|
|
3063
|
-
docs: ['Total liquidity for Flop (in TRD)'];
|
|
3064
|
-
type: 'u64';
|
|
3065
|
-
},
|
|
3066
|
-
{
|
|
3067
|
-
name: 'winningDirection';
|
|
3068
|
-
docs: ['The winning direction (Hype, Flop or None)'];
|
|
3069
|
-
type: {
|
|
3070
|
-
defined: {
|
|
3071
|
-
name: 'winningDirection';
|
|
3072
|
-
};
|
|
3073
|
-
};
|
|
3074
|
-
},
|
|
3075
|
-
{
|
|
3076
|
-
name: 'marketPrice';
|
|
3077
|
-
type: 'u64';
|
|
3078
|
-
},
|
|
3079
|
-
{
|
|
3080
|
-
name: 'finalHypePrice';
|
|
3081
|
-
docs: ['Final price for Hype outcome at the end of the week'];
|
|
3082
|
-
type: 'u64';
|
|
3083
|
-
},
|
|
3084
|
-
{
|
|
3085
|
-
name: 'finalFlopPrice';
|
|
3086
|
-
docs: ['Final price for Flop outcome at the end of the week'];
|
|
3087
|
-
type: 'u64';
|
|
3088
|
-
},
|
|
3089
|
-
{
|
|
3090
|
-
name: 'totalHypeShares';
|
|
3091
|
-
docs: ['Total number of Hype shares issued'];
|
|
3092
|
-
type: 'u64';
|
|
3093
|
-
},
|
|
3094
|
-
{
|
|
3095
|
-
name: 'totalFlopShares';
|
|
3096
|
-
docs: ['Total number of Flop shares issued'];
|
|
3097
|
-
type: 'u64';
|
|
3098
|
-
},
|
|
3099
|
-
{
|
|
3100
|
-
name: 'padding';
|
|
3101
|
-
type: {
|
|
3102
|
-
array: ['u8', 40];
|
|
3103
|
-
};
|
|
3104
|
-
}
|
|
3105
|
-
];
|
|
3106
|
-
};
|
|
3107
|
-
},
|
|
3108
2708
|
{
|
|
3109
2709
|
name: 'stakeRewardsEvent';
|
|
3110
2710
|
type: {
|
|
@@ -3415,10 +3015,18 @@ export type TriadProtocol = {
|
|
|
3415
3015
|
];
|
|
3416
3016
|
};
|
|
3417
3017
|
},
|
|
3018
|
+
{
|
|
3019
|
+
name: 'nonce';
|
|
3020
|
+
type: 'u32';
|
|
3021
|
+
},
|
|
3022
|
+
{
|
|
3023
|
+
name: 'isSubUser';
|
|
3024
|
+
type: 'bool';
|
|
3025
|
+
},
|
|
3418
3026
|
{
|
|
3419
3027
|
name: 'padding';
|
|
3420
3028
|
type: {
|
|
3421
|
-
array: ['u8',
|
|
3029
|
+
array: ['u8', 27];
|
|
3422
3030
|
};
|
|
3423
3031
|
}
|
|
3424
3032
|
];
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stake, StakeVault } from './../types/stake';
|
|
2
2
|
import { User } from './../types';
|
|
3
|
-
import { Market } from '../types/trade';
|
|
3
|
+
import { Market, Order, UserTrade } from '../types/trade';
|
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
|
5
5
|
export declare const encodeString: (value: string, alloc?: number) => number[];
|
|
6
6
|
export declare const decodeString: (bytes: number[]) => string;
|
|
@@ -8,5 +8,6 @@ export declare const formatStakeVault: (stakeVault: any) => StakeVault;
|
|
|
8
8
|
export declare const formatStake: (stake: any) => Stake;
|
|
9
9
|
export declare const formatUser: (user: any) => User;
|
|
10
10
|
export declare const formatMarket: (account: any, address: PublicKey) => Market;
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const formatOrder: (order: any) => Order;
|
|
12
|
+
export declare const formatUserTrade: (account: any, publicKey: PublicKey) => UserTrade;
|
|
12
13
|
export declare const calculateStakeRewards: (stake: Stake, multiplier: number) => number;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateStakeRewards = exports.
|
|
3
|
+
exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
4
|
const trade_1 = require("../types/trade");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const encodeString = (value, alloc = 32) => {
|
|
@@ -93,39 +93,34 @@ const formatMarket = (account, address) => {
|
|
|
93
93
|
};
|
|
94
94
|
};
|
|
95
95
|
exports.formatMarket = formatMarket;
|
|
96
|
-
const
|
|
96
|
+
const formatOrder = (order) => {
|
|
97
97
|
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
marketId:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
nftHoldersFeeClaimed: '0',
|
|
122
|
-
marketFeeAvailable: '0',
|
|
123
|
-
marketFeeClaimed: '0',
|
|
124
|
-
winningDirection: trade_1.WinningDirection[Object.keys(account.previousResolvedQuestion.winningDirection)[0].toUpperCase()],
|
|
125
|
-
marketLiquidityAtStart: '0'
|
|
98
|
+
ts: order.ts.toString(),
|
|
99
|
+
orderId: order.orderId.toString(),
|
|
100
|
+
questionId: order.questionId.toString(),
|
|
101
|
+
marketId: order.marketId.toString(),
|
|
102
|
+
status: order.status,
|
|
103
|
+
price: order.price.toString(),
|
|
104
|
+
totalAmount: order.totalAmount.toString(),
|
|
105
|
+
totalShares: order.totalShares.toString(),
|
|
106
|
+
orderType: order.orderType,
|
|
107
|
+
direction: order.direction,
|
|
108
|
+
userNonce: order.userNonce.toString()
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
exports.formatOrder = formatOrder;
|
|
112
|
+
const formatUserTrade = (account, publicKey) => {
|
|
113
|
+
return {
|
|
114
|
+
user: publicKey.toString(),
|
|
115
|
+
totalDeposits: account.totalDeposits.toString(),
|
|
116
|
+
totalWithdraws: account.totalWithdraws.toString(),
|
|
117
|
+
openedOrders: account.openedOrders.toString(),
|
|
118
|
+
orders: account.orders.map((order) => (0, exports.formatOrder)(order)),
|
|
119
|
+
nonce: account.nonce.toString(),
|
|
120
|
+
isSubUser: account.isSubUser
|
|
126
121
|
};
|
|
127
122
|
};
|
|
128
|
-
exports.
|
|
123
|
+
exports.formatUserTrade = formatUserTrade;
|
|
129
124
|
const calculateStakeRewards = (stake, multiplier) => {
|
|
130
125
|
if (stake.withdrawTs !== 0)
|
|
131
126
|
return 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
export declare const getMarketPDA: (programId: PublicKey, marketId: number) => PublicKey;
|
|
3
3
|
export declare const getUserTradePDA: (programId: PublicKey, wallet: PublicKey) => PublicKey;
|
|
4
|
+
export declare const getSubUserTradePDA: (programId: PublicKey, wallet: PublicKey, nonce: number) => PublicKey;
|
package/dist/utils/pda/trade.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getUserTradePDA = exports.getMarketPDA = void 0;
|
|
6
|
+
exports.getSubUserTradePDA = exports.getUserTradePDA = exports.getMarketPDA = void 0;
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
9
9
|
const getMarketPDA = (programId, marketId) => {
|
|
@@ -14,3 +14,11 @@ const getUserTradePDA = (programId, wallet) => {
|
|
|
14
14
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('user_trade'), wallet.toBuffer()], programId)[0];
|
|
15
15
|
};
|
|
16
16
|
exports.getUserTradePDA = getUserTradePDA;
|
|
17
|
+
const getSubUserTradePDA = (programId, wallet, nonce) => {
|
|
18
|
+
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
19
|
+
Buffer.from('sub_user_trade'),
|
|
20
|
+
wallet.toBuffer(),
|
|
21
|
+
new bn_js_1.default(nonce).toArrayLike(Buffer, 'le', 8)
|
|
22
|
+
], programId)[0];
|
|
23
|
+
};
|
|
24
|
+
exports.getSubUserTradePDA = getSubUserTradePDA;
|