@triadxyz/triad-protocol 4.2.5 → 4.2.6
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/market.d.ts +7 -0
- package/dist/market.js +22 -0
- package/dist/predictor.d.ts +5 -0
- package/dist/predictor.js +19 -0
- package/dist/trade.js +6 -3
- package/package.json +1 -1
package/dist/market.d.ts
CHANGED
|
@@ -160,4 +160,11 @@ export default class Market {
|
|
|
160
160
|
* @param market.poolId - The ID of the pool
|
|
161
161
|
*/
|
|
162
162
|
createAndResolveMarket(toResolve: UpdateMarketWinningDirectionArgs['markets'][0], market: CreateMarketArgs['markets'][0], customer: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @param marketId
|
|
166
|
+
* @param usdcMint
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
migrateUSDC(marketIds: number[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
163
170
|
}
|
package/dist/market.js
CHANGED
|
@@ -567,5 +567,27 @@ class Market {
|
|
|
567
567
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
*
|
|
572
|
+
* @param marketId
|
|
573
|
+
* @param usdcMint
|
|
574
|
+
* @returns
|
|
575
|
+
*/
|
|
576
|
+
migrateUSDC(marketIds) {
|
|
577
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
+
const ixs = [];
|
|
579
|
+
for (const marketId of marketIds) {
|
|
580
|
+
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
581
|
+
ixs.push(yield this.program.methods
|
|
582
|
+
.migrateUsdc()
|
|
583
|
+
.accounts({
|
|
584
|
+
signer: this.program.provider.publicKey,
|
|
585
|
+
market: marketPDA
|
|
586
|
+
})
|
|
587
|
+
.instruction());
|
|
588
|
+
}
|
|
589
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
590
|
+
});
|
|
591
|
+
}
|
|
570
592
|
}
|
|
571
593
|
exports.default = Market;
|
package/dist/predictor.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export default class Predictor {
|
|
|
13
13
|
* @param customerId - Customer ID
|
|
14
14
|
*/
|
|
15
15
|
getPredictor(authority: PublicKey, customerId: number): Promise<PredictorType>;
|
|
16
|
+
createPredictor(users: {
|
|
17
|
+
authority: PublicKey;
|
|
18
|
+
refer: string;
|
|
19
|
+
customerId: number;
|
|
20
|
+
}[]): Promise<void>;
|
|
16
21
|
/**
|
|
17
22
|
* Get User Orders
|
|
18
23
|
* @param wallet - User wallet PublicKey
|
package/dist/predictor.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
15
16
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
16
17
|
const constants_1 = require("./utils/constants");
|
|
17
18
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
@@ -47,6 +48,24 @@ class Predictor {
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
}
|
|
51
|
+
createPredictor(users) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
let ixs = [];
|
|
54
|
+
for (const user of users) {
|
|
55
|
+
ixs.push(yield this.program.methods
|
|
56
|
+
.createPredictor({
|
|
57
|
+
customerId: user.customerId,
|
|
58
|
+
refer: new web3_js_1.PublicKey(user.refer)
|
|
59
|
+
})
|
|
60
|
+
.accounts({
|
|
61
|
+
signer: user.authority,
|
|
62
|
+
payer: this.rpcOptions.payer
|
|
63
|
+
})
|
|
64
|
+
.instruction());
|
|
65
|
+
}
|
|
66
|
+
yield (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
50
69
|
/**
|
|
51
70
|
* Get User Orders
|
|
52
71
|
* @param wallet - User wallet PublicKey
|
package/dist/trade.js
CHANGED
|
@@ -220,6 +220,7 @@ class Trade {
|
|
|
220
220
|
if (usdcAmount.lte(new bn_js_1.default(0)))
|
|
221
221
|
continue;
|
|
222
222
|
const oppositeOrderDirection = (0, helpers_1.getOppositeOrderDirectionEncoded)(orderDirection);
|
|
223
|
+
const oppositePredictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), customer.id);
|
|
223
224
|
ixs.push(yield this.program.methods
|
|
224
225
|
.marketBidOrder({
|
|
225
226
|
amount: new bn_js_1.default(usdcAmount),
|
|
@@ -232,13 +233,13 @@ class Trade {
|
|
|
232
233
|
signer: this.program.provider.publicKey,
|
|
233
234
|
payer: this.rpcOptions.payer,
|
|
234
235
|
predictor: predictorPDA,
|
|
235
|
-
oppositePredictor:
|
|
236
|
+
oppositePredictor: oppositePredictorPDA,
|
|
236
237
|
central: (0, pda_1.getCentralPDA)(this.program.programId),
|
|
237
238
|
market: marketPDA,
|
|
238
239
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
239
240
|
customer: customer.address,
|
|
240
241
|
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
241
|
-
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId,
|
|
242
|
+
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, oppositePredictorPDA, marketId, (0, helpers_1.getOrderDirection)(oppositeOrderDirection))
|
|
242
243
|
})
|
|
243
244
|
.instruction());
|
|
244
245
|
remainingUSDC = remainingUSDC.sub(usdcAmount);
|
|
@@ -285,6 +286,7 @@ class Trade {
|
|
|
285
286
|
const effectivePriceDecimal = (0, feeCalculator_1.applySellFee)(orderPrice.toNumber() / 1000000, 500, customer.marketFeeBps);
|
|
286
287
|
const adjustedPrice = new bn_js_1.default(Math.floor(effectivePriceDecimal * 1000000));
|
|
287
288
|
amountOfUSDC = amountOfUSDC.add(sharesToSell.mul(adjustedPrice).div(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS))));
|
|
289
|
+
const oppositePredictorPDA = (0, pda_1.getPredictorPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), customer.id);
|
|
288
290
|
ixs.push(yield this.program.methods
|
|
289
291
|
.marketAskOrder({
|
|
290
292
|
shares: new bn_js_1.default(sharesToSell),
|
|
@@ -294,12 +296,13 @@ class Trade {
|
|
|
294
296
|
.accounts({
|
|
295
297
|
signer: this.program.provider.publicKey,
|
|
296
298
|
predictor: predictorPDA,
|
|
299
|
+
oppositePredictor: oppositePredictorPDA,
|
|
297
300
|
market: marketPDA,
|
|
298
301
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
299
302
|
customer: customer.address,
|
|
300
303
|
central: (0, pda_1.getCentralPDA)(this.program.programId),
|
|
301
304
|
predictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, predictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
302
|
-
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId,
|
|
305
|
+
oppositePredictorOrder: (0, pda_1.getPredictorOrderPDA)(this.program.programId, oppositePredictorPDA, marketId, (0, helpers_1.getOrderDirection)(orderDirection))
|
|
303
306
|
})
|
|
304
307
|
.instruction());
|
|
305
308
|
}
|