@triadxyz/triad-protocol 0.7.0-beta.devnet → 0.7.2-beta.devnet
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/local-test.js +6 -5
- package/dist/trade.js +9 -49
- package/dist/types/idl_triad_protocol.json +41 -18
- package/dist/types/trade.d.ts +21 -0
- package/dist/types/trade.js +7 -0
- package/dist/types/triad_protocol.d.ts +70 -18
- package/dist/utils/helpers.d.ts +3 -0
- package/dist/utils/helpers.js +49 -1
- package/package.json +1 -1
package/dist/local-test.js
CHANGED
|
@@ -36,7 +36,7 @@ const markets = [
|
|
|
36
36
|
const ordersHypeAndFloopBot = [
|
|
37
37
|
{
|
|
38
38
|
marketId: 0,
|
|
39
|
-
amount:
|
|
39
|
+
amount: 1000,
|
|
40
40
|
direction: {
|
|
41
41
|
hype: {}
|
|
42
42
|
},
|
|
@@ -47,7 +47,7 @@ const ordersHypeAndFloopBot = [
|
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
marketId: 0,
|
|
50
|
-
amount:
|
|
50
|
+
amount: 10000,
|
|
51
51
|
direction: {
|
|
52
52
|
flop: {}
|
|
53
53
|
},
|
|
@@ -183,7 +183,6 @@ const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
183
183
|
});
|
|
184
184
|
const getOrders = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
185
|
const response = (yield triadProtocol.program.account.userTrade.all()).find((userTrade) => userTrade.account.authority.toBase58() === wallet.publicKey.toBase58());
|
|
186
|
-
console.log(response);
|
|
187
186
|
return response.account.orders.map((order) => order.orderId.toNumber());
|
|
188
187
|
});
|
|
189
188
|
const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -200,6 +199,7 @@ const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
200
199
|
console.log(response);
|
|
201
200
|
}
|
|
202
201
|
});
|
|
202
|
+
openOrder();
|
|
203
203
|
const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
204
204
|
for (const order of yield getOrders()) {
|
|
205
205
|
try {
|
|
@@ -209,7 +209,9 @@ const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
209
209
|
});
|
|
210
210
|
console.log(response);
|
|
211
211
|
}
|
|
212
|
-
catch (
|
|
212
|
+
catch (e) {
|
|
213
|
+
console.log(e);
|
|
214
|
+
}
|
|
213
215
|
}
|
|
214
216
|
});
|
|
215
217
|
const runBot = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -223,4 +225,3 @@ const runBot = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
223
225
|
yield closeOrder();
|
|
224
226
|
}
|
|
225
227
|
});
|
|
226
|
-
openOrder();
|
package/dist/trade.js
CHANGED
|
@@ -29,59 +29,15 @@ class Trade {
|
|
|
29
29
|
*/
|
|
30
30
|
getMarkets() {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return this.program.account.market
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
authority: account.authority.toString(),
|
|
36
|
-
marketId: account.marketId.toString(),
|
|
37
|
-
name: account.name,
|
|
38
|
-
hypePrice: account.hypePrice.toString(),
|
|
39
|
-
flopPrice: account.flopPrice.toString(),
|
|
40
|
-
hypeLiquidity: account.hypeLiquidity.toString(),
|
|
41
|
-
flopLiquidity: account.flopLiquidity.toString(),
|
|
42
|
-
totalHypeShares: account.totalHypeShares.toString(),
|
|
43
|
-
totalFlopShares: account.totalFlopShares.toString(),
|
|
44
|
-
totalVolume: account.totalVolume.toString(),
|
|
45
|
-
mint: account.mint.toString(),
|
|
46
|
-
ts: account.ts.toString(),
|
|
47
|
-
updateTs: account.updateTs.toString(),
|
|
48
|
-
openOrdersCount: account.openOrdersCount.toString(),
|
|
49
|
-
nextOrderId: account.nextOrderId.toString(),
|
|
50
|
-
feeBps: account.feeBps,
|
|
51
|
-
feeVault: account.feeVault.toBase58(),
|
|
52
|
-
isActive: account.isActive,
|
|
53
|
-
marketPrice: account.marketPrice.toString(),
|
|
54
|
-
isOfficial: account.isOfficial
|
|
55
|
-
})));
|
|
32
|
+
return this.program.account.market
|
|
33
|
+
.all()
|
|
34
|
+
.then((markets) => markets.map(({ account, publicKey }) => (0, helpers_1.accountToMarket)(account, publicKey)));
|
|
56
35
|
});
|
|
57
36
|
}
|
|
58
37
|
getMarketByAddress(address) {
|
|
59
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
39
|
const account = yield this.program.account.market.fetch(address);
|
|
61
|
-
return
|
|
62
|
-
bump: account.bump,
|
|
63
|
-
address: address.toString(),
|
|
64
|
-
authority: account.authority.toString(),
|
|
65
|
-
marketId: account.marketId.toString(),
|
|
66
|
-
name: account.name,
|
|
67
|
-
hypePrice: account.hypePrice.toString(),
|
|
68
|
-
flopPrice: account.flopPrice.toString(),
|
|
69
|
-
hypeLiquidity: account.hypeLiquidity.toString(),
|
|
70
|
-
flopLiquidity: account.flopLiquidity.toString(),
|
|
71
|
-
totalHypeShares: account.totalHypeShares.toString(),
|
|
72
|
-
totalFlopShares: account.totalFlopShares.toString(),
|
|
73
|
-
totalVolume: account.totalVolume.toString(),
|
|
74
|
-
mint: account.mint.toString(),
|
|
75
|
-
ts: account.ts.toString(),
|
|
76
|
-
updateTs: account.updateTs.toString(),
|
|
77
|
-
openOrdersCount: account.openOrdersCount.toString(),
|
|
78
|
-
nextOrderId: account.nextOrderId.toString(),
|
|
79
|
-
feeBps: account.feeBps,
|
|
80
|
-
feeVault: account.feeVault.toBase58(),
|
|
81
|
-
isActive: account.isActive,
|
|
82
|
-
marketPrice: account.marketPrice.toString(),
|
|
83
|
-
isOfficial: account.isOfficial
|
|
84
|
-
};
|
|
40
|
+
return (0, helpers_1.accountToMarket)(account, address);
|
|
85
41
|
});
|
|
86
42
|
}
|
|
87
43
|
/**
|
|
@@ -92,6 +48,8 @@ class Trade {
|
|
|
92
48
|
*/
|
|
93
49
|
initializeMarket({ marketId, name }, options) {
|
|
94
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
|
|
52
|
+
const feeVaultPDA = (0, trade_1.getFeeVaultPDA)(this.program.programId, marketId);
|
|
95
53
|
const method = this.program.methods
|
|
96
54
|
.initializeMarket({
|
|
97
55
|
marketId: new bn_js_1.default(marketId),
|
|
@@ -171,10 +129,12 @@ class Trade {
|
|
|
171
129
|
closeOrder({ marketId, orderId }, options) {
|
|
172
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
131
|
const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
|
|
132
|
+
const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
|
|
174
133
|
const method = this.program.methods.closeOrder(new bn_js_1.default(orderId)).accounts({
|
|
175
134
|
signer: this.provider.publicKey,
|
|
176
135
|
market: marketPDA,
|
|
177
|
-
mint: this.mint
|
|
136
|
+
mint: this.mint,
|
|
137
|
+
userTrade: userTradePDA
|
|
178
138
|
});
|
|
179
139
|
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
180
140
|
method.postInstructions([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"address": "
|
|
2
|
+
"address": "4YWv2Ex8WjFGyXmYELD6Xqs1ZsuQujVUzZxbvdvM2tCj",
|
|
3
3
|
"metadata": {
|
|
4
4
|
"name": "triad_protocol",
|
|
5
5
|
"version": "0.1.4",
|
|
@@ -353,10 +353,42 @@
|
|
|
353
353
|
]
|
|
354
354
|
}
|
|
355
355
|
},
|
|
356
|
+
{
|
|
357
|
+
"name": "fee_ata",
|
|
358
|
+
"writable": true,
|
|
359
|
+
"pda": {
|
|
360
|
+
"seeds": [
|
|
361
|
+
{
|
|
362
|
+
"kind": "account",
|
|
363
|
+
"path": "fee_vault"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"kind": "account",
|
|
367
|
+
"path": "token_program"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"kind": "account",
|
|
371
|
+
"path": "mint"
|
|
372
|
+
}
|
|
373
|
+
],
|
|
374
|
+
"program": {
|
|
375
|
+
"kind": "const",
|
|
376
|
+
"value": [
|
|
377
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
378
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
379
|
+
219, 233, 248, 89
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
},
|
|
356
384
|
{
|
|
357
385
|
"name": "token_program",
|
|
358
386
|
"address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
359
387
|
},
|
|
388
|
+
{
|
|
389
|
+
"name": "associated_token_program",
|
|
390
|
+
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
391
|
+
},
|
|
360
392
|
{
|
|
361
393
|
"name": "system_program",
|
|
362
394
|
"address": "11111111111111111111111111111111"
|
|
@@ -1434,25 +1466,16 @@
|
|
|
1434
1466
|
"docs": ["Whether the market is currently active for trading"],
|
|
1435
1467
|
"type": "bool"
|
|
1436
1468
|
},
|
|
1437
|
-
{
|
|
1438
|
-
"name": "is_official",
|
|
1439
|
-
"type": "bool"
|
|
1440
|
-
},
|
|
1441
1469
|
{
|
|
1442
1470
|
"name": "market_price",
|
|
1443
1471
|
"type": "u64"
|
|
1444
1472
|
},
|
|
1445
1473
|
{
|
|
1446
|
-
"name": "
|
|
1474
|
+
"name": "previous_resolved_question",
|
|
1447
1475
|
"type": {
|
|
1448
|
-
"
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
"name": "ResolvedQuestion"
|
|
1452
|
-
}
|
|
1453
|
-
},
|
|
1454
|
-
4
|
|
1455
|
-
]
|
|
1476
|
+
"defined": {
|
|
1477
|
+
"name": "ResolvedQuestion"
|
|
1478
|
+
}
|
|
1456
1479
|
}
|
|
1457
1480
|
},
|
|
1458
1481
|
{
|
|
@@ -1477,13 +1500,13 @@
|
|
|
1477
1500
|
"name": "current_question",
|
|
1478
1501
|
"docs": ["The question or prediction topic for the current week"],
|
|
1479
1502
|
"type": {
|
|
1480
|
-
"array": ["u8",
|
|
1503
|
+
"array": ["u8", 80]
|
|
1481
1504
|
}
|
|
1482
1505
|
},
|
|
1483
1506
|
{
|
|
1484
1507
|
"name": "padding",
|
|
1485
1508
|
"type": {
|
|
1486
|
-
"array": ["u8",
|
|
1509
|
+
"array": ["u8", 180]
|
|
1487
1510
|
}
|
|
1488
1511
|
}
|
|
1489
1512
|
]
|
|
@@ -1782,7 +1805,7 @@
|
|
|
1782
1805
|
"name": "question",
|
|
1783
1806
|
"docs": ["The question or prediction topic for this week"],
|
|
1784
1807
|
"type": {
|
|
1785
|
-
"array": ["u8",
|
|
1808
|
+
"array": ["u8", 80]
|
|
1786
1809
|
}
|
|
1787
1810
|
},
|
|
1788
1811
|
{
|
|
@@ -1831,7 +1854,7 @@
|
|
|
1831
1854
|
{
|
|
1832
1855
|
"name": "padding",
|
|
1833
1856
|
"type": {
|
|
1834
|
-
"array": ["u8",
|
|
1857
|
+
"array": ["u8", 64]
|
|
1835
1858
|
}
|
|
1836
1859
|
}
|
|
1837
1860
|
]
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -21,7 +21,28 @@ export type Market = {
|
|
|
21
21
|
isActive: boolean;
|
|
22
22
|
marketPrice: string;
|
|
23
23
|
isOfficial: boolean;
|
|
24
|
+
resolvedQuestions: ResolvedQuestion[];
|
|
25
|
+
currentQuestionId: string;
|
|
26
|
+
currentQuestionStart: string;
|
|
27
|
+
currentQuestionEnd: string;
|
|
28
|
+
currentQuestion: string;
|
|
24
29
|
};
|
|
30
|
+
export type ResolvedQuestion = {
|
|
31
|
+
question: string;
|
|
32
|
+
startTime: string;
|
|
33
|
+
endTime: string;
|
|
34
|
+
hypeLiquidity: string;
|
|
35
|
+
flopLiquidity: string;
|
|
36
|
+
winningDirection: WinningDirection;
|
|
37
|
+
marketPrice: string;
|
|
38
|
+
finalHypePrice: string;
|
|
39
|
+
finalFlopPrice: string;
|
|
40
|
+
};
|
|
41
|
+
export declare enum WinningDirection {
|
|
42
|
+
Hype = "Hype",
|
|
43
|
+
Flop = "Flop",
|
|
44
|
+
None = "None"
|
|
45
|
+
}
|
|
25
46
|
export type OrderDirection = {
|
|
26
47
|
hype: {};
|
|
27
48
|
} | {
|
package/dist/types/trade.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WinningDirection = void 0;
|
|
4
|
+
var WinningDirection;
|
|
5
|
+
(function (WinningDirection) {
|
|
6
|
+
WinningDirection["Hype"] = "Hype";
|
|
7
|
+
WinningDirection["Flop"] = "Flop";
|
|
8
|
+
WinningDirection["None"] = "None";
|
|
9
|
+
})(WinningDirection || (exports.WinningDirection = WinningDirection = {}));
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* IDL can be found at `target/idl/triad_protocol.json`.
|
|
6
6
|
*/
|
|
7
7
|
export type TriadProtocol = {
|
|
8
|
-
address: '
|
|
8
|
+
address: '4YWv2Ex8WjFGyXmYELD6Xqs1ZsuQujVUzZxbvdvM2tCj';
|
|
9
9
|
metadata: {
|
|
10
10
|
name: 'triadProtocol';
|
|
11
11
|
version: '0.1.4';
|
|
@@ -475,10 +475,71 @@ export type TriadProtocol = {
|
|
|
475
475
|
];
|
|
476
476
|
};
|
|
477
477
|
},
|
|
478
|
+
{
|
|
479
|
+
name: 'feeAta';
|
|
480
|
+
writable: true;
|
|
481
|
+
pda: {
|
|
482
|
+
seeds: [
|
|
483
|
+
{
|
|
484
|
+
kind: 'account';
|
|
485
|
+
path: 'feeVault';
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
kind: 'account';
|
|
489
|
+
path: 'tokenProgram';
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
kind: 'account';
|
|
493
|
+
path: 'mint';
|
|
494
|
+
}
|
|
495
|
+
];
|
|
496
|
+
program: {
|
|
497
|
+
kind: 'const';
|
|
498
|
+
value: [
|
|
499
|
+
140,
|
|
500
|
+
151,
|
|
501
|
+
37,
|
|
502
|
+
143,
|
|
503
|
+
78,
|
|
504
|
+
36,
|
|
505
|
+
137,
|
|
506
|
+
241,
|
|
507
|
+
187,
|
|
508
|
+
61,
|
|
509
|
+
16,
|
|
510
|
+
41,
|
|
511
|
+
20,
|
|
512
|
+
142,
|
|
513
|
+
13,
|
|
514
|
+
131,
|
|
515
|
+
11,
|
|
516
|
+
90,
|
|
517
|
+
19,
|
|
518
|
+
153,
|
|
519
|
+
218,
|
|
520
|
+
255,
|
|
521
|
+
16,
|
|
522
|
+
132,
|
|
523
|
+
4,
|
|
524
|
+
142,
|
|
525
|
+
123,
|
|
526
|
+
216,
|
|
527
|
+
219,
|
|
528
|
+
233,
|
|
529
|
+
248,
|
|
530
|
+
89
|
|
531
|
+
];
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
},
|
|
478
535
|
{
|
|
479
536
|
name: 'tokenProgram';
|
|
480
537
|
address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
|
|
481
538
|
},
|
|
539
|
+
{
|
|
540
|
+
name: 'associatedTokenProgram';
|
|
541
|
+
address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
542
|
+
},
|
|
482
543
|
{
|
|
483
544
|
name: 'systemProgram';
|
|
484
545
|
address: '11111111111111111111111111111111';
|
|
@@ -1844,25 +1905,16 @@ export type TriadProtocol = {
|
|
|
1844
1905
|
docs: ['Whether the market is currently active for trading'];
|
|
1845
1906
|
type: 'bool';
|
|
1846
1907
|
},
|
|
1847
|
-
{
|
|
1848
|
-
name: 'isOfficial';
|
|
1849
|
-
type: 'bool';
|
|
1850
|
-
},
|
|
1851
1908
|
{
|
|
1852
1909
|
name: 'marketPrice';
|
|
1853
1910
|
type: 'u64';
|
|
1854
1911
|
},
|
|
1855
1912
|
{
|
|
1856
|
-
name: '
|
|
1913
|
+
name: 'previousResolvedQuestion';
|
|
1857
1914
|
type: {
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
name: 'resolvedQuestion';
|
|
1862
|
-
};
|
|
1863
|
-
},
|
|
1864
|
-
4
|
|
1865
|
-
];
|
|
1915
|
+
defined: {
|
|
1916
|
+
name: 'resolvedQuestion';
|
|
1917
|
+
};
|
|
1866
1918
|
};
|
|
1867
1919
|
},
|
|
1868
1920
|
{
|
|
@@ -1887,13 +1939,13 @@ export type TriadProtocol = {
|
|
|
1887
1939
|
name: 'currentQuestion';
|
|
1888
1940
|
docs: ['The question or prediction topic for the current week'];
|
|
1889
1941
|
type: {
|
|
1890
|
-
array: ['u8',
|
|
1942
|
+
array: ['u8', 80];
|
|
1891
1943
|
};
|
|
1892
1944
|
},
|
|
1893
1945
|
{
|
|
1894
1946
|
name: 'padding';
|
|
1895
1947
|
type: {
|
|
1896
|
-
array: ['u8',
|
|
1948
|
+
array: ['u8', 180];
|
|
1897
1949
|
};
|
|
1898
1950
|
}
|
|
1899
1951
|
];
|
|
@@ -2192,7 +2244,7 @@ export type TriadProtocol = {
|
|
|
2192
2244
|
name: 'question';
|
|
2193
2245
|
docs: ['The question or prediction topic for this week'];
|
|
2194
2246
|
type: {
|
|
2195
|
-
array: ['u8',
|
|
2247
|
+
array: ['u8', 80];
|
|
2196
2248
|
};
|
|
2197
2249
|
},
|
|
2198
2250
|
{
|
|
@@ -2241,7 +2293,7 @@ export type TriadProtocol = {
|
|
|
2241
2293
|
{
|
|
2242
2294
|
name: 'padding';
|
|
2243
2295
|
type: {
|
|
2244
|
-
array: ['u8',
|
|
2296
|
+
array: ['u8', 64];
|
|
2245
2297
|
};
|
|
2246
2298
|
}
|
|
2247
2299
|
];
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Stake, StakeVault } from './../types/stake';
|
|
2
2
|
import { User } from './../types';
|
|
3
|
+
import { Market } from '../types/trade';
|
|
4
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
5
|
export declare const encodeString: (value: string, alloc?: number) => number[];
|
|
4
6
|
export declare const decodeString: (bytes: number[]) => string;
|
|
5
7
|
export declare const formatStakeVault: (stakeVault: any) => StakeVault;
|
|
6
8
|
export declare const formatStake: (stake: any) => Stake;
|
|
7
9
|
export declare const formatUser: (user: any) => User;
|
|
10
|
+
export declare const accountToMarket: (account: any, address: PublicKey) => Market;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
3
|
+
exports.accountToMarket = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
|
+
const trade_1 = require("../types/trade");
|
|
4
5
|
const encodeString = (value, alloc = 32) => {
|
|
5
6
|
const buffer = Buffer.alloc(alloc);
|
|
6
7
|
buffer.fill(value);
|
|
@@ -62,3 +63,50 @@ const formatUser = (user) => {
|
|
|
62
63
|
};
|
|
63
64
|
};
|
|
64
65
|
exports.formatUser = formatUser;
|
|
66
|
+
const accountToMarket = (account, address) => {
|
|
67
|
+
return {
|
|
68
|
+
bump: account.bump,
|
|
69
|
+
address: address.toString(),
|
|
70
|
+
authority: account.authority.toString(),
|
|
71
|
+
marketId: account.marketId.toString(),
|
|
72
|
+
name: account.name,
|
|
73
|
+
hypePrice: account.hypePrice.toString(),
|
|
74
|
+
flopPrice: account.flopPrice.toString(),
|
|
75
|
+
hypeLiquidity: account.hypeLiquidity.toString(),
|
|
76
|
+
flopLiquidity: account.flopLiquidity.toString(),
|
|
77
|
+
totalHypeShares: account.totalHypeShares.toString(),
|
|
78
|
+
totalFlopShares: account.totalFlopShares.toString(),
|
|
79
|
+
totalVolume: account.totalVolume.toString(),
|
|
80
|
+
mint: account.mint.toString(),
|
|
81
|
+
ts: account.ts.toString(),
|
|
82
|
+
updateTs: account.updateTs.toString(),
|
|
83
|
+
openOrdersCount: account.openOrdersCount.toString(),
|
|
84
|
+
nextOrderId: account.nextOrderId.toString(),
|
|
85
|
+
feeBps: account.feeBps,
|
|
86
|
+
feeVault: account.feeVault.toBase58(),
|
|
87
|
+
isActive: account.isActive,
|
|
88
|
+
marketPrice: account.marketPrice.toString(),
|
|
89
|
+
isOfficial: account.isOfficial,
|
|
90
|
+
resolvedQuestions: account.resolvedQuestions.map(accountToResolvedQuestion),
|
|
91
|
+
currentQuestionId: account.currentQuestionId.toString(),
|
|
92
|
+
currentQuestionStart: account.currentQuestionStart.toString(),
|
|
93
|
+
currentQuestionEnd: account.currentQuestionEnd.toString(),
|
|
94
|
+
currentQuestion: Buffer.from(account.currentQuestion)
|
|
95
|
+
.toString()
|
|
96
|
+
.replace(/\0+$/, '')
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.accountToMarket = accountToMarket;
|
|
100
|
+
const accountToResolvedQuestion = (question) => {
|
|
101
|
+
return {
|
|
102
|
+
question: Buffer.from(question.question).toString().replace(/\0+$/, ''),
|
|
103
|
+
startTime: question.startTime.toString(),
|
|
104
|
+
endTime: question.endTime.toString(),
|
|
105
|
+
hypeLiquidity: question.hypeLiquidity.toString(),
|
|
106
|
+
flopLiquidity: question.flopLiquidity.toString(),
|
|
107
|
+
winningDirection: trade_1.WinningDirection[question.winningDirection],
|
|
108
|
+
marketPrice: question.marketPrice.toString(),
|
|
109
|
+
finalHypePrice: question.finalHypePrice.toString(),
|
|
110
|
+
finalFlopPrice: question.finalFlopPrice.toString()
|
|
111
|
+
};
|
|
112
|
+
};
|