@triadxyz/triad-protocol 4.1.7 → 4.1.9
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/customer.d.ts +1 -1
- package/dist/customer.js +11 -6
- package/dist/index.d.ts +13 -2
- package/dist/index.js +76 -40
- package/dist/trade.d.ts +2 -2
- package/dist/trade.js +10 -6
- package/dist/types/customer.d.ts +4 -0
- package/dist/types/idl_triad_protocol.json +220 -1
- package/dist/types/index.d.ts +14 -10
- package/dist/types/trade.d.ts +2 -0
- package/dist/types/triad_protocol.d.ts +278 -1
- package/dist/utils/feeCalculator.d.ts +15 -5
- package/dist/utils/feeCalculator.js +48 -18
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +19 -1
- package/package.json +1 -1
package/dist/customer.d.ts
CHANGED
|
@@ -29,5 +29,5 @@ export default class Customer {
|
|
|
29
29
|
* @param args.feeRecipient - The fee recipient of the customer
|
|
30
30
|
* @param args.feeBps - The fee in basis points of the customer
|
|
31
31
|
*/
|
|
32
|
-
createCustomer({ id, name, authority, feeRecipient, feeBps }: CreateCustomerArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
32
|
+
createCustomer({ id, name, authority, feeRecipient, feeBps, marketFeeBps, payoutFeeBps }: CreateCustomerArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
33
33
|
}
|
package/dist/customer.js
CHANGED
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const helpers_1 = require("./utils/helpers");
|
|
16
16
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
17
|
-
const pda_1 = require("./utils/pda");
|
|
18
17
|
class Customer {
|
|
19
18
|
constructor(program, rpcOptions) {
|
|
20
19
|
this.program = program;
|
|
@@ -52,9 +51,7 @@ class Customer {
|
|
|
52
51
|
*/
|
|
53
52
|
getCustomerById(customerId) {
|
|
54
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
|
|
56
|
-
const customer = yield this.program.account.customer.fetch(customerPDA, this.rpcOptions.commitment);
|
|
57
|
-
return (0, helpers_1.formatCustomer)(customer, customerPDA);
|
|
54
|
+
return (0, helpers_1.getCustomerById)(this.program, customerId);
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
@@ -65,11 +62,19 @@ class Customer {
|
|
|
65
62
|
* @param args.feeRecipient - The fee recipient of the customer
|
|
66
63
|
* @param args.feeBps - The fee in basis points of the customer
|
|
67
64
|
*/
|
|
68
|
-
createCustomer({ id, name, authority, feeRecipient, feeBps }) {
|
|
65
|
+
createCustomer({ id, name, authority, feeRecipient, feeBps, marketFeeBps, payoutFeeBps }) {
|
|
69
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
67
|
const ixs = [
|
|
71
68
|
yield this.program.methods
|
|
72
|
-
.createCustomer({
|
|
69
|
+
.createCustomer({
|
|
70
|
+
id,
|
|
71
|
+
name,
|
|
72
|
+
authority,
|
|
73
|
+
feeRecipient,
|
|
74
|
+
feeBps,
|
|
75
|
+
marketFeeBps,
|
|
76
|
+
payoutFeeBps
|
|
77
|
+
})
|
|
73
78
|
.accounts({
|
|
74
79
|
signer: this.program.provider.publicKey
|
|
75
80
|
})
|
package/dist/index.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export default class TriadProtocol {
|
|
|
119
119
|
* @param args.poolId - The ID of the Pool
|
|
120
120
|
* @param args.withPayout - Whether to allow the market to payout
|
|
121
121
|
*/
|
|
122
|
-
updateMarketWinningDirection({
|
|
122
|
+
updateMarketWinningDirection({ markets }: UpdateMarketWinningDirectionArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
123
123
|
/**
|
|
124
124
|
* Update Market Payout
|
|
125
125
|
* @param args.marketId - The ID of the market
|
|
@@ -159,6 +159,17 @@ export default class TriadProtocol {
|
|
|
159
159
|
id: number;
|
|
160
160
|
authority: PublicKey;
|
|
161
161
|
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
162
|
+
/**
|
|
163
|
+
* Close IDLE Market
|
|
164
|
+
* @param markets.id - Market ID
|
|
165
|
+
* @param markets.authority - Market authority
|
|
166
|
+
* @param markets.mint - Market mint
|
|
167
|
+
*/
|
|
168
|
+
closeIdleMarket(markets: {
|
|
169
|
+
id: number;
|
|
170
|
+
authority: PublicKey;
|
|
171
|
+
mint: PublicKey;
|
|
172
|
+
}[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
162
173
|
/**
|
|
163
174
|
* Update Pool Question
|
|
164
175
|
* @param poolId - Pool ID
|
|
@@ -173,7 +184,7 @@ export default class TriadProtocol {
|
|
|
173
184
|
* @param args.customer - The customer of the market
|
|
174
185
|
* @param args.poolId - The ID of the pool
|
|
175
186
|
*/
|
|
176
|
-
createMarketPyth({
|
|
187
|
+
createMarketPyth({ markets }: CreateMarketPythArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
177
188
|
/**
|
|
178
189
|
* Burn Triad
|
|
179
190
|
* @param amount - Amount to burn
|
package/dist/index.js
CHANGED
|
@@ -198,8 +198,17 @@ class TriadProtocol {
|
|
|
198
198
|
*/
|
|
199
199
|
nextMarketId() {
|
|
200
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
let validId = null;
|
|
202
|
+
while (!validId) {
|
|
203
|
+
const marketId = Math.floor(Math.random() * 1000000000000000);
|
|
204
|
+
try {
|
|
205
|
+
yield this.program.account.marketV2.fetch((0, pda_1.getMarketPDA)(this.program.programId, marketId));
|
|
206
|
+
}
|
|
207
|
+
catch (_a) {
|
|
208
|
+
validId = marketId;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return validId;
|
|
203
212
|
});
|
|
204
213
|
}
|
|
205
214
|
/**
|
|
@@ -342,26 +351,29 @@ class TriadProtocol {
|
|
|
342
351
|
* @param args.poolId - The ID of the Pool
|
|
343
352
|
* @param args.withPayout - Whether to allow the market to payout
|
|
344
353
|
*/
|
|
345
|
-
updateMarketWinningDirection({
|
|
354
|
+
updateMarketWinningDirection({ markets }) {
|
|
346
355
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
|
-
const ixs = [
|
|
348
|
-
|
|
349
|
-
.updateMarketWinningDirection(winningDirection)
|
|
350
|
-
.accounts({
|
|
351
|
-
signer: this.program.provider.publicKey,
|
|
352
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
353
|
-
pool: poolId ? (0, pda_1.getPoolPDA)(this.program.programId, poolId) : null
|
|
354
|
-
})
|
|
355
|
-
.instruction()
|
|
356
|
-
];
|
|
357
|
-
if (withPayout) {
|
|
356
|
+
const ixs = [];
|
|
357
|
+
for (const market of markets) {
|
|
358
358
|
ixs.push(yield this.program.methods
|
|
359
|
-
.
|
|
359
|
+
.updateMarketWinningDirection(market.winningDirection)
|
|
360
360
|
.accounts({
|
|
361
361
|
signer: this.program.provider.publicKey,
|
|
362
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
362
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId),
|
|
363
|
+
pool: market.poolId
|
|
364
|
+
? (0, pda_1.getPoolPDA)(this.program.programId, market.poolId)
|
|
365
|
+
: null
|
|
363
366
|
})
|
|
364
367
|
.instruction());
|
|
368
|
+
if (market.withPayout) {
|
|
369
|
+
ixs.push(yield this.program.methods
|
|
370
|
+
.updateMarketPayout(true)
|
|
371
|
+
.accounts({
|
|
372
|
+
signer: this.program.provider.publicKey,
|
|
373
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
374
|
+
})
|
|
375
|
+
.instruction());
|
|
376
|
+
}
|
|
365
377
|
}
|
|
366
378
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
367
379
|
});
|
|
@@ -468,6 +480,28 @@ class TriadProtocol {
|
|
|
468
480
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
469
481
|
});
|
|
470
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Close IDLE Market
|
|
485
|
+
* @param markets.id - Market ID
|
|
486
|
+
* @param markets.authority - Market authority
|
|
487
|
+
* @param markets.mint - Market mint
|
|
488
|
+
*/
|
|
489
|
+
closeIdleMarket(markets) {
|
|
490
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
491
|
+
const ixs = [];
|
|
492
|
+
for (const market of markets) {
|
|
493
|
+
ixs.push(yield this.program.methods
|
|
494
|
+
.closeIdleMarket(new bn_js_1.default(market.id))
|
|
495
|
+
.accounts({
|
|
496
|
+
signer: this.program.provider.publicKey,
|
|
497
|
+
mint: market.mint,
|
|
498
|
+
tokenProgram: (0, helpers_1.getTokenProgram)(market.mint)
|
|
499
|
+
})
|
|
500
|
+
.instruction());
|
|
501
|
+
}
|
|
502
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
471
505
|
/**
|
|
472
506
|
* Update Pool Question
|
|
473
507
|
* @param poolId - Pool ID
|
|
@@ -495,32 +529,34 @@ class TriadProtocol {
|
|
|
495
529
|
* @param args.customer - The customer of the market
|
|
496
530
|
* @param args.poolId - The ID of the pool
|
|
497
531
|
*/
|
|
498
|
-
createMarketPyth({
|
|
532
|
+
createMarketPyth({ markets }) {
|
|
499
533
|
return __awaiter(this, void 0, void 0, function* () {
|
|
500
534
|
const ixs = [];
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
.
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
.
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
535
|
+
for (const market of markets) {
|
|
536
|
+
let poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, market.poolId);
|
|
537
|
+
const feedPDA = (0, helpers_2.getPriceFeedAccountForProgram)(market.feedId);
|
|
538
|
+
ixs.push(yield this.program.methods
|
|
539
|
+
.createMarketPyth({
|
|
540
|
+
marketId: new bn_js_1.default(market.marketId),
|
|
541
|
+
resolveIn: new bn_js_1.default(market.resolveIn),
|
|
542
|
+
direction: market.direction
|
|
543
|
+
})
|
|
544
|
+
.accounts({
|
|
545
|
+
signer: this.program.provider.publicKey,
|
|
546
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
547
|
+
pool: poolPDA,
|
|
548
|
+
customer: market.customer,
|
|
549
|
+
priceUpdate: feedPDA
|
|
550
|
+
})
|
|
551
|
+
.instruction());
|
|
552
|
+
ixs.push(yield this.program.methods
|
|
553
|
+
.createOrderBook(new bn_js_1.default(market.marketId))
|
|
554
|
+
.accounts({
|
|
555
|
+
signer: this.program.provider.publicKey,
|
|
556
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
|
|
557
|
+
})
|
|
558
|
+
.instruction());
|
|
559
|
+
}
|
|
524
560
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
525
561
|
});
|
|
526
562
|
}
|
package/dist/trade.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export default class Trade {
|
|
|
64
64
|
* @param args.amount - The amount of the Order
|
|
65
65
|
* @param args.orderDirection - The direction of the Order
|
|
66
66
|
*/
|
|
67
|
-
marketBidOrder({ marketId, amount, orderDirection }: MarketBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
67
|
+
marketBidOrder({ marketId, amount, customerId, orderDirection }: MarketBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
68
68
|
/**
|
|
69
69
|
* Market Ask Order
|
|
70
70
|
* @param args.marketId - The ID of the Market
|
|
@@ -72,7 +72,7 @@ export default class Trade {
|
|
|
72
72
|
* @param args.bookOrderBidId - The ID of the Bid Order
|
|
73
73
|
* @param args.orderDirection - The direction of the Order
|
|
74
74
|
*/
|
|
75
|
-
marketAskOrder({ marketId, shares, orderDirection }: MarketAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
75
|
+
marketAskOrder({ marketId, shares, orderDirection, customerId }: MarketAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
76
76
|
/**
|
|
77
77
|
* Payout Order
|
|
78
78
|
* @param args.marketId - The ID of the Market
|
package/dist/trade.js
CHANGED
|
@@ -196,11 +196,12 @@ class Trade {
|
|
|
196
196
|
* @param args.amount - The amount of the Order
|
|
197
197
|
* @param args.orderDirection - The direction of the Order
|
|
198
198
|
*/
|
|
199
|
-
marketBidOrder({ marketId, amount, orderDirection }) {
|
|
199
|
+
marketBidOrder({ marketId, amount, customerId, orderDirection }) {
|
|
200
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
201
|
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
202
202
|
const ixs = [];
|
|
203
203
|
const addressLookupTableAccounts = [];
|
|
204
|
+
const customer = yield (0, helpers_1.getCustomerById)(this.program, customerId);
|
|
204
205
|
const orderBook = yield this.getOrderBook(marketId);
|
|
205
206
|
let remainingUSDC = new bn_js_1.default(amount * Math.pow(10, constants_1.BASE_DECIMALS));
|
|
206
207
|
const orders = Object.keys(orderDirection)[0] === 'hype'
|
|
@@ -215,7 +216,7 @@ class Trade {
|
|
|
215
216
|
}
|
|
216
217
|
const orderPrice = new bn_js_1.default(order.price);
|
|
217
218
|
const availableShares = new bn_js_1.default(order.totalShares).sub(new bn_js_1.default(order.filledShares));
|
|
218
|
-
const effectivePriceDecimal = (0, feeCalculator_1.applyBuyFee)(orderPrice.toNumber() / 1000000, 500);
|
|
219
|
+
const effectivePriceDecimal = (0, feeCalculator_1.applyBuyFee)(orderPrice.toNumber() / 1000000, 500, customer.marketFeeBps);
|
|
219
220
|
const adjustedPrice = new bn_js_1.default(Math.floor(effectivePriceDecimal * 1000000));
|
|
220
221
|
const maxSharesForPrice = remainingUSDC
|
|
221
222
|
.mul(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS)))
|
|
@@ -244,7 +245,8 @@ class Trade {
|
|
|
244
245
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
245
246
|
bookOrderAskAuthority: new web3_js_1.PublicKey(order.authority),
|
|
246
247
|
order: (0, pda_1.getOrderPDA)(this.program.programId, this.program.provider.publicKey, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
247
|
-
oppositeOrder: (0, pda_1.getOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(oppositeOrderDirection))
|
|
248
|
+
oppositeOrder: (0, pda_1.getOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(oppositeOrderDirection)),
|
|
249
|
+
customer: (0, pda_1.getCustomerPDA)(this.program.programId, customerId)
|
|
248
250
|
})
|
|
249
251
|
.instruction());
|
|
250
252
|
remainingUSDC = remainingUSDC.sub(usdcAmount);
|
|
@@ -262,11 +264,12 @@ class Trade {
|
|
|
262
264
|
* @param args.bookOrderBidId - The ID of the Bid Order
|
|
263
265
|
* @param args.orderDirection - The direction of the Order
|
|
264
266
|
*/
|
|
265
|
-
marketAskOrder({ marketId, shares, orderDirection }) {
|
|
267
|
+
marketAskOrder({ marketId, shares, orderDirection, customerId }) {
|
|
266
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
267
269
|
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
268
270
|
const ixs = [];
|
|
269
271
|
const addressLookupTableAccounts = [];
|
|
272
|
+
const customer = yield (0, helpers_1.getCustomerById)(this.program, customerId);
|
|
270
273
|
const orderBook = yield this.getOrderBook(marketId);
|
|
271
274
|
const bidOrders = Object.keys(orderDirection)[0] === 'hype'
|
|
272
275
|
? orderBook.hype.bid
|
|
@@ -287,7 +290,7 @@ class Trade {
|
|
|
287
290
|
continue;
|
|
288
291
|
remainingShares = remainingShares.sub(sharesToSell);
|
|
289
292
|
const orderPrice = new bn_js_1.default(order.price);
|
|
290
|
-
const effectivePriceDecimal = (0, feeCalculator_1.applySellFee)(orderPrice.toNumber() / 1000000, 500);
|
|
293
|
+
const effectivePriceDecimal = (0, feeCalculator_1.applySellFee)(orderPrice.toNumber() / 1000000, 500, customer.marketFeeBps);
|
|
291
294
|
const adjustedPrice = new bn_js_1.default(Math.floor(effectivePriceDecimal * 1000000));
|
|
292
295
|
amountOfUSDC = amountOfUSDC.add(sharesToSell.mul(adjustedPrice).div(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS))));
|
|
293
296
|
ixs.push(yield this.program.methods
|
|
@@ -304,7 +307,8 @@ class Trade {
|
|
|
304
307
|
orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
|
|
305
308
|
marketAta: (0, pda_1.getTokenATA)(marketPDA, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID),
|
|
306
309
|
bidOrder: (0, pda_1.getOrderPDA)(this.program.programId, new web3_js_1.PublicKey(order.authority), marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
307
|
-
askOrder: (0, pda_1.getOrderPDA)(this.program.programId, this.program.provider.publicKey, marketId, (0, helpers_1.getOrderDirection)(orderDirection))
|
|
310
|
+
askOrder: (0, pda_1.getOrderPDA)(this.program.programId, this.program.provider.publicKey, marketId, (0, helpers_1.getOrderDirection)(orderDirection)),
|
|
311
|
+
customer: customer.address
|
|
308
312
|
})
|
|
309
313
|
.instruction());
|
|
310
314
|
}
|
package/dist/types/customer.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type Customer = {
|
|
|
7
7
|
feeBps: number;
|
|
8
8
|
isVerified: boolean;
|
|
9
9
|
address: string;
|
|
10
|
+
marketFeeBps: number;
|
|
11
|
+
payoutFeeBps: number;
|
|
10
12
|
};
|
|
11
13
|
export type CreateCustomerArgs = {
|
|
12
14
|
id: number;
|
|
@@ -14,4 +16,6 @@ export type CreateCustomerArgs = {
|
|
|
14
16
|
authority: PublicKey;
|
|
15
17
|
feeRecipient: PublicKey;
|
|
16
18
|
feeBps: number;
|
|
19
|
+
marketFeeBps: number;
|
|
20
|
+
payoutFeeBps: number;
|
|
17
21
|
};
|
|
@@ -474,6 +474,129 @@
|
|
|
474
474
|
],
|
|
475
475
|
"args": []
|
|
476
476
|
},
|
|
477
|
+
{
|
|
478
|
+
"name": "close_idle_market",
|
|
479
|
+
"discriminator": [249, 217, 214, 137, 20, 38, 112, 154],
|
|
480
|
+
"accounts": [
|
|
481
|
+
{
|
|
482
|
+
"name": "signer",
|
|
483
|
+
"writable": true,
|
|
484
|
+
"signer": true
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"name": "squads",
|
|
488
|
+
"writable": true,
|
|
489
|
+
"address": "Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"name": "market",
|
|
493
|
+
"writable": true,
|
|
494
|
+
"pda": {
|
|
495
|
+
"seeds": [
|
|
496
|
+
{
|
|
497
|
+
"kind": "const",
|
|
498
|
+
"value": [109, 97, 114, 107, 101, 116]
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
"kind": "arg",
|
|
502
|
+
"path": "market_id"
|
|
503
|
+
}
|
|
504
|
+
]
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"name": "mint"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"name": "market_to_ata",
|
|
512
|
+
"writable": true,
|
|
513
|
+
"pda": {
|
|
514
|
+
"seeds": [
|
|
515
|
+
{
|
|
516
|
+
"kind": "account",
|
|
517
|
+
"path": "market"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"kind": "account",
|
|
521
|
+
"path": "token_program"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"kind": "account",
|
|
525
|
+
"path": "mint"
|
|
526
|
+
}
|
|
527
|
+
],
|
|
528
|
+
"program": {
|
|
529
|
+
"kind": "const",
|
|
530
|
+
"value": [
|
|
531
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
532
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
533
|
+
219, 233, 248, 89
|
|
534
|
+
]
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"name": "squads_ata",
|
|
540
|
+
"writable": true,
|
|
541
|
+
"pda": {
|
|
542
|
+
"seeds": [
|
|
543
|
+
{
|
|
544
|
+
"kind": "account",
|
|
545
|
+
"path": "squads"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
"kind": "account",
|
|
549
|
+
"path": "token_program"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"kind": "account",
|
|
553
|
+
"path": "mint"
|
|
554
|
+
}
|
|
555
|
+
],
|
|
556
|
+
"program": {
|
|
557
|
+
"kind": "const",
|
|
558
|
+
"value": [
|
|
559
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
560
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
561
|
+
219, 233, 248, 89
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
"name": "order_book",
|
|
568
|
+
"pda": {
|
|
569
|
+
"seeds": [
|
|
570
|
+
{
|
|
571
|
+
"kind": "const",
|
|
572
|
+
"value": [111, 114, 100, 101, 114, 95, 98, 111, 111, 107]
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
"kind": "arg",
|
|
576
|
+
"path": "market_id"
|
|
577
|
+
}
|
|
578
|
+
]
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"name": "token_program"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
"name": "associated_token_program",
|
|
586
|
+
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
"name": "system_program",
|
|
590
|
+
"address": "11111111111111111111111111111111"
|
|
591
|
+
}
|
|
592
|
+
],
|
|
593
|
+
"args": [
|
|
594
|
+
{
|
|
595
|
+
"name": "market_id",
|
|
596
|
+
"type": "u64"
|
|
597
|
+
}
|
|
598
|
+
]
|
|
599
|
+
},
|
|
477
600
|
{
|
|
478
601
|
"name": "close_order_book",
|
|
479
602
|
"discriminator": [219, 134, 73, 219, 180, 7, 94, 206],
|
|
@@ -1194,6 +1317,10 @@
|
|
|
1194
1317
|
"name": "order_book",
|
|
1195
1318
|
"writable": true
|
|
1196
1319
|
},
|
|
1320
|
+
{
|
|
1321
|
+
"name": "customer",
|
|
1322
|
+
"writable": true
|
|
1323
|
+
},
|
|
1197
1324
|
{
|
|
1198
1325
|
"name": "ask_order",
|
|
1199
1326
|
"writable": true
|
|
@@ -1289,6 +1416,10 @@
|
|
|
1289
1416
|
"name": "order_book",
|
|
1290
1417
|
"writable": true
|
|
1291
1418
|
},
|
|
1419
|
+
{
|
|
1420
|
+
"name": "customer",
|
|
1421
|
+
"writable": true
|
|
1422
|
+
},
|
|
1292
1423
|
{
|
|
1293
1424
|
"name": "order",
|
|
1294
1425
|
"writable": true
|
|
@@ -2014,6 +2145,48 @@
|
|
|
2014
2145
|
],
|
|
2015
2146
|
"args": []
|
|
2016
2147
|
},
|
|
2148
|
+
{
|
|
2149
|
+
"name": "update_customer",
|
|
2150
|
+
"discriminator": [158, 118, 103, 177, 241, 229, 169, 124],
|
|
2151
|
+
"accounts": [
|
|
2152
|
+
{
|
|
2153
|
+
"name": "signer",
|
|
2154
|
+
"writable": true,
|
|
2155
|
+
"signer": true
|
|
2156
|
+
},
|
|
2157
|
+
{
|
|
2158
|
+
"name": "customer",
|
|
2159
|
+
"writable": true,
|
|
2160
|
+
"pda": {
|
|
2161
|
+
"seeds": [
|
|
2162
|
+
{
|
|
2163
|
+
"kind": "const",
|
|
2164
|
+
"value": [99, 117, 115, 116, 111, 109, 101, 114]
|
|
2165
|
+
},
|
|
2166
|
+
{
|
|
2167
|
+
"kind": "account",
|
|
2168
|
+
"path": "customer.id",
|
|
2169
|
+
"account": "Customer"
|
|
2170
|
+
}
|
|
2171
|
+
]
|
|
2172
|
+
}
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
"name": "system_program",
|
|
2176
|
+
"address": "11111111111111111111111111111111"
|
|
2177
|
+
}
|
|
2178
|
+
],
|
|
2179
|
+
"args": [
|
|
2180
|
+
{
|
|
2181
|
+
"name": "args",
|
|
2182
|
+
"type": {
|
|
2183
|
+
"defined": {
|
|
2184
|
+
"name": "UpdateCustomerArgs"
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
]
|
|
2189
|
+
},
|
|
2017
2190
|
{
|
|
2018
2191
|
"name": "update_market_end",
|
|
2019
2192
|
"discriminator": [10, 188, 22, 219, 206, 83, 67, 31],
|
|
@@ -2591,6 +2764,16 @@
|
|
|
2591
2764
|
"code": 6027,
|
|
2592
2765
|
"name": "InvalidQuestion",
|
|
2593
2766
|
"msg": "Invalid Question"
|
|
2767
|
+
},
|
|
2768
|
+
{
|
|
2769
|
+
"code": 6028,
|
|
2770
|
+
"name": "MarketNotIdle",
|
|
2771
|
+
"msg": "Market Not Idle"
|
|
2772
|
+
},
|
|
2773
|
+
{
|
|
2774
|
+
"code": 6029,
|
|
2775
|
+
"name": "OrderBookStillExists",
|
|
2776
|
+
"msg": "Order Book still exists"
|
|
2594
2777
|
}
|
|
2595
2778
|
],
|
|
2596
2779
|
"types": [
|
|
@@ -2998,6 +3181,14 @@
|
|
|
2998
3181
|
{
|
|
2999
3182
|
"name": "fee_bps",
|
|
3000
3183
|
"type": "u16"
|
|
3184
|
+
},
|
|
3185
|
+
{
|
|
3186
|
+
"name": "market_fee_bps",
|
|
3187
|
+
"type": "u16"
|
|
3188
|
+
},
|
|
3189
|
+
{
|
|
3190
|
+
"name": "payout_fee_bps",
|
|
3191
|
+
"type": "u16"
|
|
3001
3192
|
}
|
|
3002
3193
|
]
|
|
3003
3194
|
}
|
|
@@ -3139,10 +3330,18 @@
|
|
|
3139
3330
|
"name": "is_verified",
|
|
3140
3331
|
"type": "bool"
|
|
3141
3332
|
},
|
|
3333
|
+
{
|
|
3334
|
+
"name": "market_fee_bps",
|
|
3335
|
+
"type": "u16"
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
"name": "payout_fee_bps",
|
|
3339
|
+
"type": "u16"
|
|
3340
|
+
},
|
|
3142
3341
|
{
|
|
3143
3342
|
"name": "padding",
|
|
3144
3343
|
"type": {
|
|
3145
|
-
"array": ["u8",
|
|
3344
|
+
"array": ["u8", 25]
|
|
3146
3345
|
}
|
|
3147
3346
|
}
|
|
3148
3347
|
]
|
|
@@ -4317,6 +4516,26 @@
|
|
|
4317
4516
|
]
|
|
4318
4517
|
}
|
|
4319
4518
|
},
|
|
4519
|
+
{
|
|
4520
|
+
"name": "UpdateCustomerArgs",
|
|
4521
|
+
"type": {
|
|
4522
|
+
"kind": "struct",
|
|
4523
|
+
"fields": [
|
|
4524
|
+
{
|
|
4525
|
+
"name": "market_fee_bps",
|
|
4526
|
+
"type": {
|
|
4527
|
+
"option": "u16"
|
|
4528
|
+
}
|
|
4529
|
+
},
|
|
4530
|
+
{
|
|
4531
|
+
"name": "payout_fee_bps",
|
|
4532
|
+
"type": {
|
|
4533
|
+
"option": "u16"
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
]
|
|
4537
|
+
}
|
|
4538
|
+
},
|
|
4320
4539
|
{
|
|
4321
4540
|
"name": "VerificationLevel",
|
|
4322
4541
|
"docs": [
|
package/dist/types/index.d.ts
CHANGED
|
@@ -156,12 +156,14 @@ export type CreateMarketArgs = {
|
|
|
156
156
|
poolId?: number;
|
|
157
157
|
};
|
|
158
158
|
export type CreateMarketPythArgs = {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
markets: {
|
|
160
|
+
marketId: number;
|
|
161
|
+
resolveIn: number;
|
|
162
|
+
customer: PublicKey;
|
|
163
|
+
poolId: number;
|
|
164
|
+
feedId: string;
|
|
165
|
+
direction: 'Above' | 'Below';
|
|
166
|
+
}[];
|
|
165
167
|
};
|
|
166
168
|
export type CreatePoolArgs = {
|
|
167
169
|
poolId: number;
|
|
@@ -180,10 +182,12 @@ export type CreatePoolArgs = {
|
|
|
180
182
|
feedId?: string;
|
|
181
183
|
};
|
|
182
184
|
export type UpdateMarketWinningDirectionArgs = {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
markets: {
|
|
186
|
+
marketId: number;
|
|
187
|
+
winningDirection: WinningDirectionEncoded;
|
|
188
|
+
poolId?: number;
|
|
189
|
+
withPayout?: boolean;
|
|
190
|
+
}[];
|
|
187
191
|
};
|
|
188
192
|
export type UpdateMarketPayoutArgs = {
|
|
189
193
|
marketId: number;
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -35,10 +35,12 @@ export type CancelAskOrderArgs = {
|
|
|
35
35
|
export type MarketBidOrderArgs = {
|
|
36
36
|
marketId: number;
|
|
37
37
|
amount: number;
|
|
38
|
+
customerId: number;
|
|
38
39
|
orderDirection: OrderDirectionEncoded;
|
|
39
40
|
};
|
|
40
41
|
export type MarketAskOrderArgs = {
|
|
41
42
|
marketId: number;
|
|
42
43
|
shares: number;
|
|
44
|
+
customerId: number;
|
|
43
45
|
orderDirection: OrderDirectionEncoded;
|
|
44
46
|
};
|
|
@@ -707,6 +707,187 @@ export type TriadProtocol = {
|
|
|
707
707
|
];
|
|
708
708
|
args: [];
|
|
709
709
|
},
|
|
710
|
+
{
|
|
711
|
+
name: 'closeIdleMarket';
|
|
712
|
+
discriminator: [249, 217, 214, 137, 20, 38, 112, 154];
|
|
713
|
+
accounts: [
|
|
714
|
+
{
|
|
715
|
+
name: 'signer';
|
|
716
|
+
writable: true;
|
|
717
|
+
signer: true;
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
name: 'squads';
|
|
721
|
+
writable: true;
|
|
722
|
+
address: 'Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4';
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
name: 'market';
|
|
726
|
+
writable: true;
|
|
727
|
+
pda: {
|
|
728
|
+
seeds: [
|
|
729
|
+
{
|
|
730
|
+
kind: 'const';
|
|
731
|
+
value: [109, 97, 114, 107, 101, 116];
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
kind: 'arg';
|
|
735
|
+
path: 'marketId';
|
|
736
|
+
}
|
|
737
|
+
];
|
|
738
|
+
};
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
name: 'mint';
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: 'marketToAta';
|
|
745
|
+
writable: true;
|
|
746
|
+
pda: {
|
|
747
|
+
seeds: [
|
|
748
|
+
{
|
|
749
|
+
kind: 'account';
|
|
750
|
+
path: 'market';
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
kind: 'account';
|
|
754
|
+
path: 'tokenProgram';
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
kind: 'account';
|
|
758
|
+
path: 'mint';
|
|
759
|
+
}
|
|
760
|
+
];
|
|
761
|
+
program: {
|
|
762
|
+
kind: 'const';
|
|
763
|
+
value: [
|
|
764
|
+
140,
|
|
765
|
+
151,
|
|
766
|
+
37,
|
|
767
|
+
143,
|
|
768
|
+
78,
|
|
769
|
+
36,
|
|
770
|
+
137,
|
|
771
|
+
241,
|
|
772
|
+
187,
|
|
773
|
+
61,
|
|
774
|
+
16,
|
|
775
|
+
41,
|
|
776
|
+
20,
|
|
777
|
+
142,
|
|
778
|
+
13,
|
|
779
|
+
131,
|
|
780
|
+
11,
|
|
781
|
+
90,
|
|
782
|
+
19,
|
|
783
|
+
153,
|
|
784
|
+
218,
|
|
785
|
+
255,
|
|
786
|
+
16,
|
|
787
|
+
132,
|
|
788
|
+
4,
|
|
789
|
+
142,
|
|
790
|
+
123,
|
|
791
|
+
216,
|
|
792
|
+
219,
|
|
793
|
+
233,
|
|
794
|
+
248,
|
|
795
|
+
89
|
|
796
|
+
];
|
|
797
|
+
};
|
|
798
|
+
};
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
name: 'squadsAta';
|
|
802
|
+
writable: true;
|
|
803
|
+
pda: {
|
|
804
|
+
seeds: [
|
|
805
|
+
{
|
|
806
|
+
kind: 'account';
|
|
807
|
+
path: 'squads';
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
kind: 'account';
|
|
811
|
+
path: 'tokenProgram';
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
kind: 'account';
|
|
815
|
+
path: 'mint';
|
|
816
|
+
}
|
|
817
|
+
];
|
|
818
|
+
program: {
|
|
819
|
+
kind: 'const';
|
|
820
|
+
value: [
|
|
821
|
+
140,
|
|
822
|
+
151,
|
|
823
|
+
37,
|
|
824
|
+
143,
|
|
825
|
+
78,
|
|
826
|
+
36,
|
|
827
|
+
137,
|
|
828
|
+
241,
|
|
829
|
+
187,
|
|
830
|
+
61,
|
|
831
|
+
16,
|
|
832
|
+
41,
|
|
833
|
+
20,
|
|
834
|
+
142,
|
|
835
|
+
13,
|
|
836
|
+
131,
|
|
837
|
+
11,
|
|
838
|
+
90,
|
|
839
|
+
19,
|
|
840
|
+
153,
|
|
841
|
+
218,
|
|
842
|
+
255,
|
|
843
|
+
16,
|
|
844
|
+
132,
|
|
845
|
+
4,
|
|
846
|
+
142,
|
|
847
|
+
123,
|
|
848
|
+
216,
|
|
849
|
+
219,
|
|
850
|
+
233,
|
|
851
|
+
248,
|
|
852
|
+
89
|
|
853
|
+
];
|
|
854
|
+
};
|
|
855
|
+
};
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
name: 'orderBook';
|
|
859
|
+
pda: {
|
|
860
|
+
seeds: [
|
|
861
|
+
{
|
|
862
|
+
kind: 'const';
|
|
863
|
+
value: [111, 114, 100, 101, 114, 95, 98, 111, 111, 107];
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
kind: 'arg';
|
|
867
|
+
path: 'marketId';
|
|
868
|
+
}
|
|
869
|
+
];
|
|
870
|
+
};
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
name: 'tokenProgram';
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
name: 'associatedTokenProgram';
|
|
877
|
+
address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
name: 'systemProgram';
|
|
881
|
+
address: '11111111111111111111111111111111';
|
|
882
|
+
}
|
|
883
|
+
];
|
|
884
|
+
args: [
|
|
885
|
+
{
|
|
886
|
+
name: 'marketId';
|
|
887
|
+
type: 'u64';
|
|
888
|
+
}
|
|
889
|
+
];
|
|
890
|
+
},
|
|
710
891
|
{
|
|
711
892
|
name: 'closeOrderBook';
|
|
712
893
|
discriminator: [219, 134, 73, 219, 180, 7, 94, 206];
|
|
@@ -1670,6 +1851,10 @@ export type TriadProtocol = {
|
|
|
1670
1851
|
name: 'orderBook';
|
|
1671
1852
|
writable: true;
|
|
1672
1853
|
},
|
|
1854
|
+
{
|
|
1855
|
+
name: 'customer';
|
|
1856
|
+
writable: true;
|
|
1857
|
+
},
|
|
1673
1858
|
{
|
|
1674
1859
|
name: 'askOrder';
|
|
1675
1860
|
writable: true;
|
|
@@ -1794,6 +1979,10 @@ export type TriadProtocol = {
|
|
|
1794
1979
|
name: 'orderBook';
|
|
1795
1980
|
writable: true;
|
|
1796
1981
|
},
|
|
1982
|
+
{
|
|
1983
|
+
name: 'customer';
|
|
1984
|
+
writable: true;
|
|
1985
|
+
},
|
|
1797
1986
|
{
|
|
1798
1987
|
name: 'order';
|
|
1799
1988
|
writable: true;
|
|
@@ -2862,6 +3051,48 @@ export type TriadProtocol = {
|
|
|
2862
3051
|
];
|
|
2863
3052
|
args: [];
|
|
2864
3053
|
},
|
|
3054
|
+
{
|
|
3055
|
+
name: 'updateCustomer';
|
|
3056
|
+
discriminator: [158, 118, 103, 177, 241, 229, 169, 124];
|
|
3057
|
+
accounts: [
|
|
3058
|
+
{
|
|
3059
|
+
name: 'signer';
|
|
3060
|
+
writable: true;
|
|
3061
|
+
signer: true;
|
|
3062
|
+
},
|
|
3063
|
+
{
|
|
3064
|
+
name: 'customer';
|
|
3065
|
+
writable: true;
|
|
3066
|
+
pda: {
|
|
3067
|
+
seeds: [
|
|
3068
|
+
{
|
|
3069
|
+
kind: 'const';
|
|
3070
|
+
value: [99, 117, 115, 116, 111, 109, 101, 114];
|
|
3071
|
+
},
|
|
3072
|
+
{
|
|
3073
|
+
kind: 'account';
|
|
3074
|
+
path: 'customer.id';
|
|
3075
|
+
account: 'customer';
|
|
3076
|
+
}
|
|
3077
|
+
];
|
|
3078
|
+
};
|
|
3079
|
+
},
|
|
3080
|
+
{
|
|
3081
|
+
name: 'systemProgram';
|
|
3082
|
+
address: '11111111111111111111111111111111';
|
|
3083
|
+
}
|
|
3084
|
+
];
|
|
3085
|
+
args: [
|
|
3086
|
+
{
|
|
3087
|
+
name: 'args';
|
|
3088
|
+
type: {
|
|
3089
|
+
defined: {
|
|
3090
|
+
name: 'updateCustomerArgs';
|
|
3091
|
+
};
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
3094
|
+
];
|
|
3095
|
+
},
|
|
2865
3096
|
{
|
|
2866
3097
|
name: 'updateMarketEnd';
|
|
2867
3098
|
discriminator: [10, 188, 22, 219, 206, 83, 67, 31];
|
|
@@ -3537,6 +3768,16 @@ export type TriadProtocol = {
|
|
|
3537
3768
|
code: 6027;
|
|
3538
3769
|
name: 'invalidQuestion';
|
|
3539
3770
|
msg: 'Invalid Question';
|
|
3771
|
+
},
|
|
3772
|
+
{
|
|
3773
|
+
code: 6028;
|
|
3774
|
+
name: 'marketNotIdle';
|
|
3775
|
+
msg: 'Market Not Idle';
|
|
3776
|
+
},
|
|
3777
|
+
{
|
|
3778
|
+
code: 6029;
|
|
3779
|
+
name: 'orderBookStillExists';
|
|
3780
|
+
msg: 'Order Book still exists';
|
|
3540
3781
|
}
|
|
3541
3782
|
];
|
|
3542
3783
|
types: [
|
|
@@ -3944,6 +4185,14 @@ export type TriadProtocol = {
|
|
|
3944
4185
|
{
|
|
3945
4186
|
name: 'feeBps';
|
|
3946
4187
|
type: 'u16';
|
|
4188
|
+
},
|
|
4189
|
+
{
|
|
4190
|
+
name: 'marketFeeBps';
|
|
4191
|
+
type: 'u16';
|
|
4192
|
+
},
|
|
4193
|
+
{
|
|
4194
|
+
name: 'payoutFeeBps';
|
|
4195
|
+
type: 'u16';
|
|
3947
4196
|
}
|
|
3948
4197
|
];
|
|
3949
4198
|
};
|
|
@@ -4085,10 +4334,18 @@ export type TriadProtocol = {
|
|
|
4085
4334
|
name: 'isVerified';
|
|
4086
4335
|
type: 'bool';
|
|
4087
4336
|
},
|
|
4337
|
+
{
|
|
4338
|
+
name: 'marketFeeBps';
|
|
4339
|
+
type: 'u16';
|
|
4340
|
+
},
|
|
4341
|
+
{
|
|
4342
|
+
name: 'payoutFeeBps';
|
|
4343
|
+
type: 'u16';
|
|
4344
|
+
},
|
|
4088
4345
|
{
|
|
4089
4346
|
name: 'padding';
|
|
4090
4347
|
type: {
|
|
4091
|
-
array: ['u8',
|
|
4348
|
+
array: ['u8', 25];
|
|
4092
4349
|
};
|
|
4093
4350
|
}
|
|
4094
4351
|
];
|
|
@@ -5263,6 +5520,26 @@ export type TriadProtocol = {
|
|
|
5263
5520
|
];
|
|
5264
5521
|
};
|
|
5265
5522
|
},
|
|
5523
|
+
{
|
|
5524
|
+
name: 'updateCustomerArgs';
|
|
5525
|
+
type: {
|
|
5526
|
+
kind: 'struct';
|
|
5527
|
+
fields: [
|
|
5528
|
+
{
|
|
5529
|
+
name: 'marketFeeBps';
|
|
5530
|
+
type: {
|
|
5531
|
+
option: 'u16';
|
|
5532
|
+
};
|
|
5533
|
+
},
|
|
5534
|
+
{
|
|
5535
|
+
name: 'payoutFeeBps';
|
|
5536
|
+
type: {
|
|
5537
|
+
option: 'u16';
|
|
5538
|
+
};
|
|
5539
|
+
}
|
|
5540
|
+
];
|
|
5541
|
+
};
|
|
5542
|
+
},
|
|
5266
5543
|
{
|
|
5267
5544
|
name: 'verificationLevel';
|
|
5268
5545
|
docs: [
|
|
@@ -2,32 +2,42 @@
|
|
|
2
2
|
* Calculate dynamic fee based on price
|
|
3
3
|
* Returns fee in basis points (bps)
|
|
4
4
|
*/
|
|
5
|
-
export declare function calculateDynamicFeeBps(price: number, feeBps: number): number;
|
|
5
|
+
export declare function calculateDynamicFeeBps(price: number, feeBps: number, customerMarketFeeBps: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Calculate tiered fixed fee based on entry amount (USDC)
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculateFixedFee(amount: number): number;
|
|
6
10
|
/**
|
|
7
11
|
* Apply dynamic fee to price for buy orders (adds fee)
|
|
8
12
|
*/
|
|
9
|
-
export declare function applyBuyFee(price: number, feeBps: number): number;
|
|
13
|
+
export declare function applyBuyFee(price: number, feeBps: number, customerMarketFeeBps: number): number;
|
|
10
14
|
/**
|
|
11
15
|
* Apply dynamic fee to price for sell orders (subtracts fee)
|
|
12
16
|
*/
|
|
13
|
-
export declare function applySellFee(price: number, feeBps: number): number;
|
|
17
|
+
export declare function applySellFee(price: number, feeBps: number, customerMarketFeeBps: number): number;
|
|
14
18
|
/**
|
|
15
19
|
* Simulate a buy order with given amount and price
|
|
16
20
|
*/
|
|
17
|
-
export declare function simulateBuyOrder(amount: number, price: number, feeBps: number): {
|
|
21
|
+
export declare function simulateBuyOrder(amount: number, price: number, feeBps: number, customerMarketFeeBps: number): {
|
|
18
22
|
entryPrice: number;
|
|
19
23
|
effectivePrice: number;
|
|
20
24
|
sharesReceived: number;
|
|
21
25
|
feeAmount: number;
|
|
22
26
|
feePercentage: number;
|
|
27
|
+
fixedFee: number;
|
|
28
|
+
volumeFee: number;
|
|
29
|
+
realEntryPrice: number;
|
|
23
30
|
};
|
|
24
31
|
/**
|
|
25
32
|
* Simulate a sell order with given shares and price
|
|
26
33
|
*/
|
|
27
|
-
export declare function simulateSellOrder(shares: number, price: number, feeBps: number): {
|
|
34
|
+
export declare function simulateSellOrder(shares: number, price: number, feeBps: number, customerMarketFeeBps: number): {
|
|
28
35
|
entryPrice: number;
|
|
29
36
|
effectivePrice: number;
|
|
30
37
|
sharesReceived: number;
|
|
31
38
|
feeAmount: number;
|
|
32
39
|
feePercentage: number;
|
|
40
|
+
fixedFee: number;
|
|
41
|
+
volumeFee: number;
|
|
42
|
+
realEntryPrice: number;
|
|
33
43
|
};
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.simulateSellOrder = exports.simulateBuyOrder = exports.applySellFee = exports.applyBuyFee = exports.calculateDynamicFeeBps = void 0;
|
|
3
|
+
exports.simulateSellOrder = exports.simulateBuyOrder = exports.applySellFee = exports.applyBuyFee = exports.calculateFixedFee = exports.calculateDynamicFeeBps = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Calculate dynamic fee based on price
|
|
6
6
|
* Returns fee in basis points (bps)
|
|
7
7
|
*/
|
|
8
|
-
function calculateDynamicFeeBps(price, feeBps) {
|
|
8
|
+
function calculateDynamicFeeBps(price, feeBps, customerMarketFeeBps) {
|
|
9
9
|
const internalPrice = price * Math.pow(10, 6);
|
|
10
10
|
if (internalPrice < 900000) {
|
|
11
|
-
return feeBps;
|
|
11
|
+
return feeBps + customerMarketFeeBps;
|
|
12
12
|
}
|
|
13
|
-
return Math.floor(((990000 - internalPrice) * 1900) /
|
|
13
|
+
return Math.max(Math.floor(((990000 - internalPrice) * 1900) / internalPrice), 90);
|
|
14
14
|
}
|
|
15
15
|
exports.calculateDynamicFeeBps = calculateDynamicFeeBps;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate tiered fixed fee based on entry amount (USDC)
|
|
18
|
+
*/
|
|
19
|
+
function calculateFixedFee(amount) {
|
|
20
|
+
const internalAmount = Math.floor(amount * 1000000);
|
|
21
|
+
if (internalAmount >= 100000000) {
|
|
22
|
+
return 2.5;
|
|
23
|
+
}
|
|
24
|
+
else if (internalAmount >= 50000000) {
|
|
25
|
+
return 1.5;
|
|
26
|
+
}
|
|
27
|
+
else if (internalAmount >= 20000000) {
|
|
28
|
+
return 0.75;
|
|
29
|
+
}
|
|
30
|
+
else if (internalAmount >= 5000000) {
|
|
31
|
+
return 0.3;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return 0.15;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.calculateFixedFee = calculateFixedFee;
|
|
16
38
|
/**
|
|
17
39
|
* Apply dynamic fee to price for buy orders (adds fee)
|
|
18
40
|
*/
|
|
19
|
-
function applyBuyFee(price, feeBps) {
|
|
20
|
-
const dynamicFeeBps = calculateDynamicFeeBps(price, feeBps);
|
|
41
|
+
function applyBuyFee(price, feeBps, customerMarketFeeBps) {
|
|
42
|
+
const dynamicFeeBps = calculateDynamicFeeBps(price, feeBps, customerMarketFeeBps);
|
|
21
43
|
const internalPrice = Math.floor(price * 1000000);
|
|
22
44
|
const effectiveInternalPrice = Math.floor((internalPrice * (10000 + dynamicFeeBps)) / 10000);
|
|
23
45
|
const clampedPrice = Math.min(effectiveInternalPrice, 999999);
|
|
@@ -27,8 +49,8 @@ exports.applyBuyFee = applyBuyFee;
|
|
|
27
49
|
/**
|
|
28
50
|
* Apply dynamic fee to price for sell orders (subtracts fee)
|
|
29
51
|
*/
|
|
30
|
-
function applySellFee(price, feeBps) {
|
|
31
|
-
const dynamicFeeBps = calculateDynamicFeeBps(price, feeBps);
|
|
52
|
+
function applySellFee(price, feeBps, customerMarketFeeBps) {
|
|
53
|
+
const dynamicFeeBps = calculateDynamicFeeBps(price, feeBps, customerMarketFeeBps);
|
|
32
54
|
const internalPrice = Math.floor(price * 1000000);
|
|
33
55
|
const effectiveInternalPrice = Math.floor((internalPrice * (10000 - dynamicFeeBps)) / 10000);
|
|
34
56
|
const clampedPrice = Math.max(effectiveInternalPrice, 1);
|
|
@@ -38,36 +60,44 @@ exports.applySellFee = applySellFee;
|
|
|
38
60
|
/**
|
|
39
61
|
* Simulate a buy order with given amount and price
|
|
40
62
|
*/
|
|
41
|
-
function simulateBuyOrder(amount, price, feeBps) {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
63
|
+
function simulateBuyOrder(amount, price, feeBps, customerMarketFeeBps) {
|
|
64
|
+
const fixedFee = calculateFixedFee(amount);
|
|
65
|
+
const amountAfterFixedFee = amount - fixedFee;
|
|
66
|
+
const effectivePrice = applyBuyFee(price, feeBps, customerMarketFeeBps);
|
|
67
|
+
const sharesReceived = amountAfterFixedFee / effectivePrice;
|
|
44
68
|
const valueAtOriginalPrice = sharesReceived * price;
|
|
45
69
|
const feeAmount = amount - valueAtOriginalPrice;
|
|
46
|
-
const feePercentage = (feeAmount / amount) * 100;
|
|
47
70
|
return {
|
|
48
71
|
entryPrice: price,
|
|
49
72
|
effectivePrice,
|
|
50
73
|
sharesReceived,
|
|
51
74
|
feeAmount,
|
|
52
|
-
feePercentage
|
|
75
|
+
feePercentage: (feeAmount / amount) * 100,
|
|
76
|
+
fixedFee,
|
|
77
|
+
volumeFee: feeAmount - fixedFee,
|
|
78
|
+
realEntryPrice: amount / sharesReceived
|
|
53
79
|
};
|
|
54
80
|
}
|
|
55
81
|
exports.simulateBuyOrder = simulateBuyOrder;
|
|
56
82
|
/**
|
|
57
83
|
* Simulate a sell order with given shares and price
|
|
58
84
|
*/
|
|
59
|
-
function simulateSellOrder(shares, price, feeBps) {
|
|
60
|
-
const effectivePrice = applySellFee(price, feeBps);
|
|
61
|
-
const
|
|
85
|
+
function simulateSellOrder(shares, price, feeBps, customerMarketFeeBps) {
|
|
86
|
+
const effectivePrice = applySellFee(price, feeBps, customerMarketFeeBps);
|
|
87
|
+
const amountToReceiveBeforeFixed = shares * effectivePrice;
|
|
62
88
|
const valueAtOriginalPrice = shares * price;
|
|
89
|
+
const fixedFee = calculateFixedFee(valueAtOriginalPrice);
|
|
90
|
+
const amountReceived = amountToReceiveBeforeFixed - fixedFee;
|
|
63
91
|
const feeAmount = valueAtOriginalPrice - amountReceived;
|
|
64
|
-
const feePercentage = (feeAmount / valueAtOriginalPrice) * 100;
|
|
65
92
|
return {
|
|
66
93
|
entryPrice: price,
|
|
67
94
|
effectivePrice,
|
|
68
95
|
sharesReceived: shares,
|
|
69
96
|
feeAmount,
|
|
70
|
-
feePercentage
|
|
97
|
+
feePercentage: (feeAmount / valueAtOriginalPrice) * 100,
|
|
98
|
+
fixedFee,
|
|
99
|
+
volumeFee: feeAmount - fixedFee,
|
|
100
|
+
realEntryPrice: amountReceived / shares
|
|
71
101
|
};
|
|
72
102
|
}
|
|
73
103
|
exports.simulateSellOrder = simulateSellOrder;
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
-
import { BN, IdlAccounts } from '@coral-xyz/anchor';
|
|
2
|
+
import { BN, IdlAccounts, Program } from '@coral-xyz/anchor';
|
|
3
3
|
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, OrderDirectionEncoded, OrderTypeEncoded, OrderSideEncoded, OrderStatusEncoded, Pool, BookOrder } from '../types';
|
|
4
4
|
import { Stake, StakeVault, Unstake } from '../types/stake';
|
|
5
5
|
import { Customer } from '../types/customer';
|
|
@@ -29,3 +29,4 @@ export declare const getOppositeOrderDirectionEncoded: (orderDirection: OrderDir
|
|
|
29
29
|
export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey, balance: BN) => Predictor;
|
|
30
30
|
export declare const getPriceFeedAccountForProgram: (priceFeedId: string) => PublicKey;
|
|
31
31
|
export declare const getFeedIdFromHex: (input?: string) => PublicKey | null;
|
|
32
|
+
export declare const getCustomerById: (program: Program<TriadProtocol>, customerId: number) => Promise<Customer>;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFeedIdFromHex = exports.getPriceFeedAccountForProgram = exports.formatPredictor = exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatCustomer = exports.formatBookOrder = exports.formatOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
12
|
+
exports.getCustomerById = exports.getFeedIdFromHex = exports.getPriceFeedAccountForProgram = exports.formatPredictor = exports.getOppositeOrderDirectionEncoded = exports.getOppositeOrderDirection = exports.getOrderDirectionEncoded = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatCustomer = exports.formatBookOrder = exports.formatOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
14
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
15
|
const types_1 = require("../types");
|
|
16
|
+
const pda_1 = require("./pda");
|
|
7
17
|
const constants_1 = require("./constants");
|
|
8
18
|
const encodeString = (value, alloc = 32) => {
|
|
9
19
|
const buffer = Buffer.alloc(alloc, 32);
|
|
@@ -145,6 +155,8 @@ const formatCustomer = (account, publicKey) => {
|
|
|
145
155
|
name: account.name,
|
|
146
156
|
feeRecipient: account.feeRecipient.toString(),
|
|
147
157
|
feeBps: account.feeBps,
|
|
158
|
+
marketFeeBps: account.marketFeeBps,
|
|
159
|
+
payoutFeeBps: account.payoutFeeBps,
|
|
148
160
|
isVerified: account.isVerified,
|
|
149
161
|
address: publicKey.toString()
|
|
150
162
|
};
|
|
@@ -289,3 +301,9 @@ const getFeedIdFromHex = (input) => {
|
|
|
289
301
|
return new web3_js_1.PublicKey(feedId);
|
|
290
302
|
};
|
|
291
303
|
exports.getFeedIdFromHex = getFeedIdFromHex;
|
|
304
|
+
const getCustomerById = (program, customerId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
305
|
+
const customerPDA = (0, pda_1.getCustomerPDA)(program.programId, customerId);
|
|
306
|
+
const customer = yield program.account.customer.fetch(customerPDA, program.provider.connection.commitment);
|
|
307
|
+
return (0, exports.formatCustomer)(customer, customerPDA);
|
|
308
|
+
});
|
|
309
|
+
exports.getCustomerById = getCustomerById;
|