@triadxyz/triad-protocol 2.3.7-beta → 2.3.9-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 +2 -2
- package/dist/index.js +18 -3
- package/dist/types/idl_triad_protocol.json +44 -9
- package/dist/types/index.d.ts +4 -0
- package/dist/types/triad_protocol.d.ts +43 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
|
2
2
|
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
-
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions } from './types';
|
|
5
|
+
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, CollectMarketFeeArgs } from './types';
|
|
6
6
|
import Stake from './stake';
|
|
7
7
|
import Poseidon from './poseidon';
|
|
8
8
|
export default class TriadProtocolClient {
|
|
@@ -409,5 +409,5 @@ export default class TriadProtocolClient {
|
|
|
409
409
|
*
|
|
410
410
|
* @param options - RPC options
|
|
411
411
|
*/
|
|
412
|
-
collectMarketFee(marketId:
|
|
412
|
+
collectMarketFee({ marketId, feeRecipient }: CollectMarketFeeArgs, options?: RpcOptions): Promise<string>;
|
|
413
413
|
}
|
package/dist/index.js
CHANGED
|
@@ -188,10 +188,16 @@ class TriadProtocolClient {
|
|
|
188
188
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
189
189
|
customer,
|
|
190
190
|
pool: poolPDA,
|
|
191
|
-
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
192
191
|
userTrade
|
|
193
192
|
})
|
|
194
193
|
.instruction());
|
|
194
|
+
ixs.push(yield this.program.methods
|
|
195
|
+
.createOrderBook(new bn_js_1.default(marketId))
|
|
196
|
+
.accounts({
|
|
197
|
+
signer: this.program.provider.publicKey,
|
|
198
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
199
|
+
})
|
|
200
|
+
.instruction());
|
|
195
201
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
196
202
|
});
|
|
197
203
|
}
|
|
@@ -244,11 +250,17 @@ class TriadProtocolClient {
|
|
|
244
250
|
mint,
|
|
245
251
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
246
252
|
pool: poolPDA,
|
|
247
|
-
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, market.marketId),
|
|
248
253
|
customer,
|
|
249
254
|
userTrade
|
|
250
255
|
})
|
|
251
256
|
.instruction());
|
|
257
|
+
ixs.push(yield this.program.methods
|
|
258
|
+
.createOrderBook(new bn_js_1.default(market.marketId))
|
|
259
|
+
.accounts({
|
|
260
|
+
signer: this.program.provider.publicKey,
|
|
261
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
262
|
+
})
|
|
263
|
+
.instruction());
|
|
252
264
|
}
|
|
253
265
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
254
266
|
});
|
|
@@ -859,6 +871,8 @@ class TriadProtocolClient {
|
|
|
859
871
|
data.spreadToReward = orderBook.spreadToReward.toString();
|
|
860
872
|
const processOrders = (orders, side) => {
|
|
861
873
|
for (const order of orders) {
|
|
874
|
+
if (order.price.eq(new bn_js_1.default(0)))
|
|
875
|
+
continue;
|
|
862
876
|
if ((0, helpers_1.getOrderSideFromNumber)(order.orderSide) === types_1.OrderSide.BID) {
|
|
863
877
|
data[side].bid.push((0, helpers_1.formatBookOrder)(order));
|
|
864
878
|
}
|
|
@@ -878,7 +892,7 @@ class TriadProtocolClient {
|
|
|
878
892
|
*
|
|
879
893
|
* @param options - RPC options
|
|
880
894
|
*/
|
|
881
|
-
collectMarketFee(marketId, options) {
|
|
895
|
+
collectMarketFee({ marketId, feeRecipient }, options) {
|
|
882
896
|
return __awaiter(this, void 0, void 0, function* () {
|
|
883
897
|
const ixs = [];
|
|
884
898
|
ixs.push(yield this.program.methods
|
|
@@ -886,6 +900,7 @@ class TriadProtocolClient {
|
|
|
886
900
|
.accounts({
|
|
887
901
|
signer: this.program.provider.publicKey,
|
|
888
902
|
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
903
|
+
feeRecipient,
|
|
889
904
|
mint: constants_1.TRD_MINT
|
|
890
905
|
})
|
|
891
906
|
.instruction());
|
|
@@ -404,9 +404,8 @@
|
|
|
404
404
|
"signer": true
|
|
405
405
|
},
|
|
406
406
|
{
|
|
407
|
-
"name": "
|
|
408
|
-
"writable": true
|
|
409
|
-
"address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
|
|
407
|
+
"name": "fee_recipient",
|
|
408
|
+
"writable": true
|
|
410
409
|
},
|
|
411
410
|
{
|
|
412
411
|
"name": "market",
|
|
@@ -451,7 +450,7 @@
|
|
|
451
450
|
"seeds": [
|
|
452
451
|
{
|
|
453
452
|
"kind": "account",
|
|
454
|
-
"path": "
|
|
453
|
+
"path": "fee_recipient"
|
|
455
454
|
},
|
|
456
455
|
{
|
|
457
456
|
"kind": "account",
|
|
@@ -691,11 +690,6 @@
|
|
|
691
690
|
]
|
|
692
691
|
}
|
|
693
692
|
},
|
|
694
|
-
{
|
|
695
|
-
"name": "order_book",
|
|
696
|
-
"writable": true,
|
|
697
|
-
"signer": true
|
|
698
|
-
},
|
|
699
693
|
{
|
|
700
694
|
"name": "mint",
|
|
701
695
|
"writable": true
|
|
@@ -751,6 +745,47 @@
|
|
|
751
745
|
}
|
|
752
746
|
]
|
|
753
747
|
},
|
|
748
|
+
{
|
|
749
|
+
"name": "create_order_book",
|
|
750
|
+
"discriminator": [153, 114, 9, 51, 100, 68, 240, 197],
|
|
751
|
+
"accounts": [
|
|
752
|
+
{
|
|
753
|
+
"name": "signer",
|
|
754
|
+
"writable": true,
|
|
755
|
+
"signer": true
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"name": "market",
|
|
759
|
+
"writable": true
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"name": "order_book",
|
|
763
|
+
"writable": true,
|
|
764
|
+
"pda": {
|
|
765
|
+
"seeds": [
|
|
766
|
+
{
|
|
767
|
+
"kind": "const",
|
|
768
|
+
"value": [111, 114, 100, 101, 114, 95, 98, 111, 111, 107]
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
"kind": "arg",
|
|
772
|
+
"path": "market_id"
|
|
773
|
+
}
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
"name": "system_program",
|
|
779
|
+
"address": "11111111111111111111111111111111"
|
|
780
|
+
}
|
|
781
|
+
],
|
|
782
|
+
"args": [
|
|
783
|
+
{
|
|
784
|
+
"name": "market_id",
|
|
785
|
+
"type": "u64"
|
|
786
|
+
}
|
|
787
|
+
]
|
|
788
|
+
},
|
|
754
789
|
{
|
|
755
790
|
"name": "create_pool",
|
|
756
791
|
"discriminator": [233, 146, 209, 142, 207, 104, 64, 188],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -596,9 +596,8 @@ export type TriadProtocol = {
|
|
|
596
596
|
signer: true;
|
|
597
597
|
},
|
|
598
598
|
{
|
|
599
|
-
name: '
|
|
599
|
+
name: 'feeRecipient';
|
|
600
600
|
writable: true;
|
|
601
|
-
address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
|
|
602
601
|
},
|
|
603
602
|
{
|
|
604
603
|
name: 'market';
|
|
@@ -672,7 +671,7 @@ export type TriadProtocol = {
|
|
|
672
671
|
seeds: [
|
|
673
672
|
{
|
|
674
673
|
kind: 'account';
|
|
675
|
-
path: '
|
|
674
|
+
path: 'feeRecipient';
|
|
676
675
|
},
|
|
677
676
|
{
|
|
678
677
|
kind: 'account';
|
|
@@ -999,11 +998,6 @@ export type TriadProtocol = {
|
|
|
999
998
|
];
|
|
1000
999
|
};
|
|
1001
1000
|
},
|
|
1002
|
-
{
|
|
1003
|
-
name: 'orderBook';
|
|
1004
|
-
writable: true;
|
|
1005
|
-
signer: true;
|
|
1006
|
-
},
|
|
1007
1001
|
{
|
|
1008
1002
|
name: 'mint';
|
|
1009
1003
|
writable: true;
|
|
@@ -1088,6 +1082,47 @@ export type TriadProtocol = {
|
|
|
1088
1082
|
}
|
|
1089
1083
|
];
|
|
1090
1084
|
},
|
|
1085
|
+
{
|
|
1086
|
+
name: 'createOrderBook';
|
|
1087
|
+
discriminator: [153, 114, 9, 51, 100, 68, 240, 197];
|
|
1088
|
+
accounts: [
|
|
1089
|
+
{
|
|
1090
|
+
name: 'signer';
|
|
1091
|
+
writable: true;
|
|
1092
|
+
signer: true;
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
name: 'market';
|
|
1096
|
+
writable: true;
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
name: 'orderBook';
|
|
1100
|
+
writable: true;
|
|
1101
|
+
pda: {
|
|
1102
|
+
seeds: [
|
|
1103
|
+
{
|
|
1104
|
+
kind: 'const';
|
|
1105
|
+
value: [111, 114, 100, 101, 114, 95, 98, 111, 111, 107];
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
kind: 'arg';
|
|
1109
|
+
path: 'marketId';
|
|
1110
|
+
}
|
|
1111
|
+
];
|
|
1112
|
+
};
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: 'systemProgram';
|
|
1116
|
+
address: '11111111111111111111111111111111';
|
|
1117
|
+
}
|
|
1118
|
+
];
|
|
1119
|
+
args: [
|
|
1120
|
+
{
|
|
1121
|
+
name: 'marketId';
|
|
1122
|
+
type: 'u64';
|
|
1123
|
+
}
|
|
1124
|
+
];
|
|
1125
|
+
},
|
|
1091
1126
|
{
|
|
1092
1127
|
name: 'createPool';
|
|
1093
1128
|
discriminator: [233, 146, 209, 142, 207, 104, 64, 188];
|