@evaafi/sdk 0.9.5 → 0.9.7
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.d.ts +16 -3
- package/dist/api/math.js +356 -33
- package/dist/api/parser.js +34 -12
- package/dist/constants/assets/assetId.d.ts +2 -0
- package/dist/constants/assets/assetId.js +3 -0
- package/dist/constants/assets/mainnet.d.ts +2 -0
- package/dist/constants/assets/mainnet.js +13 -1
- package/dist/constants/general/mainnet.d.ts +2 -0
- package/dist/constants/general/mainnet.js +4 -1
- package/dist/constants/pools/mainnet.d.ts +2 -0
- package/dist/constants/pools/mainnet.js +45 -1
- package/dist/constants/pools/testnet.d.ts +3 -2
- package/dist/constants/pools/testnet.js +16 -1
- package/dist/oracles/collectors/ClassicCollector.js +13 -18
- package/dist/oracles/collectors/FakeCollector.d.ts +30 -0
- package/dist/oracles/collectors/FakeCollector.js +128 -0
- package/dist/oracles/collectors/index.d.ts +1 -0
- package/dist/oracles/collectors/index.js +1 -0
- package/dist/types/Master.d.ts +8 -2
- package/dist/types/User.d.ts +7 -3
- package/package.json +1 -1
- package/src/api/math.ts +504 -40
- package/src/api/parser.ts +57 -12
- package/src/constants/assets/assetId.ts +4 -0
- package/src/constants/assets/mainnet.ts +24 -0
- package/src/constants/general/mainnet.ts +4 -0
- package/src/constants/pools/mainnet.ts +53 -1
- package/src/constants/pools/testnet.ts +30 -5
- package/src/oracles/collectors/ClassicCollector.ts +10 -14
- package/src/oracles/collectors/FakeCollector.ts +153 -0
- package/src/oracles/collectors/index.ts +1 -0
- package/src/types/Master.ts +9 -2
- package/src/types/User.ts +7 -3
|
@@ -19,3 +19,5 @@ export declare const PT_tsUSDe_18Dec2025_MAINNET: PoolAssetConfig;
|
|
|
19
19
|
export declare const TONUSDT_STONFI_MAINNET: PoolAssetConfig;
|
|
20
20
|
export declare const STON_MAINNET: PoolAssetConfig;
|
|
21
21
|
export declare const EVAA_MAINNET: PoolAssetConfig;
|
|
22
|
+
export declare const TUSDT_MAINNET: PoolAssetConfig;
|
|
23
|
+
export declare const TUSDE_MAINNET: PoolAssetConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EVAA_MAINNET = exports.STON_MAINNET = exports.TONUSDT_STONFI_MAINNET = exports.PT_tsUSDe_18Dec2025_MAINNET = exports.PT_tsUSDe_01Sep2025_MAINNET = exports.TSUSDE_MAINNET = exports.USDE_MAINNET = exports.NOT_MAINNET = exports.DOGS_MAINNET = exports.CATI_MAINNET = exports.USDT_STORM_MAINNET = exports.TON_STORM_MAINNET = exports.TONUSDT_DEDUST_MAINNET = exports.USDT_MAINNET = exports.TSTON_MAINNET = exports.STTON_MAINNET = exports.JUSDC_MAINNET = exports.JUSDT_MAINNET = exports.TON_MAINNET = exports.UNDEFINED_ASSET = void 0;
|
|
3
|
+
exports.TUSDE_MAINNET = exports.TUSDT_MAINNET = exports.EVAA_MAINNET = exports.STON_MAINNET = exports.TONUSDT_STONFI_MAINNET = exports.PT_tsUSDe_18Dec2025_MAINNET = exports.PT_tsUSDe_01Sep2025_MAINNET = exports.TSUSDE_MAINNET = exports.USDE_MAINNET = exports.NOT_MAINNET = exports.DOGS_MAINNET = exports.CATI_MAINNET = exports.USDT_STORM_MAINNET = exports.TON_STORM_MAINNET = exports.TONUSDT_DEDUST_MAINNET = exports.USDT_MAINNET = exports.TSTON_MAINNET = exports.STTON_MAINNET = exports.JUSDC_MAINNET = exports.JUSDT_MAINNET = exports.TON_MAINNET = exports.UNDEFINED_ASSET = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const general_1 = require("../general");
|
|
6
6
|
const assetId_1 = require("./assetId");
|
|
@@ -124,3 +124,15 @@ exports.EVAA_MAINNET = {
|
|
|
124
124
|
jettonMasterAddress: core_1.Address.parse('EQBKMfjX_a_dsOLm-juxyVZytFP7_KKnzGv6J01kGc72gVBp'),
|
|
125
125
|
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
126
126
|
};
|
|
127
|
+
exports.TUSDT_MAINNET = {
|
|
128
|
+
name: 'TUSDT',
|
|
129
|
+
assetId: assetId_1.ASSET_ID.TUSDT,
|
|
130
|
+
jettonMasterAddress: core_1.Address.parse('EQCA1saJX4oYdG38m1__Of6ym2GnKSGVuccAy6UU-ESeXjvb'),
|
|
131
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
132
|
+
};
|
|
133
|
+
exports.TUSDE_MAINNET = {
|
|
134
|
+
name: 'TUSDe',
|
|
135
|
+
assetId: assetId_1.ASSET_ID.TUSDe,
|
|
136
|
+
jettonMasterAddress: core_1.Address.parse('EQC2cewpgyIzP9o1gTSGsQceuY1nt3bjpilek7ARKyhWtQKk'),
|
|
137
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
138
|
+
};
|
|
@@ -4,6 +4,8 @@ export declare const EVAA_MASTER_MAINNET: Address;
|
|
|
4
4
|
export declare const MAINNET_VERSION = 10;
|
|
5
5
|
export declare const EVAA_LP_MAINNET: Address;
|
|
6
6
|
export declare const EVAA_LP_MAINNET_VERSION = 6;
|
|
7
|
+
export declare const EVAA_LP_COPY_MAINNET: Address;
|
|
8
|
+
export declare const EVAA_LP_COPY_MAINNET_VERSION = 0;
|
|
7
9
|
export declare const EVAA_ALTS_MAINNET: Address;
|
|
8
10
|
export declare const EVAA_ALTS_MAINNET_VERSION = 4;
|
|
9
11
|
export declare const EVAA_STABLE_MAINNET: Address;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EVAA_REWARDS_USER_CODE_MAINNET = exports.EVAA_REWARDS_MASTER_CODE_MAINNET = exports.JETTON_WALLET_STANDART_CODE = exports.LENDING_CODE = exports.ORACLES_ALTS = exports.ORACLES_LP = exports.PYTH_ORACLE_MAINNET = exports.ORACLES_MAINNET = exports.EVAA_EVAA_REWARDS_MASTER_MAINNET = exports.EVAA_TON_REWARDS_MASTER_MAINNET = exports.EVAA_USDT_REWARDS_MASTER_MAINNET = exports.EVAA_PYTH_TOB_VERSION = exports.EVAA_PYTH_TOB_MAINNET = exports.EVAA_TOB_VERSION = exports.EVAA_TOB_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.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = void 0;
|
|
3
|
+
exports.EVAA_REWARDS_USER_CODE_MAINNET = exports.EVAA_REWARDS_MASTER_CODE_MAINNET = exports.JETTON_WALLET_STANDART_CODE = exports.LENDING_CODE = exports.ORACLES_ALTS = exports.ORACLES_LP = exports.PYTH_ORACLE_MAINNET = exports.ORACLES_MAINNET = exports.EVAA_EVAA_REWARDS_MASTER_MAINNET = exports.EVAA_TON_REWARDS_MASTER_MAINNET = exports.EVAA_USDT_REWARDS_MASTER_MAINNET = exports.EVAA_PYTH_TOB_VERSION = exports.EVAA_PYTH_TOB_MAINNET = exports.EVAA_TOB_VERSION = exports.EVAA_TOB_MAINNET = exports.STABLE_VERSION = exports.EVAA_STABLE_MAINNET = exports.EVAA_ALTS_MAINNET_VERSION = exports.EVAA_ALTS_MAINNET = exports.EVAA_LP_COPY_MAINNET_VERSION = exports.EVAA_LP_COPY_MAINNET = exports.EVAA_LP_MAINNET_VERSION = exports.EVAA_LP_MAINNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
/* MAIN POOL */
|
|
6
6
|
exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
@@ -8,6 +8,9 @@ exports.MAINNET_VERSION = 10;
|
|
|
8
8
|
/* LP POOL */
|
|
9
9
|
exports.EVAA_LP_MAINNET = core_1.Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLww-hdWk2G37Jc6N');
|
|
10
10
|
exports.EVAA_LP_MAINNET_VERSION = 6;
|
|
11
|
+
/* LP POOL COPY */
|
|
12
|
+
exports.EVAA_LP_COPY_MAINNET = core_1.Address.parse('EQA8H9nNHly7yJ32UmUDzH97Je2l8bAI6P74yKIIwPwKKXrz');
|
|
13
|
+
exports.EVAA_LP_COPY_MAINNET_VERSION = 0;
|
|
11
14
|
/* ALTS POOL */
|
|
12
15
|
exports.EVAA_ALTS_MAINNET = core_1.Address.parse('EQANURVS3fhBO9bivig34iyJQi97FhMbpivo1aUEAS2GYSu-');
|
|
13
16
|
exports.EVAA_ALTS_MAINNET_VERSION = 4;
|
|
@@ -7,6 +7,7 @@ export declare const MAINNET_ALTS_POOL_ASSETS_CONFIG: import("../../types/Master
|
|
|
7
7
|
export declare const MAINNET_POOL_CONFIG: PoolConfig;
|
|
8
8
|
export declare const MAINNET_STABLE_POOL_CONFIG: PoolConfig;
|
|
9
9
|
export declare const MAINNET_LP_POOL_CONFIG: PoolConfig;
|
|
10
|
+
export declare const MAINNET_LP_POOL_COPY_CONFIG: PoolConfig;
|
|
10
11
|
export declare const MAINNET_ALTS_POOL_CONFIG: PoolConfig;
|
|
11
12
|
export declare const MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG: import("../../types/Master").PoolAssetConfig[];
|
|
12
13
|
export declare const MAINNET_PYTH_V8_TOB_POOL_CONFIG: PoolConfig;
|
|
@@ -15,4 +16,5 @@ export declare const MAINNET_V8_TOB_POOL_CONFIG: PoolConfig;
|
|
|
15
16
|
export declare const MAINNET_MASTER_TON_REWARD_CONFIG: EvaaRewardsConfig;
|
|
16
17
|
export declare const MAINNET_MASTER_USDT_REWARD_CONFIG: EvaaRewardsConfig;
|
|
17
18
|
export declare const MAINNET_MASTER_EVAA_REWARD_CONFIG: EvaaRewardsConfig;
|
|
19
|
+
export declare const MAINNET_CLASSIC_HE_POOL_CONFIG: PoolConfig;
|
|
18
20
|
export declare const ALL_MAINNET_POOLS: PoolConfig[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ALL_MAINNET_POOLS = exports.MAINNET_MASTER_EVAA_REWARD_CONFIG = exports.MAINNET_MASTER_USDT_REWARD_CONFIG = exports.MAINNET_MASTER_TON_REWARD_CONFIG = exports.MAINNET_V8_TOB_POOL_CONFIG = exports.MAINNET_V8_TOB_POOL_ASSETS_CONFIG = exports.MAINNET_PYTH_V8_TOB_POOL_CONFIG = exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG = exports.MAINNET_ALTS_POOL_CONFIG = exports.MAINNET_LP_POOL_CONFIG = exports.MAINNET_STABLE_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = exports.MAINNET_ALTS_POOL_ASSETS_CONFIG = exports.MAINNET_LP_POOL_ASSETS_CONFIG = exports.MAINNET_STABLE_POOL_ASSETS_CONFIG = exports.MAINNET_POOL_ASSETS_CONFIG = void 0;
|
|
3
|
+
exports.ALL_MAINNET_POOLS = exports.MAINNET_CLASSIC_HE_POOL_CONFIG = exports.MAINNET_MASTER_EVAA_REWARD_CONFIG = exports.MAINNET_MASTER_USDT_REWARD_CONFIG = exports.MAINNET_MASTER_TON_REWARD_CONFIG = exports.MAINNET_V8_TOB_POOL_CONFIG = exports.MAINNET_V8_TOB_POOL_ASSETS_CONFIG = exports.MAINNET_PYTH_V8_TOB_POOL_CONFIG = exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG = exports.MAINNET_ALTS_POOL_CONFIG = exports.MAINNET_LP_POOL_COPY_CONFIG = exports.MAINNET_LP_POOL_CONFIG = exports.MAINNET_STABLE_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = exports.MAINNET_ALTS_POOL_ASSETS_CONFIG = exports.MAINNET_LP_POOL_ASSETS_CONFIG = exports.MAINNET_STABLE_POOL_ASSETS_CONFIG = exports.MAINNET_POOL_ASSETS_CONFIG = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const feeds_1 = require("../../api/feeds");
|
|
6
6
|
const oracles_1 = require("../../oracles");
|
|
@@ -56,6 +56,10 @@ exports.MAINNET_POOL_CONFIG = {
|
|
|
56
56
|
},
|
|
57
57
|
}),
|
|
58
58
|
poolAssetsConfig: exports.MAINNET_POOL_ASSETS_CONFIG,
|
|
59
|
+
poolAssetsHEConfig: [
|
|
60
|
+
{ title: 'ton', assets: [assets_1.TON_MAINNET, assets_1.TSTON_MAINNET], heCategory: 1 },
|
|
61
|
+
{ title: 'stable', assets: [assets_1.USDT_MAINNET, assets_1.USDE_MAINNET, assets_1.TSUSDE_MAINNET], heCategory: 2 },
|
|
62
|
+
],
|
|
59
63
|
lendingCode: general_1.LENDING_CODE,
|
|
60
64
|
};
|
|
61
65
|
exports.MAINNET_STABLE_POOL_CONFIG = {
|
|
@@ -68,6 +72,7 @@ exports.MAINNET_STABLE_POOL_CONFIG = {
|
|
|
68
72
|
evaaOracles: general_1.ORACLES_MAINNET,
|
|
69
73
|
}),
|
|
70
74
|
poolAssetsConfig: exports.MAINNET_STABLE_POOL_ASSETS_CONFIG,
|
|
75
|
+
poolAssetsHEConfig: [],
|
|
71
76
|
lendingCode: general_1.LENDING_CODE,
|
|
72
77
|
};
|
|
73
78
|
exports.MAINNET_LP_POOL_CONFIG = {
|
|
@@ -80,6 +85,26 @@ exports.MAINNET_LP_POOL_CONFIG = {
|
|
|
80
85
|
evaaOracles: general_1.ORACLES_LP,
|
|
81
86
|
}),
|
|
82
87
|
poolAssetsConfig: exports.MAINNET_LP_POOL_ASSETS_CONFIG,
|
|
88
|
+
poolAssetsHEConfig: [
|
|
89
|
+
{ title: 'ton', assets: [assets_1.TON_MAINNET, assets_1.TON_STORM_MAINNET], heCategory: 1 },
|
|
90
|
+
{ title: 'stable', assets: [assets_1.USDT_MAINNET, assets_1.USDT_STORM_MAINNET], heCategory: 2 },
|
|
91
|
+
],
|
|
92
|
+
lendingCode: general_1.LENDING_CODE,
|
|
93
|
+
};
|
|
94
|
+
exports.MAINNET_LP_POOL_COPY_CONFIG = {
|
|
95
|
+
masterAddress: general_1.EVAA_LP_COPY_MAINNET,
|
|
96
|
+
masterVersion: general_1.EVAA_LP_COPY_MAINNET_VERSION,
|
|
97
|
+
masterConstants: general_1.MASTER_CONSTANTS,
|
|
98
|
+
collector: new oracles_1.ClassicCollector({
|
|
99
|
+
poolAssetsConfig: exports.MAINNET_LP_POOL_ASSETS_CONFIG,
|
|
100
|
+
minimalOracles: 3,
|
|
101
|
+
evaaOracles: general_1.ORACLES_LP,
|
|
102
|
+
}),
|
|
103
|
+
poolAssetsConfig: exports.MAINNET_LP_POOL_ASSETS_CONFIG,
|
|
104
|
+
poolAssetsHEConfig: [
|
|
105
|
+
{ title: 'ton', assets: [assets_1.TON_MAINNET, assets_1.TON_STORM_MAINNET], heCategory: 1 },
|
|
106
|
+
{ title: 'stable', assets: [assets_1.USDT_MAINNET, assets_1.USDT_STORM_MAINNET], heCategory: 2 },
|
|
107
|
+
],
|
|
83
108
|
lendingCode: general_1.LENDING_CODE,
|
|
84
109
|
};
|
|
85
110
|
exports.MAINNET_ALTS_POOL_CONFIG = {
|
|
@@ -92,6 +117,7 @@ exports.MAINNET_ALTS_POOL_CONFIG = {
|
|
|
92
117
|
evaaOracles: general_1.ORACLES_ALTS,
|
|
93
118
|
}),
|
|
94
119
|
poolAssetsConfig: exports.MAINNET_ALTS_POOL_ASSETS_CONFIG,
|
|
120
|
+
poolAssetsHEConfig: [],
|
|
95
121
|
lendingCode: general_1.LENDING_CODE,
|
|
96
122
|
};
|
|
97
123
|
exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG = [assets_1.TON_MAINNET, assets_1.USDT_MAINNET, assets_1.JUSDT_MAINNET];
|
|
@@ -112,6 +138,7 @@ exports.MAINNET_PYTH_V8_TOB_POOL_CONFIG = {
|
|
|
112
138
|
},
|
|
113
139
|
}),
|
|
114
140
|
poolAssetsConfig: exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG,
|
|
141
|
+
poolAssetsHEConfig: [],
|
|
115
142
|
lendingCode: general_1.LENDING_CODE,
|
|
116
143
|
};
|
|
117
144
|
exports.MAINNET_V8_TOB_POOL_ASSETS_CONFIG = [assets_1.TON_MAINNET, assets_1.USDT_MAINNET];
|
|
@@ -125,6 +152,7 @@ exports.MAINNET_V8_TOB_POOL_CONFIG = {
|
|
|
125
152
|
evaaOracles: general_1.ORACLES_MAINNET,
|
|
126
153
|
}),
|
|
127
154
|
poolAssetsConfig: exports.MAINNET_V8_TOB_POOL_ASSETS_CONFIG,
|
|
155
|
+
poolAssetsHEConfig: [],
|
|
128
156
|
lendingCode: general_1.LENDING_CODE,
|
|
129
157
|
};
|
|
130
158
|
exports.MAINNET_MASTER_TON_REWARD_CONFIG = {
|
|
@@ -154,6 +182,22 @@ exports.MAINNET_MASTER_EVAA_REWARD_CONFIG = {
|
|
|
154
182
|
availableReward: 0,
|
|
155
183
|
publicKey: Buffer.from('b8eb0e312a9aa6394edceef21573f2d45e7d7a616a924e33190bd52fa31c8bb1', 'hex'), // adminAddress publicKey
|
|
156
184
|
};
|
|
185
|
+
exports.MAINNET_CLASSIC_HE_POOL_CONFIG = {
|
|
186
|
+
masterAddress: core_1.Address.parse('EQAI_O_VqUhqFQ-AW969xl1eXOi4euSWl1puxEroekJ5xpOt'),
|
|
187
|
+
masterVersion: 0,
|
|
188
|
+
masterConstants: general_1.MASTER_CONSTANTS,
|
|
189
|
+
collector: new oracles_1.FakeCollector(core_1.Dictionary.empty()
|
|
190
|
+
.set(assets_1.ASSET_ID.TON, 1300000000n)
|
|
191
|
+
.set(assets_1.ASSET_ID.tsTON, 1500000000n)
|
|
192
|
+
.set(assets_1.ASSET_ID.TUSDT, 1000000000n)
|
|
193
|
+
.set(assets_1.ASSET_ID.TUSDe, 1000000000n)),
|
|
194
|
+
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.TSTON_MAINNET, assets_1.TUSDE_MAINNET, assets_1.TUSDT_MAINNET],
|
|
195
|
+
poolAssetsHEConfig: [
|
|
196
|
+
{ title: 'ton', assets: [assets_1.TON_MAINNET, assets_1.TSTON_MAINNET], heCategory: 1 },
|
|
197
|
+
{ title: 'stable', assets: [assets_1.TUSDT_MAINNET, assets_1.TUSDE_MAINNET], heCategory: 2 },
|
|
198
|
+
],
|
|
199
|
+
lendingCode: general_1.LENDING_CODE,
|
|
200
|
+
};
|
|
157
201
|
exports.ALL_MAINNET_POOLS = [
|
|
158
202
|
exports.MAINNET_POOL_CONFIG,
|
|
159
203
|
exports.MAINNET_LP_POOL_CONFIG,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { PoolConfig } from '../../types/Master';
|
|
2
|
-
import { EvaaRewardsConfig } from '../../types/MasterRewards';
|
|
1
|
+
import type { PoolConfig } from '../../types/Master';
|
|
2
|
+
import type { EvaaRewardsConfig } from '../../types/MasterRewards';
|
|
3
3
|
export declare const TESTNET_POOL_ASSETS_CONFIG: import("../../types/Master").PoolAssetConfig[];
|
|
4
4
|
export declare const TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED: import("../../types/Master").PoolAssetConfig[];
|
|
5
5
|
export declare const TESTNET_PYTH_POOL_CONFIG_TOB_AUDITED: PoolConfig;
|
|
6
6
|
export declare const TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED: PoolConfig;
|
|
7
|
+
export declare const TESTNET_CLASSIC_HE_POOL_CONFIG: PoolConfig;
|
|
7
8
|
export declare const TESTNET_MASTER_REWARD_CONFIG: EvaaRewardsConfig;
|
|
8
9
|
export declare const TESTNET_MASTER_EUSDT_REWARD_CONFIG: EvaaRewardsConfig;
|
|
9
10
|
export declare const ALL_TESTNET_POOLS: PoolConfig[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ALL_TESTNET_POOLS = exports.TESTNET_MASTER_EUSDT_REWARD_CONFIG = exports.TESTNET_MASTER_REWARD_CONFIG = exports.TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED = exports.TESTNET_PYTH_POOL_CONFIG_TOB_AUDITED = exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED = exports.TESTNET_POOL_ASSETS_CONFIG = void 0;
|
|
3
|
+
exports.ALL_TESTNET_POOLS = exports.TESTNET_MASTER_EUSDT_REWARD_CONFIG = exports.TESTNET_MASTER_REWARD_CONFIG = exports.TESTNET_CLASSIC_HE_POOL_CONFIG = exports.TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED = exports.TESTNET_PYTH_POOL_CONFIG_TOB_AUDITED = exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED = exports.TESTNET_POOL_ASSETS_CONFIG = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const feeds_1 = require("../../api/feeds");
|
|
6
6
|
const oracles_1 = require("../../oracles");
|
|
@@ -30,6 +30,7 @@ exports.TESTNET_PYTH_POOL_CONFIG_TOB_AUDITED = {
|
|
|
30
30
|
pythConfig: oracles_1.DefaultPythPriceSourcesConfig,
|
|
31
31
|
}),
|
|
32
32
|
poolAssetsConfig: exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED,
|
|
33
|
+
poolAssetsHEConfig: [],
|
|
33
34
|
lendingCode: general_1.LENDING_CODE,
|
|
34
35
|
};
|
|
35
36
|
exports.TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED = {
|
|
@@ -43,6 +44,20 @@ exports.TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED = {
|
|
|
43
44
|
}),
|
|
44
45
|
lendingCode: general_1.LENDING_CODE,
|
|
45
46
|
poolAssetsConfig: exports.TESTNET_POOL_ASSETS_CONFIG,
|
|
47
|
+
poolAssetsHEConfig: [],
|
|
48
|
+
};
|
|
49
|
+
exports.TESTNET_CLASSIC_HE_POOL_CONFIG = {
|
|
50
|
+
masterAddress: core_1.Address.parse('EQBykKj3k97Mx_EEGwzmnqFLteFRAt0BIg-ig96ifNkdV3Wn'),
|
|
51
|
+
masterVersion: 0,
|
|
52
|
+
masterConstants: general_1.MASTER_CONSTANTS,
|
|
53
|
+
collector: new oracles_1.ClassicCollector({
|
|
54
|
+
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.TSTON_MAINNET, assets_1.USDT_MAINNET, assets_1.USDE_MAINNET],
|
|
55
|
+
minimalOracles: 1,
|
|
56
|
+
evaaOracles: general_1.ORACLES_TESTNET,
|
|
57
|
+
}),
|
|
58
|
+
lendingCode: general_1.LENDING_CODE,
|
|
59
|
+
poolAssetsConfig: [assets_1.TON_MAINNET, assets_1.TSTON_MAINNET, assets_1.USDT_MAINNET, assets_1.USDE_MAINNET],
|
|
60
|
+
poolAssetsHEConfig: [],
|
|
46
61
|
};
|
|
47
62
|
exports.TESTNET_MASTER_REWARD_CONFIG = {
|
|
48
63
|
adminAddress: general_1.EVAA_REWARDS_MASTER_TESTNET,
|
|
@@ -15,10 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ClassicCollector = void 0;
|
|
16
16
|
const core_1 = require("@ton/core");
|
|
17
17
|
const math_1 = require("../../api/math");
|
|
18
|
-
const utils_1 = require("../../utils/utils");
|
|
19
18
|
const ClassicPrices_1 = require("../prices/ClassicPrices");
|
|
20
19
|
const Types_1 = require("../Types");
|
|
21
|
-
const
|
|
20
|
+
const utils_1 = require("../utils");
|
|
22
21
|
const AbstractCollector_1 = require("./AbstractCollector");
|
|
23
22
|
class ClassicCollector extends AbstractCollector_1.AbstractCollector {
|
|
24
23
|
constructor(config) {
|
|
@@ -31,7 +30,7 @@ class ClassicCollector extends AbstractCollector_1.AbstractCollector {
|
|
|
31
30
|
_ClassicCollector_minimalOracles.set(this, void 0);
|
|
32
31
|
__classPrivateFieldSet(this, _ClassicCollector_poolAssetsConfig, config.poolAssetsConfig, "f");
|
|
33
32
|
__classPrivateFieldSet(this, _ClassicCollector_sourcesConfig, config.sourcesConfig ?? Types_1.DefaultPriceSourcesConfig, "f");
|
|
34
|
-
__classPrivateFieldSet(this, _ClassicCollector_priceSources, (0,
|
|
33
|
+
__classPrivateFieldSet(this, _ClassicCollector_priceSources, (0, utils_1.generatePriceSources)(__classPrivateFieldGet(this, _ClassicCollector_sourcesConfig, "f"), config.evaaOracles), "f");
|
|
35
34
|
__classPrivateFieldSet(this, _ClassicCollector_minimalOracles, config.minimalOracles, "f");
|
|
36
35
|
if (config.additionalPriceSources) {
|
|
37
36
|
__classPrivateFieldGet(this, _ClassicCollector_priceSources, "f").push(...config.additionalPriceSources);
|
|
@@ -116,36 +115,32 @@ _ClassicCollector_prices = new WeakMap(), _ClassicCollector_poolAssetsConfig = n
|
|
|
116
115
|
}
|
|
117
116
|
const medianData = assets.map((asset) => ({
|
|
118
117
|
assetId: asset.assetId,
|
|
119
|
-
medianPrice: (0,
|
|
118
|
+
medianPrice: (0, utils_1.getMedianPrice)(pricesFiltered, asset.assetId),
|
|
120
119
|
}));
|
|
121
120
|
const nonEmptymedianData = medianData.filter((x) => x.medianPrice != null);
|
|
122
|
-
const packedMedianData = (0,
|
|
121
|
+
const packedMedianData = (0, utils_1.packAssetsData)(nonEmptymedianData);
|
|
123
122
|
const oraclesData = pricesFiltered.map((x) => ({
|
|
124
123
|
oracle: { id: x.oracleId, pubkey: x.pubkey },
|
|
125
124
|
data: { timestamp: x.timestamp, prices: x.dict },
|
|
126
125
|
signature: x.signature,
|
|
127
126
|
}));
|
|
128
|
-
const packedOracleData = (0,
|
|
127
|
+
const packedOracleData = (0, utils_1.packOraclesData)(oraclesData, nonEmptymedianData.map((x) => x.assetId));
|
|
129
128
|
const dict = core_1.Dictionary.empty();
|
|
130
129
|
for (const medianDataAsset of nonEmptymedianData) {
|
|
131
130
|
dict.set(medianDataAsset.assetId, medianDataAsset.medianPrice);
|
|
132
131
|
}
|
|
133
132
|
return {
|
|
134
133
|
dict: dict,
|
|
135
|
-
dataCell: (0,
|
|
134
|
+
dataCell: (0, utils_1.packPrices)(packedMedianData, packedOracleData),
|
|
136
135
|
};
|
|
137
136
|
}, _ClassicCollector_collectPrices = async function _ClassicCollector_collectPrices(fetchConfig) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// Try next source
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
137
|
+
try {
|
|
138
|
+
__classPrivateFieldSet(this, _ClassicCollector_prices, await Promise.any(__classPrivateFieldGet(this, _ClassicCollector_priceSources, "f").map((source) => (0, utils_1.collectAndFilterPrices)(source, __classPrivateFieldGet(this, _ClassicCollector_minimalOracles, "f"), fetchConfig))), "f");
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return false;
|
|
147
143
|
}
|
|
148
|
-
return false;
|
|
149
144
|
}, _ClassicCollector_collectPricesWithValidation = async function _ClassicCollector_collectPricesWithValidation(fetchConfig) {
|
|
150
145
|
if (!__classPrivateFieldGet(this, _ClassicCollector_prices, "f") || __classPrivateFieldGet(this, _ClassicCollector_instances, "m", _ClassicCollector_filterPrices).call(this) < __classPrivateFieldGet(this, _ClassicCollector_minimalOracles, "f")) {
|
|
151
146
|
const success = await __classPrivateFieldGet(this, _ClassicCollector_instances, "m", _ClassicCollector_collectPrices).call(this, fetchConfig);
|
|
@@ -154,7 +149,7 @@ _ClassicCollector_prices = new WeakMap(), _ClassicCollector_poolAssetsConfig = n
|
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
}, _ClassicCollector_filterPrices = function _ClassicCollector_filterPrices() {
|
|
157
|
-
__classPrivateFieldSet(this, _ClassicCollector_prices, __classPrivateFieldGet(this, _ClassicCollector_prices, "f").filter((0,
|
|
152
|
+
__classPrivateFieldSet(this, _ClassicCollector_prices, __classPrivateFieldGet(this, _ClassicCollector_prices, "f").filter((0, utils_1.verifyPricesTimestamp)()), "f");
|
|
158
153
|
return __classPrivateFieldGet(this, _ClassicCollector_prices, "f").length;
|
|
159
154
|
}, _ClassicCollector_filterEmptyPrincipalsAndAssets = function _ClassicCollector_filterEmptyPrincipalsAndAssets(principals) {
|
|
160
155
|
return principals
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Dictionary } from '@ton/core';
|
|
2
|
+
import { ClassicPrices } from '../prices/ClassicPrices';
|
|
3
|
+
import { PoolAssetConfig } from '../../types/Master';
|
|
4
|
+
import { FetchConfig } from '../../utils/utils';
|
|
5
|
+
import { AbstractCollector } from './AbstractCollector';
|
|
6
|
+
/**
|
|
7
|
+
* FakeCollector for testing smart contracts.
|
|
8
|
+
*
|
|
9
|
+
* Accepts a Dictionary<bigint, bigint> mapping assetId to price
|
|
10
|
+
* (in ASSET_PRICE_SCALE, i.e. USD price * 1e9) and produces valid
|
|
11
|
+
* ClassicPrices without any network calls.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const prices = Dictionary.empty<bigint, bigint>();
|
|
16
|
+
* prices.set(TON_ASSET_ID, 5_000_000_000n); // $5.00
|
|
17
|
+
* prices.set(USDT_ASSET_ID, 1_000_000_000n); // $1.00
|
|
18
|
+
*
|
|
19
|
+
* const collector = new FakeCollector(prices);
|
|
20
|
+
* const classicPrices = await collector.getPrices();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class FakeCollector extends AbstractCollector {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(prices: Dictionary<bigint, bigint>);
|
|
26
|
+
getPricesForLiquidate(_realPrincipals: Dictionary<bigint, bigint>, _fetchConfig?: FetchConfig): Promise<ClassicPrices>;
|
|
27
|
+
getPricesForWithdraw(realPrincipals: Dictionary<bigint, bigint>, withdrawAsset: PoolAssetConfig, collateralToDebt?: boolean, fetchConfig?: FetchConfig): Promise<ClassicPrices>;
|
|
28
|
+
getPricesForSupplyWithdraw(_realPrincipals: Dictionary<bigint, bigint>, _supplyAsset: PoolAssetConfig | undefined, _withdrawAsset: PoolAssetConfig | undefined, _collateralToDebt: boolean, _fetchConfig?: FetchConfig): Promise<ClassicPrices>;
|
|
29
|
+
getPrices(_assets?: PoolAssetConfig[], _fetchConfig?: FetchConfig): Promise<ClassicPrices>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _FakeCollector_instances, _FakeCollector_pricesDict, _FakeCollector_buildClassicPrices;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FakeCollector = void 0;
|
|
16
|
+
const core_1 = require("@ton/core");
|
|
17
|
+
const ClassicPrices_1 = require("../prices/ClassicPrices");
|
|
18
|
+
const AbstractCollector_1 = require("./AbstractCollector");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const crypto_1 = require("@ton/crypto");
|
|
21
|
+
function createFakeOracle(id, seed) {
|
|
22
|
+
const keypair = (0, crypto_1.keyPairFromSeed)(seed);
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
pubkey: keypair.publicKey,
|
|
26
|
+
secret: keypair.secretKey,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const fakeOracles = [
|
|
30
|
+
createFakeOracle(0, Buffer.alloc(32, 0)),
|
|
31
|
+
createFakeOracle(1, Buffer.alloc(32, 1)),
|
|
32
|
+
createFakeOracle(2, Buffer.alloc(32, 2)),
|
|
33
|
+
createFakeOracle(3, Buffer.alloc(32, 3)),
|
|
34
|
+
];
|
|
35
|
+
function packPricesData(timestamp, prices) {
|
|
36
|
+
return (0, core_1.beginCell)()
|
|
37
|
+
.storeUint(timestamp, 32)
|
|
38
|
+
.storeDict(prices, core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigVarUint(4))
|
|
39
|
+
.endCell();
|
|
40
|
+
}
|
|
41
|
+
function signPricesData(oracle, data) {
|
|
42
|
+
const packedData = packPricesData(data.timestamp, data.prices);
|
|
43
|
+
return (0, crypto_1.sign)(packedData.hash(), oracle.secret);
|
|
44
|
+
}
|
|
45
|
+
function withSerializers(src) {
|
|
46
|
+
const dict = core_1.Dictionary.empty(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigVarUint(4));
|
|
47
|
+
for (const key of src.keys()) {
|
|
48
|
+
dict.set(key, src.get(key));
|
|
49
|
+
}
|
|
50
|
+
return dict;
|
|
51
|
+
}
|
|
52
|
+
function buildPricesCell(pricesDict, assetIds, timestamp) {
|
|
53
|
+
const serializedPrices = withSerializers(pricesDict);
|
|
54
|
+
const oraclesData = fakeOracles.map((oracle) => {
|
|
55
|
+
const data = { timestamp, prices: serializedPrices };
|
|
56
|
+
const signature = signPricesData(oracle, data);
|
|
57
|
+
return {
|
|
58
|
+
oracle: { id: oracle.id, pubkey: oracle.pubkey },
|
|
59
|
+
data,
|
|
60
|
+
signature,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
const medianData = assetIds.map((assetId) => ({
|
|
64
|
+
assetId,
|
|
65
|
+
medianPrice: pricesDict.get(assetId),
|
|
66
|
+
}));
|
|
67
|
+
const assetsDataCell = (0, utils_1.packAssetsData)(medianData);
|
|
68
|
+
const oraclesDataCell = (0, utils_1.packOraclesData)(oraclesData, assetIds);
|
|
69
|
+
const dataCell = (0, utils_1.packPrices)(assetsDataCell, oraclesDataCell);
|
|
70
|
+
const dict = core_1.Dictionary.empty();
|
|
71
|
+
for (const { assetId, medianPrice } of medianData) {
|
|
72
|
+
dict.set(assetId, medianPrice);
|
|
73
|
+
}
|
|
74
|
+
return { dict, dataCell };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* FakeCollector for testing smart contracts.
|
|
78
|
+
*
|
|
79
|
+
* Accepts a Dictionary<bigint, bigint> mapping assetId to price
|
|
80
|
+
* (in ASSET_PRICE_SCALE, i.e. USD price * 1e9) and produces valid
|
|
81
|
+
* ClassicPrices without any network calls.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const prices = Dictionary.empty<bigint, bigint>();
|
|
86
|
+
* prices.set(TON_ASSET_ID, 5_000_000_000n); // $5.00
|
|
87
|
+
* prices.set(USDT_ASSET_ID, 1_000_000_000n); // $1.00
|
|
88
|
+
*
|
|
89
|
+
* const collector = new FakeCollector(prices);
|
|
90
|
+
* const classicPrices = await collector.getPrices();
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
class FakeCollector extends AbstractCollector_1.AbstractCollector {
|
|
94
|
+
constructor(prices) {
|
|
95
|
+
super();
|
|
96
|
+
_FakeCollector_instances.add(this);
|
|
97
|
+
_FakeCollector_pricesDict.set(this, void 0);
|
|
98
|
+
__classPrivateFieldSet(this, _FakeCollector_pricesDict, prices, "f");
|
|
99
|
+
}
|
|
100
|
+
async getPricesForLiquidate(_realPrincipals, _fetchConfig) {
|
|
101
|
+
return __classPrivateFieldGet(this, _FakeCollector_instances, "m", _FakeCollector_buildClassicPrices).call(this, ClassicPrices_1.ClassicPricesMode.SPOT);
|
|
102
|
+
}
|
|
103
|
+
async getPricesForWithdraw(realPrincipals, withdrawAsset, collateralToDebt = false, fetchConfig) {
|
|
104
|
+
return await this.getPrices();
|
|
105
|
+
}
|
|
106
|
+
async getPricesForSupplyWithdraw(_realPrincipals, _supplyAsset, _withdrawAsset, _collateralToDebt, _fetchConfig) {
|
|
107
|
+
return __classPrivateFieldGet(this, _FakeCollector_instances, "m", _FakeCollector_buildClassicPrices).call(this, ClassicPrices_1.ClassicPricesMode.TWAP);
|
|
108
|
+
}
|
|
109
|
+
async getPrices(_assets, _fetchConfig) {
|
|
110
|
+
return __classPrivateFieldGet(this, _FakeCollector_instances, "m", _FakeCollector_buildClassicPrices).call(this);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.FakeCollector = FakeCollector;
|
|
114
|
+
_FakeCollector_pricesDict = new WeakMap(), _FakeCollector_instances = new WeakSet(), _FakeCollector_buildClassicPrices = function _FakeCollector_buildClassicPrices(mode) {
|
|
115
|
+
const keys = __classPrivateFieldGet(this, _FakeCollector_pricesDict, "f").keys();
|
|
116
|
+
if (keys.length === 0) {
|
|
117
|
+
return ClassicPrices_1.ClassicPrices.createEmptyPrices();
|
|
118
|
+
}
|
|
119
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
120
|
+
const { dict, dataCell } = buildPricesCell(__classPrivateFieldGet(this, _FakeCollector_pricesDict, "f"), keys, timestamp);
|
|
121
|
+
return new ClassicPrices_1.ClassicPrices({
|
|
122
|
+
mode,
|
|
123
|
+
dict,
|
|
124
|
+
dataCell,
|
|
125
|
+
minPublishTime: undefined,
|
|
126
|
+
maxPublishTime: undefined,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AbstractCollector"), exports);
|
|
18
18
|
__exportStar(require("./ClassicCollector"), exports);
|
|
19
|
+
__exportStar(require("./FakeCollector"), exports);
|
|
19
20
|
__exportStar(require("./PythCollector"), exports);
|
package/dist/types/Master.d.ts
CHANGED
|
@@ -21,11 +21,17 @@ export type PoolAssetConfig = {
|
|
|
21
21
|
jettonMasterAddress: Address;
|
|
22
22
|
jettonWalletCode: Cell;
|
|
23
23
|
};
|
|
24
|
+
export type PoolAssetHEConfig = {
|
|
25
|
+
title: string;
|
|
26
|
+
assets: PoolAssetConfig[];
|
|
27
|
+
heCategory: number;
|
|
28
|
+
};
|
|
24
29
|
export type PoolConfig = {
|
|
25
30
|
masterAddress: Address;
|
|
26
31
|
masterVersion: number;
|
|
27
32
|
masterConstants: MasterConstants;
|
|
28
33
|
poolAssetsConfig: PoolAssetConfig[];
|
|
34
|
+
poolAssetsHEConfig: PoolAssetHEConfig[];
|
|
29
35
|
lendingCode: Cell;
|
|
30
36
|
collector: AbstractCollector;
|
|
31
37
|
};
|
|
@@ -61,8 +67,8 @@ export type AssetConfig = {
|
|
|
61
67
|
baseTrackingBorrowSpeed: bigint;
|
|
62
68
|
borrowCap: number | bigint;
|
|
63
69
|
heCategory: number;
|
|
64
|
-
heCollateralFactor:
|
|
65
|
-
heLiquidationThreshold:
|
|
70
|
+
heCollateralFactor: bigint;
|
|
71
|
+
heLiquidationThreshold: bigint;
|
|
66
72
|
};
|
|
67
73
|
export type AssetData = {
|
|
68
74
|
sRate: bigint;
|
package/dist/types/User.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, Cell, Dictionary } from '@ton/core';
|
|
1
|
+
import { Address, Cell, Dictionary, ExternalAddress } from '@ton/core';
|
|
2
2
|
import { AssetConfig, AssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants, PoolAssetConfig, PoolConfig } from './Master';
|
|
3
3
|
export declare enum BalanceType {
|
|
4
4
|
supply = "supply",
|
|
@@ -28,8 +28,8 @@ export type LiquidationData = LiquidableData | NonLiquidableData;
|
|
|
28
28
|
export type UserLiteData = {
|
|
29
29
|
type: 'active';
|
|
30
30
|
codeVersion: number;
|
|
31
|
-
masterAddress: Address;
|
|
32
|
-
ownerAddress: Address;
|
|
31
|
+
masterAddress: Address | ExternalAddress | null;
|
|
32
|
+
ownerAddress: Address | ExternalAddress | null;
|
|
33
33
|
principals: Dictionary<bigint, bigint>;
|
|
34
34
|
realPrincipals: Dictionary<bigint, bigint>;
|
|
35
35
|
state: number;
|
|
@@ -46,15 +46,19 @@ export type UserLiteData = {
|
|
|
46
46
|
export type UserDataActive = UserLiteData & {
|
|
47
47
|
withdrawalLimits: Dictionary<bigint, bigint>;
|
|
48
48
|
borrowLimits: Dictionary<bigint, bigint>;
|
|
49
|
+
borrowLimitsWithEmode: Dictionary<bigint, bigint>;
|
|
49
50
|
repayLimits?: Dictionary<bigint, bigint>;
|
|
50
51
|
supplyBalance: bigint;
|
|
51
52
|
borrowBalance: bigint;
|
|
52
53
|
availableToBorrow: bigint;
|
|
54
|
+
availableToBorrowWithEmode: bigint;
|
|
53
55
|
limitUsedPercent: number;
|
|
54
56
|
limitUsed: bigint;
|
|
55
57
|
healthFactor: number;
|
|
56
58
|
liquidationData: LiquidationData;
|
|
57
59
|
havePrincipalWithoutPrice: boolean;
|
|
60
|
+
predictedHeCategory: number;
|
|
61
|
+
activeHeCategory: number;
|
|
58
62
|
};
|
|
59
63
|
export type UserDataInactive = {
|
|
60
64
|
type: 'inactive';
|