@triadxyz/triad-protocol 4.2.0 → 4.2.2
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/index.d.ts +5 -188
- package/dist/index.js +9 -630
- package/dist/market.d.ts +163 -0
- package/dist/market.js +571 -0
- package/dist/poseidon.d.ts +2 -4
- package/dist/poseidon.js +10 -16
- package/dist/predictor.d.ts +32 -1
- package/dist/predictor.js +99 -15
- package/dist/stake.d.ts +0 -15
- package/dist/stake.js +0 -60
- package/dist/trade.d.ts +7 -6
- package/dist/trade.js +44 -54
- package/dist/types/idl_triad_protocol.json +511 -900
- package/dist/types/index.d.ts +3 -8
- package/dist/types/predictor.d.ts +6 -0
- package/dist/types/trade.d.ts +7 -2
- package/dist/types/triad_protocol.d.ts +619 -1388
- package/dist/utils/helpers.d.ts +4 -4
- package/dist/utils/helpers.js +10 -13
- package/dist/utils/sendVersionedTransaction.js +3 -11
- package/package.json +1 -1
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
-
import {
|
|
3
|
-
import { Market,
|
|
2
|
+
import { IdlAccounts, Program } from '@coral-xyz/anchor';
|
|
3
|
+
import { Market, PredictorOrder, 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';
|
|
6
6
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
@@ -12,7 +12,7 @@ export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV3'],
|
|
|
12
12
|
export declare const formatUnstake: (unstake: IdlAccounts<TriadProtocol>['unstake'], address: PublicKey) => Unstake;
|
|
13
13
|
export declare const formatPool: (account: IdlAccounts<TriadProtocol>['pool'], address: PublicKey) => Pool;
|
|
14
14
|
export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const formatPredictorOrder: (order: IdlAccounts<TriadProtocol>['predictorOrder'], address: PublicKey) => PredictorOrder;
|
|
16
16
|
export declare const formatBookOrder: (order: IdlAccounts<TriadProtocol>['orderBook']['hypeOrders'][number] | IdlAccounts<TriadProtocol>['orderBook']['flopOrders'][number], marketId: number) => BookOrder;
|
|
17
17
|
export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
|
|
18
18
|
export declare const calculateStakeRewards: (stake: Stake) => number;
|
|
@@ -26,7 +26,7 @@ export declare const getOrderStatus: (status: OrderStatusEncoded) => OrderStatus
|
|
|
26
26
|
export declare const getOrderDirectionEncoded: (orderDirection: OrderDirection) => OrderDirectionEncoded;
|
|
27
27
|
export declare const getOppositeOrderDirection: (orderDirection: OrderDirection) => OrderDirection;
|
|
28
28
|
export declare const getOppositeOrderDirectionEncoded: (orderDirection: OrderDirectionEncoded) => OrderDirectionEncoded;
|
|
29
|
-
export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey
|
|
29
|
+
export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey) => Predictor;
|
|
30
30
|
export declare const getPriceFeedAccountForProgram: (priceFeedId: string) => PublicKey;
|
|
31
31
|
export declare const getFeedIdFromHex: (input?: string) => PublicKey | null;
|
|
32
32
|
export declare const getCustomerById: (program: Program<TriadProtocol>, customerId: number) => Promise<Customer>;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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.
|
|
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.formatPredictorOrder = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const spl_token_1 = require("@solana/spl-token");
|
|
15
15
|
const types_1 = require("../types");
|
|
@@ -103,10 +103,7 @@ const formatMarket = (account, address) => {
|
|
|
103
103
|
marketStart: account.marketStart.toString(),
|
|
104
104
|
marketEnd: account.marketEnd.toString(),
|
|
105
105
|
question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
|
|
106
|
-
|
|
107
|
-
payoutFeeClaimed: account.payoutFeeClaimed.toString(),
|
|
108
|
-
marketFeeAvailable: account.marketFeeAvailable.toString(),
|
|
109
|
-
marketFeeClaimed: account.marketFeeClaimed.toString(),
|
|
106
|
+
feeGenerated: account.feeGenerated.toString(),
|
|
110
107
|
winningDirection: types_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()],
|
|
111
108
|
marketLiquidityAtStart: account.marketLiquidityAtStart.toNumber() > 0
|
|
112
109
|
? account.marketLiquidityAtStart.toString()
|
|
@@ -119,20 +116,18 @@ const formatMarket = (account, address) => {
|
|
|
119
116
|
};
|
|
120
117
|
};
|
|
121
118
|
exports.formatMarket = formatMarket;
|
|
122
|
-
const
|
|
119
|
+
const formatPredictorOrder = (order, address) => {
|
|
123
120
|
return {
|
|
124
121
|
address: address.toString(),
|
|
125
|
-
|
|
122
|
+
predictor: order.predictor.toString(),
|
|
126
123
|
marketId: order.marketId.toString(),
|
|
127
124
|
orderStatus: (0, exports.getOrderStatus)(order.orderStatus),
|
|
128
|
-
orderType: (0, exports.getOrderType)(order.orderType),
|
|
129
125
|
orderDirection: (0, exports.getOrderDirection)(order.orderDirection),
|
|
130
|
-
orderSide: (0, exports.getOrderSide)(order.orderSide),
|
|
131
126
|
price: order.price.toString(),
|
|
132
127
|
shares: order.shares.toString()
|
|
133
128
|
};
|
|
134
129
|
};
|
|
135
|
-
exports.
|
|
130
|
+
exports.formatPredictorOrder = formatPredictorOrder;
|
|
136
131
|
const formatBookOrder = (order, marketId) => {
|
|
137
132
|
return {
|
|
138
133
|
id: order.id.toString(),
|
|
@@ -262,13 +257,15 @@ const getOppositeOrderDirectionEncoded = (orderDirection) => {
|
|
|
262
257
|
return { hype: {} };
|
|
263
258
|
};
|
|
264
259
|
exports.getOppositeOrderDirectionEncoded = getOppositeOrderDirectionEncoded;
|
|
265
|
-
const formatPredictor = (account, publicKey
|
|
260
|
+
const formatPredictor = (account, publicKey) => {
|
|
266
261
|
return {
|
|
267
262
|
address: publicKey.toBase58(),
|
|
268
|
-
authority:
|
|
263
|
+
authority: account.authority.toString(),
|
|
269
264
|
refer: account.refer.toString(),
|
|
270
265
|
customerId: account.customerId,
|
|
271
|
-
balance: balance.toNumber() / 1e6
|
|
266
|
+
balance: account.balance.toNumber() / 1e6,
|
|
267
|
+
rewardsAvailable: account.rewardsAvailable.toNumber() / 1e6,
|
|
268
|
+
rewardsClaimed: account.rewardsClaimed.toNumber() / 1e6
|
|
272
269
|
};
|
|
273
270
|
};
|
|
274
271
|
exports.formatPredictor = formatPredictor;
|
|
@@ -8,12 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const web3_js_1 = require("@solana/web3.js");
|
|
16
|
-
const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
|
|
17
13
|
const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
14
|
var _a;
|
|
19
15
|
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
@@ -21,13 +17,9 @@ const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccou
|
|
|
21
17
|
microLamports: options.microLamports
|
|
22
18
|
}));
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
microLamports: priorityFee
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
const { blockhash } = yield program.provider.connection.getLatestBlockhash();
|
|
20
|
+
const { blockhash } = yield program.provider.connection.getLatestBlockhash({
|
|
21
|
+
commitment: 'confirmed'
|
|
22
|
+
});
|
|
31
23
|
if (program.provider.publicKey.toBase58() !== ((_a = options === null || options === void 0 ? void 0 : options.payer) === null || _a === void 0 ? void 0 : _a.toBase58())) {
|
|
32
24
|
return new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
33
25
|
instructions: ixs,
|