@triadxyz/triad-protocol 4.2.3 → 4.2.5
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/predictor.d.ts +1 -1
- package/dist/predictor.js +5 -2
- package/dist/trade.js +8 -8
- package/dist/types/customer.d.ts +2 -0
- package/dist/types/idl_triad_protocol.json +12 -19
- package/dist/types/triad_protocol.d.ts +11 -18
- package/dist/utils/helpers.js +3 -1
- package/dist/utils/pda.d.ts +1 -1
- package/dist/utils/pda.js +5 -5
- package/package.json +1 -1
package/dist/predictor.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export default class Predictor {
|
|
|
49
49
|
* Withdraw
|
|
50
50
|
* @param args.authority - Authority of the withdraw
|
|
51
51
|
* @param args.amount - Amount to deposit
|
|
52
|
-
* @param args.customerId - Customer ID
|
|
52
|
+
* @param args.customerId - Customer ID
|
|
53
53
|
*/
|
|
54
54
|
withdraw({ authority, amount, customerId }: WithdrawArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
55
55
|
/**
|
package/dist/predictor.js
CHANGED
|
@@ -107,7 +107,8 @@ class Predictor {
|
|
|
107
107
|
const predictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, wallet, customerId);
|
|
108
108
|
return orders
|
|
109
109
|
.map((order) => (0, helpers_1.formatBookOrder)(order, marketId))
|
|
110
|
-
.filter((order) => order.authority === predictorPDA.toBase58()
|
|
110
|
+
.filter((order) => (order.authority === predictorPDA.toBase58() ||
|
|
111
|
+
order.authority === wallet.toBase58()) &&
|
|
111
112
|
order.linkedBookOrderId === constants_1.BOOK_ORDER_NULL.toString());
|
|
112
113
|
});
|
|
113
114
|
}
|
|
@@ -151,7 +152,7 @@ class Predictor {
|
|
|
151
152
|
* Withdraw
|
|
152
153
|
* @param args.authority - Authority of the withdraw
|
|
153
154
|
* @param args.amount - Amount to deposit
|
|
154
|
-
* @param args.customerId - Customer ID
|
|
155
|
+
* @param args.customerId - Customer ID
|
|
155
156
|
*/
|
|
156
157
|
withdraw({ authority, amount, customerId }) {
|
|
157
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -161,6 +162,7 @@ class Predictor {
|
|
|
161
162
|
.withdraw(new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS)))
|
|
162
163
|
.accounts({
|
|
163
164
|
signer: authority,
|
|
165
|
+
payer: this.rpcOptions.payer,
|
|
164
166
|
predictor: predictorPDA
|
|
165
167
|
})
|
|
166
168
|
.instruction()
|
|
@@ -182,6 +184,7 @@ class Predictor {
|
|
|
182
184
|
.collectRewards()
|
|
183
185
|
.accounts({
|
|
184
186
|
signer: authority,
|
|
187
|
+
payer: this.rpcOptions.payer,
|
|
185
188
|
predictor: predictorPDA
|
|
186
189
|
})
|
|
187
190
|
.instruction()
|
package/dist/trade.js
CHANGED
|
@@ -85,7 +85,7 @@ class Trade {
|
|
|
85
85
|
predictor: predictorPDA,
|
|
86
86
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
87
87
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId),
|
|
88
|
-
predictorOrder: (0, pda_1.
|
|
88
|
+
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
|
|
89
89
|
})
|
|
90
90
|
.instruction());
|
|
91
91
|
}
|
|
@@ -115,7 +115,7 @@ class Trade {
|
|
|
115
115
|
signer: this.program.provider.publicKey,
|
|
116
116
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
117
117
|
predictor: predictorPDA,
|
|
118
|
-
predictorOrder: (0, pda_1.
|
|
118
|
+
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection)),
|
|
119
119
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId)
|
|
120
120
|
})
|
|
121
121
|
.instruction());
|
|
@@ -174,7 +174,7 @@ class Trade {
|
|
|
174
174
|
predictor: predictorPDA,
|
|
175
175
|
market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
|
|
176
176
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, order.marketId),
|
|
177
|
-
predictorOrder: (0, pda_1.
|
|
177
|
+
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
|
|
178
178
|
})
|
|
179
179
|
.instruction());
|
|
180
180
|
}
|
|
@@ -237,8 +237,8 @@ class Trade {
|
|
|
237
237
|
market: marketPDA,
|
|
238
238
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
239
239
|
customer: customer.address,
|
|
240
|
-
predictorOrder: (0, pda_1.
|
|
241
|
-
oppositePredictorOrder: (0, pda_1.
|
|
240
|
+
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
241
|
+
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(oppositeOrderDirection))
|
|
242
242
|
})
|
|
243
243
|
.instruction());
|
|
244
244
|
remainingUSDC = remainingUSDC.sub(usdcAmount);
|
|
@@ -298,8 +298,8 @@ class Trade {
|
|
|
298
298
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
299
299
|
customer: customer.address,
|
|
300
300
|
central: (0, pda_1.getCentralPDA)(this.program.programId),
|
|
301
|
-
predictorOrder: (0, pda_1.
|
|
302
|
-
oppositePredictorOrder: (0, pda_1.
|
|
301
|
+
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
302
|
+
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(orderDirection))
|
|
303
303
|
})
|
|
304
304
|
.instruction());
|
|
305
305
|
}
|
|
@@ -328,7 +328,7 @@ class Trade {
|
|
|
328
328
|
predictor: predictorPDA,
|
|
329
329
|
customer: (0, pda_1.getCustomerPDA)(this.program.programId, order.customerId),
|
|
330
330
|
central: (0, pda_1.getCentralPDA)(this.program.programId),
|
|
331
|
-
predictorOrder: (0, pda_1.
|
|
331
|
+
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, order.marketId, (0, helpers_1.getOrderDirection)(order.orderDirection))
|
|
332
332
|
})
|
|
333
333
|
.instruction());
|
|
334
334
|
}
|
package/dist/types/customer.d.ts
CHANGED
|
@@ -456,6 +456,11 @@
|
|
|
456
456
|
"writable": true,
|
|
457
457
|
"signer": true
|
|
458
458
|
},
|
|
459
|
+
{
|
|
460
|
+
"name": "payer",
|
|
461
|
+
"writable": true,
|
|
462
|
+
"signer": true
|
|
463
|
+
},
|
|
459
464
|
{
|
|
460
465
|
"name": "central",
|
|
461
466
|
"writable": true,
|
|
@@ -1384,20 +1389,7 @@
|
|
|
1384
1389
|
},
|
|
1385
1390
|
{
|
|
1386
1391
|
"name": "market",
|
|
1387
|
-
"writable": true
|
|
1388
|
-
"pda": {
|
|
1389
|
-
"seeds": [
|
|
1390
|
-
{
|
|
1391
|
-
"kind": "const",
|
|
1392
|
-
"value": [109, 97, 114, 107, 101, 116]
|
|
1393
|
-
},
|
|
1394
|
-
{
|
|
1395
|
-
"kind": "account",
|
|
1396
|
-
"path": "market.market_id",
|
|
1397
|
-
"account": "MarketV2"
|
|
1398
|
-
}
|
|
1399
|
-
]
|
|
1400
|
-
}
|
|
1392
|
+
"writable": true
|
|
1401
1393
|
},
|
|
1402
1394
|
{
|
|
1403
1395
|
"name": "mint",
|
|
@@ -1927,6 +1919,11 @@
|
|
|
1927
1919
|
"writable": true,
|
|
1928
1920
|
"signer": true
|
|
1929
1921
|
},
|
|
1922
|
+
{
|
|
1923
|
+
"name": "payer",
|
|
1924
|
+
"writable": true,
|
|
1925
|
+
"signer": true
|
|
1926
|
+
},
|
|
1930
1927
|
{
|
|
1931
1928
|
"name": "central",
|
|
1932
1929
|
"writable": true,
|
|
@@ -2644,10 +2641,6 @@
|
|
|
2644
2641
|
"name": "bump",
|
|
2645
2642
|
"type": "u8"
|
|
2646
2643
|
},
|
|
2647
|
-
{
|
|
2648
|
-
"name": "balance",
|
|
2649
|
-
"type": "u64"
|
|
2650
|
-
},
|
|
2651
2644
|
{
|
|
2652
2645
|
"name": "is_locked",
|
|
2653
2646
|
"type": "bool"
|
|
@@ -2667,7 +2660,7 @@
|
|
|
2667
2660
|
{
|
|
2668
2661
|
"name": "padding",
|
|
2669
2662
|
"type": {
|
|
2670
|
-
"array": ["u8",
|
|
2663
|
+
"array": ["u8", 295]
|
|
2671
2664
|
}
|
|
2672
2665
|
}
|
|
2673
2666
|
]
|
|
@@ -619,6 +619,11 @@ export type TriadProtocol = {
|
|
|
619
619
|
writable: true;
|
|
620
620
|
signer: true;
|
|
621
621
|
},
|
|
622
|
+
{
|
|
623
|
+
name: 'payer';
|
|
624
|
+
writable: true;
|
|
625
|
+
signer: true;
|
|
626
|
+
},
|
|
622
627
|
{
|
|
623
628
|
name: 'central';
|
|
624
629
|
writable: true;
|
|
@@ -1824,19 +1829,6 @@ export type TriadProtocol = {
|
|
|
1824
1829
|
{
|
|
1825
1830
|
name: 'market';
|
|
1826
1831
|
writable: true;
|
|
1827
|
-
pda: {
|
|
1828
|
-
seeds: [
|
|
1829
|
-
{
|
|
1830
|
-
kind: 'const';
|
|
1831
|
-
value: [109, 97, 114, 107, 101, 116];
|
|
1832
|
-
},
|
|
1833
|
-
{
|
|
1834
|
-
kind: 'account';
|
|
1835
|
-
path: 'market.market_id';
|
|
1836
|
-
account: 'marketV2';
|
|
1837
|
-
}
|
|
1838
|
-
];
|
|
1839
|
-
};
|
|
1840
1832
|
},
|
|
1841
1833
|
{
|
|
1842
1834
|
name: 'mint';
|
|
@@ -2482,6 +2474,11 @@ export type TriadProtocol = {
|
|
|
2482
2474
|
writable: true;
|
|
2483
2475
|
signer: true;
|
|
2484
2476
|
},
|
|
2477
|
+
{
|
|
2478
|
+
name: 'payer';
|
|
2479
|
+
writable: true;
|
|
2480
|
+
signer: true;
|
|
2481
|
+
},
|
|
2485
2482
|
{
|
|
2486
2483
|
name: 'central';
|
|
2487
2484
|
writable: true;
|
|
@@ -3268,10 +3265,6 @@ export type TriadProtocol = {
|
|
|
3268
3265
|
name: 'bump';
|
|
3269
3266
|
type: 'u8';
|
|
3270
3267
|
},
|
|
3271
|
-
{
|
|
3272
|
-
name: 'balance';
|
|
3273
|
-
type: 'u64';
|
|
3274
|
-
},
|
|
3275
3268
|
{
|
|
3276
3269
|
name: 'isLocked';
|
|
3277
3270
|
type: 'bool';
|
|
@@ -3291,7 +3284,7 @@ export type TriadProtocol = {
|
|
|
3291
3284
|
{
|
|
3292
3285
|
name: 'padding';
|
|
3293
3286
|
type: {
|
|
3294
|
-
array: ['u8',
|
|
3287
|
+
array: ['u8', 295];
|
|
3295
3288
|
};
|
|
3296
3289
|
}
|
|
3297
3290
|
];
|
package/dist/utils/helpers.js
CHANGED
|
@@ -153,7 +153,9 @@ const formatCustomer = (account, publicKey) => {
|
|
|
153
153
|
marketFeeBps: account.marketFeeBps,
|
|
154
154
|
payoutFeeBps: account.payoutFeeBps,
|
|
155
155
|
isVerified: account.isVerified,
|
|
156
|
-
address: publicKey.toString()
|
|
156
|
+
address: publicKey.toString(),
|
|
157
|
+
feeAvailable: account.feeAvailable.toNumber() / Math.pow(10, 6),
|
|
158
|
+
feeClaimed: account.feeClaimed.toNumber() / Math.pow(10, 6)
|
|
157
159
|
};
|
|
158
160
|
};
|
|
159
161
|
exports.formatCustomer = formatCustomer;
|
package/dist/utils/pda.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare const getNftPDA: (programId: PublicKey, number: number) => Public
|
|
|
11
11
|
export declare const getPoseidonPDA: (programId: PublicKey, number: number) => PublicKey;
|
|
12
12
|
export declare const getClaimVaultPDA: (programId: PublicKey, name: string) => PublicKey;
|
|
13
13
|
export declare const getClaimedUserPDA: (programId: PublicKey, claimVault: PublicKey, user: PublicKey) => PublicKey;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getPredictorOrderPDA: (programId: PublicKey, predictor: PublicKey, marketId: number, orderDirection: OrderDirection) => PublicKey;
|
|
15
15
|
export declare const getPredictorPDA: (programId: PublicKey, authority: PublicKey, customerId: number) => PublicKey;
|
|
16
16
|
export declare const getCentralPDA: (programId: PublicKey) => PublicKey;
|
package/dist/utils/pda.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getCentralPDA = exports.getPredictorPDA = exports.
|
|
6
|
+
exports.getCentralPDA = exports.getPredictorPDA = exports.getPredictorOrderPDA = exports.getClaimedUserPDA = exports.getClaimVaultPDA = exports.getPoseidonPDA = exports.getNftPDA = exports.getCollectionPDA = exports.getStakePDA = exports.getPoolPDA = exports.getCustomerPDA = exports.getOrderBookPDA = exports.getMarketPDA = exports.getTokenATA = void 0;
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
9
9
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -52,18 +52,18 @@ const getClaimedUserPDA = (programId, claimVault, user) => {
|
|
|
52
52
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('claimed_user'), claimVault.toBuffer(), user.toBuffer()], programId)[0];
|
|
53
53
|
};
|
|
54
54
|
exports.getClaimedUserPDA = getClaimedUserPDA;
|
|
55
|
-
const
|
|
55
|
+
const getPredictorOrderPDA = (programId, predictor, marketId, orderDirection) => {
|
|
56
56
|
let enumOrderDirection = 0;
|
|
57
57
|
if (orderDirection === types_1.OrderDirection.FLOP)
|
|
58
58
|
enumOrderDirection = 1;
|
|
59
59
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
60
|
-
Buffer.from('
|
|
61
|
-
|
|
60
|
+
Buffer.from('predictor_order'),
|
|
61
|
+
predictor.toBuffer(),
|
|
62
62
|
new bn_js_1.default(marketId).toArrayLike(Buffer, 'le', 8),
|
|
63
63
|
new bn_js_1.default(enumOrderDirection).toArrayLike(Buffer, 'le', 1)
|
|
64
64
|
], programId)[0];
|
|
65
65
|
};
|
|
66
|
-
exports.
|
|
66
|
+
exports.getPredictorOrderPDA = getPredictorOrderPDA;
|
|
67
67
|
const getPredictorPDA = (programId, authority, customerId) => {
|
|
68
68
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
69
69
|
Buffer.from('predictor'),
|