@evaafi/sdk 0.9.0-a → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/feeds.d.ts +15 -24
- package/dist/api/feeds.js +22 -49
- package/dist/api/math.d.ts +1 -1
- package/dist/api/math.js +55 -38
- package/dist/api/parser.d.ts +2 -2
- package/dist/api/parser.js +3 -3
- package/dist/api/parsers/PythOracleParser.d.ts +3 -3
- package/dist/api/parsers/PythOracleParser.js +2 -1
- package/dist/api/prices.js +2 -1
- package/dist/constants/general/index.d.ts +25 -11
- package/dist/constants/general/index.js +15 -1
- package/dist/constants/pools/mainnet.js +20 -18
- package/dist/constants/pools/testnet.js +14 -6
- package/dist/contracts/AbstractMaster.d.ts +239 -127
- package/dist/contracts/AbstractMaster.js +101 -16
- package/dist/contracts/ClassicMaster.d.ts +12 -12
- package/dist/contracts/PythMaster.d.ts +40 -24
- package/dist/contracts/PythMaster.js +61 -76
- package/dist/contracts/PythOracle.d.ts +16 -0
- package/dist/contracts/PythOracle.js +19 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{prices → oracles}/Types.d.ts +0 -4
- package/dist/oracles/collectors/AbstractCollector.d.ts +10 -0
- package/dist/oracles/collectors/AbstractCollector.js +6 -0
- package/dist/oracles/collectors/ClassicCollector.d.ts +22 -0
- package/dist/oracles/collectors/ClassicCollector.js +192 -0
- package/dist/oracles/collectors/PythCollector.d.ts +27 -0
- package/dist/oracles/collectors/PythCollector.js +252 -0
- package/dist/oracles/collectors/index.d.ts +3 -0
- package/dist/oracles/collectors/index.js +19 -0
- package/dist/{prices → oracles}/index.d.ts +2 -3
- package/dist/{prices → oracles}/index.js +2 -3
- package/dist/oracles/prices/AbstractPrices.d.ts +33 -0
- package/dist/oracles/prices/AbstractPrices.js +40 -0
- package/dist/oracles/prices/ClassicPrices.d.ts +19 -0
- package/dist/oracles/prices/ClassicPrices.js +48 -0
- package/dist/oracles/prices/PythPrices.d.ts +18 -0
- package/dist/oracles/prices/PythPrices.js +32 -0
- package/dist/oracles/prices/index.d.ts +3 -0
- package/dist/oracles/prices/index.js +19 -0
- package/dist/{prices → oracles}/utils.d.ts +6 -1
- package/dist/{prices → oracles}/utils.js +10 -1
- package/dist/types/Master.d.ts +4 -5
- package/package.json +2 -3
- package/src/api/feeds.ts +24 -60
- package/src/api/math.ts +118 -90
- package/src/api/parser.ts +5 -5
- package/src/api/parsers/PythOracleParser.ts +6 -2
- package/src/api/prices.ts +2 -1
- package/src/constants/general/index.ts +16 -1
- package/src/constants/pools/mainnet.ts +20 -35
- package/src/constants/pools/testnet.ts +17 -8
- package/src/contracts/AbstractMaster.ts +272 -144
- package/src/contracts/ClassicMaster.ts +12 -12
- package/src/contracts/PythMaster.ts +130 -123
- package/src/contracts/PythOracle.ts +20 -0
- package/src/contracts/index.ts +2 -0
- package/src/index.ts +1 -1
- package/src/{prices → oracles}/Types.ts +0 -5
- package/src/oracles/collectors/AbstractCollector.ts +22 -0
- package/src/oracles/collectors/ClassicCollector.ts +263 -0
- package/src/oracles/collectors/PythCollector.ts +358 -0
- package/src/oracles/collectors/index.ts +3 -0
- package/src/{prices → oracles}/index.ts +2 -3
- package/src/oracles/prices/AbstractPrices.ts +59 -0
- package/src/oracles/prices/ClassicPrices.ts +52 -0
- package/src/oracles/prices/PythPrices.ts +40 -0
- package/src/oracles/prices/index.ts +3 -0
- package/src/{prices → oracles}/utils.ts +12 -1
- package/src/types/Master.ts +4 -6
- package/dist/prices/Oracle.interface.d.ts +0 -9
- package/dist/prices/Oracle.interface.js +0 -2
- package/dist/prices/Prices.d.ts +0 -11
- package/dist/prices/Prices.js +0 -53
- package/dist/prices/PricesCollector.d.ts +0 -22
- package/dist/prices/PricesCollector.js +0 -146
- package/dist/prices/PythCollector.d.ts +0 -22
- package/dist/prices/PythCollector.js +0 -217
- package/src/prices/Oracle.interface.ts +0 -18
- package/src/prices/Prices.ts +0 -45
- package/src/prices/PricesCollector.ts +0 -169
- package/src/prices/PythCollector.ts +0 -294
- /package/dist/{prices → oracles}/Types.js +0 -0
- /package/dist/{prices → oracles}/constants.d.ts +0 -0
- /package/dist/{prices → oracles}/constants.js +0 -0
- /package/dist/{prices → oracles}/sources/Backend.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/Backend.js +0 -0
- /package/dist/{prices → oracles}/sources/Icp.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/Icp.js +0 -0
- /package/dist/{prices → oracles}/sources/PriceSource.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/PriceSource.js +0 -0
- /package/dist/{prices → oracles}/sources/index.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/index.js +0 -0
- /package/src/{prices → oracles}/constants.ts +0 -0
- /package/src/{prices → oracles}/sources/Backend.ts +0 -0
- /package/src/{prices → oracles}/sources/Icp.ts +0 -0
- /package/src/{prices → oracles}/sources/PriceSource.ts +0 -0
- /package/src/{prices → oracles}/sources/index.ts +0 -0
package/dist/api/feeds.d.ts
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
import { HexString } from '@pythnetwork/hermes-client';
|
|
3
4
|
import { Dictionary } from '@ton/ton';
|
|
4
5
|
import { Buffer } from 'buffer';
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export declare const FEED_ID: {
|
|
7
|
+
TON: string;
|
|
8
|
+
USDT: string;
|
|
9
|
+
stTON: string;
|
|
10
|
+
tsTON: string;
|
|
11
|
+
USDC: string;
|
|
12
|
+
USDe: string;
|
|
13
|
+
tsUSDe: string;
|
|
14
|
+
};
|
|
12
15
|
export declare function bigintToBuffer(value: bigint, size: number): Buffer;
|
|
13
|
-
export declare const packConnectedFeeds: (evaa_id: bigint,
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const EVAA_NOT_PRICE_FEED_ID: bigint;
|
|
16
|
-
export declare const EVAA_DOGS_PRICE_FEED_ID: bigint;
|
|
17
|
-
export declare const EVAA_USDT_PRICE_FEED_ID: bigint;
|
|
18
|
-
export declare const EVAA_STTON_PRICE_FEED_ID: bigint;
|
|
19
|
-
export declare const EVAA_TSTON_PRICE_FEED_ID: bigint;
|
|
20
|
-
export declare const EVAA_JUSDC_PRICE_FEED_ID: bigint;
|
|
21
|
-
export declare const EVAA_JUSDT_PRICE_FEED_ID: bigint;
|
|
22
|
-
export declare const EVAA_USDE_PRICE_FEED_ID: bigint;
|
|
23
|
-
export declare const EVAA_TSUSDE_PRICE_FEED_ID: bigint;
|
|
24
|
-
export declare const MAIN_POOL_FEEDS_MAP: Dictionary<bigint, Buffer>;
|
|
16
|
+
export declare const packConnectedFeeds: (evaa_id: bigint, feedId: HexString) => Buffer;
|
|
17
|
+
export declare const unpackConnectedFeeds: (buffer: Buffer) => FeedMapItem;
|
|
25
18
|
export type FeedMapItem = {
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
assetId: bigint;
|
|
20
|
+
feedId: HexString;
|
|
28
21
|
};
|
|
29
|
-
export declare function parseFeedsMapDict(dict: Dictionary<bigint, Buffer>): Map<
|
|
30
|
-
export declare const TESTNET_ALLOWED_REF_TOKENS: Dictionary<bigint, bigint>;
|
|
31
|
-
export declare const TESTNET_FEEDS_MAP: Dictionary<bigint, Buffer>;
|
|
22
|
+
export declare function parseFeedsMapDict(dict: Dictionary<bigint, Buffer>): Map<string, FeedMapItem>;
|
package/dist/api/feeds.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const ton_1 = require("@ton/ton");
|
|
3
|
+
exports.parseFeedsMapDict = exports.unpackConnectedFeeds = exports.packConnectedFeeds = exports.bigintToBuffer = exports.FEED_ID = void 0;
|
|
5
4
|
const buffer_1 = require("buffer");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
exports.FEED_ID = {
|
|
6
|
+
TON: '0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026',
|
|
7
|
+
USDT: '0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b',
|
|
8
|
+
stTON: '0x9145e059026a4d5a46f3b96408f7e572e33b3257b9c2dbe8dba551c772762002',
|
|
9
|
+
tsTON: '0x3d1784128eeab5961ec60648fe497d3901eebd211b7f51e4bb0db9f024977d25',
|
|
10
|
+
USDC: '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
|
11
|
+
USDe: '0x6ec879b1e9963de5ee97e9c8710b742d6228252a5e2ca12d4ae81d7fe5ee8c5d',
|
|
12
|
+
tsUSDe: '0xcbe184846426619a60f51056d26efecb0537ad3a73b1e965fe695d06a257cb19',
|
|
13
|
+
};
|
|
14
14
|
function bigintToBuffer(value, size) {
|
|
15
15
|
if (value < 0n) {
|
|
16
16
|
throw new Error('Only non-negative bigint is supported');
|
|
@@ -22,52 +22,25 @@ function bigintToBuffer(value, size) {
|
|
|
22
22
|
return buffer_1.Buffer.from(padded, 'hex');
|
|
23
23
|
}
|
|
24
24
|
exports.bigintToBuffer = bigintToBuffer;
|
|
25
|
-
const packConnectedFeeds = (evaa_id,
|
|
26
|
-
return buffer_1.Buffer.concat([bigintToBuffer(evaa_id, 32), bigintToBuffer(
|
|
25
|
+
const packConnectedFeeds = (evaa_id, feedId) => {
|
|
26
|
+
return buffer_1.Buffer.concat([bigintToBuffer(evaa_id, 32), bigintToBuffer(BigInt(feedId), 32)]);
|
|
27
27
|
};
|
|
28
28
|
exports.packConnectedFeeds = packConnectedFeeds;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.
|
|
36
|
-
exports.EVAA_JUSDT_PRICE_FEED_ID = assets_1.ASSET_ID.jUSDT;
|
|
37
|
-
exports.EVAA_USDE_PRICE_FEED_ID = assets_1.ASSET_ID.USDe;
|
|
38
|
-
exports.EVAA_TSUSDE_PRICE_FEED_ID = assets_1.ASSET_ID.tsUSDe;
|
|
39
|
-
exports.MAIN_POOL_FEEDS_MAP = (() => {
|
|
40
|
-
const map = ton_1.Dictionary.empty();
|
|
41
|
-
map.set(BigInt(exports.PYTH_TON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TON_PRICE_FEED_ID, 0n));
|
|
42
|
-
map.set(BigInt(exports.PYTH_USDT_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_USDT_PRICE_FEED_ID, 0n));
|
|
43
|
-
map.set(BigInt(exports.PYTH_STTON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_STTON_PRICE_FEED_ID, BigInt(exports.PYTH_TON_PRICE_FEED_ID)));
|
|
44
|
-
map.set(BigInt(exports.PYTH_TSTON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TSTON_PRICE_FEED_ID, BigInt(exports.PYTH_TON_PRICE_FEED_ID)));
|
|
45
|
-
map.set(BigInt(exports.PYTH_USDC_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_JUSDC_PRICE_FEED_ID, 0n));
|
|
46
|
-
map.set(BigInt(exports.PYTH_USDT_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_JUSDT_PRICE_FEED_ID, 0n));
|
|
47
|
-
map.set(BigInt(exports.PYTH_USDE_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_USDE_PRICE_FEED_ID, 0n));
|
|
48
|
-
map.set(BigInt(exports.PYTH_TSUSDE_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TSUSDE_PRICE_FEED_ID, 0n));
|
|
49
|
-
return map;
|
|
50
|
-
})();
|
|
29
|
+
const unpackConnectedFeeds = (buffer) => {
|
|
30
|
+
return {
|
|
31
|
+
assetId: BigInt(`0x${buffer.toString('hex', 0, 32)}`),
|
|
32
|
+
feedId: `0x${buffer.toString('hex', 32)}`,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.unpackConnectedFeeds = unpackConnectedFeeds;
|
|
51
36
|
function parseFeedsMapDict(dict) {
|
|
52
37
|
const parsedData = new Map();
|
|
53
38
|
for (const key of dict.keys()) {
|
|
54
39
|
const buffer = dict.get(key);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const referredPythFeed = BigInt(hex2);
|
|
59
|
-
parsedData.set(key, { evaaId, referredPythFeed });
|
|
40
|
+
const assetId = BigInt(`0x${buffer.toString('hex', 0, 32)}`);
|
|
41
|
+
const feedId = `0x${buffer.toString('hex', 32)}`;
|
|
42
|
+
parsedData.set(`0x${key.toString(16)}`, { assetId, feedId });
|
|
60
43
|
}
|
|
61
44
|
return parsedData;
|
|
62
45
|
}
|
|
63
46
|
exports.parseFeedsMapDict = parseFeedsMapDict;
|
|
64
|
-
exports.TESTNET_ALLOWED_REF_TOKENS = (() => {
|
|
65
|
-
const map = ton_1.Dictionary.empty();
|
|
66
|
-
map.set(BigInt(exports.EVAA_JUSDT_PRICE_FEED_ID), BigInt(exports.EVAA_USDT_PRICE_FEED_ID));
|
|
67
|
-
return map;
|
|
68
|
-
})();
|
|
69
|
-
exports.TESTNET_FEEDS_MAP = (() => {
|
|
70
|
-
const map = ton_1.Dictionary.empty();
|
|
71
|
-
map.set(BigInt(exports.PYTH_TON_PRICE_FEED_ID), (0, exports.packConnectedFeeds)(exports.EVAA_TON_PRICE_FEED_ID, 0n));
|
|
72
|
-
return map;
|
|
73
|
-
})();
|
package/dist/api/math.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgregatedBalances, AssetApy, AssetConfig, AssetData, AssetInterest, ExtendedAssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants, PoolConfig } from '../types/Master';
|
|
2
1
|
import { Dictionary } from '@ton/core';
|
|
2
|
+
import { AgregatedBalances, AssetApy, AssetConfig, AssetData, AssetInterest, ExtendedAssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants, PoolConfig } from '../types/Master';
|
|
3
3
|
import { HealthParamsArgs, LiquidationData, PredictAPYArgs, PredictHealthFactorArgs, UserBalance } from '../types/User';
|
|
4
4
|
export declare function mulFactor(decimal: bigint, a: bigint, b: bigint): bigint;
|
|
5
5
|
export declare function mulDiv(x: bigint, y: bigint, z: bigint): bigint;
|
package/dist/api/math.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.predictAPY = exports.predictHealthFactor = exports.calculateLiquidationData = exports.calculateHealthParams = exports.presentValue = exports.getAvailableToBorrow = exports.calculateMaximumWithdrawAmount = exports.getAgregatedBalances = exports.checkNotInDebtAtAll = exports.calculateInterestWithSupplyBorrow = exports.calculateAssetInterest = exports.calculateAssetData = exports.calculateCurrentRates = exports.getAssetLiquidityMinusReserves = exports.calculatePresentValue = exports.BigMath = exports.bigIntMin = exports.bigIntMax = exports.bigAbs = exports.mulDivC = exports.mulDiv = exports.mulFactor = void 0;
|
|
4
|
-
const User_1 = require("../types/User");
|
|
5
4
|
const assets_1 = require("../constants/assets");
|
|
5
|
+
const User_1 = require("../types/User");
|
|
6
6
|
const liquidation_1 = require("./liquidation");
|
|
7
7
|
function mulFactor(decimal, a, b) {
|
|
8
8
|
return (a * b) / decimal;
|
|
@@ -43,7 +43,7 @@ function getAssetLiquidityMinusReserves(assetData, masterConstants) {
|
|
|
43
43
|
exports.getAssetLiquidityMinusReserves = getAssetLiquidityMinusReserves;
|
|
44
44
|
function calculateCurrentRates(assetConfig, assetData, masterConstants) {
|
|
45
45
|
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
46
|
-
const timeElapsed = now - assetData.
|
|
46
|
+
const timeElapsed = now - assetData.lastAccrual;
|
|
47
47
|
const { supplyInterest, borrowInterest } = calculateAssetInterest(assetConfig, assetData, masterConstants);
|
|
48
48
|
if (timeElapsed > 0) {
|
|
49
49
|
const updatedSRate = assetData.sRate + mulFactor(masterConstants.FACTOR_SCALE, assetData.sRate, supplyInterest * timeElapsed);
|
|
@@ -53,7 +53,7 @@ function calculateCurrentRates(assetConfig, assetData, masterConstants) {
|
|
|
53
53
|
bRate: updatedBRate,
|
|
54
54
|
supplyInterest,
|
|
55
55
|
borrowInterest,
|
|
56
|
-
now
|
|
56
|
+
now,
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
return {
|
|
@@ -61,7 +61,7 @@ function calculateCurrentRates(assetConfig, assetData, masterConstants) {
|
|
|
61
61
|
bRate: assetData.bRate,
|
|
62
62
|
supplyInterest,
|
|
63
63
|
borrowInterest,
|
|
64
|
-
now
|
|
64
|
+
now,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
exports.calculateCurrentRates = calculateCurrentRates;
|
|
@@ -74,13 +74,13 @@ function calculateAssetData(assetsConfigDict, assetsDataDict, assetId, masterCon
|
|
|
74
74
|
const { sRate, bRate, supplyInterest, borrowInterest, now } = calculateCurrentRates(config, data, masterConstants);
|
|
75
75
|
data.sRate = sRate || 0n;
|
|
76
76
|
data.bRate = bRate || 0n;
|
|
77
|
-
data.
|
|
77
|
+
data.lastAccrual = now;
|
|
78
78
|
const supplyApy = (1 + (Number(supplyInterest) / 1e12) * 24 * 3600) ** 365 - 1;
|
|
79
79
|
const borrowApy = (1 + (Number(borrowInterest) / 1e12) * 24 * 3600) ** 365 - 1;
|
|
80
80
|
return {
|
|
81
81
|
...data,
|
|
82
82
|
...{ supplyInterest, borrowInterest },
|
|
83
|
-
...{ supplyApy, borrowApy }
|
|
83
|
+
...{ supplyApy, borrowApy },
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
exports.calculateAssetData = calculateAssetData;
|
|
@@ -111,12 +111,12 @@ function calculateInterestWithSupplyBorrow(totalSupply, totalBorrow, assetConfig
|
|
|
111
111
|
supplyInterest = mulDiv(mulDiv(borrowInterest, utilization, masterConstants.FACTOR_SCALE), masterConstants.ASSET_RESERVE_FACTOR_SCALE - assetConfig.reserveFactor, masterConstants.ASSET_RESERVE_FACTOR_SCALE);
|
|
112
112
|
return {
|
|
113
113
|
supplyInterest,
|
|
114
|
-
borrowInterest
|
|
114
|
+
borrowInterest,
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
exports.calculateInterestWithSupplyBorrow = calculateInterestWithSupplyBorrow;
|
|
118
118
|
function checkNotInDebtAtAll(principals) {
|
|
119
|
-
return principals.values().every(x => x >= 0n);
|
|
119
|
+
return principals.values().every((x) => x >= 0n);
|
|
120
120
|
}
|
|
121
121
|
exports.checkNotInDebtAtAll = checkNotInDebtAtAll;
|
|
122
122
|
function getAgregatedBalances(assetsData, assetsConfig, principals, prices, masterConstants) {
|
|
@@ -131,10 +131,14 @@ function getAgregatedBalances(assetsData, assetsConfig, principals, prices, mast
|
|
|
131
131
|
const assetData = assetsData.get(assetId);
|
|
132
132
|
const assetConfig = assetsConfig.get(assetId);
|
|
133
133
|
if (principal < 0) {
|
|
134
|
-
user_total_borrow +=
|
|
134
|
+
user_total_borrow +=
|
|
135
|
+
(presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price) /
|
|
136
|
+
10n ** assetConfig.decimals;
|
|
135
137
|
}
|
|
136
138
|
else {
|
|
137
|
-
user_total_supply +=
|
|
139
|
+
user_total_supply +=
|
|
140
|
+
(presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price) /
|
|
141
|
+
10n ** assetConfig.decimals;
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
}
|
|
@@ -162,9 +166,8 @@ function calculateMaximumWithdrawAmount(assetsConfig, assetsData, principals, pr
|
|
|
162
166
|
maxAmountToReclaim = oldPresentValue.amount;
|
|
163
167
|
}
|
|
164
168
|
else if (price > 0) {
|
|
165
|
-
maxAmountToReclaim =
|
|
166
|
-
|
|
167
|
-
- calculatePresentValue(assetData.sRate, assetConfig.dust, masterConstants) / 2n);
|
|
169
|
+
maxAmountToReclaim = bigIntMax(0n, mulDiv(mulDiv(borrowable, masterConstants.ASSET_COEFFICIENT_SCALE, assetConfig.collateralFactor), 10n ** assetConfig.decimals, price) -
|
|
170
|
+
calculatePresentValue(assetData.sRate, assetConfig.dust, masterConstants) / 2n);
|
|
168
171
|
}
|
|
169
172
|
withdrawAmountMax = bigIntMin(maxAmountToReclaim, oldPresentValue.amount);
|
|
170
173
|
}
|
|
@@ -174,7 +177,9 @@ function calculateMaximumWithdrawAmount(assetsConfig, assetsData, principals, pr
|
|
|
174
177
|
return 0n;
|
|
175
178
|
}
|
|
176
179
|
const price = prices.get(assetId);
|
|
177
|
-
return getAvailableToBorrow(assetsConfig, assetsData, principals, prices, masterConstants) *
|
|
180
|
+
return ((getAvailableToBorrow(assetsConfig, assetsData, principals, prices, masterConstants) *
|
|
181
|
+
10n ** assetConfig.decimals) /
|
|
182
|
+
price);
|
|
178
183
|
}
|
|
179
184
|
return withdrawAmountMax;
|
|
180
185
|
}
|
|
@@ -197,8 +202,7 @@ function getAvailableToBorrow(assetsConfig, assetsData, principals, prices, mast
|
|
|
197
202
|
borrowAmount += mulDiv(calculatePresentValue(assetData.bRate, -principal, masterConstants), price, 10n ** assetConfig.decimals);
|
|
198
203
|
}
|
|
199
204
|
else if (principal > 0n) {
|
|
200
|
-
borrowLimit +=
|
|
201
|
-
mulDiv(mulDiv(calculatePresentValue(assetData.sRate, principal, masterConstants), price, 10n ** assetConfig.decimals), assetConfig.collateralFactor, masterConstants.ASSET_COEFFICIENT_SCALE);
|
|
205
|
+
borrowLimit += mulDiv(mulDiv(calculatePresentValue(assetData.sRate, principal, masterConstants), price, 10n ** assetConfig.decimals), assetConfig.collateralFactor, masterConstants.ASSET_COEFFICIENT_SCALE);
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
return borrowLimit - borrowAmount;
|
|
@@ -215,19 +219,19 @@ function presentValue(sRate, bRate, principalValue, masterConstants) {
|
|
|
215
219
|
if (principalValue > 0) {
|
|
216
220
|
return {
|
|
217
221
|
amount: calculatePresentValue(sRate, principalValue, masterConstants),
|
|
218
|
-
type: User_1.BalanceType.supply
|
|
222
|
+
type: User_1.BalanceType.supply,
|
|
219
223
|
};
|
|
220
224
|
}
|
|
221
225
|
else if (principalValue < 0) {
|
|
222
226
|
return {
|
|
223
227
|
amount: calculatePresentValue(bRate, -principalValue, masterConstants),
|
|
224
|
-
type: User_1.BalanceType.borrow
|
|
228
|
+
type: User_1.BalanceType.borrow,
|
|
225
229
|
};
|
|
226
230
|
}
|
|
227
231
|
else {
|
|
228
232
|
return {
|
|
229
233
|
amount: 0n,
|
|
230
|
-
type: undefined
|
|
234
|
+
type: undefined,
|
|
231
235
|
};
|
|
232
236
|
}
|
|
233
237
|
}
|
|
@@ -247,21 +251,21 @@ function calculateHealthParams(parameters) {
|
|
|
247
251
|
continue;
|
|
248
252
|
const assetPrincipal = principals.get(asset.assetId);
|
|
249
253
|
if (!assetsConfig.has(asset.assetId))
|
|
250
|
-
throw
|
|
254
|
+
throw `No config for ${asset.name}:${asset.assetId}`;
|
|
251
255
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
252
256
|
if (!assetsData.has(asset.assetId))
|
|
253
|
-
throw
|
|
257
|
+
throw `No data for asset ${asset.name}:${asset.assetId}`;
|
|
254
258
|
const assetData = assetsData.get(asset.assetId);
|
|
255
259
|
if (!prices.has(asset.assetId))
|
|
256
|
-
throw
|
|
260
|
+
throw `No price for asset ${asset.name}:${asset.assetId}`;
|
|
257
261
|
const assetPrice = prices.get(asset.assetId);
|
|
258
262
|
const assetScale = 10n ** assetConfig.decimals;
|
|
259
263
|
const { sRate, bRate } = assetData;
|
|
260
264
|
const assetBalance = presentValue(sRate, bRate, assetPrincipal, poolConfig.masterConstants);
|
|
261
|
-
const assetWorth = assetBalance.amount * assetPrice / assetScale;
|
|
265
|
+
const assetWorth = (assetBalance.amount * assetPrice) / assetScale;
|
|
262
266
|
if (assetBalance.type === User_1.BalanceType.supply) {
|
|
263
267
|
totalSupply += assetWorth;
|
|
264
|
-
totalLimit += assetWorth * assetConfig.liquidationThreshold / ASSET_LIQUIDATION_THRESHOLD_SCALE;
|
|
268
|
+
totalLimit += (assetWorth * assetConfig.liquidationThreshold) / ASSET_LIQUIDATION_THRESHOLD_SCALE;
|
|
265
269
|
}
|
|
266
270
|
else if (assetBalance.type === User_1.BalanceType.borrow && assetConfig.dust < assetBalance.amount) {
|
|
267
271
|
totalDebt += assetWorth;
|
|
@@ -274,9 +278,11 @@ function calculateHealthParams(parameters) {
|
|
|
274
278
|
return (0, liquidation_1.isBadDebt)(totalSupply, totalDebt, liquidationBonus, poolConfig.masterConstants);
|
|
275
279
|
};
|
|
276
280
|
return {
|
|
277
|
-
totalDebt,
|
|
281
|
+
totalDebt,
|
|
282
|
+
totalLimit,
|
|
283
|
+
totalSupply,
|
|
278
284
|
isLiquidatable: _isLiquidable,
|
|
279
|
-
isBadDebt: _isBadDebt
|
|
285
|
+
isBadDebt: _isBadDebt,
|
|
280
286
|
};
|
|
281
287
|
}
|
|
282
288
|
exports.calculateHealthParams = calculateHealthParams;
|
|
@@ -303,12 +309,13 @@ function calculateLiquidationData(assetsConfig, assetsData, principals, prices,
|
|
|
303
309
|
continue;
|
|
304
310
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
305
311
|
const assetData = assetsData.get(asset.assetId);
|
|
306
|
-
const balance = principal > 0
|
|
307
|
-
(principal * assetData.sRate) / ASSET_SRATE_SCALE
|
|
308
|
-
(principal * assetData.bRate) / ASSET_BRATE_SCALE;
|
|
312
|
+
const balance = principal > 0
|
|
313
|
+
? (principal * assetData.sRate) / ASSET_SRATE_SCALE
|
|
314
|
+
: (principal * assetData.bRate) / ASSET_BRATE_SCALE;
|
|
309
315
|
const assetWorth = (bigAbs(balance) * prices.get(asset.assetId)) / 10n ** assetConfig.decimals;
|
|
310
316
|
if (balance > 0) {
|
|
311
|
-
totalLimit +=
|
|
317
|
+
totalLimit +=
|
|
318
|
+
(assetWorth * assetConfig.liquidationThreshold) / poolConfig.masterConstants.ASSET_COEFFICIENT_SCALE;
|
|
312
319
|
// get the greatest collateral
|
|
313
320
|
if (assetWorth > collateralValue) {
|
|
314
321
|
collateralValue = assetWorth;
|
|
@@ -340,7 +347,9 @@ function calculateLiquidationData(assetsConfig, assetsData, principals, prices,
|
|
|
340
347
|
const liquidationAmount = bigIntMin(...values) - 5n;
|
|
341
348
|
const collateralAssetPrice = prices.get(collateralAsset.assetId);
|
|
342
349
|
const collateralDecimal = 10n ** collateralAssetConfig.decimals;
|
|
343
|
-
let minCollateralAmount = (((liquidationAmount * loanAssetPrice * liquidationBonus) /
|
|
350
|
+
let minCollateralAmount = (((liquidationAmount * loanAssetPrice * liquidationBonus) /
|
|
351
|
+
poolConfig.masterConstants.ASSET_LIQUIDATION_BONUS_SCALE) *
|
|
352
|
+
collateralDecimal) /
|
|
344
353
|
collateralAssetPrice /
|
|
345
354
|
loanScale -
|
|
346
355
|
10n;
|
|
@@ -355,7 +364,7 @@ function calculateLiquidationData(assetsConfig, assetsData, principals, prices,
|
|
|
355
364
|
totalLimit,
|
|
356
365
|
liquidable: true,
|
|
357
366
|
liquidationAmount: (0, liquidation_1.addReserve)(liquidationAmount, loanAssetConfig.liquidationReserveFactor, poolConfig.masterConstants.ASSET_RESERVE_FACTOR_SCALE),
|
|
358
|
-
minCollateralAmount
|
|
367
|
+
minCollateralAmount,
|
|
359
368
|
};
|
|
360
369
|
}
|
|
361
370
|
}
|
|
@@ -366,7 +375,7 @@ function calculateLiquidationData(assetsConfig, assetsData, principals, prices,
|
|
|
366
375
|
greatestLoanValue: loanValue,
|
|
367
376
|
totalDebt,
|
|
368
377
|
totalLimit,
|
|
369
|
-
liquidable: false
|
|
378
|
+
liquidable: false,
|
|
370
379
|
};
|
|
371
380
|
}
|
|
372
381
|
exports.calculateLiquidationData = calculateLiquidationData;
|
|
@@ -379,20 +388,28 @@ function predictHealthFactor(args) {
|
|
|
379
388
|
let totalBorrow = Number(healthParams.totalDebt);
|
|
380
389
|
const currentAmount = args.amount;
|
|
381
390
|
const decimals = Number(assetConfig.decimals);
|
|
382
|
-
const currentBalance = assetPrice * Number(currentAmount) / Math.pow(10, decimals);
|
|
391
|
+
const currentBalance = (assetPrice * Number(currentAmount)) / Math.pow(10, decimals);
|
|
383
392
|
const changeType = args.balanceChangeType;
|
|
384
393
|
if (currentAmount != null && currentAmount != 0n) {
|
|
385
394
|
if (changeType == User_1.BalanceChangeType.Borrow) {
|
|
386
|
-
totalBorrow +=
|
|
395
|
+
totalBorrow +=
|
|
396
|
+
currentBalance *
|
|
397
|
+
(1 +
|
|
398
|
+
Number(assetConfig.originationFee) /
|
|
399
|
+
Number(args.poolConfig.masterConstants.ASSET_ORIGINATION_FEE_SCALE));
|
|
387
400
|
}
|
|
388
401
|
else if (changeType == User_1.BalanceChangeType.Repay) {
|
|
389
402
|
totalBorrow -= currentBalance;
|
|
390
403
|
}
|
|
391
404
|
else if (changeType == User_1.BalanceChangeType.Withdraw) {
|
|
392
|
-
totalLimit -=
|
|
405
|
+
totalLimit -=
|
|
406
|
+
(currentBalance * Number(assetConfig.liquidationThreshold)) /
|
|
407
|
+
Number(args.poolConfig.masterConstants.ASSET_COEFFICIENT_SCALE);
|
|
393
408
|
}
|
|
394
409
|
else if (changeType == User_1.BalanceChangeType.Supply) {
|
|
395
|
-
totalLimit +=
|
|
410
|
+
totalLimit +=
|
|
411
|
+
(currentBalance * Number(assetConfig.liquidationThreshold)) /
|
|
412
|
+
Number(args.poolConfig.masterConstants.ASSET_COEFFICIENT_SCALE);
|
|
396
413
|
}
|
|
397
414
|
}
|
|
398
415
|
if (Number(totalLimit) == 0) {
|
|
@@ -434,7 +451,7 @@ function predictAPY(args) {
|
|
|
434
451
|
return {
|
|
435
452
|
...interest,
|
|
436
453
|
supplyApy: (1 + (Number(interest.supplyInterest) / 1e12) * 24 * 3600) ** 365 - 1,
|
|
437
|
-
borrowApy: (1 + (Number(interest.borrowInterest) / 1e12) * 24 * 3600) ** 365 - 1
|
|
454
|
+
borrowApy: (1 + (Number(interest.borrowInterest) / 1e12) * 24 * 3600) ** 365 - 1,
|
|
438
455
|
};
|
|
439
456
|
}
|
|
440
457
|
exports.predictAPY = predictAPY;
|
package/dist/api/parser.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Dictionary, DictionaryValue } from '@ton/core';
|
|
2
2
|
import { MasterConfig, MasterData, OracleInfo } from '../contracts/AbstractMaster';
|
|
3
|
-
import { AssetConfig, AssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants,
|
|
3
|
+
import { AssetConfig, AssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants, PoolAssetConfig, PoolConfig } from '../types/Master';
|
|
4
4
|
import { UserData, UserLiteData, UserRewards } from '../types/User';
|
|
5
5
|
import { OracleParser } from './parsers/AbstractOracleParser';
|
|
6
6
|
export declare function createUserRewards(): DictionaryValue<UserRewards>;
|
|
7
7
|
export declare function createAssetData(): DictionaryValue<AssetData>;
|
|
8
8
|
export declare function createAssetConfig(): DictionaryValue<AssetConfig>;
|
|
9
|
-
export declare function parseMasterData(masterDataBOC: string, poolAssetsConfig:
|
|
9
|
+
export declare function parseMasterData(masterDataBOC: string, poolAssetsConfig: PoolAssetConfig[], masterConstants: MasterConstants, oracleParser: OracleParser): MasterData<MasterConfig<OracleInfo>>;
|
|
10
10
|
export declare function parseUserLiteData(userDataBOC: string, assetsData: ExtendedAssetsData, assetsConfig: ExtendedAssetsConfig, poolConfig: PoolConfig, applyDust?: boolean): UserLiteData;
|
|
11
11
|
export declare function parseUserData(userLiteData: UserLiteData, assetsData: ExtendedAssetsData, assetsConfig: ExtendedAssetsConfig, prices: Dictionary<bigint, bigint>, poolConfig: PoolConfig, applyDust?: boolean): UserData;
|
package/dist/api/parser.js
CHANGED
|
@@ -26,7 +26,7 @@ function createAssetData() {
|
|
|
26
26
|
buidler.storeUint(src.bRate, 64);
|
|
27
27
|
buidler.storeInt(src.totalSupply, 64);
|
|
28
28
|
buidler.storeInt(src.totalBorrow, 64);
|
|
29
|
-
buidler.storeUint(src.
|
|
29
|
+
buidler.storeUint(src.lastAccrual, 32);
|
|
30
30
|
buidler.storeUint(src.balance, 64);
|
|
31
31
|
buidler.storeUint(src.trackingSupplyIndex, 64);
|
|
32
32
|
buidler.storeUint(src.trackingBorrowIndex, 64);
|
|
@@ -37,7 +37,7 @@ function createAssetData() {
|
|
|
37
37
|
const bRate = BigInt(src.loadUintBig(64));
|
|
38
38
|
const totalSupply = BigInt(src.loadIntBig(64));
|
|
39
39
|
const totalBorrow = BigInt(src.loadIntBig(64));
|
|
40
|
-
const
|
|
40
|
+
const lastAccrual = BigInt(src.loadUintBig(32));
|
|
41
41
|
const balance = BigInt(src.loadUintBig(64));
|
|
42
42
|
const trackingSupplyIndex = BigInt(src.loadUintBig(64));
|
|
43
43
|
const trackingBorrowIndex = BigInt(src.loadUintBig(64));
|
|
@@ -47,7 +47,7 @@ function createAssetData() {
|
|
|
47
47
|
bRate,
|
|
48
48
|
totalSupply,
|
|
49
49
|
totalBorrow,
|
|
50
|
-
|
|
50
|
+
lastAccrual,
|
|
51
51
|
balance,
|
|
52
52
|
trackingSupplyIndex,
|
|
53
53
|
trackingBorrowIndex,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
import { HexString } from '@pythnetwork/hermes-client';
|
|
3
2
|
import { Address, Dictionary, Slice } from '@ton/core';
|
|
3
|
+
import { FeedMapItem } from '../feeds';
|
|
4
4
|
import { AbstractOracleParser } from './AbstractOracleParser';
|
|
5
5
|
export type OracleConfig = {
|
|
6
6
|
pythAddress: Address;
|
|
7
|
-
feedsMap:
|
|
7
|
+
feedsMap: Map<HexString, FeedMapItem>;
|
|
8
8
|
allowedRefTokens: Dictionary<bigint, bigint>;
|
|
9
9
|
};
|
|
10
10
|
export type PythOracleInfo = OracleConfig & {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PythOracleParser = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
|
+
const feeds_1 = require("../feeds");
|
|
5
6
|
const AbstractOracleParser_1 = require("./AbstractOracleParser");
|
|
6
7
|
class PythOracleParser extends AbstractOracleParser_1.AbstractOracleParser {
|
|
7
8
|
parseOracleConfig(masterConfigSlice) {
|
|
@@ -10,7 +11,7 @@ class PythOracleParser extends AbstractOracleParser_1.AbstractOracleParser {
|
|
|
10
11
|
const feedDataSlice = feedDataCell.beginParse();
|
|
11
12
|
return {
|
|
12
13
|
pythAddress: oraclesSlice.loadAddress(),
|
|
13
|
-
feedsMap: feedDataSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.Buffer(64)),
|
|
14
|
+
feedsMap: (0, feeds_1.parseFeedsMapDict)(feedDataSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.Buffer(64))),
|
|
14
15
|
allowedRefTokens: feedDataSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigUint(256)),
|
|
15
16
|
pricesTtl: oraclesSlice.loadUint(32),
|
|
16
17
|
pythComputeBaseGas: oraclesSlice.loadUintBig(64),
|
package/dist/api/prices.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.packPythUpdatesData = exports.composeFeedsCell = void 0;
|
|
|
4
4
|
const pyth_ton_js_1 = require("@pythnetwork/pyth-ton-js");
|
|
5
5
|
const core_1 = require("@ton/core");
|
|
6
6
|
const ton_1 = require("@ton/ton");
|
|
7
|
+
// TODO: move to PythCollector
|
|
7
8
|
function composeFeedsCell(feeds) {
|
|
8
9
|
if (feeds.length === 0) {
|
|
9
10
|
return (0, ton_1.beginCell)().storeUint(0, 8).endCell();
|
|
@@ -39,7 +40,7 @@ export async function getPrices(endpoints: string[] = ["api.stardust-mainnet.iot
|
|
|
39
40
|
backendEndpoints: DefaultPriceSourcesConfig.backendEndpoints,
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
const priceCollector = new
|
|
43
|
+
const priceCollector = new ClassicCollector(poolConfig, sources);
|
|
43
44
|
const prices = await priceCollector.getPrices();
|
|
44
45
|
|
|
45
46
|
return { dict: prices.dict, dataCell: prices.dataCell };
|
|
@@ -51,15 +51,29 @@ export declare const OPCODES: {
|
|
|
51
51
|
JETTON_TRANSFER: number;
|
|
52
52
|
};
|
|
53
53
|
export declare const FEES: {
|
|
54
|
-
JETTON_FWD: bigint;
|
|
55
|
-
SUPPLY: bigint;
|
|
56
|
-
SUPPLY_WITHDRAW: bigint;
|
|
57
|
-
LIQUIDATION: bigint;
|
|
58
|
-
LIQUIDATION_JETTON: bigint;
|
|
59
|
-
LIQUIDATION_JETTON_FWD: bigint;
|
|
60
|
-
REWARD_MASTER_TON_TOP_UP: bigint;
|
|
61
|
-
REWARD_MASTER_DEPLOY: bigint;
|
|
62
|
-
REWARD_MASTER_WITHDRAW: bigint;
|
|
63
|
-
REWARD_USER_DEPLOY: bigint;
|
|
64
|
-
REWARD_USER_CLAIM: bigint;
|
|
54
|
+
readonly JETTON_FWD: bigint;
|
|
55
|
+
readonly SUPPLY: bigint;
|
|
56
|
+
readonly SUPPLY_WITHDRAW: bigint;
|
|
57
|
+
readonly LIQUIDATION: bigint;
|
|
58
|
+
readonly LIQUIDATION_JETTON: bigint;
|
|
59
|
+
readonly LIQUIDATION_JETTON_FWD: bigint;
|
|
60
|
+
readonly REWARD_MASTER_TON_TOP_UP: bigint;
|
|
61
|
+
readonly REWARD_MASTER_DEPLOY: bigint;
|
|
62
|
+
readonly REWARD_MASTER_WITHDRAW: bigint;
|
|
63
|
+
readonly REWARD_USER_DEPLOY: bigint;
|
|
64
|
+
readonly REWARD_USER_CLAIM: bigint;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Common validation constants and error messages
|
|
68
|
+
*/
|
|
69
|
+
export declare const VALIDATION: {
|
|
70
|
+
readonly ERRORS: {
|
|
71
|
+
readonly INVALID_AMOUNT: "Amount must be positive";
|
|
72
|
+
readonly INVALID_SUBACCOUNT_ID: "Subaccount ID must be between 0 and 255";
|
|
73
|
+
readonly MISSING_JETTON_AMOUNT: "Either amount, liquidationAmount, or supplyAmount must be provided";
|
|
74
|
+
readonly MISSING_RESPONSE_ADDRESS: "responseAddress, userAddress, or liquidatorAddress must be provided";
|
|
75
|
+
readonly INVALID_ASSET_CONFIG: "Invalid asset configuration provided";
|
|
76
|
+
readonly MASTER_CONTRACT_INACTIVE: "Master contract is not active";
|
|
77
|
+
readonly OUTDATED_SDK_VERSION: "Outdated SDK pool version";
|
|
78
|
+
};
|
|
65
79
|
};
|
|
@@ -14,7 +14,7 @@ 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.FEES = exports.OPCODES = exports.MASTER_CONSTANTS = exports.ASSET_PRICE_SCALE = exports.NULL_ADDRESS = void 0;
|
|
17
|
+
exports.VALIDATION = exports.FEES = exports.OPCODES = exports.MASTER_CONSTANTS = exports.ASSET_PRICE_SCALE = exports.NULL_ADDRESS = void 0;
|
|
18
18
|
const core_1 = require("@ton/core");
|
|
19
19
|
__exportStar(require("./mainnet"), exports);
|
|
20
20
|
__exportStar(require("./testnet"), exports);
|
|
@@ -91,3 +91,17 @@ exports.FEES = {
|
|
|
91
91
|
REWARD_USER_DEPLOY: (0, core_1.toNano)('0.05'),
|
|
92
92
|
REWARD_USER_CLAIM: (0, core_1.toNano)('0.1'),
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Common validation constants and error messages
|
|
96
|
+
*/
|
|
97
|
+
exports.VALIDATION = {
|
|
98
|
+
ERRORS: {
|
|
99
|
+
INVALID_AMOUNT: 'Amount must be positive',
|
|
100
|
+
INVALID_SUBACCOUNT_ID: 'Subaccount ID must be between 0 and 255',
|
|
101
|
+
MISSING_JETTON_AMOUNT: 'Either amount, liquidationAmount, or supplyAmount must be provided',
|
|
102
|
+
MISSING_RESPONSE_ADDRESS: 'responseAddress, userAddress, or liquidatorAddress must be provided',
|
|
103
|
+
INVALID_ASSET_CONFIG: 'Invalid asset configuration provided',
|
|
104
|
+
MASTER_CONTRACT_INACTIVE: 'Master contract is not active',
|
|
105
|
+
OUTDATED_SDK_VERSION: 'Outdated SDK pool version',
|
|
106
|
+
},
|
|
107
|
+
};
|