@evaafi/sdk 0.6.3-b → 0.6.4-a
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/api/math.js +1 -1
- package/dist/api/prices.js +0 -1
- package/dist/constants/assets.d.ts +5 -0
- package/dist/constants/assets.js +21 -1
- package/dist/constants/general.d.ts +2 -0
- package/dist/constants/general.js +3 -1
- package/dist/constants/pools.d.ts +2 -0
- package/dist/constants/pools.js +23 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +4 -45
- package/dist/prices/PricesCollector.js +9 -2
- package/dist/prices/Types.d.ts +0 -2
- package/dist/prices/Types.js +1 -2
- package/dist/prices/sources/index.d.ts +0 -1
- package/dist/prices/sources/index.js +0 -1
- package/dist/prices/utils.js +1 -2
- package/dist/utils/userJettonWallet.js +6 -0
- package/package.json +1 -1
- package/src/api/math.ts +1 -1
- package/src/api/prices.ts +0 -1
- package/src/constants/assets.ts +39 -0
- package/src/constants/general.ts +2 -0
- package/src/constants/pools.ts +29 -2
- package/src/index.ts +2 -47
- package/src/prices/PricesCollector.ts +9 -2
- package/src/prices/Types.ts +1 -5
- package/src/prices/sources/index.ts +0 -1
- package/src/prices/utils.ts +5 -6
- package/src/utils/userJettonWallet.ts +6 -0
- package/CHANGELOG.md +0 -280
- package/dist/prices/sources/Iota.d.ts +0 -39
- package/dist/prices/sources/Iota.js +0 -49
- package/src/prices/sources/Iota.ts +0 -90
package/dist/api/math.js
CHANGED
|
@@ -263,7 +263,7 @@ function calculateHealthParams(parameters) {
|
|
|
263
263
|
totalSupply += assetWorth;
|
|
264
264
|
totalLimit += assetWorth * assetConfig.liquidationThreshold / ASSET_LIQUIDATION_THRESHOLD_SCALE;
|
|
265
265
|
}
|
|
266
|
-
else if (assetBalance.type === User_1.BalanceType.borrow) {
|
|
266
|
+
else if (assetBalance.type === User_1.BalanceType.borrow && assetConfig.dust < assetBalance.amount) {
|
|
267
267
|
totalDebt += assetWorth;
|
|
268
268
|
}
|
|
269
269
|
}
|
package/dist/api/prices.js
CHANGED
|
@@ -11,7 +11,6 @@ async function getPrices(endpoints = ["api.stardust-mainnet.iotaledger.net"], po
|
|
|
11
11
|
throw new Error("Empty endpoint list");
|
|
12
12
|
}
|
|
13
13
|
const sources = {
|
|
14
|
-
iotaEndpoints: endpoints,
|
|
15
14
|
icpEndpoints: prices_1.DefaultPriceSourcesConfig.icpEndpoints,
|
|
16
15
|
backendEndpoints: prices_1.DefaultPriceSourcesConfig.backendEndpoints,
|
|
17
16
|
};
|
|
@@ -10,6 +10,7 @@ export declare const ASSET_ID: {
|
|
|
10
10
|
tgBTC: bigint;
|
|
11
11
|
USDe: bigint;
|
|
12
12
|
tsUSDe: bigint;
|
|
13
|
+
PT_tsUSDe_01Sep2025: bigint;
|
|
13
14
|
TONUSDT_DEDUST: bigint;
|
|
14
15
|
TONUSDT_STONFI: bigint;
|
|
15
16
|
TON_STORM: bigint;
|
|
@@ -17,6 +18,7 @@ export declare const ASSET_ID: {
|
|
|
17
18
|
NOT: bigint;
|
|
18
19
|
DOGS: bigint;
|
|
19
20
|
CATI: bigint;
|
|
21
|
+
STON: bigint;
|
|
20
22
|
EUSDT: bigint;
|
|
21
23
|
};
|
|
22
24
|
export declare const UNDEFINED_ASSET: PoolAssetConfig;
|
|
@@ -41,3 +43,6 @@ export declare const TGBTC_TESTNET: PoolAssetConfig;
|
|
|
41
43
|
export declare const EUSDT_TESTNET: PoolAssetConfig;
|
|
42
44
|
export declare const USDE_MAINNET: PoolAssetConfig;
|
|
43
45
|
export declare const TSUSDE_MAINNET: PoolAssetConfig;
|
|
46
|
+
export declare const PT_tsUSDe_01Sep2025_MAINNET: PoolAssetConfig;
|
|
47
|
+
export declare const TONUSDT_STONFI_MAINNET: PoolAssetConfig;
|
|
48
|
+
export declare const STON_MAINNET: PoolAssetConfig;
|
package/dist/constants/assets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TSUSDE_MAINNET = exports.USDE_MAINNET = exports.EUSDT_TESTNET = exports.TGBTC_TESTNET = exports.UTON_MAINNET = exports.NOT_MAINNET = exports.DOGS_MAINNET = exports.CATI_MAINNET = exports.USDT_STORM_MAINNET = exports.TON_STORM_MAINNET = exports.TONUSDT_DEDUST_MAINNET = exports.STTON_TESTNET = exports.JUSDC_TESTNET = exports.JUSDT_TESTNET = exports.USDT_MAINNET = exports.TSTON_MAINNET = exports.STTON_MAINNET = exports.JUSDC_MAINNET = exports.JUSDT_MAINNET = exports.TON_TESTNET = exports.TON_MAINNET = exports.UNDEFINED_ASSET = exports.ASSET_ID = void 0;
|
|
3
|
+
exports.STON_MAINNET = exports.TONUSDT_STONFI_MAINNET = exports.PT_tsUSDe_01Sep2025_MAINNET = exports.TSUSDE_MAINNET = exports.USDE_MAINNET = exports.EUSDT_TESTNET = exports.TGBTC_TESTNET = exports.UTON_MAINNET = exports.NOT_MAINNET = exports.DOGS_MAINNET = exports.CATI_MAINNET = exports.USDT_STORM_MAINNET = exports.TON_STORM_MAINNET = exports.TONUSDT_DEDUST_MAINNET = exports.STTON_TESTNET = exports.JUSDC_TESTNET = exports.JUSDT_TESTNET = exports.USDT_MAINNET = exports.TSTON_MAINNET = exports.STTON_MAINNET = exports.JUSDC_MAINNET = exports.JUSDT_MAINNET = exports.TON_TESTNET = exports.TON_MAINNET = exports.UNDEFINED_ASSET = exports.ASSET_ID = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const sha256BigInt_1 = require("../utils/sha256BigInt");
|
|
6
6
|
const general_1 = require("./general");
|
|
@@ -15,6 +15,7 @@ exports.ASSET_ID = {
|
|
|
15
15
|
tgBTC: (0, sha256BigInt_1.sha256Hash)('tgBTC'),
|
|
16
16
|
USDe: (0, sha256BigInt_1.sha256Hash)('USDe'),
|
|
17
17
|
tsUSDe: (0, sha256BigInt_1.sha256Hash)('tsUSDe'),
|
|
18
|
+
PT_tsUSDe_01Sep2025: (0, sha256BigInt_1.sha256Hash)('PT_tsUSDe_01Sep2025'),
|
|
18
19
|
// LP
|
|
19
20
|
TONUSDT_DEDUST: (0, sha256BigInt_1.sha256Hash)('TONUSDT_DEDUST'),
|
|
20
21
|
TONUSDT_STONFI: (0, sha256BigInt_1.sha256Hash)('TONUSDT_STONFI'),
|
|
@@ -24,6 +25,7 @@ exports.ASSET_ID = {
|
|
|
24
25
|
NOT: (0, sha256BigInt_1.sha256Hash)('NOT'),
|
|
25
26
|
DOGS: (0, sha256BigInt_1.sha256Hash)('DOGS'),
|
|
26
27
|
CATI: (0, sha256BigInt_1.sha256Hash)('CATI'),
|
|
28
|
+
STON: (0, sha256BigInt_1.sha256Hash)('STON'),
|
|
27
29
|
// Testnet assets
|
|
28
30
|
EUSDT: (0, sha256BigInt_1.sha256Hash)('EUSDT'),
|
|
29
31
|
};
|
|
@@ -154,3 +156,21 @@ exports.TSUSDE_MAINNET = {
|
|
|
154
156
|
jettonMasterAddress: core_1.Address.parse('EQDQ5UUyPHrLcQJlPAczd_fjxn8SLrlNQwolBznxCdSlfQwr'),
|
|
155
157
|
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c72010219010006bf000114ff00f4a413f4bcf2c80b01020162020302f6d001d0d3030171b08ef0135f038020d721ed44d0d303fa00fa40fa40fa00d33fd106d31f01840f218210178d4519ba228210b2583ed5bab12282107bdd97debab1f2f4018040d721fa0030218210178d4519ba0282107bdd97deba12b18e19a0550405c8cb035004fa0258cf1601cf1601fa02cb3fc9ed54e30de004050201201516003614a004413505c8cb035004fa0258cf1601cf1601fa02cb3fc9ed5404a0fa40fa4031fa0031f401fa0031fa00013170f83a02d31f012082100f8a7ea5ba8e85303459db3ce0208210d750cec9ba8e85303459db3ce033228210178d4519ba8e84325adb3ce0228210b2583ed5ba0607080901ec03d33f0101fa00fa4021fa4430c000f2e14ded44d0d303fa00fa40fa40fa00d33fd15327c705533cc7052771b0c00021b1f2ad525ec705500db1f2e0495148a120c2fff2af06fa40f401fa002020d70b009ad74bc00101c001b0f2b19130e22d8e1170c80101ca0001cf16c971c8cb00ccc9d0de70c80a01f603d33f0101fa00fa4021fa4430c000f2e14ded44d0d303fa00fa40fa40fa00d33fd15228c705532bc7052671b0c00021b1f2ad524dc705500cb1f2e049f82327bcf2e14e0af2e04b5196a120c2fff2af04fa40f401fa002020d70b009ad74bc00101c001b0f2b19130e27fc80101ca0001cf16c971c8cb00ccc9d00d01f4ed44d0d303fa00fa40fa40fa00d33fd12572b0c002f26d09d33f0101fa005161a006d33f31fa40fa40536cc705f82a5464907054700020103510241037102605c8cb035004fa0258cf1601cf1601fa02cb3fc921c8cb0113f40012f400cb00c9f9007074c8cb02ca07cbffc9d0500ec7051db1f2e04a0bfa00210f02d88e84325adb3ce034218210595f07bcba8e843101db3ce032208210eed236d3ba8e3b30018040d721d303d1ed44d0d303fa00fa40fa40fa00d33fd1355161c705f2e04a1045551205c8cb035004fa0258cf1601cf1601fa02cb3fc9ed54e06c218210d372158cbadc840ff2f0111202fe8210178d451901cb1f500d01cb3f500bfa021bcb3f24cf1601cf1629fa025008cf16c90a8e57f82a5426607054700020103510241037102605c8cb035004fa0258cf1601cf1601fa02cb3fc921c8cb0113f40012f400cb00c920f9007074c8cb02ca07cbffc9d0c8801801cb0501cf1670fa02401a775003cb6bccccc9e30d0b0c002a35c8801801cb0525cf1670fa0250097158cb6accc900cc47692191729171e2f839206e938126e29120e2216e9431812a169101e25023a813a0738103e770f83ca00270f83612a00170f836a07381044d82100966018070f837a0bcf2b0068050fb00103510340205c8cb035004fa0258cf1601cf1601fa02cb3fc9ed5401fe70c88210b2583ed501cb1f500b01cb3f5009fa0219cb3f22cf1601cf1627fa025006cf16c9c8801801cb0529cf1670fa02017158cb6accc947692191729171e2f839206e938126e29120e2216e9431812a169101e25023a813a0738103e770f83ca00270f83612a00170f836a07381044d82100966018070f837a0bcf2b0060e003c8050fb001035443005c8cb035004fa0258cf1601cf1601fa02cb3fc9ed5401be8e30c882107362d09c01cb1f2501cb3f5004fa0258cf1658cf16c9c8801001cb0526cf1658fa02017158cb6accc98011fb00925f04e228d70b01c000b396301027353530e30d55300505c8cb035004fa0258cf1601cf1601fa02cb3fc9ed541000825076a1f82fa07381044d82100966018070f837b60972fb02c8801001cb055007cf1670fa027001cb6a8210d53276db01cb1f500401cb3fc9810082fb001024102301b8ed44d0d303fa00fa40fa40fa00d33fd1302472b0c002f26d08d33f0101fa00d33f50b2a001fa4031fa4030523ac705f2e04a28d70b01c000b39710381027365f03e30d55300505c8cb035004fa0258cf1601cf1601fa02cb3fc9ed541301f6ed44d0d303fa00fa40fa40fa00d33fd108d33f0101fa00fa40f401d15161a1524ac705f2e04928c2fff2afc882107bdd97de01cb1f5801cb3f01fa0223cf165004cf16c9c8801801cb0522cf1670fa02017158cb6accc905f839206e943081187fde718102f270f8380170f836a081203770f836a0bcf2b004805014007e5076a1f82fa07381044d82100966018070f837b60972fb02c8801001cb055007cf1670fa027001cb6a8210d53276db01cb1f500501cb3fc9810082fb0010340036fb0045130205c8cb035004fa0258cf1601cf1601fa02cb3fc9ed5402015817180029bc508f6a2686981fd007d207d207d00699fe8af82c0029b74e5da89a1a607f401f481f481f401a67fa2d88500031b7605da89a1a607f401f481f481f401a67fa2b667f05482610', 'hex'))[0],
|
|
156
158
|
};
|
|
159
|
+
exports.PT_tsUSDe_01Sep2025_MAINNET = {
|
|
160
|
+
name: 'PT_tsUSDe_01Sep2025',
|
|
161
|
+
assetId: exports.ASSET_ID.PT_tsUSDe_01Sep2025,
|
|
162
|
+
jettonMasterAddress: core_1.Address.parse('EQDb90Bss5FnIyq7VMmnG2UeZIzZomQsILw9Hjo1wxaF1df3'),
|
|
163
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201020f010003c2000114ff00f4a413f4bcf2c80b0102016202030202ce0405001da0f605da89a1f401f481f48061f05504b3420c700925f04e001d0d3030171b08e85135f03db3ce0fa40fa4031fa003171d721fa0031fa003073a9b40002d31f012082100f8a7ea5ba8e85303459db3ce0208210178d4519ba8e8630444403db3ce035248210595f07bcba80607080900114fa4430c000f2e14d800848020d721ed44d0fa00fa40fa403003d31f018200fff0218210178d4519ba0282107bdd97deba12b1f2f4d33f0130fa003012a002c85003fa0201cf1601cf16c9ed5401f403d33f0101fa00fa4021f002ed44d0fa00fa40fa40305125a15219c705f2e2c127c2fff2e2c2f82a5424207054201314c85003fa0201cf1601cf16c922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d003fa40f40431fa0020d749c200f2e2c4c88210178d451901cb1f500901cb3f5007fa02250a02f4ed44d0fa00fa40fa403007d33f0101fa005141a004fa40fa4053bac705f82a5464e07054201314c85003fa0201cf1601cf16c922c8cb0112f400f400cb00c9f9007074c8cb02ca07cbffc9d0500cc7051bb1f2e2c309fa005197a121951049385f04e30d038208989680b60972fb0224d70b01c30002c20012b00b0c02ce8e843459db3ce06c22ed44d0fa00fa40fa403030312382106d8e5e3cba8e37335222c705f2e2c1820898968070fb02c8801001cb0558cf1670fa027001cb6a8210d53276db01cb1f01d33f013101cb3fc9810082fb00e0038210768a50b2bae3025f03840ff2f00d0e009ccf1601cf1625fa025006cf16c9c8801801cb055003cf1670fa025052775003cb6bcccc2291729171e25007a812a082096e3600a013bcf2e2c503c98040fb0058c85003fa0201cf1601cf16c9ed5400725219a017a1c882107362d09c01cb1f2401cb3f5003fa0201cf165007cf16c9c8801001cb0523cf165005fa0250047158cb6accc971fb00102400748e25c8801001cb055004cf1670fa027001cb6a8210d53276db01cb1f5801cb3fc9810082fb0001926c22e202c85003fa0201cf1601cf16c9ed5400deed44d0fa00fa40fa403006d33f0101fa00fa40305141a15238c705f2e2c126c2fff2e2c2048208d59f80a015bcf2e2c3c882107bdd97de01cb1f500401cb3f58fa0222cf1601cf16c9c8801801cb0524cf1670fa02017158cb6accc98040fb0058c85003fa0201cf1601cf16c9ed5400965222c705f2e2c1d33f0101fa40fa00f40430c8801801cb055003cf1670fa0270c882100f8a7ea501cb1f500501cb3f58fa0224cf165004cf16f40070fa02ca00c97158cb6accc98040fb00', 'hex'))[0],
|
|
164
|
+
};
|
|
165
|
+
exports.TONUSDT_STONFI_MAINNET = {
|
|
166
|
+
name: 'TONUSDT_STONFI',
|
|
167
|
+
assetId: exports.ASSET_ID.TONUSDT_STONFI,
|
|
168
|
+
jettonMasterAddress: core_1.Address.parse('EQCGScrZe1xbyWqWDvdI6mzP-GAcAWFv6ZXuaJOuSqemxku4'),
|
|
169
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201010101002300084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8', 'hex'))[0],
|
|
170
|
+
};
|
|
171
|
+
exports.STON_MAINNET = {
|
|
172
|
+
name: 'STON',
|
|
173
|
+
assetId: exports.ASSET_ID.STON,
|
|
174
|
+
jettonMasterAddress: core_1.Address.parse('EQA2kCVNwVsil2EM2mB0SkXytxCqQjS4mttjDpnXmwG9T6bO'),
|
|
175
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000334000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020148080900c30831c02497c138007434c0c05c6c2544d7c0fc02f83e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0238208405e3514654882ea58c511100fc02780d60841657c1ef2ea4d67c02b817c12103fcbc2000113e910c1c2ebcb853600201200a0b020120101101f100f4cffe803e90087c007b51343e803e903e90350c144da8548ab1c17cb8b04a30bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032483e401c1d3232c0b281f2fff274013e903d010c7e800835d270803cb8b11de0063232c1540233c59c3e8085f2dac4f3200c03f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a020822625a004ad8228608239387028062849f8c3c975c2c070c008e00d0e0f00ae8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08208e4e1c0aa008208989680a0a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5400705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023000e10491038375f040076c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5400db3b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b0a0823938702a8005a805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b55200083200835c87b51343e803e903e90350c0134c7e08405e3514654882ea0841ef765f784ee84ac7cb8b174cfcc7e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
176
|
+
};
|
|
@@ -22,6 +22,8 @@ export declare const EVAA_LP_MAINNET: Address;
|
|
|
22
22
|
export declare const EVAA_LP_MAINNET_VERSION = 3;
|
|
23
23
|
export declare const EVAA_ALTS_MAINNET: Address;
|
|
24
24
|
export declare const EVAA_ALTS_MAINNET_VERSION = 0;
|
|
25
|
+
export declare const EVAA_STABLE_MAINNET: Address;
|
|
26
|
+
export declare const STABLE_VERSION = 0;
|
|
25
27
|
export declare const EVAA_ETHENA_MAINNET: Address;
|
|
26
28
|
export declare const EVAA_ETHENA_VERSION = 0;
|
|
27
29
|
export declare const EVAA_REWARDS_MASTER_TESTNET: Address;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FEES = exports.OPCODES = exports.EVAA_REWARDS_USER_CODE_MAINNET = exports.EVAA_REWARDS_USER_CODE_TESTNET = exports.EVAA_REWARDS_MASTER_CODE_MAINNET = exports.EVAA_REWARDS_MASTER_CODE_TESTNET = exports.JETTON_WALLET_STANDART_CODE_TESTNET = exports.JETTON_WALLET_STANDART_CODE = exports.LENDING_CODE = exports.ORACLES_ALTS = exports.ORACLES_LP = exports.ORACLES_TESTNET = exports.ORACLES_MAINNET = exports.EVAA_TON_REWARDS_MASTER_MAINNET = exports.EVAA_USDT_REWARDS_MASTER_MAINNET = exports.EVAA_REWARDS_MASTER_TESTNET = exports.EVAA_ETHENA_VERSION = exports.EVAA_ETHENA_MAINNET = exports.EVAA_ALTS_MAINNET_VERSION = exports.EVAA_ALTS_MAINNET = exports.EVAA_LP_MAINNET_VERSION = exports.EVAA_LP_MAINNET = exports.TESTNET_VERSION = exports.EVAA_MASTER_TESTNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = exports.NULL_ADDRESS = exports.MASTER_CONSTANTS = void 0;
|
|
3
|
+
exports.FEES = exports.OPCODES = exports.EVAA_REWARDS_USER_CODE_MAINNET = exports.EVAA_REWARDS_USER_CODE_TESTNET = exports.EVAA_REWARDS_MASTER_CODE_MAINNET = exports.EVAA_REWARDS_MASTER_CODE_TESTNET = exports.JETTON_WALLET_STANDART_CODE_TESTNET = exports.JETTON_WALLET_STANDART_CODE = exports.LENDING_CODE = exports.ORACLES_ALTS = exports.ORACLES_LP = exports.ORACLES_TESTNET = exports.ORACLES_MAINNET = exports.EVAA_TON_REWARDS_MASTER_MAINNET = exports.EVAA_USDT_REWARDS_MASTER_MAINNET = exports.EVAA_REWARDS_MASTER_TESTNET = exports.EVAA_ETHENA_VERSION = exports.EVAA_ETHENA_MAINNET = exports.STABLE_VERSION = exports.EVAA_STABLE_MAINNET = exports.EVAA_ALTS_MAINNET_VERSION = exports.EVAA_ALTS_MAINNET = exports.EVAA_LP_MAINNET_VERSION = exports.EVAA_LP_MAINNET = exports.TESTNET_VERSION = exports.EVAA_MASTER_TESTNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = exports.NULL_ADDRESS = exports.MASTER_CONSTANTS = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const ASSET_PRICE_SCALE = BigInt(1e9);
|
|
6
6
|
exports.MASTER_CONSTANTS = {
|
|
@@ -25,6 +25,8 @@ exports.EVAA_LP_MAINNET = core_1.Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBo
|
|
|
25
25
|
exports.EVAA_LP_MAINNET_VERSION = 3;
|
|
26
26
|
exports.EVAA_ALTS_MAINNET = core_1.Address.parse('EQANURVS3fhBO9bivig34iyJQi97FhMbpivo1aUEAS2GYSu-');
|
|
27
27
|
exports.EVAA_ALTS_MAINNET_VERSION = 0;
|
|
28
|
+
exports.EVAA_STABLE_MAINNET = core_1.Address.parse('EQCdIdXf1kA_2Hd9mbGzSFDEPA-Px-et8qTWHEXgRGo0K3zd');
|
|
29
|
+
exports.STABLE_VERSION = 0;
|
|
28
30
|
exports.EVAA_ETHENA_MAINNET = core_1.Address.parse('EQCn95X_qLJa5VUXfyIQkWDH2iq3PTatsO4esunMaIsnyyeW');
|
|
29
31
|
exports.EVAA_ETHENA_VERSION = 0;
|
|
30
32
|
exports.EVAA_REWARDS_MASTER_TESTNET = core_1.Address.parse('EQCnp0iRGcfDJAvnKhAEN9sB-nPYSPuc83Ff4y75s8AtoSW1');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PoolConfig } from '../types/Master';
|
|
2
2
|
import { EvaaRewardsConfig } from '../types/MasterRewards';
|
|
3
3
|
export declare const MAINNET_POOL_CONFIG: PoolConfig;
|
|
4
|
+
export declare const MAINNET_STABLE_POOL_CONFIG: PoolConfig;
|
|
4
5
|
export declare const MAINNET_TEST_ETHENA_POOL_CONFIG: PoolConfig;
|
|
5
6
|
export declare const TESTNET_POOL_CONFIG: PoolConfig;
|
|
6
7
|
export declare const MAINNET_LP_POOL_CONFIG: PoolConfig;
|
|
@@ -9,3 +10,4 @@ export declare const TESTNET_MASTER_REWARD_CONFIG: EvaaRewardsConfig;
|
|
|
9
10
|
export declare const TESTNET_MASTER_EUSDT_REWARD_CONFIG: EvaaRewardsConfig;
|
|
10
11
|
export declare const MAINNET_MASTER_TON_REWARD_CONFIG: EvaaRewardsConfig;
|
|
11
12
|
export declare const MAINNET_MASTER_USDT_REWARD_CONFIG: EvaaRewardsConfig;
|
|
13
|
+
export declare const ALL_MAINNET_POOLS: PoolConfig[];
|
package/dist/constants/pools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAINNET_MASTER_USDT_REWARD_CONFIG = exports.MAINNET_MASTER_TON_REWARD_CONFIG = exports.TESTNET_MASTER_EUSDT_REWARD_CONFIG = exports.TESTNET_MASTER_REWARD_CONFIG = exports.MAINNET_ALTS_POOL_CONFIG = exports.MAINNET_LP_POOL_CONFIG = exports.TESTNET_POOL_CONFIG = exports.MAINNET_TEST_ETHENA_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = void 0;
|
|
3
|
+
exports.ALL_MAINNET_POOLS = exports.MAINNET_MASTER_USDT_REWARD_CONFIG = exports.MAINNET_MASTER_TON_REWARD_CONFIG = exports.TESTNET_MASTER_EUSDT_REWARD_CONFIG = exports.TESTNET_MASTER_REWARD_CONFIG = exports.MAINNET_ALTS_POOL_CONFIG = exports.MAINNET_LP_POOL_CONFIG = exports.TESTNET_POOL_CONFIG = exports.MAINNET_TEST_ETHENA_POOL_CONFIG = exports.MAINNET_STABLE_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const assets_1 = require("./assets");
|
|
6
6
|
const general_1 = require("./general");
|
|
@@ -23,6 +23,20 @@ exports.MAINNET_POOL_CONFIG = {
|
|
|
23
23
|
],
|
|
24
24
|
lendingCode: general_1.LENDING_CODE,
|
|
25
25
|
};
|
|
26
|
+
exports.MAINNET_STABLE_POOL_CONFIG = {
|
|
27
|
+
masterAddress: general_1.EVAA_STABLE_MAINNET,
|
|
28
|
+
masterVersion: general_1.STABLE_VERSION,
|
|
29
|
+
masterConstants: general_1.MASTER_CONSTANTS,
|
|
30
|
+
oracles: general_1.ORACLES_MAINNET,
|
|
31
|
+
minimalOracles: 3,
|
|
32
|
+
poolAssetsConfig: [
|
|
33
|
+
assets_1.USDT_MAINNET,
|
|
34
|
+
assets_1.USDE_MAINNET,
|
|
35
|
+
assets_1.TSUSDE_MAINNET,
|
|
36
|
+
assets_1.PT_tsUSDe_01Sep2025_MAINNET
|
|
37
|
+
],
|
|
38
|
+
lendingCode: general_1.LENDING_CODE,
|
|
39
|
+
};
|
|
26
40
|
exports.MAINNET_TEST_ETHENA_POOL_CONFIG = {
|
|
27
41
|
masterAddress: general_1.EVAA_ETHENA_MAINNET,
|
|
28
42
|
masterVersion: general_1.EVAA_ETHENA_VERSION,
|
|
@@ -50,7 +64,7 @@ exports.MAINNET_LP_POOL_CONFIG = {
|
|
|
50
64
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
51
65
|
oracles: general_1.ORACLES_LP,
|
|
52
66
|
minimalOracles: 3,
|
|
53
|
-
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.TONUSDT_DEDUST_MAINNET, assets_1.TON_STORM_MAINNET, assets_1.USDT_STORM_MAINNET],
|
|
67
|
+
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.TONUSDT_DEDUST_MAINNET, assets_1.TON_STORM_MAINNET, assets_1.USDT_STORM_MAINNET, assets_1.TONUSDT_STONFI_MAINNET],
|
|
54
68
|
lendingCode: general_1.LENDING_CODE,
|
|
55
69
|
};
|
|
56
70
|
exports.MAINNET_ALTS_POOL_CONFIG = {
|
|
@@ -59,7 +73,7 @@ exports.MAINNET_ALTS_POOL_CONFIG = {
|
|
|
59
73
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
60
74
|
oracles: general_1.ORACLES_ALTS,
|
|
61
75
|
minimalOracles: 3,
|
|
62
|
-
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.CATI_MAINNET, assets_1.NOT_MAINNET, assets_1.DOGS_MAINNET],
|
|
76
|
+
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.CATI_MAINNET, assets_1.NOT_MAINNET, assets_1.DOGS_MAINNET /*, STON_MAINNET announce*/],
|
|
63
77
|
lendingCode: general_1.LENDING_CODE,
|
|
64
78
|
};
|
|
65
79
|
exports.TESTNET_MASTER_REWARD_CONFIG = {
|
|
@@ -98,3 +112,9 @@ exports.MAINNET_MASTER_USDT_REWARD_CONFIG = {
|
|
|
98
112
|
availableReward: 0,
|
|
99
113
|
publicKey: Buffer.from('9813725d6cead1c9bbc0e24b21d4fc62a7fa8ac4bb01b6758df30169a71dba67', 'hex'), // adminAddress publicKey
|
|
100
114
|
};
|
|
115
|
+
exports.ALL_MAINNET_POOLS = [
|
|
116
|
+
exports.MAINNET_POOL_CONFIG,
|
|
117
|
+
exports.MAINNET_LP_POOL_CONFIG,
|
|
118
|
+
exports.MAINNET_ALTS_POOL_CONFIG,
|
|
119
|
+
exports.MAINNET_STABLE_POOL_CONFIG,
|
|
120
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,8 @@ export { JettonWallet as RewardJettonWallet, type JettonWalletConfig } from './r
|
|
|
14
14
|
export { EvaaUserRewards } from './rewards/EvaaRewards';
|
|
15
15
|
export { UpgradeConfig, AssetConfig, MasterConfig, AssetData, AssetInterest, AssetApy, ExtendedAssetData, MasterData, PoolConfig, ExtendedAssetsData, ExtendedAssetsConfig, PoolAssetConfig, PoolAssetsConfig, MasterConstants } from './types/Master';
|
|
16
16
|
export { BalanceType, UserBalance, UserLiqudationData, LiquidableData, NonLiquidableData, LiquidationData, UserDataInactive, UserDataActive, UserData, BalanceChangeType } from './types/User';
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export { ASSET_ID, UNDEFINED_ASSET, TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET, DOGS_MAINNET, CATI_MAINNET, UTON_MAINNET, NOT_MAINNET, JUSDT_MAINNET, JUSDC_MAINNET, STTON_MAINNET, TSTON_MAINNET, JUSDT_TESTNET, JUSDC_TESTNET, STTON_TESTNET } from './constants/assets';
|
|
17
|
+
export * from './constants/general';
|
|
18
|
+
export * from './constants/pools';
|
|
20
19
|
export * from './constants/assets';
|
|
21
20
|
export * from './utils/utils';
|
|
22
21
|
export * from './prices';
|
package/dist/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.getUserJettonWallet =
|
|
17
|
+
exports.getTonConnectSender = exports.getLastSentBoc = exports.BalanceChangeType = exports.BalanceType = exports.EvaaUserRewards = exports.RewardJettonWallet = exports.RewardJettonMinter = exports.RewardUser = exports.RewardMaster = exports.EvaaUser = exports.Evaa = exports.JettonWallet = exports.getPrices = exports.parseUserLiteData = exports.parseUserData = exports.parseMasterData = exports.createAssetConfig = exports.createAssetData = exports.calculateAssetsValues = exports.selectGreatestAssets = exports.findAssetById = exports.prepareAssetInfo = exports.toAssetWorth = exports.toAssetAmount = exports.deductLiquidationBonus = exports.addLiquidationBonus = exports.deductReserve = exports.addReserve = exports.isBadDebt = exports.isLiquidatable = exports.calculateMinCollateralByTransferredAmount = exports.calculateLiquidationAmounts = exports.getAssetLiquidityMinusReserves = exports.BigMath = exports.predictAPY = exports.calculateInterestWithSupplyBorrow = exports.calculateHealthParams = exports.predictHealthFactor = exports.calculateLiquidationData = exports.presentValue = exports.calculateMaximumWithdrawAmount = exports.getAvailableToBorrow = exports.calculateAssetInterest = exports.calculateAssetData = exports.calculateCurrentRates = exports.calculatePresentValue = exports.bigIntMax = exports.bigIntMin = exports.mulDiv = exports.mulFactor = void 0;
|
|
18
|
+
exports.getUserJettonWallet = void 0;
|
|
19
19
|
// Math
|
|
20
20
|
var math_1 = require("./api/math");
|
|
21
21
|
Object.defineProperty(exports, "mulFactor", { enumerable: true, get: function () { return math_1.mulFactor; } });
|
|
@@ -83,49 +83,8 @@ var User_1 = require("./types/User");
|
|
|
83
83
|
Object.defineProperty(exports, "BalanceType", { enumerable: true, get: function () { return User_1.BalanceType; } });
|
|
84
84
|
Object.defineProperty(exports, "BalanceChangeType", { enumerable: true, get: function () { return User_1.BalanceChangeType; } });
|
|
85
85
|
// Constants
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Object.defineProperty(exports, "MAINNET_VERSION", { enumerable: true, get: function () { return general_1.MAINNET_VERSION; } });
|
|
89
|
-
Object.defineProperty(exports, "EVAA_MASTER_TESTNET", { enumerable: true, get: function () { return general_1.EVAA_MASTER_TESTNET; } });
|
|
90
|
-
Object.defineProperty(exports, "TESTNET_VERSION", { enumerable: true, get: function () { return general_1.TESTNET_VERSION; } });
|
|
91
|
-
Object.defineProperty(exports, "LENDING_CODE", { enumerable: true, get: function () { return general_1.LENDING_CODE; } });
|
|
92
|
-
Object.defineProperty(exports, "OPCODES", { enumerable: true, get: function () { return general_1.OPCODES; } });
|
|
93
|
-
Object.defineProperty(exports, "FEES", { enumerable: true, get: function () { return general_1.FEES; } });
|
|
94
|
-
Object.defineProperty(exports, "MASTER_CONSTANTS", { enumerable: true, get: function () { return general_1.MASTER_CONSTANTS; } });
|
|
95
|
-
Object.defineProperty(exports, "EVAA_REWARDS_MASTER_TESTNET", { enumerable: true, get: function () { return general_1.EVAA_REWARDS_MASTER_TESTNET; } });
|
|
96
|
-
Object.defineProperty(exports, "EVAA_REWARDS_MASTER_CODE_TESTNET", { enumerable: true, get: function () { return general_1.EVAA_REWARDS_MASTER_CODE_TESTNET; } });
|
|
97
|
-
Object.defineProperty(exports, "EVAA_REWARDS_USER_CODE_TESTNET", { enumerable: true, get: function () { return general_1.EVAA_REWARDS_USER_CODE_TESTNET; } });
|
|
98
|
-
Object.defineProperty(exports, "EVAA_REWARDS_MASTER_CODE_MAINNET", { enumerable: true, get: function () { return general_1.EVAA_REWARDS_MASTER_CODE_MAINNET; } });
|
|
99
|
-
Object.defineProperty(exports, "EVAA_REWARDS_USER_CODE_MAINNET", { enumerable: true, get: function () { return general_1.EVAA_REWARDS_USER_CODE_MAINNET; } });
|
|
100
|
-
var pools_1 = require("./constants/pools");
|
|
101
|
-
Object.defineProperty(exports, "MAINNET_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_POOL_CONFIG; } });
|
|
102
|
-
Object.defineProperty(exports, "TESTNET_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.TESTNET_POOL_CONFIG; } });
|
|
103
|
-
Object.defineProperty(exports, "MAINNET_LP_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_LP_POOL_CONFIG; } });
|
|
104
|
-
Object.defineProperty(exports, "MAINNET_ALTS_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_ALTS_POOL_CONFIG; } });
|
|
105
|
-
Object.defineProperty(exports, "MAINNET_TEST_ETHENA_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_TEST_ETHENA_POOL_CONFIG; } });
|
|
106
|
-
// Reward Pools
|
|
107
|
-
Object.defineProperty(exports, "TESTNET_MASTER_REWARD_CONFIG", { enumerable: true, get: function () { return pools_1.TESTNET_MASTER_REWARD_CONFIG; } });
|
|
108
|
-
Object.defineProperty(exports, "MAINNET_MASTER_TON_REWARD_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_MASTER_TON_REWARD_CONFIG; } });
|
|
109
|
-
Object.defineProperty(exports, "MAINNET_MASTER_USDT_REWARD_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_MASTER_USDT_REWARD_CONFIG; } });
|
|
110
|
-
var assets_1 = require("./constants/assets");
|
|
111
|
-
Object.defineProperty(exports, "ASSET_ID", { enumerable: true, get: function () { return assets_1.ASSET_ID; } });
|
|
112
|
-
Object.defineProperty(exports, "UNDEFINED_ASSET", { enumerable: true, get: function () { return assets_1.UNDEFINED_ASSET; } });
|
|
113
|
-
Object.defineProperty(exports, "TON_MAINNET", { enumerable: true, get: function () { return assets_1.TON_MAINNET; } });
|
|
114
|
-
Object.defineProperty(exports, "USDT_MAINNET", { enumerable: true, get: function () { return assets_1.USDT_MAINNET; } });
|
|
115
|
-
Object.defineProperty(exports, "TONUSDT_DEDUST_MAINNET", { enumerable: true, get: function () { return assets_1.TONUSDT_DEDUST_MAINNET; } });
|
|
116
|
-
Object.defineProperty(exports, "TON_STORM_MAINNET", { enumerable: true, get: function () { return assets_1.TON_STORM_MAINNET; } });
|
|
117
|
-
Object.defineProperty(exports, "USDT_STORM_MAINNET", { enumerable: true, get: function () { return assets_1.USDT_STORM_MAINNET; } });
|
|
118
|
-
Object.defineProperty(exports, "DOGS_MAINNET", { enumerable: true, get: function () { return assets_1.DOGS_MAINNET; } });
|
|
119
|
-
Object.defineProperty(exports, "CATI_MAINNET", { enumerable: true, get: function () { return assets_1.CATI_MAINNET; } });
|
|
120
|
-
Object.defineProperty(exports, "UTON_MAINNET", { enumerable: true, get: function () { return assets_1.UTON_MAINNET; } });
|
|
121
|
-
Object.defineProperty(exports, "NOT_MAINNET", { enumerable: true, get: function () { return assets_1.NOT_MAINNET; } });
|
|
122
|
-
Object.defineProperty(exports, "JUSDT_MAINNET", { enumerable: true, get: function () { return assets_1.JUSDT_MAINNET; } });
|
|
123
|
-
Object.defineProperty(exports, "JUSDC_MAINNET", { enumerable: true, get: function () { return assets_1.JUSDC_MAINNET; } });
|
|
124
|
-
Object.defineProperty(exports, "STTON_MAINNET", { enumerable: true, get: function () { return assets_1.STTON_MAINNET; } });
|
|
125
|
-
Object.defineProperty(exports, "TSTON_MAINNET", { enumerable: true, get: function () { return assets_1.TSTON_MAINNET; } });
|
|
126
|
-
Object.defineProperty(exports, "JUSDT_TESTNET", { enumerable: true, get: function () { return assets_1.JUSDT_TESTNET; } });
|
|
127
|
-
Object.defineProperty(exports, "JUSDC_TESTNET", { enumerable: true, get: function () { return assets_1.JUSDC_TESTNET; } });
|
|
128
|
-
Object.defineProperty(exports, "STTON_TESTNET", { enumerable: true, get: function () { return assets_1.STTON_TESTNET; } });
|
|
86
|
+
__exportStar(require("./constants/general"), exports);
|
|
87
|
+
__exportStar(require("./constants/pools"), exports);
|
|
129
88
|
__exportStar(require("./constants/assets"), exports);
|
|
130
89
|
__exportStar(require("./utils/utils"), exports);
|
|
131
90
|
__exportStar(require("./prices"), exports);
|
|
@@ -95,10 +95,17 @@ _PricesCollector_prices = new WeakMap(), _PricesCollector_poolConfig = new WeakM
|
|
|
95
95
|
const newerPrices = sortedByTimestamp.slice(0, __classPrivateFieldGet(this, _PricesCollector_poolConfig, "f").minimalOracles);
|
|
96
96
|
pricesFiltered = newerPrices.sort((a, b) => a.oracleId - b.oracleId);
|
|
97
97
|
}
|
|
98
|
-
const medianData = assets.map(asset => ({
|
|
98
|
+
const medianData = assets.map((asset) => ({
|
|
99
|
+
assetId: asset.assetId,
|
|
100
|
+
medianPrice: (0, utils_1.getMedianPrice)(pricesFiltered, asset.assetId),
|
|
101
|
+
}));
|
|
99
102
|
const nonEmptymedianData = medianData.filter(x => x.medianPrice != null);
|
|
100
103
|
const packedMedianData = (0, utils_1.packAssetsData)(nonEmptymedianData);
|
|
101
|
-
const oraclesData =
|
|
104
|
+
const oraclesData = pricesFiltered.map((x) => ({
|
|
105
|
+
oracle: { id: x.oracleId, pubkey: x.pubkey },
|
|
106
|
+
data: { timestamp: x.timestamp, prices: x.dict },
|
|
107
|
+
signature: x.signature,
|
|
108
|
+
}));
|
|
102
109
|
const packedOracleData = (0, utils_1.packOraclesData)(oraclesData, nonEmptymedianData.map(x => x.assetId));
|
|
103
110
|
const dict = core_1.Dictionary.empty();
|
|
104
111
|
for (const medianDataAsset of nonEmptymedianData) {
|
package/dist/prices/Types.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ import { Cell, Dictionary } from '@ton/core';
|
|
|
6
6
|
export type PriceSourcesConfig = {
|
|
7
7
|
/** Endpoints for backend price data */
|
|
8
8
|
backendEndpoints: string[];
|
|
9
|
-
/** Endpoints for IOTA price data */
|
|
10
|
-
iotaEndpoints: string[];
|
|
11
9
|
/** Endpoints for ICP price data */
|
|
12
10
|
icpEndpoints: string[];
|
|
13
11
|
};
|
package/dist/prices/Types.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.DefaultPriceSourcesConfig = void 0;
|
|
|
5
5
|
* Default configuration for price source endpoints.
|
|
6
6
|
*/
|
|
7
7
|
exports.DefaultPriceSourcesConfig = {
|
|
8
|
-
backendEndpoints: ['evaa.space'],
|
|
9
|
-
iotaEndpoints: ['api.stardust-mainnet.iotaledger.net'],
|
|
8
|
+
backendEndpoints: ['api.evaa.space', 'evaa.space'],
|
|
10
9
|
icpEndpoints: ['6khmc-aiaaa-aaaap-ansfq-cai.raw.icp0.io'],
|
|
11
10
|
};
|
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./Backend"), exports);
|
|
18
|
-
__exportStar(require("./Iota"), exports);
|
|
19
18
|
__exportStar(require("./Icp"), exports);
|
|
20
19
|
__exportStar(require("./PriceSource"), exports);
|
package/dist/prices/utils.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyRawPriceDataSign = exports.unpackMedianPrices = exports.collectAndFilterPrices = exports.generatePriceSources = exports.sumDicts = exports.packOraclesData = exports.createOracleDataProof = exports.packPrices = exports.packAssetsData = exports.getMedianPrice = exports.verifyPricesSign = exports.verifyPricesTimestamp = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
|
+
const crypto_1 = require("@ton/crypto");
|
|
5
6
|
const __1 = require("..");
|
|
6
7
|
const merkleProof_1 = require("../utils/merkleProof");
|
|
7
|
-
const crypto_1 = require("@ton/crypto");
|
|
8
8
|
function verifyPricesTimestamp() {
|
|
9
9
|
return function (priceData) {
|
|
10
10
|
const timestamp = Date.now() / 1000;
|
|
@@ -104,7 +104,6 @@ exports.sumDicts = sumDicts;
|
|
|
104
104
|
function generatePriceSources(config = __1.DefaultPriceSourcesConfig, nfts = __1.MAINNET_POOL_CONFIG.oracles) {
|
|
105
105
|
let result = config.backendEndpoints.map(x => new __1.BackendPriceSource(x, nfts));
|
|
106
106
|
result.push(...config.icpEndpoints.map(x => new __1.IcpPriceSource(x, nfts)));
|
|
107
|
-
result.push(...config.iotaEndpoints.map(x => new __1.IotaPriceSource(x, nfts)));
|
|
108
107
|
return result;
|
|
109
108
|
}
|
|
110
109
|
exports.generatePriceSources = generatePriceSources;
|
|
@@ -23,6 +23,12 @@ function getUserJettonData(ownerAddress, assetName, jettonWalletCode, jettonMast
|
|
|
23
23
|
.storeAddress(ownerAddress)
|
|
24
24
|
.storeAddress(jettonMasterAddress)
|
|
25
25
|
.endCell();
|
|
26
|
+
case 'PT_tsUSDe_01Sep2025':
|
|
27
|
+
return (0, core_1.beginCell)()
|
|
28
|
+
.storeCoins(0)
|
|
29
|
+
.storeAddress(ownerAddress)
|
|
30
|
+
.storeAddress(jettonMasterAddress)
|
|
31
|
+
.endCell();
|
|
26
32
|
case 'tsUSDe':
|
|
27
33
|
return (0, core_1.beginCell)()
|
|
28
34
|
.storeUint(0, 4)
|
package/package.json
CHANGED
package/src/api/math.ts
CHANGED
|
@@ -369,7 +369,7 @@ export function calculateHealthParams(parameters: HealthParamsArgs) {
|
|
|
369
369
|
if (assetBalance.type === BalanceType.supply) {
|
|
370
370
|
totalSupply += assetWorth;
|
|
371
371
|
totalLimit += assetWorth * assetConfig.liquidationThreshold / ASSET_LIQUIDATION_THRESHOLD_SCALE;
|
|
372
|
-
} else if (assetBalance.type === BalanceType.borrow) {
|
|
372
|
+
} else if (assetBalance.type === BalanceType.borrow && assetConfig.dust < assetBalance.amount) {
|
|
373
373
|
totalDebt += assetWorth;
|
|
374
374
|
}
|
|
375
375
|
}
|
package/src/api/prices.ts
CHANGED
|
@@ -11,7 +11,6 @@ export async function getPrices(endpoints: string[] = ["api.stardust-mainnet.iot
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const sources: PriceSourcesConfig = {
|
|
14
|
-
iotaEndpoints: endpoints,
|
|
15
14
|
icpEndpoints: DefaultPriceSourcesConfig.icpEndpoints,
|
|
16
15
|
backendEndpoints: DefaultPriceSourcesConfig.backendEndpoints,
|
|
17
16
|
}
|
package/src/constants/assets.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const ASSET_ID = {
|
|
|
14
14
|
tgBTC: sha256Hash('tgBTC'),
|
|
15
15
|
USDe: sha256Hash('USDe'),
|
|
16
16
|
tsUSDe: sha256Hash('tsUSDe'),
|
|
17
|
+
PT_tsUSDe_01Sep2025: sha256Hash('PT_tsUSDe_01Sep2025'),
|
|
17
18
|
|
|
18
19
|
// LP
|
|
19
20
|
TONUSDT_DEDUST: sha256Hash('TONUSDT_DEDUST'),
|
|
@@ -25,6 +26,8 @@ export const ASSET_ID = {
|
|
|
25
26
|
NOT: sha256Hash('NOT'),
|
|
26
27
|
DOGS: sha256Hash('DOGS'),
|
|
27
28
|
CATI: sha256Hash('CATI'),
|
|
29
|
+
STON: sha256Hash('STON'),
|
|
30
|
+
|
|
28
31
|
|
|
29
32
|
// Testnet assets
|
|
30
33
|
EUSDT: sha256Hash('EUSDT'),
|
|
@@ -246,3 +249,39 @@ export const TSUSDE_MAINNET: PoolAssetConfig = {
|
|
|
246
249
|
),
|
|
247
250
|
)[0],
|
|
248
251
|
};
|
|
252
|
+
|
|
253
|
+
export const PT_tsUSDe_01Sep2025_MAINNET: PoolAssetConfig = {
|
|
254
|
+
name: 'PT_tsUSDe_01Sep2025',
|
|
255
|
+
assetId: ASSET_ID.PT_tsUSDe_01Sep2025,
|
|
256
|
+
jettonMasterAddress: Address.parse('EQDb90Bss5FnIyq7VMmnG2UeZIzZomQsILw9Hjo1wxaF1df3'),
|
|
257
|
+
jettonWalletCode: Cell.fromBoc(
|
|
258
|
+
Buffer.from(
|
|
259
|
+
'b5ee9c7201020f010003c2000114ff00f4a413f4bcf2c80b0102016202030202ce0405001da0f605da89a1f401f481f48061f05504b3420c700925f04e001d0d3030171b08e85135f03db3ce0fa40fa4031fa003171d721fa0031fa003073a9b40002d31f012082100f8a7ea5ba8e85303459db3ce0208210178d4519ba8e8630444403db3ce035248210595f07bcba80607080900114fa4430c000f2e14d800848020d721ed44d0fa00fa40fa403003d31f018200fff0218210178d4519ba0282107bdd97deba12b1f2f4d33f0130fa003012a002c85003fa0201cf1601cf16c9ed5401f403d33f0101fa00fa4021f002ed44d0fa00fa40fa40305125a15219c705f2e2c127c2fff2e2c2f82a5424207054201314c85003fa0201cf1601cf16c922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d003fa40f40431fa0020d749c200f2e2c4c88210178d451901cb1f500901cb3f5007fa02250a02f4ed44d0fa00fa40fa403007d33f0101fa005141a004fa40fa4053bac705f82a5464e07054201314c85003fa0201cf1601cf16c922c8cb0112f400f400cb00c9f9007074c8cb02ca07cbffc9d0500cc7051bb1f2e2c309fa005197a121951049385f04e30d038208989680b60972fb0224d70b01c30002c20012b00b0c02ce8e843459db3ce06c22ed44d0fa00fa40fa403030312382106d8e5e3cba8e37335222c705f2e2c1820898968070fb02c8801001cb0558cf1670fa027001cb6a8210d53276db01cb1f01d33f013101cb3fc9810082fb00e0038210768a50b2bae3025f03840ff2f00d0e009ccf1601cf1625fa025006cf16c9c8801801cb055003cf1670fa025052775003cb6bcccc2291729171e25007a812a082096e3600a013bcf2e2c503c98040fb0058c85003fa0201cf1601cf16c9ed5400725219a017a1c882107362d09c01cb1f2401cb3f5003fa0201cf165007cf16c9c8801001cb0523cf165005fa0250047158cb6accc971fb00102400748e25c8801001cb055004cf1670fa027001cb6a8210d53276db01cb1f5801cb3fc9810082fb0001926c22e202c85003fa0201cf1601cf16c9ed5400deed44d0fa00fa40fa403006d33f0101fa00fa40305141a15238c705f2e2c126c2fff2e2c2048208d59f80a015bcf2e2c3c882107bdd97de01cb1f500401cb3f58fa0222cf1601cf16c9c8801801cb0524cf1670fa02017158cb6accc98040fb0058c85003fa0201cf1601cf16c9ed5400965222c705f2e2c1d33f0101fa40fa00f40430c8801801cb055003cf1670fa0270c882100f8a7ea501cb1f500501cb3f58fa0224cf165004cf16f40070fa02ca00c97158cb6accc98040fb00',
|
|
260
|
+
'hex',
|
|
261
|
+
),
|
|
262
|
+
)[0],
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export const TONUSDT_STONFI_MAINNET: PoolAssetConfig = {
|
|
266
|
+
name: 'TONUSDT_STONFI',
|
|
267
|
+
assetId: ASSET_ID.TONUSDT_STONFI,
|
|
268
|
+
jettonMasterAddress: Address.parse('EQCGScrZe1xbyWqWDvdI6mzP-GAcAWFv6ZXuaJOuSqemxku4'),
|
|
269
|
+
jettonWalletCode: Cell.fromBoc(
|
|
270
|
+
Buffer.from(
|
|
271
|
+
'b5ee9c7201010101002300084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8',
|
|
272
|
+
'hex',
|
|
273
|
+
),
|
|
274
|
+
)[0],
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export const STON_MAINNET: PoolAssetConfig = {
|
|
278
|
+
name: 'STON',
|
|
279
|
+
assetId: ASSET_ID.STON,
|
|
280
|
+
jettonMasterAddress: Address.parse('EQA2kCVNwVsil2EM2mB0SkXytxCqQjS4mttjDpnXmwG9T6bO'),
|
|
281
|
+
jettonWalletCode: Cell.fromBoc(
|
|
282
|
+
Buffer.from(
|
|
283
|
+
'b5ee9c7201021201000334000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020148080900c30831c02497c138007434c0c05c6c2544d7c0fc02f83e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0238208405e3514654882ea58c511100fc02780d60841657c1ef2ea4d67c02b817c12103fcbc2000113e910c1c2ebcb853600201200a0b020120101101f100f4cffe803e90087c007b51343e803e903e90350c144da8548ab1c17cb8b04a30bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032483e401c1d3232c0b281f2fff274013e903d010c7e800835d270803cb8b11de0063232c1540233c59c3e8085f2dac4f3200c03f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a020822625a004ad8228608239387028062849f8c3c975c2c070c008e00d0e0f00ae8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08208e4e1c0aa008208989680a0a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5400705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023000e10491038375f040076c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5400db3b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b0a0823938702a8005a805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b55200083200835c87b51343e803e903e90350c0134c7e08405e3514654882ea0841ef765f784ee84ac7cb8b174cfcc7e800c04e81408f214013e809633c58073c5b3327b5520',
|
|
284
|
+
'hex',
|
|
285
|
+
),
|
|
286
|
+
)[0],
|
|
287
|
+
};
|
package/src/constants/general.ts
CHANGED
|
@@ -27,6 +27,8 @@ export const EVAA_LP_MAINNET = Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLw
|
|
|
27
27
|
export const EVAA_LP_MAINNET_VERSION = 3;
|
|
28
28
|
export const EVAA_ALTS_MAINNET = Address.parse('EQANURVS3fhBO9bivig34iyJQi97FhMbpivo1aUEAS2GYSu-');
|
|
29
29
|
export const EVAA_ALTS_MAINNET_VERSION = 0;
|
|
30
|
+
export const EVAA_STABLE_MAINNET = Address.parse('EQCdIdXf1kA_2Hd9mbGzSFDEPA-Px-et8qTWHEXgRGo0K3zd');
|
|
31
|
+
export const STABLE_VERSION = 0;
|
|
30
32
|
|
|
31
33
|
export const EVAA_ETHENA_MAINNET = Address.parse('EQCn95X_qLJa5VUXfyIQkWDH2iq3PTatsO4esunMaIsnyyeW');
|
|
32
34
|
export const EVAA_ETHENA_VERSION = 0;
|
package/src/constants/pools.ts
CHANGED
|
@@ -8,12 +8,15 @@ import {
|
|
|
8
8
|
JUSDC_MAINNET,
|
|
9
9
|
JUSDT_MAINNET,
|
|
10
10
|
NOT_MAINNET,
|
|
11
|
+
PT_tsUSDe_01Sep2025_MAINNET,
|
|
12
|
+
STON_MAINNET,
|
|
11
13
|
STTON_MAINNET,
|
|
12
14
|
TGBTC_TESTNET,
|
|
13
15
|
TON_MAINNET,
|
|
14
16
|
TON_STORM_MAINNET,
|
|
15
17
|
TON_TESTNET,
|
|
16
18
|
TONUSDT_DEDUST_MAINNET,
|
|
19
|
+
TONUSDT_STONFI_MAINNET,
|
|
17
20
|
TSTON_MAINNET,
|
|
18
21
|
TSUSDE_MAINNET,
|
|
19
22
|
USDE_MAINNET,
|
|
@@ -34,6 +37,7 @@ import {
|
|
|
34
37
|
EVAA_REWARDS_MASTER_TESTNET,
|
|
35
38
|
EVAA_REWARDS_USER_CODE_MAINNET,
|
|
36
39
|
EVAA_REWARDS_USER_CODE_TESTNET,
|
|
40
|
+
EVAA_STABLE_MAINNET,
|
|
37
41
|
EVAA_TON_REWARDS_MASTER_MAINNET,
|
|
38
42
|
EVAA_USDT_REWARDS_MASTER_MAINNET,
|
|
39
43
|
LENDING_CODE,
|
|
@@ -43,6 +47,7 @@ import {
|
|
|
43
47
|
ORACLES_LP,
|
|
44
48
|
ORACLES_MAINNET,
|
|
45
49
|
ORACLES_TESTNET,
|
|
50
|
+
STABLE_VERSION,
|
|
46
51
|
TESTNET_VERSION,
|
|
47
52
|
} from './general';
|
|
48
53
|
|
|
@@ -66,6 +71,21 @@ export const MAINNET_POOL_CONFIG: PoolConfig = {
|
|
|
66
71
|
lendingCode: LENDING_CODE,
|
|
67
72
|
};
|
|
68
73
|
|
|
74
|
+
export const MAINNET_STABLE_POOL_CONFIG: PoolConfig = {
|
|
75
|
+
masterAddress: EVAA_STABLE_MAINNET,
|
|
76
|
+
masterVersion: STABLE_VERSION,
|
|
77
|
+
masterConstants: MASTER_CONSTANTS,
|
|
78
|
+
oracles: ORACLES_MAINNET,
|
|
79
|
+
minimalOracles: 3,
|
|
80
|
+
poolAssetsConfig: [
|
|
81
|
+
USDT_MAINNET,
|
|
82
|
+
USDE_MAINNET,
|
|
83
|
+
TSUSDE_MAINNET,
|
|
84
|
+
PT_tsUSDe_01Sep2025_MAINNET
|
|
85
|
+
],
|
|
86
|
+
lendingCode: LENDING_CODE,
|
|
87
|
+
};
|
|
88
|
+
|
|
69
89
|
export const MAINNET_TEST_ETHENA_POOL_CONFIG: PoolConfig = {
|
|
70
90
|
masterAddress: EVAA_ETHENA_MAINNET,
|
|
71
91
|
masterVersion: EVAA_ETHENA_VERSION,
|
|
@@ -95,7 +115,7 @@ export const MAINNET_LP_POOL_CONFIG: PoolConfig = {
|
|
|
95
115
|
masterConstants: MASTER_CONSTANTS,
|
|
96
116
|
oracles: ORACLES_LP,
|
|
97
117
|
minimalOracles: 3,
|
|
98
|
-
poolAssetsConfig: [TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET],
|
|
118
|
+
poolAssetsConfig: [TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET, TONUSDT_STONFI_MAINNET],
|
|
99
119
|
lendingCode: LENDING_CODE,
|
|
100
120
|
};
|
|
101
121
|
|
|
@@ -105,7 +125,7 @@ export const MAINNET_ALTS_POOL_CONFIG: PoolConfig = {
|
|
|
105
125
|
masterConstants: MASTER_CONSTANTS,
|
|
106
126
|
oracles: ORACLES_ALTS,
|
|
107
127
|
minimalOracles: 3,
|
|
108
|
-
poolAssetsConfig: [TON_MAINNET, USDT_MAINNET, CATI_MAINNET, NOT_MAINNET, DOGS_MAINNET],
|
|
128
|
+
poolAssetsConfig: [TON_MAINNET, USDT_MAINNET, CATI_MAINNET, NOT_MAINNET, DOGS_MAINNET/*, STON_MAINNET announce*/],
|
|
109
129
|
lendingCode: LENDING_CODE,
|
|
110
130
|
};
|
|
111
131
|
|
|
@@ -148,3 +168,10 @@ export const MAINNET_MASTER_USDT_REWARD_CONFIG: EvaaRewardsConfig = {
|
|
|
148
168
|
availableReward: 0,
|
|
149
169
|
publicKey: Buffer.from('9813725d6cead1c9bbc0e24b21d4fc62a7fa8ac4bb01b6758df30169a71dba67', 'hex'), // adminAddress publicKey
|
|
150
170
|
};
|
|
171
|
+
|
|
172
|
+
export const ALL_MAINNET_POOLS: PoolConfig[] = [
|
|
173
|
+
MAINNET_POOL_CONFIG,
|
|
174
|
+
MAINNET_LP_POOL_CONFIG,
|
|
175
|
+
MAINNET_ALTS_POOL_CONFIG,
|
|
176
|
+
MAINNET_STABLE_POOL_CONFIG,
|
|
177
|
+
];
|
package/src/index.ts
CHANGED
|
@@ -99,54 +99,9 @@ export {
|
|
|
99
99
|
} from './types/User';
|
|
100
100
|
|
|
101
101
|
// Constants
|
|
102
|
-
export
|
|
103
|
-
EVAA_MASTER_MAINNET,
|
|
104
|
-
MAINNET_VERSION,
|
|
105
|
-
EVAA_MASTER_TESTNET,
|
|
106
|
-
TESTNET_VERSION,
|
|
107
|
-
LENDING_CODE,
|
|
108
|
-
OPCODES,
|
|
109
|
-
FEES,
|
|
110
|
-
MASTER_CONSTANTS,
|
|
111
|
-
EVAA_REWARDS_MASTER_TESTNET,
|
|
112
|
-
EVAA_REWARDS_MASTER_CODE_TESTNET,
|
|
113
|
-
EVAA_REWARDS_USER_CODE_TESTNET,
|
|
114
|
-
EVAA_REWARDS_MASTER_CODE_MAINNET,
|
|
115
|
-
EVAA_REWARDS_USER_CODE_MAINNET,
|
|
116
|
-
} from './constants/general';
|
|
117
|
-
|
|
118
|
-
export {
|
|
119
|
-
MAINNET_POOL_CONFIG,
|
|
120
|
-
TESTNET_POOL_CONFIG,
|
|
121
|
-
MAINNET_LP_POOL_CONFIG,
|
|
122
|
-
MAINNET_ALTS_POOL_CONFIG,
|
|
123
|
-
MAINNET_TEST_ETHENA_POOL_CONFIG,
|
|
124
|
-
// Reward Pools
|
|
125
|
-
TESTNET_MASTER_REWARD_CONFIG,
|
|
126
|
-
MAINNET_MASTER_TON_REWARD_CONFIG,
|
|
127
|
-
MAINNET_MASTER_USDT_REWARD_CONFIG,
|
|
128
|
-
} from './constants/pools';
|
|
102
|
+
export * from './constants/general';
|
|
129
103
|
|
|
130
|
-
export
|
|
131
|
-
ASSET_ID,
|
|
132
|
-
UNDEFINED_ASSET,
|
|
133
|
-
TON_MAINNET,
|
|
134
|
-
USDT_MAINNET,
|
|
135
|
-
TONUSDT_DEDUST_MAINNET,
|
|
136
|
-
TON_STORM_MAINNET,
|
|
137
|
-
USDT_STORM_MAINNET,
|
|
138
|
-
DOGS_MAINNET,
|
|
139
|
-
CATI_MAINNET,
|
|
140
|
-
UTON_MAINNET,
|
|
141
|
-
NOT_MAINNET,
|
|
142
|
-
JUSDT_MAINNET,
|
|
143
|
-
JUSDC_MAINNET,
|
|
144
|
-
STTON_MAINNET,
|
|
145
|
-
TSTON_MAINNET,
|
|
146
|
-
JUSDT_TESTNET,
|
|
147
|
-
JUSDC_TESTNET,
|
|
148
|
-
STTON_TESTNET
|
|
149
|
-
} from './constants/assets';
|
|
104
|
+
export * from './constants/pools';
|
|
150
105
|
|
|
151
106
|
export * from './constants/assets';
|
|
152
107
|
export * from './utils/utils';
|
|
@@ -99,13 +99,20 @@ export class PricesCollector {
|
|
|
99
99
|
pricesFiltered = newerPrices.sort((a, b) => a.oracleId - b.oracleId);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const medianData = assets.map(asset => ({
|
|
102
|
+
const medianData = assets.map((asset) => ({
|
|
103
|
+
assetId: asset.assetId,
|
|
104
|
+
medianPrice: getMedianPrice(pricesFiltered, asset.assetId),
|
|
105
|
+
}));
|
|
103
106
|
|
|
104
107
|
const nonEmptymedianData = medianData.filter(x => x.medianPrice != null) as { assetId: bigint, medianPrice: bigint }[];
|
|
105
108
|
|
|
106
109
|
const packedMedianData = packAssetsData(nonEmptymedianData);
|
|
107
110
|
|
|
108
|
-
const oraclesData =
|
|
111
|
+
const oraclesData = pricesFiltered.map((x) => ({
|
|
112
|
+
oracle: { id: x.oracleId, pubkey: x.pubkey },
|
|
113
|
+
data: { timestamp: x.timestamp, prices: x.dict },
|
|
114
|
+
signature: x.signature,
|
|
115
|
+
}));
|
|
109
116
|
const packedOracleData = packOraclesData(oraclesData, nonEmptymedianData.map(x => x.assetId));
|
|
110
117
|
|
|
111
118
|
const dict = Dictionary.empty<bigint, bigint>();
|
package/src/prices/Types.ts
CHANGED
|
@@ -7,9 +7,6 @@ export type PriceSourcesConfig = {
|
|
|
7
7
|
/** Endpoints for backend price data */
|
|
8
8
|
backendEndpoints: string[];
|
|
9
9
|
|
|
10
|
-
/** Endpoints for IOTA price data */
|
|
11
|
-
iotaEndpoints: string[];
|
|
12
|
-
|
|
13
10
|
/** Endpoints for ICP price data */
|
|
14
11
|
icpEndpoints: string[];
|
|
15
12
|
};
|
|
@@ -18,8 +15,7 @@ export type PriceSourcesConfig = {
|
|
|
18
15
|
* Default configuration for price source endpoints.
|
|
19
16
|
*/
|
|
20
17
|
export const DefaultPriceSourcesConfig: PriceSourcesConfig = {
|
|
21
|
-
backendEndpoints: ['evaa.space'],
|
|
22
|
-
iotaEndpoints: ['api.stardust-mainnet.iotaledger.net'],
|
|
18
|
+
backendEndpoints: ['api.evaa.space', 'evaa.space'],
|
|
23
19
|
icpEndpoints: ['6khmc-aiaaa-aaaap-ansfq-cai.raw.icp0.io'],
|
|
24
20
|
}
|
|
25
21
|
|
package/src/prices/utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { beginCell, Cell, Dictionary, Slice } from "@ton/core"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { beginCell, Cell, Dictionary, Slice } from "@ton/core"
|
|
2
|
+
import { signVerify } from "@ton/crypto"
|
|
3
|
+
import { BackendPriceSource, DefaultPriceSourcesConfig, IcpPriceSource, MAINNET_POOL_CONFIG, OraclePricesData, PriceData, PriceSource, PriceSourcesConfig, RawPriceData, TTL_ORACLE_DATA_SEC } from ".."
|
|
4
|
+
import { Oracle, OracleNFT, PoolConfig } from "../types/Master"
|
|
5
|
+
import { convertToMerkleProof, generateMerkleProofDirect } from "../utils/merkleProof"
|
|
6
6
|
|
|
7
7
|
export function verifyPricesTimestamp() {
|
|
8
8
|
return function(priceData: RawPriceData): boolean {
|
|
@@ -119,7 +119,6 @@ export function generatePriceSources(config: PriceSourcesConfig = DefaultPriceSo
|
|
|
119
119
|
let result: PriceSource[] = config.backendEndpoints.map(x => new BackendPriceSource(x, nfts));
|
|
120
120
|
|
|
121
121
|
result.push(...config.icpEndpoints.map(x => new IcpPriceSource(x, nfts)));
|
|
122
|
-
result.push(...config.iotaEndpoints.map(x => new IotaPriceSource(x, nfts)));
|
|
123
122
|
|
|
124
123
|
return result;
|
|
125
124
|
}
|
|
@@ -22,6 +22,12 @@ function getUserJettonData(ownerAddress: Address, assetName: string, jettonWalle
|
|
|
22
22
|
.storeAddress(ownerAddress)
|
|
23
23
|
.storeAddress(jettonMasterAddress)
|
|
24
24
|
.endCell();
|
|
25
|
+
case 'PT_tsUSDe_01Sep2025':
|
|
26
|
+
return beginCell()
|
|
27
|
+
.storeCoins(0)
|
|
28
|
+
.storeAddress(ownerAddress)
|
|
29
|
+
.storeAddress(jettonMasterAddress)
|
|
30
|
+
.endCell();
|
|
25
31
|
case 'tsUSDe':
|
|
26
32
|
return beginCell()
|
|
27
33
|
.storeUint(0, 4)
|
package/CHANGELOG.md
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
|
|
4
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/)
|
|
5
|
-
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
-
|
|
7
|
-
## 0.6.3-b — 2025-04-30
|
|
8
|
-
### Added
|
|
9
|
-
- ```USDe and tsUSDe``` new tokens in Main ```PoolConfig```
|
|
10
|
-
- Minor bug fixes
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## 0.6.3 — 2025-04-01
|
|
14
|
-
### Added
|
|
15
|
-
- ```EvaaRewards``` wrapper of RewardUser contract with ```PoolAssetConfig```
|
|
16
|
-
- ```RewardUser``` wrapper of reward user contract
|
|
17
|
-
- ```RewardMaster``` wrapper of reward master contract
|
|
18
|
-
- ```JettonMinget``` wrapper of jetton master contract
|
|
19
|
-
- ```JettonWallet``` wrapper of jetton wallet contract
|
|
20
|
-
- ```EVAA_REWARDS_MASTER_CODE_MAINNET``` and ```EVAA_REWARDS_MASTER_CODE_TESTNET``` is constants for reward master code
|
|
21
|
-
- ```EVAA_REWARDS_USER_CODE_TESTNET``` and ```EVAA_REWARDS_USER_CODE_MAINNET``` is constants for reward user code
|
|
22
|
-
- ```TESTNET_MASTER_REWARD_CONFIG``` testnet TON config of reward
|
|
23
|
-
- ```TESTNET_MASTER_EUSDT_REWARD_CONFIG``` testnet EUSDT config of reward
|
|
24
|
-
- ```MAINNET_MASTER_TON_REWARD_CONFIG``` mainnet TON config of reward
|
|
25
|
-
- ```MAINNET_MASTER_USDT_REWARD_CONFIG``` mainnet USDT config of reward
|
|
26
|
-
|
|
27
|
-
## 0.6.2-c — 2025-01-07
|
|
28
|
-
### Added
|
|
29
|
-
- ```getAssetLiquidityMinusReserves``` function needed to count the amount of free amount for withdrawal
|
|
30
|
-
### Fixed
|
|
31
|
-
- ```borrowLimits``` function now take into account the amount available for withdrawal
|
|
32
|
-
|
|
33
|
-
## 0.6.2-b — 2024-12-17
|
|
34
|
-
### Added
|
|
35
|
-
- new field in ```UserLiteData``` . ```fullyParsed``` and ```havePrincipalWithoutPrice```
|
|
36
|
-
true if all prices for user parsing were provided or true if have a principal without price
|
|
37
|
-
now user.getSync and parseUserData can work without some prices
|
|
38
|
-
- ```predictAPY``` - function that predicts a change in apy after supply or withdraw
|
|
39
|
-
|
|
40
|
-
## 0.6.2-a — 2024-12-13
|
|
41
|
-
### Added
|
|
42
|
-
- new field in UserLiteData ```user.data.realPrincipals``` -
|
|
43
|
-
principals before applying dusts
|
|
44
|
-
### Fixed
|
|
45
|
-
- getPricesForWithdraw/getPricesForLiquidate they should now be called with a different argument
|
|
46
|
-
|
|
47
|
-
## 0.6.2 — 2024-11-21
|
|
48
|
-
### Added
|
|
49
|
-
- ALTS Pool
|
|
50
|
-
- PricesCollector class
|
|
51
|
-
- Supports multiple prices sources [iota nft, evaa backend, internetcomputer (icp) http backend] (sources can be configured)
|
|
52
|
-
- Updates prices only when needed, prices may expire no earlier than a minute later
|
|
53
|
-
- Ability to cut prices and resign it and send only the necessary ones in order to reduce fee
|
|
54
|
-
- ```typescript
|
|
55
|
-
async getPricesForWithdraw(userPrincipals: Dictionary<bigint, bigint>, withdrawAsset: PoolAssetConfig, collateralToDebt = false, ....)
|
|
56
|
-
```
|
|
57
|
-
collateralToDebt param responsible for the fact that supply can go to borrow (there is no such case at the front end)
|
|
58
|
-
- ```typescript
|
|
59
|
-
async getPricesForLiquidate(userPrincipals: Dictionary<bigint, bigint> ...)
|
|
60
|
-
```
|
|
61
|
-
- Price Signature Vrification
|
|
62
|
-
- Minimal Oracles Number Verification
|
|
63
|
-
- Independent and parallel loading of prices (now the fastest but invalid response won't break anything)
|
|
64
|
-
- Support for partial number of assets from price sources
|
|
65
|
-
- Updated examples in docs/examples
|
|
66
|
-
- PricesCollector test coverage
|
|
67
|
-
- If the price is missing (for example, for security reasons), then there will be no error, it will simply NOT be added to the result dict
|
|
68
|
-
|
|
69
|
-
### Changed
|
|
70
|
-
- getPrices is deprecated use PricesCollector instead
|
|
71
|
-
|
|
72
|
-
## 0.6.1-a — 2024-10-29
|
|
73
|
-
### Changed
|
|
74
|
-
- updated `EVAA_LP_MAINNET_VERSION` to `3`
|
|
75
|
-
- `awaitedSupply` is always defined
|
|
76
|
-
### Fixed
|
|
77
|
-
- `applyDust` is `false` by default in `parseUserLiteData` and `parseUserData`
|
|
78
|
-
- `minimalOracles` is `3` in all pools
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
## 0.6.1 — 2024-10-22
|
|
82
|
-
### Changed
|
|
83
|
-
- added liquidation.ts with ```findAssetById```, ```calculateAssetsValues```, ```selectGreatestAssets```, ```calculateMinCollateralByTransferredAmount```, ```calculateLiquidationAmounts```, ```isLiquidatable```, ```isBadDebt```, ```addReserve```, ```deductReserve```, ```toAssetAmount```, ```toAssetWorth```, ```addLiquidationBonus```, ```deductLiquidationBonus```, ```PreparedAssetInfo```, ```prepareAssetInfo``` functions required or flexible liquidations calculation.
|
|
84
|
-
- user. ```getSync``` and ```getSyncLite``` new argument ```applyDust``` by default is ```false```;
|
|
85
|
-
- updated sdk usage example
|
|
86
|
-
### Fixed
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## 0.6.0a — 2024-10-14
|
|
90
|
-
### Changed
|
|
91
|
-
- user. ```getSync``` and ```getSyncLite``` new argument ```applyDust``` by default is ```false```
|
|
92
|
-
### Fixed
|
|
93
|
-
- Healthfactor calculation minor bug
|
|
94
|
-
- createLiquidationMessage fix new field payloadForwardAmount
|
|
95
|
-
|
|
96
|
-
## 0.6.0 — 2024-10-10
|
|
97
|
-
### Added
|
|
98
|
-
- SDK Supports Evaa v6 smart contracts
|
|
99
|
-
### Fixed
|
|
100
|
-
- Updated documentation and examples for v6 interactions
|
|
101
|
-
- User Withdrawal and Borrow limits
|
|
102
|
-
## 0.5.6a - 2024-10-09
|
|
103
|
-
### Fixed
|
|
104
|
-
- Fix typo in ```calculateMaximumWithdrawAmount```
|
|
105
|
-
|
|
106
|
-
## 0.5.6 — 2024-09-28
|
|
107
|
-
|
|
108
|
-
### Added
|
|
109
|
-
- ```isTonAsset(PoolAssetConfig)``` function
|
|
110
|
-
### Fixed
|
|
111
|
-
Dust is a small amount of principal that is ignored
|
|
112
|
-
- ```parseUserLiteData``` (dust) & ```parseUserData``` (dust and withdrawLimits) calculations problem
|
|
113
|
-
- ```user.data.withdrawalLimits```, ```user.data.balance```, ```user.data.principals``` calculation for LP pool contract and main pool contract
|
|
114
|
-
### Changed
|
|
115
|
-
- ```parseUserLiteData``` (without prices), ```parseUserData``` applyDust argument default value changed to ```True```
|
|
116
|
-
- Many composite types were removed from sdk
|
|
117
|
-
- ```PoolTonAssetConfig, PoolJettonAssetConfig``` -> ```PoolAssetConfig```,
|
|
118
|
-
- ```JettonMessageParameters, SupplyBaseParameters, TonSupplyParameters, JettonSupplyParameters``` -> ```SupplyParameters```,
|
|
119
|
-
- ```LiquidationBasePrameters, TonLiquidationParameters, JettonLiquidationParameters``` -> ```LiquidationParameters```
|
|
120
|
-
|
|
121
|
-
## 0.5.5
|
|
122
|
-
|
|
123
|
-
### Added
|
|
124
|
-
- calculateMaximumWithdrawAmount function
|
|
125
|
-
### Fixed
|
|
126
|
-
- parseUserLiteData (dust) & parseUserData (dust and withdrawLimits) calculations problem
|
|
127
|
-
|
|
128
|
-
## 0.5.4 — 2024-09-09
|
|
129
|
-
|
|
130
|
-
check ```tests\supply_withdraw_test.ts``` for new examples
|
|
131
|
-
|
|
132
|
-
### Added
|
|
133
|
-
|
|
134
|
-
- Pools supports (new argument for Evaa master contract) + LP_POOL constants, default is MAINNET_POOL_CONFIG, default pool is MAINNET_POOL_CONFIG
|
|
135
|
-
```typescript
|
|
136
|
-
const evaa = client.open(new Evaa({poolConfig: TESTNET_LP_POOL_CONFIG}));
|
|
137
|
-
|
|
138
|
-
const evaaMainNet = clientMainNet.open(new Evaa({poolConfig: MAINNET_LP_POOL_CONFIG}));
|
|
139
|
-
```
|
|
140
|
-
- New types for pools initializtion, for assets
|
|
141
|
-
check ```constants\assets.ts``` for new examples
|
|
142
|
-
|
|
143
|
-
- getPrices - a new function inside Evaa, returns prices of current pool
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
await evaaMainNet.getPrices()
|
|
147
|
-
```
|
|
148
|
-
### Changed
|
|
149
|
-
- New argument nftId (depends on pool) for getPrices
|
|
150
|
-
```typescript
|
|
151
|
-
export async function getPrices(endpoints: string[] = ["api.stardust-mainnet.iotaledger.net"], nftId: string = MAIN_POOL_NFT_ID) {
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
- Everything about working with assets, new assets list
|
|
155
|
-
```typescript
|
|
156
|
-
import { JUSDC_MAINNET, JUSDC_TESTNET, JUSDT_MAINNET, JUSDT_TESTNET, STTON_MAINNET, STTON_TESTNET, TON_MAINNET, TON_STORM_MAINNET, TONUSDT_DEDUST_MAINNET, TSTON_MAINNET, USDT_MAINNET, USDT_STORM_MAINNET } from "@evaafi/sdk";
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
await evaaMainNet.sendSupply(sender_mainnet, toNano(1), {
|
|
161
|
-
queryID: 0n,
|
|
162
|
-
includeUserCode: true,
|
|
163
|
-
amount: 500_000_000n,
|
|
164
|
-
userAddress: address_mainnet,
|
|
165
|
-
asset: TON_MAINNET
|
|
166
|
-
});
|
|
167
|
-
```
|
|
168
|
-
### Fixed
|
|
169
|
-
- predictHealthFactor minor fixes
|
|
170
|
-
- getUserJettonWallet all currencies support
|
|
171
|
-
|
|
172
|
-
## 0.5.3 — 2024-08-20
|
|
173
|
-
|
|
174
|
-
### Fixed
|
|
175
|
-
- getPrices now supports several endpoints (works on the principle of which one will answer faster, whose answer is used) and throws an exception if prices are not loaded
|
|
176
|
-
|
|
177
|
-
## 0.5.2 — 2024-08-19
|
|
178
|
-
|
|
179
|
-
### Fixed
|
|
180
|
-
- predictHealthFactor argument processing improving
|
|
181
|
-
- getSync fixed parsing contract state, base64url was replaced to base64 encoding which has much higher support
|
|
182
|
-
|
|
183
|
-
## 0.5.1 — 2024-07-05
|
|
184
|
-
|
|
185
|
-
### Added
|
|
186
|
-
- predictHealthFactor function to predict a change in a health factor after repay, borrow, supply, withdraw
|
|
187
|
-
|
|
188
|
-
## 0.5.0 — 2024-06-29
|
|
189
|
-
This release contains breaking changes.
|
|
190
|
-
|
|
191
|
-
### Added
|
|
192
|
-
- Reserve variables parsing on user & master sc
|
|
193
|
-
- Added endpoint argument for getPrices, default api.stardust-mainnet.iotaledger.net
|
|
194
|
-
- Added applyDust (default false) option in parseUserLiteData and parseUserData
|
|
195
|
-
|
|
196
|
-
### Changed
|
|
197
|
-
- Master contracts' version
|
|
198
|
-
- Testnet master contract address
|
|
199
|
-
- Parsers on master sc
|
|
200
|
-
- Parsers on user sc
|
|
201
|
-
- Liquidation calculations now counts with reserve factor from master config
|
|
202
|
-
|
|
203
|
-
### Fixed
|
|
204
|
-
- UserBalance calculation was fixed
|
|
205
|
-
|
|
206
|
-
## 0.4.0 — 2024-06-01
|
|
207
|
-
This release contains breaking changes.
|
|
208
|
-
|
|
209
|
-
### Added
|
|
210
|
-
- Master storage onchain getter
|
|
211
|
-
- User storage onchain getter
|
|
212
|
-
- Testnet flag for `parseMasterData`, `parseUserData` and `parseUserLiteData` functions
|
|
213
|
-
- `maxTotalSupply` field to Assets Config
|
|
214
|
-
- Seperate Assets ID for Mainnet and Testnet
|
|
215
|
-
|
|
216
|
-
### Changed
|
|
217
|
-
- Master contracts' version
|
|
218
|
-
- Testnet master contract address
|
|
219
|
-
|
|
220
|
-
### Removed
|
|
221
|
-
- `ASSET_ID` constant
|
|
222
|
-
|
|
223
|
-
### Fixed
|
|
224
|
-
- Jetton wallets address calculation
|
|
225
|
-
- Field names in Assets Config and Assets Data serialization functions
|
|
226
|
-
|
|
227
|
-
## 0.3.2 — 2024-04-20
|
|
228
|
-
### Added
|
|
229
|
-
- New asset - Tether USD
|
|
230
|
-
|
|
231
|
-
## 0.3.1 — 2024-04-19
|
|
232
|
-
### Added
|
|
233
|
-
- New asset - tsTON
|
|
234
|
-
|
|
235
|
-
## 0.3.0 — 2024-04-04
|
|
236
|
-
### Added
|
|
237
|
-
- New asset - stTON
|
|
238
|
-
|
|
239
|
-
### Changed
|
|
240
|
-
- Price fetching from another source
|
|
241
|
-
- Testnet master contract address
|
|
242
|
-
- Master contracts' version
|
|
243
|
-
|
|
244
|
-
### Removed
|
|
245
|
-
- Ethereum dependencies
|
|
246
|
-
|
|
247
|
-
## 0.2.0 — 2024-03-13
|
|
248
|
-
This release contains breaking changes.
|
|
249
|
-
|
|
250
|
-
### Added
|
|
251
|
-
- BOC of last sent message via TonConnect. Can be obtained by `getLastSentBoc` function
|
|
252
|
-
- Calculation of user's health factor
|
|
253
|
-
|
|
254
|
-
### Changed
|
|
255
|
-
- Testnet master contract address and version
|
|
256
|
-
- Supply fee from 0.5 TON to 0.3 TON
|
|
257
|
-
- APY moved from user data to master data
|
|
258
|
-
|
|
259
|
-
### Removed
|
|
260
|
-
- Description of some methods in `UserContract` and `MasterContract`
|
|
261
|
-
|
|
262
|
-
### Fixed
|
|
263
|
-
- Calculation of borrow limits
|
|
264
|
-
|
|
265
|
-
## 0.1.0 — 2024-03-11
|
|
266
|
-
### Added
|
|
267
|
-
- Parsing user lite data, which does not require prices
|
|
268
|
-
- Assets reserves to `MasterData`
|
|
269
|
-
- Types and methods descriptions in `MasterContract` and `UserContract`
|
|
270
|
-
|
|
271
|
-
### Changed
|
|
272
|
-
- Added parallel price fetching
|
|
273
|
-
- Crypto library to 'crypto-js' for compatibility with browser
|
|
274
|
-
- Testnet Master version to 2
|
|
275
|
-
|
|
276
|
-
### Removed
|
|
277
|
-
- `sort-deep-object-arrays` dependency
|
|
278
|
-
|
|
279
|
-
### Fixed
|
|
280
|
-
- Getting user's jetton wallet
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { PriceSource } from "./PriceSource";
|
|
2
|
-
import { RawPriceData } from "..";
|
|
3
|
-
export declare class IotaPriceSource extends PriceSource {
|
|
4
|
-
protected priceSourceName: string;
|
|
5
|
-
getPrices(): Promise<RawPriceData[]>;
|
|
6
|
-
loadOracleData(oracleNftId: String): Promise<OutputData>;
|
|
7
|
-
parsePrices(outputData: OutputData, oracleId: number): RawPriceData;
|
|
8
|
-
}
|
|
9
|
-
type OutputData = {
|
|
10
|
-
metadata: {
|
|
11
|
-
blockId: string;
|
|
12
|
-
transactionId: string;
|
|
13
|
-
outputIndex: number;
|
|
14
|
-
isSpent: boolean;
|
|
15
|
-
milestoneIndexSpent: number;
|
|
16
|
-
milestoneTimestampSpent: number;
|
|
17
|
-
transactionIdSpent: string;
|
|
18
|
-
milestoneIndexBooked: number;
|
|
19
|
-
milestoneTimestampBooked: number;
|
|
20
|
-
ledgerIndex: number;
|
|
21
|
-
};
|
|
22
|
-
output: {
|
|
23
|
-
type: number;
|
|
24
|
-
amount: string;
|
|
25
|
-
nftId: string;
|
|
26
|
-
unlockConditions: {
|
|
27
|
-
type: number;
|
|
28
|
-
address: {
|
|
29
|
-
type: number;
|
|
30
|
-
pubKeyHash: string;
|
|
31
|
-
};
|
|
32
|
-
}[];
|
|
33
|
-
features: {
|
|
34
|
-
type: number;
|
|
35
|
-
data: string;
|
|
36
|
-
}[];
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IotaPriceSource = void 0;
|
|
4
|
-
const core_1 = require("@ton/core");
|
|
5
|
-
const PriceSource_1 = require("./PriceSource");
|
|
6
|
-
class IotaPriceSource extends PriceSource_1.PriceSource {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.priceSourceName = 'IotaPriceSource';
|
|
10
|
-
}
|
|
11
|
-
async getPrices() {
|
|
12
|
-
return await Promise.all(this.nfts.map(nft => this.loadOracleData(nft.address)
|
|
13
|
-
.then(x => this.parsePrices(x, nft.id))));
|
|
14
|
-
}
|
|
15
|
-
async loadOracleData(oracleNftId) {
|
|
16
|
-
let result = await fetch(`https://${this._endpoint}/api/indexer/v1/outputs/nft/${oracleNftId}`, {
|
|
17
|
-
headers: { accept: 'application/json' },
|
|
18
|
-
signal: AbortSignal.timeout(5000)
|
|
19
|
-
});
|
|
20
|
-
let outputId = (await result.json());
|
|
21
|
-
result = await fetch(`https://${this._endpoint}/api/core/v2/outputs/${outputId.items[0]}`, {
|
|
22
|
-
headers: { accept: 'application/json' },
|
|
23
|
-
signal: AbortSignal.timeout(5000)
|
|
24
|
-
});
|
|
25
|
-
return await result.json();
|
|
26
|
-
}
|
|
27
|
-
parsePrices(outputData, oracleId) {
|
|
28
|
-
const data = JSON.parse(decodeURIComponent(outputData.output.features[0].data.replace('0x', '').replace(/[0-9a-f]{2}/g, '%$&')));
|
|
29
|
-
try {
|
|
30
|
-
const pricesCell = core_1.Cell.fromBoc(Buffer.from(data['packedPrices'], 'hex'))[0];
|
|
31
|
-
const signature = Buffer.from(data['signature'], 'hex');
|
|
32
|
-
const publicKey = Buffer.from(data['publicKey'], 'hex');
|
|
33
|
-
const timestamp = Number(data['timestamp']);
|
|
34
|
-
return {
|
|
35
|
-
dict: pricesCell.beginParse().loadRef().beginParse().loadDictDirect(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigVarUint(4)),
|
|
36
|
-
dataCell: (0, core_1.beginCell)().storeRef(pricesCell).storeBuffer(signature).endCell(),
|
|
37
|
-
oracleId: oracleId,
|
|
38
|
-
signature: signature,
|
|
39
|
-
pubkey: publicKey,
|
|
40
|
-
timestamp: timestamp,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
//console.debug(`Price source error ${this.priceSourceName} ${outputData} ${error}`);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.IotaPriceSource = IotaPriceSource;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { beginCell, Cell, Dictionary } from "@ton/core";
|
|
2
|
-
import { PriceSource } from "./PriceSource";
|
|
3
|
-
import { RawPriceData } from "..";
|
|
4
|
-
|
|
5
|
-
export class IotaPriceSource extends PriceSource {
|
|
6
|
-
protected priceSourceName: string = 'IotaPriceSource';
|
|
7
|
-
|
|
8
|
-
async getPrices(): Promise<RawPriceData[]> {
|
|
9
|
-
return await Promise.all(this.nfts.map(nft => this.loadOracleData(nft.address)
|
|
10
|
-
.then(x => this.parsePrices(x, nft.id))));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async loadOracleData(oracleNftId: String): Promise<OutputData> {
|
|
14
|
-
let result = await fetch(`https://${this._endpoint}/api/indexer/v1/outputs/nft/${oracleNftId}`, {
|
|
15
|
-
headers: { accept: 'application/json' },
|
|
16
|
-
signal: AbortSignal.timeout(5000)
|
|
17
|
-
});
|
|
18
|
-
let outputId = (await result.json()) as NftData;
|
|
19
|
-
|
|
20
|
-
result = await fetch(`https://${this._endpoint}/api/core/v2/outputs/${outputId.items[0]}`, {
|
|
21
|
-
headers: { accept: 'application/json' },
|
|
22
|
-
signal: AbortSignal.timeout(5000)
|
|
23
|
-
});
|
|
24
|
-
return (await result.json() as OutputData);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
parsePrices(outputData: OutputData, oracleId: number): RawPriceData {
|
|
29
|
-
const data = JSON.parse(
|
|
30
|
-
decodeURIComponent(outputData.output.features[0].data.replace('0x', '').replace(/[0-9a-f]{2}/g, '%$&')),
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const pricesCell = Cell.fromBoc(Buffer.from(data['packedPrices'], 'hex'))[0];
|
|
35
|
-
const signature = Buffer.from(data['signature'], 'hex');
|
|
36
|
-
const publicKey = Buffer.from(data['publicKey'], 'hex');
|
|
37
|
-
const timestamp = Number(data['timestamp']);
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
dict: pricesCell.beginParse().loadRef().beginParse().loadDictDirect(Dictionary.Keys.BigUint(256), Dictionary.Values.BigVarUint(4)),
|
|
41
|
-
dataCell: beginCell().storeRef(pricesCell).storeBuffer(signature).endCell(),
|
|
42
|
-
oracleId: oracleId,
|
|
43
|
-
signature: signature,
|
|
44
|
-
pubkey: publicKey,
|
|
45
|
-
timestamp: timestamp,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
//console.debug(`Price source error ${this.priceSourceName} ${outputData} ${error}`);
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type NftData = {
|
|
56
|
-
ledgerIndex: number;
|
|
57
|
-
pageSize: number;
|
|
58
|
-
items: string[];
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
type OutputData = {
|
|
62
|
-
metadata: {
|
|
63
|
-
blockId: string;
|
|
64
|
-
transactionId: string;
|
|
65
|
-
outputIndex: number;
|
|
66
|
-
isSpent: boolean;
|
|
67
|
-
milestoneIndexSpent: number;
|
|
68
|
-
milestoneTimestampSpent: number;
|
|
69
|
-
transactionIdSpent: string;
|
|
70
|
-
milestoneIndexBooked: number;
|
|
71
|
-
milestoneTimestampBooked: number;
|
|
72
|
-
ledgerIndex: number;
|
|
73
|
-
};
|
|
74
|
-
output: {
|
|
75
|
-
type: number;
|
|
76
|
-
amount: string;
|
|
77
|
-
nftId: string;
|
|
78
|
-
unlockConditions: {
|
|
79
|
-
type: number;
|
|
80
|
-
address: {
|
|
81
|
-
type: number;
|
|
82
|
-
pubKeyHash: string;
|
|
83
|
-
};
|
|
84
|
-
}[];
|
|
85
|
-
features: {
|
|
86
|
-
type: number;
|
|
87
|
-
data: string;
|
|
88
|
-
}[];
|
|
89
|
-
};
|
|
90
|
-
};
|