@triadxyz/triad-protocol 3.5.0-beta → 3.5.2-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/index.d.ts +10 -5
- package/dist/index.js +35 -38
- package/dist/types/idl_triad_protocol.json +42 -256
- package/dist/types/index.d.ts +3 -0
- package/dist/types/triad_protocol.d.ts +42 -256
- package/dist/utils/feeCalculator.js +2 -8
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +10 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './types';
|
|
|
10
10
|
export * from './utils/helpers';
|
|
11
11
|
export * from './utils/merkle';
|
|
12
12
|
export * from './utils/feeCalculator';
|
|
13
|
+
export * from './utils/constants';
|
|
13
14
|
export default class TriadProtocol {
|
|
14
15
|
private connection;
|
|
15
16
|
private wallet;
|
|
@@ -25,6 +26,11 @@ export default class TriadProtocol {
|
|
|
25
26
|
* @param wallet - User wallet PublicKey
|
|
26
27
|
*/
|
|
27
28
|
getUserOrders(wallet: PublicKey): Promise<import("./types").Order[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Get Orders By Market ID
|
|
31
|
+
* @param marketId - The ID of the market
|
|
32
|
+
*/
|
|
33
|
+
getOrdersByMarketId(marketId: number): Promise<import("./types").Order[]>;
|
|
28
34
|
/**
|
|
29
35
|
* Get User Orders By Market ID
|
|
30
36
|
* @param wallet - User wallet PublicKey
|
|
@@ -189,6 +195,7 @@ export default class TriadProtocol {
|
|
|
189
195
|
marketId: number;
|
|
190
196
|
orderDirection: OrderDirectionEncoded;
|
|
191
197
|
mint: PublicKey;
|
|
198
|
+
authority: PublicKey;
|
|
192
199
|
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
193
200
|
/**
|
|
194
201
|
* Create Customer
|
|
@@ -210,12 +217,11 @@ export default class TriadProtocol {
|
|
|
210
217
|
placeBidOrder({ orders, isTrdPayout }: PlaceBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
211
218
|
/**
|
|
212
219
|
* Place Ask Order
|
|
213
|
-
* @param args.marketId - The ID of the Market
|
|
214
220
|
* @param args.orders - Array of orders to execute
|
|
215
221
|
* @param args.orders.amount - The amount of the Order
|
|
216
222
|
* @param args.orders.price - The price of the Order
|
|
217
|
-
* @param args.orders.
|
|
218
|
-
* @param args.orders.
|
|
223
|
+
* @param args.orders.marketId - The Id from the market
|
|
224
|
+
* @param args.orders.orderDirection - The direction of the Order
|
|
219
225
|
*/
|
|
220
226
|
placeAskOrder({ orders }: PlaceAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
221
227
|
/**
|
|
@@ -228,6 +234,7 @@ export default class TriadProtocol {
|
|
|
228
234
|
/**
|
|
229
235
|
* Cancel Ask Order
|
|
230
236
|
* @param args.orders.marketId - The ID of the Market
|
|
237
|
+
* @param args.orders.authority - The authority of the order
|
|
231
238
|
* @param args.orders.bookOrderId - The ID of the Book Order
|
|
232
239
|
* @param args.orders.orderDirection - The direction of the Order
|
|
233
240
|
*/
|
|
@@ -275,6 +282,4 @@ export default class TriadProtocol {
|
|
|
275
282
|
customerId: number;
|
|
276
283
|
feeBps: number;
|
|
277
284
|
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
278
|
-
closeUser(userTrade: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
279
|
-
migrateUserTradeToOrder(userTrade: PublicKey, marketId: number, orderId: number, orderDirection: OrderDirectionEncoded): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
280
285
|
}
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
30
30
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
31
31
|
const spl_token_1 = require("@solana/spl-token");
|
|
32
32
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
33
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
33
34
|
const helpers_1 = require("./utils/helpers");
|
|
34
35
|
const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
|
|
35
36
|
const types_1 = require("./types");
|
|
@@ -46,6 +47,7 @@ __exportStar(require("./types"), exports);
|
|
|
46
47
|
__exportStar(require("./utils/helpers"), exports);
|
|
47
48
|
__exportStar(require("./utils/merkle"), exports);
|
|
48
49
|
__exportStar(require("./utils/feeCalculator"), exports);
|
|
50
|
+
__exportStar(require("./utils/constants"), exports);
|
|
49
51
|
class TriadProtocol {
|
|
50
52
|
constructor(connection, wallet, rpcOptions) {
|
|
51
53
|
this.connection = connection;
|
|
@@ -76,7 +78,25 @@ class TriadProtocol {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
]);
|
|
79
|
-
return orders.map(({ account }) => (0, helpers_1.formatOrder)(account));
|
|
81
|
+
return orders.map(({ account, publicKey }) => (0, helpers_1.formatOrder)(account, publicKey));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get Orders By Market ID
|
|
86
|
+
* @param marketId - The ID of the market
|
|
87
|
+
*/
|
|
88
|
+
getOrdersByMarketId(marketId) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const marketIdBytes = new bn_js_1.default(marketId).toArray('le', 8);
|
|
91
|
+
const orders = yield this.program.account.orderV2.all([
|
|
92
|
+
{
|
|
93
|
+
memcmp: {
|
|
94
|
+
offset: 8 + 32,
|
|
95
|
+
bytes: bs58_1.default.encode(marketIdBytes)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]);
|
|
99
|
+
return orders.map(({ account, publicKey }) => (0, helpers_1.formatOrder)(account, publicKey));
|
|
80
100
|
});
|
|
81
101
|
}
|
|
82
102
|
/**
|
|
@@ -557,19 +577,19 @@ class TriadProtocol {
|
|
|
557
577
|
payoutOrder(orders) {
|
|
558
578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
559
579
|
const ixs = [];
|
|
560
|
-
if (orders.length >
|
|
561
|
-
throw new Error('Max
|
|
580
|
+
if (orders.length > 4) {
|
|
581
|
+
throw new Error('Max 4 orders per transaction');
|
|
562
582
|
}
|
|
563
583
|
for (const order of orders) {
|
|
564
584
|
ixs.push(yield this.program.methods
|
|
565
|
-
.payoutOrder(
|
|
585
|
+
.payoutOrder()
|
|
566
586
|
.accounts({
|
|
567
|
-
signer:
|
|
587
|
+
signer: order.authority,
|
|
568
588
|
payer: this.rpcOptions.payer,
|
|
569
589
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
570
590
|
mint: order.mint,
|
|
571
591
|
tokenProgram: (0, helpers_2.getTokenProgram)(order.mint),
|
|
572
|
-
order: (0, pda_1.getOrderPDA)(this.program.programId,
|
|
592
|
+
order: (0, pda_1.getOrderPDA)(this.program.programId, order.authority, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
|
|
573
593
|
})
|
|
574
594
|
.instruction());
|
|
575
595
|
}
|
|
@@ -661,12 +681,11 @@ class TriadProtocol {
|
|
|
661
681
|
}
|
|
662
682
|
/**
|
|
663
683
|
* Place Ask Order
|
|
664
|
-
* @param args.marketId - The ID of the Market
|
|
665
684
|
* @param args.orders - Array of orders to execute
|
|
666
685
|
* @param args.orders.amount - The amount of the Order
|
|
667
686
|
* @param args.orders.price - The price of the Order
|
|
668
|
-
* @param args.orders.
|
|
669
|
-
* @param args.orders.
|
|
687
|
+
* @param args.orders.marketId - The Id from the market
|
|
688
|
+
* @param args.orders.orderDirection - The direction of the Order
|
|
670
689
|
*/
|
|
671
690
|
placeAskOrder({ orders }) {
|
|
672
691
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -707,11 +726,12 @@ class TriadProtocol {
|
|
|
707
726
|
for (const order of orders) {
|
|
708
727
|
ixs.push(yield this.program.methods
|
|
709
728
|
.cancelBidOrder({
|
|
729
|
+
marketId: new bn_js_1.default(order.marketId),
|
|
710
730
|
bookOrderId: new bn_js_1.default(order.bookOrderId),
|
|
711
731
|
orderDirection: order.orderDirection
|
|
712
732
|
})
|
|
713
733
|
.accounts({
|
|
714
|
-
signer:
|
|
734
|
+
signer: new web3_js_1.PublicKey(order.authority),
|
|
715
735
|
payer: this.rpcOptions.payer,
|
|
716
736
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
717
737
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId)
|
|
@@ -724,6 +744,7 @@ class TriadProtocol {
|
|
|
724
744
|
/**
|
|
725
745
|
* Cancel Ask Order
|
|
726
746
|
* @param args.orders.marketId - The ID of the Market
|
|
747
|
+
* @param args.orders.authority - The authority of the order
|
|
727
748
|
* @param args.orders.bookOrderId - The ID of the Book Order
|
|
728
749
|
* @param args.orders.orderDirection - The direction of the Order
|
|
729
750
|
*/
|
|
@@ -736,14 +757,16 @@ class TriadProtocol {
|
|
|
736
757
|
for (const order of orders) {
|
|
737
758
|
ixs.push(yield this.program.methods
|
|
738
759
|
.cancelAskOrder({
|
|
760
|
+
marketId: new bn_js_1.default(order.marketId),
|
|
739
761
|
bookOrderId: new bn_js_1.default(order.bookOrderId),
|
|
740
762
|
orderDirection: order.orderDirection
|
|
741
763
|
})
|
|
742
764
|
.accounts({
|
|
743
|
-
signer:
|
|
765
|
+
signer: order.authority,
|
|
766
|
+
payer: this.rpcOptions.payer,
|
|
744
767
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
745
768
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId),
|
|
746
|
-
order: (0, pda_1.getOrderPDA)(this.program.programId,
|
|
769
|
+
order: (0, pda_1.getOrderPDA)(this.program.programId, order.authority, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
|
|
747
770
|
})
|
|
748
771
|
.instruction());
|
|
749
772
|
}
|
|
@@ -979,31 +1002,5 @@ class TriadProtocol {
|
|
|
979
1002
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
980
1003
|
});
|
|
981
1004
|
}
|
|
982
|
-
closeUser(userTrade) {
|
|
983
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
984
|
-
const ixs = [
|
|
985
|
-
yield this.program.methods
|
|
986
|
-
.closeUser()
|
|
987
|
-
.accounts({ userTrade })
|
|
988
|
-
.instruction()
|
|
989
|
-
];
|
|
990
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
migrateUserTradeToOrder(userTrade, marketId, orderId, orderDirection) {
|
|
994
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
995
|
-
const ixs = [
|
|
996
|
-
yield this.program.methods
|
|
997
|
-
.migrateUserTradeToOrder({
|
|
998
|
-
marketId: new bn_js_1.default(marketId),
|
|
999
|
-
orderId: new bn_js_1.default(orderId),
|
|
1000
|
-
orderDirection
|
|
1001
|
-
})
|
|
1002
|
-
.accounts({ userTrade })
|
|
1003
|
-
.instruction()
|
|
1004
|
-
];
|
|
1005
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
1005
|
}
|
|
1009
1006
|
exports.default = TriadProtocol;
|
|
@@ -155,6 +155,11 @@
|
|
|
155
155
|
"name": "signer",
|
|
156
156
|
"writable": true
|
|
157
157
|
},
|
|
158
|
+
{
|
|
159
|
+
"name": "payer",
|
|
160
|
+
"writable": true,
|
|
161
|
+
"signer": true
|
|
162
|
+
},
|
|
158
163
|
{
|
|
159
164
|
"name": "market",
|
|
160
165
|
"writable": true
|
|
@@ -670,26 +675,6 @@
|
|
|
670
675
|
],
|
|
671
676
|
"args": []
|
|
672
677
|
},
|
|
673
|
-
{
|
|
674
|
-
"name": "close_user",
|
|
675
|
-
"discriminator": [86, 219, 138, 140, 236, 24, 118, 200],
|
|
676
|
-
"accounts": [
|
|
677
|
-
{
|
|
678
|
-
"name": "signer",
|
|
679
|
-
"writable": true,
|
|
680
|
-
"signer": true
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
"name": "user_trade",
|
|
684
|
-
"writable": true
|
|
685
|
-
},
|
|
686
|
-
{
|
|
687
|
-
"name": "system_program",
|
|
688
|
-
"address": "11111111111111111111111111111111"
|
|
689
|
-
}
|
|
690
|
-
],
|
|
691
|
-
"args": []
|
|
692
|
-
},
|
|
693
678
|
{
|
|
694
679
|
"name": "collect_market_fee",
|
|
695
680
|
"discriminator": [139, 4, 96, 182, 216, 250, 122, 79],
|
|
@@ -1568,39 +1553,6 @@
|
|
|
1568
1553
|
}
|
|
1569
1554
|
]
|
|
1570
1555
|
},
|
|
1571
|
-
{
|
|
1572
|
-
"name": "migrate_user_trade_to_order",
|
|
1573
|
-
"discriminator": [33, 123, 184, 50, 31, 199, 7, 73],
|
|
1574
|
-
"accounts": [
|
|
1575
|
-
{
|
|
1576
|
-
"name": "signer",
|
|
1577
|
-
"writable": true,
|
|
1578
|
-
"signer": true
|
|
1579
|
-
},
|
|
1580
|
-
{
|
|
1581
|
-
"name": "user_trade",
|
|
1582
|
-
"writable": true
|
|
1583
|
-
},
|
|
1584
|
-
{
|
|
1585
|
-
"name": "order",
|
|
1586
|
-
"writable": true
|
|
1587
|
-
},
|
|
1588
|
-
{
|
|
1589
|
-
"name": "system_program",
|
|
1590
|
-
"address": "11111111111111111111111111111111"
|
|
1591
|
-
}
|
|
1592
|
-
],
|
|
1593
|
-
"args": [
|
|
1594
|
-
{
|
|
1595
|
-
"name": "args",
|
|
1596
|
-
"type": {
|
|
1597
|
-
"defined": {
|
|
1598
|
-
"name": "MigrateUserTradeToOrderArgs"
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
]
|
|
1603
|
-
},
|
|
1604
1556
|
{
|
|
1605
1557
|
"name": "open_order",
|
|
1606
1558
|
"discriminator": [206, 88, 88, 143, 38, 136, 50, 224],
|
|
@@ -1810,16 +1762,7 @@
|
|
|
1810
1762
|
"address": "11111111111111111111111111111111"
|
|
1811
1763
|
}
|
|
1812
1764
|
],
|
|
1813
|
-
"args": [
|
|
1814
|
-
{
|
|
1815
|
-
"name": "order_direction",
|
|
1816
|
-
"type": {
|
|
1817
|
-
"defined": {
|
|
1818
|
-
"name": "OrderDirection"
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
]
|
|
1765
|
+
"args": []
|
|
1823
1766
|
},
|
|
1824
1767
|
{
|
|
1825
1768
|
"name": "place_ask_order",
|
|
@@ -2089,6 +2032,38 @@
|
|
|
2089
2032
|
}
|
|
2090
2033
|
]
|
|
2091
2034
|
},
|
|
2035
|
+
{
|
|
2036
|
+
"name": "stake_authority",
|
|
2037
|
+
"discriminator": [246, 215, 84, 204, 198, 135, 235, 247],
|
|
2038
|
+
"accounts": [
|
|
2039
|
+
{
|
|
2040
|
+
"name": "signer",
|
|
2041
|
+
"writable": true,
|
|
2042
|
+
"signer": true
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
"name": "stake",
|
|
2046
|
+
"writable": true,
|
|
2047
|
+
"pda": {
|
|
2048
|
+
"seeds": [
|
|
2049
|
+
{
|
|
2050
|
+
"kind": "const",
|
|
2051
|
+
"value": [115, 116, 97, 107, 101, 95, 118, 51]
|
|
2052
|
+
},
|
|
2053
|
+
{
|
|
2054
|
+
"kind": "account",
|
|
2055
|
+
"path": "signer"
|
|
2056
|
+
}
|
|
2057
|
+
]
|
|
2058
|
+
}
|
|
2059
|
+
},
|
|
2060
|
+
{
|
|
2061
|
+
"name": "system_program",
|
|
2062
|
+
"address": "11111111111111111111111111111111"
|
|
2063
|
+
}
|
|
2064
|
+
],
|
|
2065
|
+
"args": []
|
|
2066
|
+
},
|
|
2092
2067
|
{
|
|
2093
2068
|
"name": "stake_token",
|
|
2094
2069
|
"discriminator": [191, 127, 193, 101, 37, 96, 87, 211],
|
|
@@ -2854,10 +2829,6 @@
|
|
|
2854
2829
|
{
|
|
2855
2830
|
"name": "Unstake",
|
|
2856
2831
|
"discriminator": [154, 148, 131, 67, 52, 244, 244, 19]
|
|
2857
|
-
},
|
|
2858
|
-
{
|
|
2859
|
-
"name": "UserTrade",
|
|
2860
|
-
"discriminator": [149, 190, 47, 218, 136, 9, 222, 222]
|
|
2861
2832
|
}
|
|
2862
2833
|
],
|
|
2863
2834
|
"events": [
|
|
@@ -3233,6 +3204,10 @@
|
|
|
3233
3204
|
"type": {
|
|
3234
3205
|
"kind": "struct",
|
|
3235
3206
|
"fields": [
|
|
3207
|
+
{
|
|
3208
|
+
"name": "market_id",
|
|
3209
|
+
"type": "u64"
|
|
3210
|
+
},
|
|
3236
3211
|
{
|
|
3237
3212
|
"name": "book_order_id",
|
|
3238
3213
|
"type": "u64"
|
|
@@ -4073,30 +4048,6 @@
|
|
|
4073
4048
|
]
|
|
4074
4049
|
}
|
|
4075
4050
|
},
|
|
4076
|
-
{
|
|
4077
|
-
"name": "MigrateUserTradeToOrderArgs",
|
|
4078
|
-
"type": {
|
|
4079
|
-
"kind": "struct",
|
|
4080
|
-
"fields": [
|
|
4081
|
-
{
|
|
4082
|
-
"name": "market_id",
|
|
4083
|
-
"type": "u64"
|
|
4084
|
-
},
|
|
4085
|
-
{
|
|
4086
|
-
"name": "order_id",
|
|
4087
|
-
"type": "u64"
|
|
4088
|
-
},
|
|
4089
|
-
{
|
|
4090
|
-
"name": "order_direction",
|
|
4091
|
-
"type": {
|
|
4092
|
-
"defined": {
|
|
4093
|
-
"name": "OrderDirection"
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
]
|
|
4098
|
-
}
|
|
4099
|
-
},
|
|
4100
4051
|
{
|
|
4101
4052
|
"name": "Nft",
|
|
4102
4053
|
"type": {
|
|
@@ -4128,106 +4079,6 @@
|
|
|
4128
4079
|
]
|
|
4129
4080
|
}
|
|
4130
4081
|
},
|
|
4131
|
-
{
|
|
4132
|
-
"name": "Order",
|
|
4133
|
-
"type": {
|
|
4134
|
-
"kind": "struct",
|
|
4135
|
-
"fields": [
|
|
4136
|
-
{
|
|
4137
|
-
"name": "ts",
|
|
4138
|
-
"type": "i64"
|
|
4139
|
-
},
|
|
4140
|
-
{
|
|
4141
|
-
"name": "order_id",
|
|
4142
|
-
"type": "u64"
|
|
4143
|
-
},
|
|
4144
|
-
{
|
|
4145
|
-
"name": "filled_shares",
|
|
4146
|
-
"type": "u64"
|
|
4147
|
-
},
|
|
4148
|
-
{
|
|
4149
|
-
"name": "market_id",
|
|
4150
|
-
"type": "u64"
|
|
4151
|
-
},
|
|
4152
|
-
{
|
|
4153
|
-
"name": "order_status",
|
|
4154
|
-
"type": {
|
|
4155
|
-
"defined": {
|
|
4156
|
-
"name": "OrderStatus"
|
|
4157
|
-
}
|
|
4158
|
-
}
|
|
4159
|
-
},
|
|
4160
|
-
{
|
|
4161
|
-
"name": "price",
|
|
4162
|
-
"type": "u64"
|
|
4163
|
-
},
|
|
4164
|
-
{
|
|
4165
|
-
"name": "padding_1",
|
|
4166
|
-
"type": {
|
|
4167
|
-
"array": ["u8", 8]
|
|
4168
|
-
}
|
|
4169
|
-
},
|
|
4170
|
-
{
|
|
4171
|
-
"name": "total_shares",
|
|
4172
|
-
"type": "u64"
|
|
4173
|
-
},
|
|
4174
|
-
{
|
|
4175
|
-
"name": "order_type",
|
|
4176
|
-
"type": {
|
|
4177
|
-
"defined": {
|
|
4178
|
-
"name": "OrderType"
|
|
4179
|
-
}
|
|
4180
|
-
}
|
|
4181
|
-
},
|
|
4182
|
-
{
|
|
4183
|
-
"name": "order_direction",
|
|
4184
|
-
"type": {
|
|
4185
|
-
"defined": {
|
|
4186
|
-
"name": "OrderDirection"
|
|
4187
|
-
}
|
|
4188
|
-
}
|
|
4189
|
-
},
|
|
4190
|
-
{
|
|
4191
|
-
"name": "user_nonce",
|
|
4192
|
-
"type": "u32"
|
|
4193
|
-
},
|
|
4194
|
-
{
|
|
4195
|
-
"name": "order_side",
|
|
4196
|
-
"type": {
|
|
4197
|
-
"defined": {
|
|
4198
|
-
"name": "OrderSide"
|
|
4199
|
-
}
|
|
4200
|
-
}
|
|
4201
|
-
},
|
|
4202
|
-
{
|
|
4203
|
-
"name": "padding_2",
|
|
4204
|
-
"type": {
|
|
4205
|
-
"array": ["u8", 8]
|
|
4206
|
-
}
|
|
4207
|
-
},
|
|
4208
|
-
{
|
|
4209
|
-
"name": "created_at",
|
|
4210
|
-
"type": "i64"
|
|
4211
|
-
},
|
|
4212
|
-
{
|
|
4213
|
-
"name": "padding_3",
|
|
4214
|
-
"type": {
|
|
4215
|
-
"array": ["u8", 8]
|
|
4216
|
-
}
|
|
4217
|
-
},
|
|
4218
|
-
{
|
|
4219
|
-
"name": "is_trd_payout",
|
|
4220
|
-
"type": "bool"
|
|
4221
|
-
},
|
|
4222
|
-
{
|
|
4223
|
-
"name": "padding",
|
|
4224
|
-
"type": {
|
|
4225
|
-
"array": ["u8", 2]
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
|
-
]
|
|
4229
|
-
}
|
|
4230
|
-
},
|
|
4231
4082
|
{
|
|
4232
4083
|
"name": "OrderBook",
|
|
4233
4084
|
"serialization": "bytemuck",
|
|
@@ -4887,71 +4738,6 @@
|
|
|
4887
4738
|
]
|
|
4888
4739
|
}
|
|
4889
4740
|
},
|
|
4890
|
-
{
|
|
4891
|
-
"name": "UserTrade",
|
|
4892
|
-
"type": {
|
|
4893
|
-
"kind": "struct",
|
|
4894
|
-
"fields": [
|
|
4895
|
-
{
|
|
4896
|
-
"name": "bump",
|
|
4897
|
-
"type": "u8"
|
|
4898
|
-
},
|
|
4899
|
-
{
|
|
4900
|
-
"name": "authority",
|
|
4901
|
-
"type": "pubkey"
|
|
4902
|
-
},
|
|
4903
|
-
{
|
|
4904
|
-
"name": "padding_1",
|
|
4905
|
-
"type": {
|
|
4906
|
-
"array": ["u8", 8]
|
|
4907
|
-
}
|
|
4908
|
-
},
|
|
4909
|
-
{
|
|
4910
|
-
"name": "padding_2",
|
|
4911
|
-
"type": {
|
|
4912
|
-
"array": ["u8", 8]
|
|
4913
|
-
}
|
|
4914
|
-
},
|
|
4915
|
-
{
|
|
4916
|
-
"name": "padding_3",
|
|
4917
|
-
"type": {
|
|
4918
|
-
"array": ["u8", 8]
|
|
4919
|
-
}
|
|
4920
|
-
},
|
|
4921
|
-
{
|
|
4922
|
-
"name": "orders",
|
|
4923
|
-
"type": {
|
|
4924
|
-
"array": [
|
|
4925
|
-
{
|
|
4926
|
-
"defined": {
|
|
4927
|
-
"name": "Order"
|
|
4928
|
-
}
|
|
4929
|
-
},
|
|
4930
|
-
10
|
|
4931
|
-
]
|
|
4932
|
-
}
|
|
4933
|
-
},
|
|
4934
|
-
{
|
|
4935
|
-
"name": "nonce",
|
|
4936
|
-
"type": "u32"
|
|
4937
|
-
},
|
|
4938
|
-
{
|
|
4939
|
-
"name": "is_sub_user",
|
|
4940
|
-
"type": "bool"
|
|
4941
|
-
},
|
|
4942
|
-
{
|
|
4943
|
-
"name": "poseidon",
|
|
4944
|
-
"type": "u16"
|
|
4945
|
-
},
|
|
4946
|
-
{
|
|
4947
|
-
"name": "padding",
|
|
4948
|
-
"type": {
|
|
4949
|
-
"array": ["u8", 25]
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4952
|
-
]
|
|
4953
|
-
}
|
|
4954
|
-
},
|
|
4955
4741
|
{
|
|
4956
4742
|
"name": "WinningDirection",
|
|
4957
4743
|
"type": {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export type Market = {
|
|
|
47
47
|
feeRecipient: string;
|
|
48
48
|
};
|
|
49
49
|
export type Order = {
|
|
50
|
+
address: string;
|
|
50
51
|
marketId: string;
|
|
51
52
|
orderStatus: OrderStatus;
|
|
52
53
|
price: string;
|
|
@@ -272,6 +273,7 @@ export type CreatePoolArgs = {
|
|
|
272
273
|
};
|
|
273
274
|
export type CancelBidOrderArgs = {
|
|
274
275
|
orders: {
|
|
276
|
+
authority: PublicKey;
|
|
275
277
|
marketId: number;
|
|
276
278
|
bookOrderId: number;
|
|
277
279
|
orderDirection: OrderDirectionEncoded;
|
|
@@ -279,6 +281,7 @@ export type CancelBidOrderArgs = {
|
|
|
279
281
|
};
|
|
280
282
|
export type CancelAskOrderArgs = {
|
|
281
283
|
orders: {
|
|
284
|
+
authority: PublicKey;
|
|
282
285
|
marketId: number;
|
|
283
286
|
bookOrderId: number;
|
|
284
287
|
orderDirection: OrderDirectionEncoded;
|
|
@@ -231,6 +231,11 @@ export type TriadProtocol = {
|
|
|
231
231
|
name: 'signer';
|
|
232
232
|
writable: true;
|
|
233
233
|
},
|
|
234
|
+
{
|
|
235
|
+
name: 'payer';
|
|
236
|
+
writable: true;
|
|
237
|
+
signer: true;
|
|
238
|
+
},
|
|
234
239
|
{
|
|
235
240
|
name: 'market';
|
|
236
241
|
writable: true;
|
|
@@ -988,26 +993,6 @@ export type TriadProtocol = {
|
|
|
988
993
|
];
|
|
989
994
|
args: [];
|
|
990
995
|
},
|
|
991
|
-
{
|
|
992
|
-
name: 'closeUser';
|
|
993
|
-
discriminator: [86, 219, 138, 140, 236, 24, 118, 200];
|
|
994
|
-
accounts: [
|
|
995
|
-
{
|
|
996
|
-
name: 'signer';
|
|
997
|
-
writable: true;
|
|
998
|
-
signer: true;
|
|
999
|
-
},
|
|
1000
|
-
{
|
|
1001
|
-
name: 'userTrade';
|
|
1002
|
-
writable: true;
|
|
1003
|
-
},
|
|
1004
|
-
{
|
|
1005
|
-
name: 'systemProgram';
|
|
1006
|
-
address: '11111111111111111111111111111111';
|
|
1007
|
-
}
|
|
1008
|
-
];
|
|
1009
|
-
args: [];
|
|
1010
|
-
},
|
|
1011
996
|
{
|
|
1012
997
|
name: 'collectMarketFee';
|
|
1013
998
|
discriminator: [139, 4, 96, 182, 216, 250, 122, 79];
|
|
@@ -2275,39 +2260,6 @@ export type TriadProtocol = {
|
|
|
2275
2260
|
}
|
|
2276
2261
|
];
|
|
2277
2262
|
},
|
|
2278
|
-
{
|
|
2279
|
-
name: 'migrateUserTradeToOrder';
|
|
2280
|
-
discriminator: [33, 123, 184, 50, 31, 199, 7, 73];
|
|
2281
|
-
accounts: [
|
|
2282
|
-
{
|
|
2283
|
-
name: 'signer';
|
|
2284
|
-
writable: true;
|
|
2285
|
-
signer: true;
|
|
2286
|
-
},
|
|
2287
|
-
{
|
|
2288
|
-
name: 'userTrade';
|
|
2289
|
-
writable: true;
|
|
2290
|
-
},
|
|
2291
|
-
{
|
|
2292
|
-
name: 'order';
|
|
2293
|
-
writable: true;
|
|
2294
|
-
},
|
|
2295
|
-
{
|
|
2296
|
-
name: 'systemProgram';
|
|
2297
|
-
address: '11111111111111111111111111111111';
|
|
2298
|
-
}
|
|
2299
|
-
];
|
|
2300
|
-
args: [
|
|
2301
|
-
{
|
|
2302
|
-
name: 'args';
|
|
2303
|
-
type: {
|
|
2304
|
-
defined: {
|
|
2305
|
-
name: 'migrateUserTradeToOrderArgs';
|
|
2306
|
-
};
|
|
2307
|
-
};
|
|
2308
|
-
}
|
|
2309
|
-
];
|
|
2310
|
-
},
|
|
2311
2263
|
{
|
|
2312
2264
|
name: 'openOrder';
|
|
2313
2265
|
discriminator: [206, 88, 88, 143, 38, 136, 50, 224];
|
|
@@ -2633,16 +2585,7 @@ export type TriadProtocol = {
|
|
|
2633
2585
|
address: '11111111111111111111111111111111';
|
|
2634
2586
|
}
|
|
2635
2587
|
];
|
|
2636
|
-
args: [
|
|
2637
|
-
{
|
|
2638
|
-
name: 'orderDirection';
|
|
2639
|
-
type: {
|
|
2640
|
-
defined: {
|
|
2641
|
-
name: 'orderDirection';
|
|
2642
|
-
};
|
|
2643
|
-
};
|
|
2644
|
-
}
|
|
2645
|
-
];
|
|
2588
|
+
args: [];
|
|
2646
2589
|
},
|
|
2647
2590
|
{
|
|
2648
2591
|
name: 'placeAskOrder';
|
|
@@ -2982,6 +2925,38 @@ export type TriadProtocol = {
|
|
|
2982
2925
|
}
|
|
2983
2926
|
];
|
|
2984
2927
|
},
|
|
2928
|
+
{
|
|
2929
|
+
name: 'stakeAuthority';
|
|
2930
|
+
discriminator: [246, 215, 84, 204, 198, 135, 235, 247];
|
|
2931
|
+
accounts: [
|
|
2932
|
+
{
|
|
2933
|
+
name: 'signer';
|
|
2934
|
+
writable: true;
|
|
2935
|
+
signer: true;
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
name: 'stake';
|
|
2939
|
+
writable: true;
|
|
2940
|
+
pda: {
|
|
2941
|
+
seeds: [
|
|
2942
|
+
{
|
|
2943
|
+
kind: 'const';
|
|
2944
|
+
value: [115, 116, 97, 107, 101, 95, 118, 51];
|
|
2945
|
+
},
|
|
2946
|
+
{
|
|
2947
|
+
kind: 'account';
|
|
2948
|
+
path: 'signer';
|
|
2949
|
+
}
|
|
2950
|
+
];
|
|
2951
|
+
};
|
|
2952
|
+
},
|
|
2953
|
+
{
|
|
2954
|
+
name: 'systemProgram';
|
|
2955
|
+
address: '11111111111111111111111111111111';
|
|
2956
|
+
}
|
|
2957
|
+
];
|
|
2958
|
+
args: [];
|
|
2959
|
+
},
|
|
2985
2960
|
{
|
|
2986
2961
|
name: 'stakeToken';
|
|
2987
2962
|
discriminator: [191, 127, 193, 101, 37, 96, 87, 211];
|
|
@@ -3945,10 +3920,6 @@ export type TriadProtocol = {
|
|
|
3945
3920
|
{
|
|
3946
3921
|
name: 'unstake';
|
|
3947
3922
|
discriminator: [154, 148, 131, 67, 52, 244, 244, 19];
|
|
3948
|
-
},
|
|
3949
|
-
{
|
|
3950
|
-
name: 'userTrade';
|
|
3951
|
-
discriminator: [149, 190, 47, 218, 136, 9, 222, 222];
|
|
3952
3923
|
}
|
|
3953
3924
|
];
|
|
3954
3925
|
events: [
|
|
@@ -4324,6 +4295,10 @@ export type TriadProtocol = {
|
|
|
4324
4295
|
type: {
|
|
4325
4296
|
kind: 'struct';
|
|
4326
4297
|
fields: [
|
|
4298
|
+
{
|
|
4299
|
+
name: 'marketId';
|
|
4300
|
+
type: 'u64';
|
|
4301
|
+
},
|
|
4327
4302
|
{
|
|
4328
4303
|
name: 'bookOrderId';
|
|
4329
4304
|
type: 'u64';
|
|
@@ -5164,30 +5139,6 @@ export type TriadProtocol = {
|
|
|
5164
5139
|
];
|
|
5165
5140
|
};
|
|
5166
5141
|
},
|
|
5167
|
-
{
|
|
5168
|
-
name: 'migrateUserTradeToOrderArgs';
|
|
5169
|
-
type: {
|
|
5170
|
-
kind: 'struct';
|
|
5171
|
-
fields: [
|
|
5172
|
-
{
|
|
5173
|
-
name: 'marketId';
|
|
5174
|
-
type: 'u64';
|
|
5175
|
-
},
|
|
5176
|
-
{
|
|
5177
|
-
name: 'orderId';
|
|
5178
|
-
type: 'u64';
|
|
5179
|
-
},
|
|
5180
|
-
{
|
|
5181
|
-
name: 'orderDirection';
|
|
5182
|
-
type: {
|
|
5183
|
-
defined: {
|
|
5184
|
-
name: 'orderDirection';
|
|
5185
|
-
};
|
|
5186
|
-
};
|
|
5187
|
-
}
|
|
5188
|
-
];
|
|
5189
|
-
};
|
|
5190
|
-
},
|
|
5191
5142
|
{
|
|
5192
5143
|
name: 'nft';
|
|
5193
5144
|
type: {
|
|
@@ -5219,106 +5170,6 @@ export type TriadProtocol = {
|
|
|
5219
5170
|
];
|
|
5220
5171
|
};
|
|
5221
5172
|
},
|
|
5222
|
-
{
|
|
5223
|
-
name: 'order';
|
|
5224
|
-
type: {
|
|
5225
|
-
kind: 'struct';
|
|
5226
|
-
fields: [
|
|
5227
|
-
{
|
|
5228
|
-
name: 'ts';
|
|
5229
|
-
type: 'i64';
|
|
5230
|
-
},
|
|
5231
|
-
{
|
|
5232
|
-
name: 'orderId';
|
|
5233
|
-
type: 'u64';
|
|
5234
|
-
},
|
|
5235
|
-
{
|
|
5236
|
-
name: 'filledShares';
|
|
5237
|
-
type: 'u64';
|
|
5238
|
-
},
|
|
5239
|
-
{
|
|
5240
|
-
name: 'marketId';
|
|
5241
|
-
type: 'u64';
|
|
5242
|
-
},
|
|
5243
|
-
{
|
|
5244
|
-
name: 'orderStatus';
|
|
5245
|
-
type: {
|
|
5246
|
-
defined: {
|
|
5247
|
-
name: 'orderStatus';
|
|
5248
|
-
};
|
|
5249
|
-
};
|
|
5250
|
-
},
|
|
5251
|
-
{
|
|
5252
|
-
name: 'price';
|
|
5253
|
-
type: 'u64';
|
|
5254
|
-
},
|
|
5255
|
-
{
|
|
5256
|
-
name: 'padding1';
|
|
5257
|
-
type: {
|
|
5258
|
-
array: ['u8', 8];
|
|
5259
|
-
};
|
|
5260
|
-
},
|
|
5261
|
-
{
|
|
5262
|
-
name: 'totalShares';
|
|
5263
|
-
type: 'u64';
|
|
5264
|
-
},
|
|
5265
|
-
{
|
|
5266
|
-
name: 'orderType';
|
|
5267
|
-
type: {
|
|
5268
|
-
defined: {
|
|
5269
|
-
name: 'orderType';
|
|
5270
|
-
};
|
|
5271
|
-
};
|
|
5272
|
-
},
|
|
5273
|
-
{
|
|
5274
|
-
name: 'orderDirection';
|
|
5275
|
-
type: {
|
|
5276
|
-
defined: {
|
|
5277
|
-
name: 'orderDirection';
|
|
5278
|
-
};
|
|
5279
|
-
};
|
|
5280
|
-
},
|
|
5281
|
-
{
|
|
5282
|
-
name: 'userNonce';
|
|
5283
|
-
type: 'u32';
|
|
5284
|
-
},
|
|
5285
|
-
{
|
|
5286
|
-
name: 'orderSide';
|
|
5287
|
-
type: {
|
|
5288
|
-
defined: {
|
|
5289
|
-
name: 'orderSide';
|
|
5290
|
-
};
|
|
5291
|
-
};
|
|
5292
|
-
},
|
|
5293
|
-
{
|
|
5294
|
-
name: 'padding2';
|
|
5295
|
-
type: {
|
|
5296
|
-
array: ['u8', 8];
|
|
5297
|
-
};
|
|
5298
|
-
},
|
|
5299
|
-
{
|
|
5300
|
-
name: 'createdAt';
|
|
5301
|
-
type: 'i64';
|
|
5302
|
-
},
|
|
5303
|
-
{
|
|
5304
|
-
name: 'padding3';
|
|
5305
|
-
type: {
|
|
5306
|
-
array: ['u8', 8];
|
|
5307
|
-
};
|
|
5308
|
-
},
|
|
5309
|
-
{
|
|
5310
|
-
name: 'isTrdPayout';
|
|
5311
|
-
type: 'bool';
|
|
5312
|
-
},
|
|
5313
|
-
{
|
|
5314
|
-
name: 'padding';
|
|
5315
|
-
type: {
|
|
5316
|
-
array: ['u8', 2];
|
|
5317
|
-
};
|
|
5318
|
-
}
|
|
5319
|
-
];
|
|
5320
|
-
};
|
|
5321
|
-
},
|
|
5322
5173
|
{
|
|
5323
5174
|
name: 'orderBook';
|
|
5324
5175
|
serialization: 'bytemuck';
|
|
@@ -5978,71 +5829,6 @@ export type TriadProtocol = {
|
|
|
5978
5829
|
];
|
|
5979
5830
|
};
|
|
5980
5831
|
},
|
|
5981
|
-
{
|
|
5982
|
-
name: 'userTrade';
|
|
5983
|
-
type: {
|
|
5984
|
-
kind: 'struct';
|
|
5985
|
-
fields: [
|
|
5986
|
-
{
|
|
5987
|
-
name: 'bump';
|
|
5988
|
-
type: 'u8';
|
|
5989
|
-
},
|
|
5990
|
-
{
|
|
5991
|
-
name: 'authority';
|
|
5992
|
-
type: 'pubkey';
|
|
5993
|
-
},
|
|
5994
|
-
{
|
|
5995
|
-
name: 'padding1';
|
|
5996
|
-
type: {
|
|
5997
|
-
array: ['u8', 8];
|
|
5998
|
-
};
|
|
5999
|
-
},
|
|
6000
|
-
{
|
|
6001
|
-
name: 'padding2';
|
|
6002
|
-
type: {
|
|
6003
|
-
array: ['u8', 8];
|
|
6004
|
-
};
|
|
6005
|
-
},
|
|
6006
|
-
{
|
|
6007
|
-
name: 'padding3';
|
|
6008
|
-
type: {
|
|
6009
|
-
array: ['u8', 8];
|
|
6010
|
-
};
|
|
6011
|
-
},
|
|
6012
|
-
{
|
|
6013
|
-
name: 'orders';
|
|
6014
|
-
type: {
|
|
6015
|
-
array: [
|
|
6016
|
-
{
|
|
6017
|
-
defined: {
|
|
6018
|
-
name: 'order';
|
|
6019
|
-
};
|
|
6020
|
-
},
|
|
6021
|
-
10
|
|
6022
|
-
];
|
|
6023
|
-
};
|
|
6024
|
-
},
|
|
6025
|
-
{
|
|
6026
|
-
name: 'nonce';
|
|
6027
|
-
type: 'u32';
|
|
6028
|
-
},
|
|
6029
|
-
{
|
|
6030
|
-
name: 'isSubUser';
|
|
6031
|
-
type: 'bool';
|
|
6032
|
-
},
|
|
6033
|
-
{
|
|
6034
|
-
name: 'poseidon';
|
|
6035
|
-
type: 'u16';
|
|
6036
|
-
},
|
|
6037
|
-
{
|
|
6038
|
-
name: 'padding';
|
|
6039
|
-
type: {
|
|
6040
|
-
array: ['u8', 25];
|
|
6041
|
-
};
|
|
6042
|
-
}
|
|
6043
|
-
];
|
|
6044
|
-
};
|
|
6045
|
-
},
|
|
6046
5832
|
{
|
|
6047
5833
|
name: 'winningDirection';
|
|
6048
5834
|
type: {
|
|
@@ -6,17 +6,11 @@ exports.generateFeeCurve = exports.simulateSellOrder = exports.simulateBuyOrder
|
|
|
6
6
|
* Returns fee in basis points (bps)
|
|
7
7
|
*/
|
|
8
8
|
function calculateDynamicFeeBps(price) {
|
|
9
|
-
const internalPrice = Math.
|
|
9
|
+
const internalPrice = price * Math.pow(10, 6);
|
|
10
10
|
if (internalPrice <= 900000) {
|
|
11
11
|
return 380;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const feeReduction = Math.floor((priceAbove90 * 100) / 80000);
|
|
15
|
-
const calculatedFee = Math.max(0, 190 - feeReduction);
|
|
16
|
-
const maxPossibleFee = internalPrice < 999999
|
|
17
|
-
? Math.floor(((999999 - internalPrice) * 10000) / internalPrice)
|
|
18
|
-
: 0;
|
|
19
|
-
return Math.max(90, Math.min(calculatedFee, maxPossibleFee));
|
|
13
|
+
return Math.floor(((990000 - internalPrice) * 1900) / price);
|
|
20
14
|
}
|
|
21
15
|
exports.calculateDynamicFeeBps = calculateDynamicFeeBps;
|
|
22
16
|
/**
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV3'])
|
|
|
9
9
|
export declare const formatUnstake: (unstake: IdlAccounts<TriadProtocol>['unstake'], address: PublicKey) => Unstake;
|
|
10
10
|
export declare const formatPool: (account: IdlAccounts<TriadProtocol>['pool'], address: PublicKey) => Pool;
|
|
11
11
|
export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
|
|
12
|
-
export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['orderV2']) => Order;
|
|
12
|
+
export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['orderV2'], address: PublicKey) => Order;
|
|
13
13
|
export declare const formatBookOrder: (order: IdlAccounts<TriadProtocol>['orderBook']['hypeOrders'][number] | IdlAccounts<TriadProtocol>['orderBook']['flopOrders'][number], marketId: number) => BookOrder;
|
|
14
14
|
export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
|
|
15
15
|
export declare const formatClaimVault: (account: IdlAccounts<TriadProtocol>['claimVault'], address: PublicKey) => ClaimVault;
|
|
@@ -22,5 +22,6 @@ export declare const getOrderSideFromNumber: (orderSide: number) => OrderSide;
|
|
|
22
22
|
export declare const getOrderType: (orderType: OrderTypeEncoded) => OrderType;
|
|
23
23
|
export declare const getOrderSide: (orderSide: OrderSideEncoded) => OrderSide;
|
|
24
24
|
export declare const getOrderStatus: (status: OrderStatusEncoded) => OrderStatus;
|
|
25
|
+
export declare const getOrderDirectionEncoded: (orderDirection: OrderDirection) => OrderDirectionEncoded;
|
|
25
26
|
export declare const getOppositeOrderDirection: (orderDirection: OrderDirection) => OrderDirection;
|
|
26
27
|
export declare const getOppositeOrderDirectionEncoded: (orderDirection: OrderDirectionEncoded) => OrderDirectionEncoded;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatClaimedUser = exports.formatClaimVault = exports.formatCustomer = exports.formatBookOrder = exports.formatOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
3
|
+
exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatClaimedUser = exports.formatClaimVault = exports.formatCustomer = exports.formatBookOrder = exports.formatOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
6
|
const types_1 = require("../types");
|
|
@@ -105,8 +105,9 @@ const formatMarket = (account, address) => {
|
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
exports.formatMarket = formatMarket;
|
|
108
|
-
const formatOrder = (order) => {
|
|
108
|
+
const formatOrder = (order, address) => {
|
|
109
109
|
return {
|
|
110
|
+
address: address.toString(),
|
|
110
111
|
authority: order.authority.toString(),
|
|
111
112
|
marketId: order.marketId.toString(),
|
|
112
113
|
orderStatus: (0, exports.getOrderStatus)(order.orderStatus),
|
|
@@ -254,6 +255,13 @@ const getOrderStatus = (status) => {
|
|
|
254
255
|
}
|
|
255
256
|
};
|
|
256
257
|
exports.getOrderStatus = getOrderStatus;
|
|
258
|
+
const getOrderDirectionEncoded = (orderDirection) => {
|
|
259
|
+
if (orderDirection === types_1.OrderDirection.HYPE) {
|
|
260
|
+
return { hype: {} };
|
|
261
|
+
}
|
|
262
|
+
return { flop: {} };
|
|
263
|
+
};
|
|
264
|
+
exports.getOrderDirectionEncoded = getOrderDirectionEncoded;
|
|
257
265
|
const getOppositeOrderDirection = (orderDirection) => {
|
|
258
266
|
if (orderDirection === types_1.OrderDirection.HYPE) {
|
|
259
267
|
return types_1.OrderDirection.FLOP;
|