@triadxyz/triad-protocol 1.9.9-beta → 2.0.1-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/trade.js +17 -2
- package/dist/types/idl_triad_protocol.json +10 -29
- package/dist/types/triad_protocol.d.ts +9 -57
- package/package.json +1 -1
package/dist/trade.js
CHANGED
|
@@ -568,6 +568,20 @@ class Trade {
|
|
|
568
568
|
if (order.authority === this.program.provider.publicKey.toBase58()) {
|
|
569
569
|
continue;
|
|
570
570
|
}
|
|
571
|
+
let linkedSellerBidTradePDA = null;
|
|
572
|
+
if (order.linkedBidOrderId !== '0') {
|
|
573
|
+
const userOrders = yield this.getUserOrders(new web3_js_1.PublicKey(order.authority));
|
|
574
|
+
let linkedSellerBidTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority));
|
|
575
|
+
const linkedBidOrder = userOrders.find((order) => order.orderId === order.linkedBidOrderId &&
|
|
576
|
+
order.marketId === marketId.toString());
|
|
577
|
+
if (!linkedBidOrder) {
|
|
578
|
+
throw new Error('Linked bid order not found');
|
|
579
|
+
}
|
|
580
|
+
if (linkedBidOrder.userNonce !== '0') {
|
|
581
|
+
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), Number(linkedBidOrder.userNonce));
|
|
582
|
+
linkedSellerBidTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
571
585
|
const orderPrice = Number(order.price);
|
|
572
586
|
const maxSharesForPrice = remainingUSDC / orderPrice;
|
|
573
587
|
const availableShares = Number(order.totalShares);
|
|
@@ -593,8 +607,9 @@ class Trade {
|
|
|
593
607
|
mint,
|
|
594
608
|
tokenProgram,
|
|
595
609
|
sellerAuthority: new web3_js_1.PublicKey(order.authority),
|
|
596
|
-
|
|
597
|
-
|
|
610
|
+
marketAta: (0, pda_2.getTokenATA)(marketPDA, mint, tokenProgram),
|
|
611
|
+
buyerAta: (0, pda_2.getTokenATA)(this.program.provider.publicKey, mint, tokenProgram),
|
|
612
|
+
linkedSellerBidTrade: linkedSellerBidTradePDA
|
|
598
613
|
})
|
|
599
614
|
.instruction());
|
|
600
615
|
remainingUSDC -= usdcAmount;
|
|
@@ -747,7 +747,7 @@
|
|
|
747
747
|
"writable": true
|
|
748
748
|
},
|
|
749
749
|
{
|
|
750
|
-
"name": "
|
|
750
|
+
"name": "seller_ata",
|
|
751
751
|
"writable": true,
|
|
752
752
|
"pda": {
|
|
753
753
|
"seeds": [
|
|
@@ -776,31 +776,7 @@
|
|
|
776
776
|
},
|
|
777
777
|
{
|
|
778
778
|
"name": "market_ata",
|
|
779
|
-
"writable": true
|
|
780
|
-
"pda": {
|
|
781
|
-
"seeds": [
|
|
782
|
-
{
|
|
783
|
-
"kind": "account",
|
|
784
|
-
"path": "market"
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
"kind": "account",
|
|
788
|
-
"path": "token_program"
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
"kind": "account",
|
|
792
|
-
"path": "mint"
|
|
793
|
-
}
|
|
794
|
-
],
|
|
795
|
-
"program": {
|
|
796
|
-
"kind": "const",
|
|
797
|
-
"value": [
|
|
798
|
-
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
799
|
-
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
800
|
-
219, 233, 248, 89
|
|
801
|
-
]
|
|
802
|
-
}
|
|
803
|
-
}
|
|
779
|
+
"writable": true
|
|
804
780
|
},
|
|
805
781
|
{
|
|
806
782
|
"name": "token_program"
|
|
@@ -851,6 +827,11 @@
|
|
|
851
827
|
"name": "seller_trade",
|
|
852
828
|
"writable": true
|
|
853
829
|
},
|
|
830
|
+
{
|
|
831
|
+
"name": "linked_seller_bid_trade",
|
|
832
|
+
"writable": true,
|
|
833
|
+
"optional": true
|
|
834
|
+
},
|
|
854
835
|
{
|
|
855
836
|
"name": "market",
|
|
856
837
|
"writable": true
|
|
@@ -860,15 +841,15 @@
|
|
|
860
841
|
"writable": true
|
|
861
842
|
},
|
|
862
843
|
{
|
|
863
|
-
"name": "
|
|
844
|
+
"name": "buyer_ata",
|
|
864
845
|
"writable": true
|
|
865
846
|
},
|
|
866
847
|
{
|
|
867
|
-
"name": "
|
|
848
|
+
"name": "market_ata",
|
|
868
849
|
"writable": true
|
|
869
850
|
},
|
|
870
851
|
{
|
|
871
|
-
"name": "
|
|
852
|
+
"name": "seller_ata",
|
|
872
853
|
"writable": true,
|
|
873
854
|
"pda": {
|
|
874
855
|
"seeds": [
|
|
@@ -1026,7 +1026,7 @@ export type TriadProtocol = {
|
|
|
1026
1026
|
writable: true;
|
|
1027
1027
|
},
|
|
1028
1028
|
{
|
|
1029
|
-
name: '
|
|
1029
|
+
name: 'sellerAta';
|
|
1030
1030
|
writable: true;
|
|
1031
1031
|
pda: {
|
|
1032
1032
|
seeds: [
|
|
@@ -1085,59 +1085,6 @@ export type TriadProtocol = {
|
|
|
1085
1085
|
{
|
|
1086
1086
|
name: 'marketAta';
|
|
1087
1087
|
writable: true;
|
|
1088
|
-
pda: {
|
|
1089
|
-
seeds: [
|
|
1090
|
-
{
|
|
1091
|
-
kind: 'account';
|
|
1092
|
-
path: 'market';
|
|
1093
|
-
},
|
|
1094
|
-
{
|
|
1095
|
-
kind: 'account';
|
|
1096
|
-
path: 'tokenProgram';
|
|
1097
|
-
},
|
|
1098
|
-
{
|
|
1099
|
-
kind: 'account';
|
|
1100
|
-
path: 'mint';
|
|
1101
|
-
}
|
|
1102
|
-
];
|
|
1103
|
-
program: {
|
|
1104
|
-
kind: 'const';
|
|
1105
|
-
value: [
|
|
1106
|
-
140,
|
|
1107
|
-
151,
|
|
1108
|
-
37,
|
|
1109
|
-
143,
|
|
1110
|
-
78,
|
|
1111
|
-
36,
|
|
1112
|
-
137,
|
|
1113
|
-
241,
|
|
1114
|
-
187,
|
|
1115
|
-
61,
|
|
1116
|
-
16,
|
|
1117
|
-
41,
|
|
1118
|
-
20,
|
|
1119
|
-
142,
|
|
1120
|
-
13,
|
|
1121
|
-
131,
|
|
1122
|
-
11,
|
|
1123
|
-
90,
|
|
1124
|
-
19,
|
|
1125
|
-
153,
|
|
1126
|
-
218,
|
|
1127
|
-
255,
|
|
1128
|
-
16,
|
|
1129
|
-
132,
|
|
1130
|
-
4,
|
|
1131
|
-
142,
|
|
1132
|
-
123,
|
|
1133
|
-
216,
|
|
1134
|
-
219,
|
|
1135
|
-
233,
|
|
1136
|
-
248,
|
|
1137
|
-
89
|
|
1138
|
-
];
|
|
1139
|
-
};
|
|
1140
|
-
};
|
|
1141
1088
|
},
|
|
1142
1089
|
{
|
|
1143
1090
|
name: 'tokenProgram';
|
|
@@ -1188,6 +1135,11 @@ export type TriadProtocol = {
|
|
|
1188
1135
|
name: 'sellerTrade';
|
|
1189
1136
|
writable: true;
|
|
1190
1137
|
},
|
|
1138
|
+
{
|
|
1139
|
+
name: 'linkedSellerBidTrade';
|
|
1140
|
+
writable: true;
|
|
1141
|
+
optional: true;
|
|
1142
|
+
},
|
|
1191
1143
|
{
|
|
1192
1144
|
name: 'market';
|
|
1193
1145
|
writable: true;
|
|
@@ -1197,15 +1149,15 @@ export type TriadProtocol = {
|
|
|
1197
1149
|
writable: true;
|
|
1198
1150
|
},
|
|
1199
1151
|
{
|
|
1200
|
-
name: '
|
|
1152
|
+
name: 'buyerAta';
|
|
1201
1153
|
writable: true;
|
|
1202
1154
|
},
|
|
1203
1155
|
{
|
|
1204
|
-
name: '
|
|
1156
|
+
name: 'marketAta';
|
|
1205
1157
|
writable: true;
|
|
1206
1158
|
},
|
|
1207
1159
|
{
|
|
1208
|
-
name: '
|
|
1160
|
+
name: 'sellerAta';
|
|
1209
1161
|
writable: true;
|
|
1210
1162
|
pda: {
|
|
1211
1163
|
seeds: [
|