@triadxyz/triad-protocol 4.2.4 → 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 +3 -2
- package/dist/trade.js +8 -8
- package/dist/types/customer.d.ts +2 -0
- package/dist/types/idl_triad_protocol.json +1 -14
- package/dist/types/triad_protocol.d.ts +0 -13
- 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* () {
|
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
|
@@ -1389,20 +1389,7 @@
|
|
|
1389
1389
|
},
|
|
1390
1390
|
{
|
|
1391
1391
|
"name": "market",
|
|
1392
|
-
"writable": true
|
|
1393
|
-
"pda": {
|
|
1394
|
-
"seeds": [
|
|
1395
|
-
{
|
|
1396
|
-
"kind": "const",
|
|
1397
|
-
"value": [109, 97, 114, 107, 101, 116]
|
|
1398
|
-
},
|
|
1399
|
-
{
|
|
1400
|
-
"kind": "account",
|
|
1401
|
-
"path": "market.market_id",
|
|
1402
|
-
"account": "MarketV2"
|
|
1403
|
-
}
|
|
1404
|
-
]
|
|
1405
|
-
}
|
|
1392
|
+
"writable": true
|
|
1406
1393
|
},
|
|
1407
1394
|
{
|
|
1408
1395
|
"name": "mint",
|
|
@@ -1829,19 +1829,6 @@ export type TriadProtocol = {
|
|
|
1829
1829
|
{
|
|
1830
1830
|
name: 'market';
|
|
1831
1831
|
writable: true;
|
|
1832
|
-
pda: {
|
|
1833
|
-
seeds: [
|
|
1834
|
-
{
|
|
1835
|
-
kind: 'const';
|
|
1836
|
-
value: [109, 97, 114, 107, 101, 116];
|
|
1837
|
-
},
|
|
1838
|
-
{
|
|
1839
|
-
kind: 'account';
|
|
1840
|
-
path: 'market.market_id';
|
|
1841
|
-
account: 'marketV2';
|
|
1842
|
-
}
|
|
1843
|
-
];
|
|
1844
|
-
};
|
|
1845
1832
|
},
|
|
1846
1833
|
{
|
|
1847
1834
|
name: 'mint';
|
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'),
|