@triadxyz/triad-protocol 4.2.6 → 4.2.8
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 +1 -0
- package/dist/index.js +9 -0
- package/dist/market.d.ts +0 -7
- package/dist/market.js +0 -22
- package/dist/predictor.d.ts +0 -5
- package/dist/predictor.js +0 -19
- package/dist/trade.js +4 -6
- package/dist/types/idl_triad_protocol.json +0 -107
- package/dist/types/index.d.ts +7 -0
- package/dist/types/triad_protocol.d.ts +0 -176
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +12 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export default class TriadProtocol {
|
|
|
31
31
|
market: Market;
|
|
32
32
|
constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
|
|
33
33
|
getPriorityFee(): Promise<void>;
|
|
34
|
+
getCentral(): Promise<import("./types").Central>;
|
|
34
35
|
/**
|
|
35
36
|
* Burn Triad
|
|
36
37
|
* @param amount - Amount to burn
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
30
30
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
31
31
|
const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
|
|
32
|
+
const pda_1 = require("./utils/pda");
|
|
33
|
+
const helpers_1 = require("./utils/helpers");
|
|
32
34
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
33
35
|
const stake_1 = __importDefault(require("./stake"));
|
|
34
36
|
const poseidon_1 = __importDefault(require("./poseidon"));
|
|
@@ -74,6 +76,13 @@ class TriadProtocol {
|
|
|
74
76
|
this.rpcOptions.microLamports = yield (0, getPriorityFee_1.default)();
|
|
75
77
|
});
|
|
76
78
|
}
|
|
79
|
+
getCentral() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const centralPDA = (0, pda_1.getCentralPDA)(this.program.programId);
|
|
82
|
+
const central = yield this.program.account.central.fetch(centralPDA);
|
|
83
|
+
return (0, helpers_1.formatCentral)(central, centralPDA);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
77
86
|
/**
|
|
78
87
|
* Burn Triad
|
|
79
88
|
* @param amount - Amount to burn
|
package/dist/market.d.ts
CHANGED
|
@@ -160,11 +160,4 @@ export default class Market {
|
|
|
160
160
|
* @param market.poolId - The ID of the pool
|
|
161
161
|
*/
|
|
162
162
|
createAndResolveMarket(toResolve: UpdateMarketWinningDirectionArgs['markets'][0], market: CreateMarketArgs['markets'][0], customer: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
* @param marketId
|
|
166
|
-
* @param usdcMint
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
migrateUSDC(marketIds: number[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
170
163
|
}
|
package/dist/market.js
CHANGED
|
@@ -567,27 +567,5 @@ class Market {
|
|
|
567
567
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
-
/**
|
|
571
|
-
*
|
|
572
|
-
* @param marketId
|
|
573
|
-
* @param usdcMint
|
|
574
|
-
* @returns
|
|
575
|
-
*/
|
|
576
|
-
migrateUSDC(marketIds) {
|
|
577
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
-
const ixs = [];
|
|
579
|
-
for (const marketId of marketIds) {
|
|
580
|
-
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
581
|
-
ixs.push(yield this.program.methods
|
|
582
|
-
.migrateUsdc()
|
|
583
|
-
.accounts({
|
|
584
|
-
signer: this.program.provider.publicKey,
|
|
585
|
-
market: marketPDA
|
|
586
|
-
})
|
|
587
|
-
.instruction());
|
|
588
|
-
}
|
|
589
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
570
|
}
|
|
593
571
|
exports.default = Market;
|
package/dist/predictor.d.ts
CHANGED
|
@@ -13,11 +13,6 @@ export default class Predictor {
|
|
|
13
13
|
* @param customerId - Customer ID
|
|
14
14
|
*/
|
|
15
15
|
getPredictor(authority: PublicKey, customerId: number): Promise<PredictorType>;
|
|
16
|
-
createPredictor(users: {
|
|
17
|
-
authority: PublicKey;
|
|
18
|
-
refer: string;
|
|
19
|
-
customerId: number;
|
|
20
|
-
}[]): Promise<void>;
|
|
21
16
|
/**
|
|
22
17
|
* Get User Orders
|
|
23
18
|
* @param wallet - User wallet PublicKey
|
package/dist/predictor.js
CHANGED
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
16
15
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
17
16
|
const constants_1 = require("./utils/constants");
|
|
18
17
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
@@ -48,24 +47,6 @@ class Predictor {
|
|
|
48
47
|
}
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
|
-
createPredictor(users) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
let ixs = [];
|
|
54
|
-
for (const user of users) {
|
|
55
|
-
ixs.push(yield this.program.methods
|
|
56
|
-
.createPredictor({
|
|
57
|
-
customerId: user.customerId,
|
|
58
|
-
refer: new web3_js_1.PublicKey(user.refer)
|
|
59
|
-
})
|
|
60
|
-
.accounts({
|
|
61
|
-
signer: user.authority,
|
|
62
|
-
payer: this.rpcOptions.payer
|
|
63
|
-
})
|
|
64
|
-
.instruction());
|
|
65
|
-
}
|
|
66
|
-
yield (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
50
|
/**
|
|
70
51
|
* Get User Orders
|
|
71
52
|
* @param wallet - User wallet PublicKey
|
package/dist/trade.js
CHANGED
|
@@ -220,7 +220,6 @@ class Trade {
|
|
|
220
220
|
if (usdcAmount.lte(new bn_js_1.default(0)))
|
|
221
221
|
continue;
|
|
222
222
|
const oppositeOrderDirection = (0, helpers_1.getOppositeOrderDirectionEncoded)(orderDirection);
|
|
223
|
-
const oppositePredictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), customer.id);
|
|
224
223
|
ixs.push(yield this.program.methods
|
|
225
224
|
.marketBidOrder({
|
|
226
225
|
amount: new bn_js_1.default(usdcAmount),
|
|
@@ -233,13 +232,13 @@ class Trade {
|
|
|
233
232
|
signer: this.program.provider.publicKey,
|
|
234
233
|
payer: this.rpcOptions.payer,
|
|
235
234
|
predictor: predictorPDA,
|
|
236
|
-
oppositePredictor:
|
|
235
|
+
oppositePredictor: new web3_js_1.PublicKey(order.authority),
|
|
237
236
|
central: (0, pda_1.getCentralPDA)(this.program.programId),
|
|
238
237
|
market: marketPDA,
|
|
239
238
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
240
239
|
customer: customer.address,
|
|
241
240
|
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
242
|
-
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId,
|
|
241
|
+
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(oppositeOrderDirection))
|
|
243
242
|
})
|
|
244
243
|
.instruction());
|
|
245
244
|
remainingUSDC = remainingUSDC.sub(usdcAmount);
|
|
@@ -286,7 +285,6 @@ class Trade {
|
|
|
286
285
|
const effectivePriceDecimal = (0, feeCalculator_1.applySellFee)(orderPrice.toNumber() / 1000000, 500, customer.marketFeeBps);
|
|
287
286
|
const adjustedPrice = new bn_js_1.default(Math.floor(effectivePriceDecimal * 1000000));
|
|
288
287
|
amountOfUSDC = amountOfUSDC.add(sharesToSell.mul(adjustedPrice).div(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS))));
|
|
289
|
-
const oppositePredictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), customer.id);
|
|
290
288
|
ixs.push(yield this.program.methods
|
|
291
289
|
.marketAskOrder({
|
|
292
290
|
shares: new bn_js_1.default(sharesToSell),
|
|
@@ -296,13 +294,13 @@ class Trade {
|
|
|
296
294
|
.accounts({
|
|
297
295
|
signer: this.program.provider.publicKey,
|
|
298
296
|
predictor: predictorPDA,
|
|
299
|
-
oppositePredictor:
|
|
297
|
+
oppositePredictor: new web3_js_1.PublicKey(order.authority),
|
|
300
298
|
market: marketPDA,
|
|
301
299
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
302
300
|
customer: customer.address,
|
|
303
301
|
central: (0, pda_1.getCentralPDA)(this.program.programId),
|
|
304
302
|
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
305
|
-
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId,
|
|
303
|
+
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(orderDirection))
|
|
306
304
|
})
|
|
307
305
|
.instruction());
|
|
308
306
|
}
|
|
@@ -1360,113 +1360,6 @@
|
|
|
1360
1360
|
],
|
|
1361
1361
|
"args": []
|
|
1362
1362
|
},
|
|
1363
|
-
{
|
|
1364
|
-
"name": "migrate_usdc",
|
|
1365
|
-
"discriminator": [8, 131, 126, 107, 248, 44, 154, 73],
|
|
1366
|
-
"accounts": [
|
|
1367
|
-
{
|
|
1368
|
-
"name": "signer",
|
|
1369
|
-
"writable": true,
|
|
1370
|
-
"signer": true
|
|
1371
|
-
},
|
|
1372
|
-
{
|
|
1373
|
-
"name": "central",
|
|
1374
|
-
"writable": true,
|
|
1375
|
-
"pda": {
|
|
1376
|
-
"seeds": [
|
|
1377
|
-
{
|
|
1378
|
-
"kind": "const",
|
|
1379
|
-
"value": [99, 101, 110, 116, 114, 97, 108]
|
|
1380
|
-
},
|
|
1381
|
-
{
|
|
1382
|
-
"kind": "const",
|
|
1383
|
-
"value": [
|
|
1384
|
-
116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
|
|
1385
|
-
]
|
|
1386
|
-
}
|
|
1387
|
-
]
|
|
1388
|
-
}
|
|
1389
|
-
},
|
|
1390
|
-
{
|
|
1391
|
-
"name": "market",
|
|
1392
|
-
"writable": true
|
|
1393
|
-
},
|
|
1394
|
-
{
|
|
1395
|
-
"name": "mint",
|
|
1396
|
-
"writable": true,
|
|
1397
|
-
"address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
1398
|
-
},
|
|
1399
|
-
{
|
|
1400
|
-
"name": "market_ata",
|
|
1401
|
-
"writable": true,
|
|
1402
|
-
"pda": {
|
|
1403
|
-
"seeds": [
|
|
1404
|
-
{
|
|
1405
|
-
"kind": "account",
|
|
1406
|
-
"path": "market"
|
|
1407
|
-
},
|
|
1408
|
-
{
|
|
1409
|
-
"kind": "account",
|
|
1410
|
-
"path": "token_program"
|
|
1411
|
-
},
|
|
1412
|
-
{
|
|
1413
|
-
"kind": "account",
|
|
1414
|
-
"path": "mint"
|
|
1415
|
-
}
|
|
1416
|
-
],
|
|
1417
|
-
"program": {
|
|
1418
|
-
"kind": "const",
|
|
1419
|
-
"value": [
|
|
1420
|
-
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1421
|
-
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1422
|
-
219, 233, 248, 89
|
|
1423
|
-
]
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
"name": "central_ata",
|
|
1429
|
-
"writable": true,
|
|
1430
|
-
"pda": {
|
|
1431
|
-
"seeds": [
|
|
1432
|
-
{
|
|
1433
|
-
"kind": "account",
|
|
1434
|
-
"path": "central"
|
|
1435
|
-
},
|
|
1436
|
-
{
|
|
1437
|
-
"kind": "account",
|
|
1438
|
-
"path": "token_program"
|
|
1439
|
-
},
|
|
1440
|
-
{
|
|
1441
|
-
"kind": "account",
|
|
1442
|
-
"path": "mint"
|
|
1443
|
-
}
|
|
1444
|
-
],
|
|
1445
|
-
"program": {
|
|
1446
|
-
"kind": "const",
|
|
1447
|
-
"value": [
|
|
1448
|
-
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1449
|
-
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1450
|
-
219, 233, 248, 89
|
|
1451
|
-
]
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
},
|
|
1455
|
-
{
|
|
1456
|
-
"name": "token_program",
|
|
1457
|
-
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
1458
|
-
},
|
|
1459
|
-
{
|
|
1460
|
-
"name": "associated_token_program",
|
|
1461
|
-
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
1462
|
-
},
|
|
1463
|
-
{
|
|
1464
|
-
"name": "system_program",
|
|
1465
|
-
"address": "11111111111111111111111111111111"
|
|
1466
|
-
}
|
|
1467
|
-
],
|
|
1468
|
-
"args": []
|
|
1469
|
-
},
|
|
1470
1363
|
{
|
|
1471
1364
|
"name": "payout_order",
|
|
1472
1365
|
"discriminator": [247, 233, 158, 228, 63, 32, 236, 113],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -55,6 +55,13 @@ export type PredictorOrder = {
|
|
|
55
55
|
orderDirection: OrderDirection;
|
|
56
56
|
predictor: string;
|
|
57
57
|
};
|
|
58
|
+
export type Central = {
|
|
59
|
+
address: string;
|
|
60
|
+
isLocked: boolean;
|
|
61
|
+
feeAvailable: number;
|
|
62
|
+
feeClaimed: number;
|
|
63
|
+
rewardsPaid: number;
|
|
64
|
+
};
|
|
58
65
|
export type BookOrder = {
|
|
59
66
|
id: string;
|
|
60
67
|
price: string;
|
|
@@ -1788,182 +1788,6 @@ export type TriadProtocol = {
|
|
|
1788
1788
|
];
|
|
1789
1789
|
args: [];
|
|
1790
1790
|
},
|
|
1791
|
-
{
|
|
1792
|
-
name: 'migrateUsdc';
|
|
1793
|
-
discriminator: [8, 131, 126, 107, 248, 44, 154, 73];
|
|
1794
|
-
accounts: [
|
|
1795
|
-
{
|
|
1796
|
-
name: 'signer';
|
|
1797
|
-
writable: true;
|
|
1798
|
-
signer: true;
|
|
1799
|
-
},
|
|
1800
|
-
{
|
|
1801
|
-
name: 'central';
|
|
1802
|
-
writable: true;
|
|
1803
|
-
pda: {
|
|
1804
|
-
seeds: [
|
|
1805
|
-
{
|
|
1806
|
-
kind: 'const';
|
|
1807
|
-
value: [99, 101, 110, 116, 114, 97, 108];
|
|
1808
|
-
},
|
|
1809
|
-
{
|
|
1810
|
-
kind: 'const';
|
|
1811
|
-
value: [
|
|
1812
|
-
116,
|
|
1813
|
-
114,
|
|
1814
|
-
105,
|
|
1815
|
-
97,
|
|
1816
|
-
100,
|
|
1817
|
-
109,
|
|
1818
|
-
97,
|
|
1819
|
-
114,
|
|
1820
|
-
107,
|
|
1821
|
-
101,
|
|
1822
|
-
116,
|
|
1823
|
-
115
|
|
1824
|
-
];
|
|
1825
|
-
}
|
|
1826
|
-
];
|
|
1827
|
-
};
|
|
1828
|
-
},
|
|
1829
|
-
{
|
|
1830
|
-
name: 'market';
|
|
1831
|
-
writable: true;
|
|
1832
|
-
},
|
|
1833
|
-
{
|
|
1834
|
-
name: 'mint';
|
|
1835
|
-
writable: true;
|
|
1836
|
-
address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
|
|
1837
|
-
},
|
|
1838
|
-
{
|
|
1839
|
-
name: 'marketAta';
|
|
1840
|
-
writable: true;
|
|
1841
|
-
pda: {
|
|
1842
|
-
seeds: [
|
|
1843
|
-
{
|
|
1844
|
-
kind: 'account';
|
|
1845
|
-
path: 'market';
|
|
1846
|
-
},
|
|
1847
|
-
{
|
|
1848
|
-
kind: 'account';
|
|
1849
|
-
path: 'tokenProgram';
|
|
1850
|
-
},
|
|
1851
|
-
{
|
|
1852
|
-
kind: 'account';
|
|
1853
|
-
path: 'mint';
|
|
1854
|
-
}
|
|
1855
|
-
];
|
|
1856
|
-
program: {
|
|
1857
|
-
kind: 'const';
|
|
1858
|
-
value: [
|
|
1859
|
-
140,
|
|
1860
|
-
151,
|
|
1861
|
-
37,
|
|
1862
|
-
143,
|
|
1863
|
-
78,
|
|
1864
|
-
36,
|
|
1865
|
-
137,
|
|
1866
|
-
241,
|
|
1867
|
-
187,
|
|
1868
|
-
61,
|
|
1869
|
-
16,
|
|
1870
|
-
41,
|
|
1871
|
-
20,
|
|
1872
|
-
142,
|
|
1873
|
-
13,
|
|
1874
|
-
131,
|
|
1875
|
-
11,
|
|
1876
|
-
90,
|
|
1877
|
-
19,
|
|
1878
|
-
153,
|
|
1879
|
-
218,
|
|
1880
|
-
255,
|
|
1881
|
-
16,
|
|
1882
|
-
132,
|
|
1883
|
-
4,
|
|
1884
|
-
142,
|
|
1885
|
-
123,
|
|
1886
|
-
216,
|
|
1887
|
-
219,
|
|
1888
|
-
233,
|
|
1889
|
-
248,
|
|
1890
|
-
89
|
|
1891
|
-
];
|
|
1892
|
-
};
|
|
1893
|
-
};
|
|
1894
|
-
},
|
|
1895
|
-
{
|
|
1896
|
-
name: 'centralAta';
|
|
1897
|
-
writable: true;
|
|
1898
|
-
pda: {
|
|
1899
|
-
seeds: [
|
|
1900
|
-
{
|
|
1901
|
-
kind: 'account';
|
|
1902
|
-
path: 'central';
|
|
1903
|
-
},
|
|
1904
|
-
{
|
|
1905
|
-
kind: 'account';
|
|
1906
|
-
path: 'tokenProgram';
|
|
1907
|
-
},
|
|
1908
|
-
{
|
|
1909
|
-
kind: 'account';
|
|
1910
|
-
path: 'mint';
|
|
1911
|
-
}
|
|
1912
|
-
];
|
|
1913
|
-
program: {
|
|
1914
|
-
kind: 'const';
|
|
1915
|
-
value: [
|
|
1916
|
-
140,
|
|
1917
|
-
151,
|
|
1918
|
-
37,
|
|
1919
|
-
143,
|
|
1920
|
-
78,
|
|
1921
|
-
36,
|
|
1922
|
-
137,
|
|
1923
|
-
241,
|
|
1924
|
-
187,
|
|
1925
|
-
61,
|
|
1926
|
-
16,
|
|
1927
|
-
41,
|
|
1928
|
-
20,
|
|
1929
|
-
142,
|
|
1930
|
-
13,
|
|
1931
|
-
131,
|
|
1932
|
-
11,
|
|
1933
|
-
90,
|
|
1934
|
-
19,
|
|
1935
|
-
153,
|
|
1936
|
-
218,
|
|
1937
|
-
255,
|
|
1938
|
-
16,
|
|
1939
|
-
132,
|
|
1940
|
-
4,
|
|
1941
|
-
142,
|
|
1942
|
-
123,
|
|
1943
|
-
216,
|
|
1944
|
-
219,
|
|
1945
|
-
233,
|
|
1946
|
-
248,
|
|
1947
|
-
89
|
|
1948
|
-
];
|
|
1949
|
-
};
|
|
1950
|
-
};
|
|
1951
|
-
},
|
|
1952
|
-
{
|
|
1953
|
-
name: 'tokenProgram';
|
|
1954
|
-
address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
1955
|
-
},
|
|
1956
|
-
{
|
|
1957
|
-
name: 'associatedTokenProgram';
|
|
1958
|
-
address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
1959
|
-
},
|
|
1960
|
-
{
|
|
1961
|
-
name: 'systemProgram';
|
|
1962
|
-
address: '11111111111111111111111111111111';
|
|
1963
|
-
}
|
|
1964
|
-
];
|
|
1965
|
-
args: [];
|
|
1966
|
-
},
|
|
1967
1791
|
{
|
|
1968
1792
|
name: 'payoutOrder';
|
|
1969
1793
|
discriminator: [247, 233, 158, 228, 63, 32, 236, 113];
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { IdlAccounts, Program } from '@coral-xyz/anchor';
|
|
3
|
-
import { Market, PredictorOrder, OrderDirection, OrderSide, OrderStatus, OrderType, OrderDirectionEncoded, OrderTypeEncoded, OrderSideEncoded, OrderStatusEncoded, Pool, BookOrder } from '../types';
|
|
3
|
+
import { Market, PredictorOrder, OrderDirection, OrderSide, OrderStatus, OrderType, OrderDirectionEncoded, OrderTypeEncoded, OrderSideEncoded, OrderStatusEncoded, Pool, BookOrder, Central } from '../types';
|
|
4
4
|
import { Stake, StakeVault, Unstake } from '../types/stake';
|
|
5
5
|
import { Customer } from '../types/customer';
|
|
6
6
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
@@ -27,6 +27,7 @@ export declare const getOrderDirectionEncoded: (orderDirection: OrderDirection)
|
|
|
27
27
|
export declare const getOppositeOrderDirection: (orderDirection: OrderDirection) => OrderDirection;
|
|
28
28
|
export declare const getOppositeOrderDirectionEncoded: (orderDirection: OrderDirectionEncoded) => OrderDirectionEncoded;
|
|
29
29
|
export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey) => Predictor;
|
|
30
|
+
export declare const formatCentral: (account: IdlAccounts<TriadProtocol>['central'], publicKey: PublicKey) => Central;
|
|
30
31
|
export declare const getPriceFeedAccountForProgram: (priceFeedId: string) => PublicKey;
|
|
31
32
|
export declare const getFeedIdFromHex: (input?: string) => PublicKey | null;
|
|
32
33
|
export declare const getCustomerById: (program: Program<TriadProtocol>, customerId: number) => Promise<Customer>;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getCustomerById = exports.getFeedIdFromHex = exports.getPriceFeedAccountForProgram = exports.formatPredictor = exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatCustomer = exports.formatBookOrder = exports.formatPredictorOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
12
|
+
exports.getCustomerById = exports.getFeedIdFromHex = exports.getPriceFeedAccountForProgram = exports.formatCentral = exports.formatPredictor = exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatCustomer = exports.formatBookOrder = exports.formatPredictorOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const spl_token_1 = require("@solana/spl-token");
|
|
15
15
|
const types_1 = require("../types");
|
|
@@ -146,7 +146,7 @@ exports.formatBookOrder = formatBookOrder;
|
|
|
146
146
|
const formatCustomer = (account, publicKey) => {
|
|
147
147
|
return {
|
|
148
148
|
id: account.id,
|
|
149
|
-
authority:
|
|
149
|
+
authority: account.authority.toString(),
|
|
150
150
|
name: account.name,
|
|
151
151
|
feeRecipient: account.feeRecipient.toString(),
|
|
152
152
|
feeBps: account.feeBps,
|
|
@@ -271,6 +271,16 @@ const formatPredictor = (account, publicKey) => {
|
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
273
|
exports.formatPredictor = formatPredictor;
|
|
274
|
+
const formatCentral = (account, publicKey) => {
|
|
275
|
+
return {
|
|
276
|
+
address: publicKey.toBase58(),
|
|
277
|
+
isLocked: account.isLocked,
|
|
278
|
+
feeAvailable: account.feeAvailable.toNumber() / 1e6,
|
|
279
|
+
feeClaimed: account.feeClaimed.toNumber() / 1e6,
|
|
280
|
+
rewardsPaid: account.rewardsPaid.toNumber() / 1e6
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
exports.formatCentral = formatCentral;
|
|
274
284
|
const getPriceFeedAccountForProgram = (priceFeedId) => {
|
|
275
285
|
let buffer = null;
|
|
276
286
|
if (typeof priceFeedId == 'string') {
|