@triadxyz/triad-protocol 0.6.8-beta.devnet → 0.6.9-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 +40 -9
- package/dist/trade.js +26 -24
- package/dist/types/idl_triad_protocol.json +5 -1
- package/dist/types/trade.d.ts +13 -12
- package/dist/types/triad_protocol.d.ts +5 -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: Math.floor(Math.random() * 2),
|
|
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: Math.floor(Math.random() * 2),
|
|
51
51
|
direction: {
|
|
52
52
|
flop: {}
|
|
53
53
|
},
|
|
@@ -58,7 +58,7 @@ const ordersHypeAndFloopBot = [
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
marketId: 0,
|
|
61
|
-
amount:
|
|
61
|
+
amount: Math.floor(Math.random() * 2),
|
|
62
62
|
direction: {
|
|
63
63
|
hype: {}
|
|
64
64
|
},
|
|
@@ -69,7 +69,7 @@ const ordersHypeAndFloopBot = [
|
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
marketId: 0,
|
|
72
|
-
amount:
|
|
72
|
+
amount: Math.floor(Math.random() * 2),
|
|
73
73
|
direction: {
|
|
74
74
|
flop: {}
|
|
75
75
|
},
|
|
@@ -80,7 +80,7 @@ const ordersHypeAndFloopBot = [
|
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
marketId: 0,
|
|
83
|
-
amount:
|
|
83
|
+
amount: Math.floor(Math.random() * 2),
|
|
84
84
|
direction: {
|
|
85
85
|
hype: {}
|
|
86
86
|
},
|
|
@@ -90,7 +90,7 @@ const ordersHypeAndFloopBot = [
|
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
marketId: 0,
|
|
93
|
-
amount:
|
|
93
|
+
amount: Math.floor(Math.random() * 2),
|
|
94
94
|
direction: {
|
|
95
95
|
flop: {}
|
|
96
96
|
},
|
|
@@ -100,7 +100,7 @@ const ordersHypeAndFloopBot = [
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
marketId: 0,
|
|
103
|
-
amount:
|
|
103
|
+
amount: Math.floor(Math.random() * 2),
|
|
104
104
|
direction: {
|
|
105
105
|
flop: {}
|
|
106
106
|
},
|
|
@@ -110,7 +110,27 @@ const ordersHypeAndFloopBot = [
|
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
marketId: 0,
|
|
113
|
-
amount:
|
|
113
|
+
amount: Math.floor(Math.random() * 2),
|
|
114
|
+
direction: {
|
|
115
|
+
hype: {}
|
|
116
|
+
},
|
|
117
|
+
orderType: {
|
|
118
|
+
market: {}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
marketId: 0,
|
|
123
|
+
amount: Math.floor(Math.random() * 2),
|
|
124
|
+
direction: {
|
|
125
|
+
hype: {}
|
|
126
|
+
},
|
|
127
|
+
orderType: {
|
|
128
|
+
market: {}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
marketId: 0,
|
|
133
|
+
amount: Math.floor(Math.random() * 2),
|
|
114
134
|
direction: {
|
|
115
135
|
hype: {}
|
|
116
136
|
},
|
|
@@ -148,6 +168,7 @@ const getMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
148
168
|
const markets = yield triadProtocol.trade.getMarkets();
|
|
149
169
|
console.log(markets);
|
|
150
170
|
});
|
|
171
|
+
getMarkets();
|
|
151
172
|
const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
173
|
for (const market of markets) {
|
|
153
174
|
try {
|
|
@@ -178,7 +199,6 @@ const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
178
199
|
console.log(response);
|
|
179
200
|
}
|
|
180
201
|
});
|
|
181
|
-
openOrder();
|
|
182
202
|
const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
203
|
for (const order of yield getOrders()) {
|
|
184
204
|
try {
|
|
@@ -191,3 +211,14 @@ const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
191
211
|
catch (_a) { }
|
|
192
212
|
}
|
|
193
213
|
});
|
|
214
|
+
const runBot = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
+
while (true) {
|
|
216
|
+
const hasOpenOrders = (yield getOrders()).find((order) => order !== 0);
|
|
217
|
+
if (hasOpenOrders) {
|
|
218
|
+
yield closeOrder();
|
|
219
|
+
}
|
|
220
|
+
yield openOrder();
|
|
221
|
+
yield closeOrder();
|
|
222
|
+
yield new Promise((resolve) => setTimeout(resolve, 5000));
|
|
223
|
+
}
|
|
224
|
+
});
|
package/dist/trade.js
CHANGED
|
@@ -31,23 +31,24 @@ class Trade {
|
|
|
31
31
|
bump: account.bump,
|
|
32
32
|
address: publicKey.toString(),
|
|
33
33
|
authority: account.authority.toString(),
|
|
34
|
-
marketId: account.marketId.
|
|
34
|
+
marketId: account.marketId.toString(),
|
|
35
35
|
name: account.name,
|
|
36
|
-
hypePrice: account.hypePrice.
|
|
37
|
-
flopPrice: account.flopPrice.
|
|
38
|
-
hypeLiquidity: account.hypeLiquidity.
|
|
39
|
-
flopLiquidity: account.flopLiquidity.
|
|
40
|
-
totalHypeShares: account.totalHypeShares.
|
|
41
|
-
totalFlopShares: account.totalFlopShares.
|
|
42
|
-
totalVolume: account.totalVolume.
|
|
36
|
+
hypePrice: account.hypePrice.toString(),
|
|
37
|
+
flopPrice: account.flopPrice.toString(),
|
|
38
|
+
hypeLiquidity: account.hypeLiquidity.toString(),
|
|
39
|
+
flopLiquidity: account.flopLiquidity.toString(),
|
|
40
|
+
totalHypeShares: account.totalHypeShares.toString(),
|
|
41
|
+
totalFlopShares: account.totalFlopShares.toString(),
|
|
42
|
+
totalVolume: account.totalVolume.toString(),
|
|
43
43
|
mint: account.mint.toString(),
|
|
44
|
-
ts: account.ts.
|
|
45
|
-
updateTs: account.updateTs.
|
|
46
|
-
openOrdersCount: account.openOrdersCount.
|
|
47
|
-
nextOrderId: account.nextOrderId.
|
|
44
|
+
ts: account.ts.toString(),
|
|
45
|
+
updateTs: account.updateTs.toString(),
|
|
46
|
+
openOrdersCount: account.openOrdersCount.toString(),
|
|
47
|
+
nextOrderId: account.nextOrderId.toString(),
|
|
48
48
|
feeBps: account.feeBps,
|
|
49
49
|
feeVault: account.feeVault.toBase58(),
|
|
50
50
|
isActive: account.isActive,
|
|
51
|
+
marketPrice: account.marketPrice.toString(),
|
|
51
52
|
isOfficial: account.isOfficial
|
|
52
53
|
})));
|
|
53
54
|
});
|
|
@@ -59,23 +60,24 @@ class Trade {
|
|
|
59
60
|
bump: account.bump,
|
|
60
61
|
address: address.toString(),
|
|
61
62
|
authority: account.authority.toString(),
|
|
62
|
-
marketId: account.marketId.
|
|
63
|
+
marketId: account.marketId.toString(),
|
|
63
64
|
name: account.name,
|
|
64
|
-
hypePrice: account.hypePrice.
|
|
65
|
-
flopPrice: account.flopPrice.
|
|
66
|
-
hypeLiquidity: account.hypeLiquidity.
|
|
67
|
-
flopLiquidity: account.flopLiquidity.
|
|
68
|
-
totalHypeShares: account.totalHypeShares.
|
|
69
|
-
totalFlopShares: account.totalFlopShares.
|
|
70
|
-
totalVolume: account.totalVolume.
|
|
65
|
+
hypePrice: account.hypePrice.toString(),
|
|
66
|
+
flopPrice: account.flopPrice.toString(),
|
|
67
|
+
hypeLiquidity: account.hypeLiquidity.toString(),
|
|
68
|
+
flopLiquidity: account.flopLiquidity.toString(),
|
|
69
|
+
totalHypeShares: account.totalHypeShares.toString(),
|
|
70
|
+
totalFlopShares: account.totalFlopShares.toString(),
|
|
71
|
+
totalVolume: account.totalVolume.toString(),
|
|
71
72
|
mint: account.mint.toString(),
|
|
72
|
-
ts: account.ts.
|
|
73
|
-
updateTs: account.updateTs.
|
|
74
|
-
openOrdersCount: account.openOrdersCount.
|
|
75
|
-
nextOrderId: account.nextOrderId.
|
|
73
|
+
ts: account.ts.toString(),
|
|
74
|
+
updateTs: account.updateTs.toString(),
|
|
75
|
+
openOrdersCount: account.openOrdersCount.toString(),
|
|
76
|
+
nextOrderId: account.nextOrderId.toString(),
|
|
76
77
|
feeBps: account.feeBps,
|
|
77
78
|
feeVault: account.feeVault.toBase58(),
|
|
78
79
|
isActive: account.isActive,
|
|
80
|
+
marketPrice: account.marketPrice.toString(),
|
|
79
81
|
isOfficial: account.isOfficial
|
|
80
82
|
};
|
|
81
83
|
});
|
|
@@ -1515,10 +1515,14 @@
|
|
|
1515
1515
|
"name": "is_official",
|
|
1516
1516
|
"type": "bool"
|
|
1517
1517
|
},
|
|
1518
|
+
{
|
|
1519
|
+
"name": "market_price",
|
|
1520
|
+
"type": "u64"
|
|
1521
|
+
},
|
|
1518
1522
|
{
|
|
1519
1523
|
"name": "padding",
|
|
1520
1524
|
"type": {
|
|
1521
|
-
"array": ["u8",
|
|
1525
|
+
"array": ["u8", 224]
|
|
1522
1526
|
}
|
|
1523
1527
|
}
|
|
1524
1528
|
]
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -2,23 +2,24 @@ export type Market = {
|
|
|
2
2
|
address: string;
|
|
3
3
|
bump: number;
|
|
4
4
|
authority: string;
|
|
5
|
-
marketId:
|
|
5
|
+
marketId: string;
|
|
6
6
|
name: string;
|
|
7
|
-
hypePrice:
|
|
8
|
-
flopPrice:
|
|
9
|
-
hypeLiquidity:
|
|
10
|
-
flopLiquidity:
|
|
11
|
-
totalHypeShares:
|
|
12
|
-
totalFlopShares:
|
|
13
|
-
totalVolume:
|
|
7
|
+
hypePrice: string;
|
|
8
|
+
flopPrice: string;
|
|
9
|
+
hypeLiquidity: string;
|
|
10
|
+
flopLiquidity: string;
|
|
11
|
+
totalHypeShares: string;
|
|
12
|
+
totalFlopShares: string;
|
|
13
|
+
totalVolume: string;
|
|
14
14
|
mint: string;
|
|
15
|
-
ts:
|
|
16
|
-
updateTs:
|
|
17
|
-
openOrdersCount:
|
|
18
|
-
nextOrderId:
|
|
15
|
+
ts: string;
|
|
16
|
+
updateTs: string;
|
|
17
|
+
openOrdersCount: string;
|
|
18
|
+
nextOrderId: string;
|
|
19
19
|
feeBps: number;
|
|
20
20
|
feeVault: string;
|
|
21
21
|
isActive: boolean;
|
|
22
|
+
marketPrice: string;
|
|
22
23
|
isOfficial: boolean;
|
|
23
24
|
};
|
|
24
25
|
export type OrderDirection = {
|
|
@@ -1985,10 +1985,14 @@ export type TriadProtocol = {
|
|
|
1985
1985
|
name: 'isOfficial';
|
|
1986
1986
|
type: 'bool';
|
|
1987
1987
|
},
|
|
1988
|
+
{
|
|
1989
|
+
name: 'marketPrice';
|
|
1990
|
+
type: 'u64';
|
|
1991
|
+
},
|
|
1988
1992
|
{
|
|
1989
1993
|
name: 'padding';
|
|
1990
1994
|
type: {
|
|
1991
|
-
array: ['u8',
|
|
1995
|
+
array: ['u8', 224];
|
|
1992
1996
|
};
|
|
1993
1997
|
}
|
|
1994
1998
|
];
|