@triadxyz/triad-protocol 4.1.0 → 4.1.1
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/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PRICE_FEED = exports.BOOK_ORDER_NULL = exports.BASE_DECIMALS = exports.POSEIDON_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.TRIAD_ADMIN = exports.UNIT_MINT = exports.TRD_MINT = exports.USDC_MINT = void 0;
|
|
3
|
+
exports.DEFAULT_PUSH_ORACLE_PROGRAM_ID = exports.PRICE_FEED = exports.BOOK_ORDER_NULL = exports.BASE_DECIMALS = exports.POSEIDON_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.TRIAD_ADMIN = exports.UNIT_MINT = exports.TRD_MINT = exports.USDC_MINT = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
exports.USDC_MINT = new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
|
|
6
6
|
exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
|
|
@@ -15,3 +15,4 @@ exports.PRICE_FEED = {
|
|
|
15
15
|
SOL: '0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d',
|
|
16
16
|
ETH: '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace'
|
|
17
17
|
};
|
|
18
|
+
exports.DEFAULT_PUSH_ORACLE_PROGRAM_ID = new web3_js_1.PublicKey('pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT');
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export declare const getOrderDirectionEncoded: (orderDirection: OrderDirection)
|
|
|
27
27
|
export declare const getOppositeOrderDirection: (orderDirection: OrderDirection) => OrderDirection;
|
|
28
28
|
export declare const getOppositeOrderDirectionEncoded: (orderDirection: OrderDirectionEncoded) => OrderDirectionEncoded;
|
|
29
29
|
export declare const formatPredictor: (account: IdlAccounts<TriadProtocol>['predictor'], publicKey: PublicKey, balance: BN) => Predictor;
|
|
30
|
+
export declare const getPriceFeedAccountForProgram: (priceFeedId: string) => PublicKey;
|
|
30
31
|
export declare const getFeedIdFromHex: (input?: string) => PublicKey | null;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFeedIdFromHex = 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;
|
|
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;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
6
|
const types_1 = require("../types");
|
|
@@ -258,6 +258,21 @@ const formatPredictor = (account, publicKey, balance) => {
|
|
|
258
258
|
};
|
|
259
259
|
};
|
|
260
260
|
exports.formatPredictor = formatPredictor;
|
|
261
|
+
const getPriceFeedAccountForProgram = (priceFeedId) => {
|
|
262
|
+
let buffer = null;
|
|
263
|
+
if (typeof priceFeedId == 'string') {
|
|
264
|
+
buffer = priceFeedId.startsWith('0x')
|
|
265
|
+
? Buffer.from(priceFeedId.slice(2), 'hex')
|
|
266
|
+
: Buffer.from(priceFeedId, 'hex');
|
|
267
|
+
}
|
|
268
|
+
if (buffer.length != 32) {
|
|
269
|
+
throw new Error('Feed ID should be 32 bytes long');
|
|
270
|
+
}
|
|
271
|
+
const shardBuffer = Buffer.alloc(2);
|
|
272
|
+
shardBuffer.writeUint16LE(0, 0);
|
|
273
|
+
return web3_js_1.PublicKey.findProgramAddressSync([shardBuffer, buffer], constants_1.DEFAULT_PUSH_ORACLE_PROGRAM_ID)[0];
|
|
274
|
+
};
|
|
275
|
+
exports.getPriceFeedAccountForProgram = getPriceFeedAccountForProgram;
|
|
261
276
|
const getFeedIdFromHex = (input) => {
|
|
262
277
|
let feedId = new Uint8Array(32);
|
|
263
278
|
if (!input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triadxyz/triad-protocol",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@coral-xyz/anchor": "0.31.1",
|
|
36
|
-
"@pythnetwork/pyth-solana-receiver": "0.14.0",
|
|
37
36
|
"@solana/spl-token": "0.4.14",
|
|
38
37
|
"@solana/web3.js": "1.98.4",
|
|
39
38
|
"axios": "1.13.6",
|