@evaafi/sdk 0.6.1 → 0.6.2-b
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/LICENSE.md +7 -0
- package/README.md +2 -1
- package/dist/api/liquidation.js +1 -3
- package/dist/api/math.d.ts +10 -1
- package/dist/api/math.js +45 -6
- package/dist/api/parser.js +49 -27
- package/dist/api/prices.d.ts +5 -2
- package/dist/api/prices.js +35 -13
- package/dist/constants/assets.d.ts +8 -0
- package/dist/constants/assets.js +31 -1
- package/dist/constants/general.d.ts +5 -2
- package/dist/constants/general.js +12 -22
- package/dist/constants/pools.d.ts +1 -0
- package/dist/constants/pools.js +19 -3
- package/dist/contracts/MasterContract.d.ts +5 -0
- package/dist/contracts/MasterContract.js +6 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +10 -2
- package/dist/prices/Prices.d.ts +9 -0
- package/dist/prices/Prices.js +43 -0
- package/dist/prices/PricesCollector.d.ts +12 -0
- package/dist/prices/PricesCollector.js +123 -0
- package/dist/prices/Types.d.ts +33 -0
- package/dist/prices/Types.js +11 -0
- package/dist/prices/constants.d.ts +1 -0
- package/dist/prices/constants.js +4 -0
- package/dist/prices/index.d.ts +6 -0
- package/dist/prices/index.js +22 -0
- package/dist/prices/sources/Backend.d.ts +13 -0
- package/dist/prices/sources/Backend.js +52 -0
- package/dist/prices/sources/Icp.d.ts +10 -0
- package/dist/prices/sources/Icp.js +23 -0
- package/dist/prices/sources/Iota.d.ts +39 -0
- package/dist/prices/sources/Iota.js +49 -0
- package/dist/prices/sources/PriceSource.d.ts +14 -0
- package/dist/prices/sources/PriceSource.js +26 -0
- package/dist/prices/sources/index.d.ts +4 -0
- package/dist/prices/sources/index.js +20 -0
- package/dist/prices/utils.d.ts +23 -0
- package/dist/prices/utils.js +148 -0
- package/dist/types/Master.d.ts +2 -1
- package/dist/types/User.d.ts +11 -1
- package/dist/utils/userJettonWallet.js +42 -43
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +5 -1
- package/package.json +11 -9
- package/src/api/liquidation.ts +0 -1
- package/src/api/math.ts +66 -5
- package/src/api/parser.ts +56 -31
- package/src/api/prices.ts +20 -7
- package/src/constants/assets.ts +57 -0
- package/src/constants/general.ts +11 -23
- package/src/constants/pools.ts +21 -5
- package/src/contracts/MasterContract.ts +8 -1
- package/src/index.ts +9 -2
- package/src/prices/Prices.ts +32 -0
- package/src/prices/PricesCollector.ts +139 -0
- package/src/prices/Types.ts +44 -0
- package/src/prices/constants.ts +1 -0
- package/src/prices/index.ts +6 -0
- package/src/prices/sources/Backend.ts +62 -0
- package/src/prices/sources/Icp.ts +27 -0
- package/src/prices/sources/Iota.ts +90 -0
- package/src/prices/sources/PriceSource.ts +35 -0
- package/src/prices/sources/index.ts +4 -0
- package/src/prices/utils.ts +170 -0
- package/src/types/Master.ts +3 -2
- package/src/types/User.ts +13 -3
- package/src/utils/userJettonWallet.ts +43 -53
- package/src/utils/utils.ts +5 -1
- package/src/config.ts +0 -1
- package/src/types/Common.ts +0 -16
- package/src/utils/priceUtils.ts +0 -177
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 TON LANDING FOUNDATION
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
The EVAA SDK is designed to easily integrate with the EVAA lending protocol on TON blockchain.
|
|
4
4
|
|
|
5
5
|
## Documentation
|
|
6
|
+
You can find the Typedoc documentation [here](https://evaafi.github.io/sdk/).
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Additional (older) documentation can also be found in the [docs](./docs) folder.
|
package/dist/api/liquidation.js
CHANGED
|
@@ -121,9 +121,7 @@ principalsDict, pricesDict, assetsDataDict, assetsConfigDict, masterConstants) {
|
|
|
121
121
|
allowedCollateralValue = math_1.BigMath.min(allowedCollateralValue, math_1.BigMath.max(allowedCollateralValue / 2n, collateralThreshold));
|
|
122
122
|
}
|
|
123
123
|
const loanValue = toAssetWorth(loanInfo.balance, loanInfo.scale, loanInfo.price);
|
|
124
|
-
const baseLiquidationValue = math_1.BigMath.min(
|
|
125
|
-
// deductReserve(loanValue, reserveFactor, reserveFactorScale),
|
|
126
|
-
loanValue, deductLiquidationBonus(allowedCollateralValue, liquidationBonus, liquidationBonusScale));
|
|
124
|
+
const baseLiquidationValue = math_1.BigMath.min(loanValue, deductLiquidationBonus(allowedCollateralValue, liquidationBonus, liquidationBonusScale));
|
|
127
125
|
// calculate collateral amount
|
|
128
126
|
let collateralAmount = addLiquidationBonus(baseLiquidationValue, liquidationBonus, liquidationBonusScale);
|
|
129
127
|
collateralAmount = toAssetAmount(collateralAmount, collateralInfo.scale, collateralInfo.price);
|
package/dist/api/math.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgregatedBalances, AssetConfig, AssetData, AssetInterest, ExtendedAssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants, PoolConfig } from '../types/Master';
|
|
2
2
|
import { Dictionary } from '@ton/core';
|
|
3
|
-
import { HealthParamsArgs, LiquidationData, PredictHealthFactorArgs, UserBalance } from '../types/User';
|
|
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;
|
|
6
6
|
export declare function mulDivC(x: bigint, y: bigint, z: bigint): bigint;
|
|
@@ -25,6 +25,7 @@ export declare function calculateCurrentRates(assetConfig: AssetConfig, assetDat
|
|
|
25
25
|
};
|
|
26
26
|
export declare function calculateAssetData(assetsConfigDict: ExtendedAssetsConfig, assetsDataDict: Dictionary<bigint, AssetData>, assetId: bigint, masterConstants: MasterConstants): ExtendedAssetData;
|
|
27
27
|
export declare function calculateAssetInterest(assetConfig: AssetConfig, assetData: AssetData, masterConstants: MasterConstants): AssetInterest;
|
|
28
|
+
export declare function calculateInterestWithSupplyBorrow(totalSupply: bigint, totalBorrow: bigint, assetConfig: AssetConfig, masterConstants: MasterConstants): AssetInterest;
|
|
28
29
|
export declare function checkNotInDebtAtAll(principals: Dictionary<bigint, bigint>): boolean;
|
|
29
30
|
export declare function getAgregatedBalances(assetsData: ExtendedAssetsData, assetsConfig: ExtendedAssetsConfig, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants): AgregatedBalances;
|
|
30
31
|
export declare function calculateMaximumWithdrawAmount(assetsConfig: ExtendedAssetsConfig, assetsData: ExtendedAssetsData, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants, assetId: bigint): bigint;
|
|
@@ -59,3 +60,11 @@ export declare function calculateHealthParams(parameters: HealthParamsArgs): {
|
|
|
59
60
|
*/
|
|
60
61
|
export declare function calculateLiquidationData(assetsConfig: ExtendedAssetsConfig, assetsData: ExtendedAssetsData, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, poolConfig: PoolConfig): LiquidationData;
|
|
61
62
|
export declare function predictHealthFactor(args: PredictHealthFactorArgs): number;
|
|
63
|
+
/**
|
|
64
|
+
* Predicts how APY will change as a result of one of the actions Borrow, Supply, Withdraw or Repay.
|
|
65
|
+
*
|
|
66
|
+
* Used on the front-end.
|
|
67
|
+
*
|
|
68
|
+
* @returns Estimated APYs for Supply and Borrow
|
|
69
|
+
*/
|
|
70
|
+
export declare function predictAPY(args: PredictAPYArgs): AssetInterest;
|
package/dist/api/math.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.predictHealthFactor = exports.calculateLiquidationData = exports.calculateHealthParams = exports.presentValue = exports.getAvailableToBorrow = exports.calculateMaximumWithdrawAmount = exports.getAgregatedBalances = exports.checkNotInDebtAtAll = exports.calculateAssetInterest = exports.calculateAssetData = exports.calculateCurrentRates = exports.calculatePresentValue = exports.BigMath = exports.bigIntMin = exports.bigIntMax = exports.bigAbs = exports.mulDivC = exports.mulDiv = exports.mulFactor = void 0;
|
|
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.calculatePresentValue = exports.BigMath = exports.bigIntMin = exports.bigIntMax = exports.bigAbs = exports.mulDivC = exports.mulDiv = exports.mulFactor = void 0;
|
|
4
4
|
const User_1 = require("../types/User");
|
|
5
5
|
const assets_1 = require("../constants/assets");
|
|
6
6
|
const liquidation_1 = require("./liquidation");
|
|
@@ -81,6 +81,10 @@ exports.calculateAssetData = calculateAssetData;
|
|
|
81
81
|
function calculateAssetInterest(assetConfig, assetData, masterConstants) {
|
|
82
82
|
const totalSupply = calculatePresentValue(assetData.sRate, assetData.totalSupply, masterConstants);
|
|
83
83
|
const totalBorrow = calculatePresentValue(assetData.bRate, assetData.totalBorrow, masterConstants);
|
|
84
|
+
return calculateInterestWithSupplyBorrow(totalSupply, totalBorrow, assetConfig, masterConstants);
|
|
85
|
+
}
|
|
86
|
+
exports.calculateAssetInterest = calculateAssetInterest;
|
|
87
|
+
function calculateInterestWithSupplyBorrow(totalSupply, totalBorrow, assetConfig, masterConstants) {
|
|
84
88
|
let utilization = 0n;
|
|
85
89
|
let supplyInterest = 0n;
|
|
86
90
|
let borrowInterest = 0n;
|
|
@@ -104,7 +108,7 @@ function calculateAssetInterest(assetConfig, assetData, masterConstants) {
|
|
|
104
108
|
borrowInterest
|
|
105
109
|
};
|
|
106
110
|
}
|
|
107
|
-
exports.
|
|
111
|
+
exports.calculateInterestWithSupplyBorrow = calculateInterestWithSupplyBorrow;
|
|
108
112
|
function checkNotInDebtAtAll(principals) {
|
|
109
113
|
return principals.values().every(x => x >= 0n);
|
|
110
114
|
}
|
|
@@ -120,14 +124,12 @@ function getAgregatedBalances(assetsData, assetsConfig, principals, prices, mast
|
|
|
120
124
|
const price = prices.get(assetId);
|
|
121
125
|
const assetData = assetsData.get(assetId);
|
|
122
126
|
const assetConfig = assetsConfig.get(assetId);
|
|
123
|
-
// console.log('price', price);
|
|
124
127
|
if (principal < 0) {
|
|
125
128
|
user_total_borrow += presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price / 10n ** assetConfig.decimals;
|
|
126
129
|
}
|
|
127
130
|
else {
|
|
128
131
|
user_total_supply += presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price / 10n ** assetConfig.decimals;
|
|
129
132
|
}
|
|
130
|
-
// console.log('aggregated', assetId, presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).type, presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price / 10n ** assetConfig.decimals)
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
return { totalSupply: user_total_supply, totalBorrow: user_total_borrow };
|
|
@@ -175,10 +177,16 @@ function getAvailableToBorrow(assetsConfig, assetsData, principals, prices, mast
|
|
|
175
177
|
let borrowLimit = 0n;
|
|
176
178
|
let borrowAmount = 0n;
|
|
177
179
|
for (const assetID of principals.keys()) {
|
|
180
|
+
const principal = principals.get(assetID);
|
|
181
|
+
if (principal == 0n) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!prices.has(assetID)) {
|
|
185
|
+
return 0n;
|
|
186
|
+
}
|
|
178
187
|
const assetConfig = assetsConfig.get(assetID);
|
|
179
188
|
const assetData = assetsData.get(assetID);
|
|
180
189
|
const price = prices.get(assetID);
|
|
181
|
-
const principal = principals.get(assetID);
|
|
182
190
|
if (principal < 0n) {
|
|
183
191
|
borrowAmount += mulDiv(calculatePresentValue(assetData.bRate, -principal, masterConstants), price, 10n ** assetConfig.decimals);
|
|
184
192
|
}
|
|
@@ -361,7 +369,6 @@ function predictHealthFactor(args) {
|
|
|
361
369
|
const assetId = args.asset.assetId;
|
|
362
370
|
const assetConfig = args.assetsConfig.get(assetId);
|
|
363
371
|
const assetPrice = Number(args.prices.get(assetId));
|
|
364
|
-
const assetData = args.assetsData.get(assetId);
|
|
365
372
|
let totalLimit = Number(healthParams.totalLimit);
|
|
366
373
|
let totalBorrow = Number(healthParams.totalDebt);
|
|
367
374
|
const currentAmount = args.amount;
|
|
@@ -388,3 +395,35 @@ function predictHealthFactor(args) {
|
|
|
388
395
|
return Math.min(Math.max(1 - totalBorrow / totalLimit, 0), 1); // let's limit a result to zero below and one above
|
|
389
396
|
}
|
|
390
397
|
exports.predictHealthFactor = predictHealthFactor;
|
|
398
|
+
/**
|
|
399
|
+
* Predicts how APY will change as a result of one of the actions Borrow, Supply, Withdraw or Repay.
|
|
400
|
+
*
|
|
401
|
+
* Used on the front-end.
|
|
402
|
+
*
|
|
403
|
+
* @returns Estimated APYs for Supply and Borrow
|
|
404
|
+
*/
|
|
405
|
+
function predictAPY(args) {
|
|
406
|
+
const assetConfig = args.assetConfig;
|
|
407
|
+
const assetData = args.assetData;
|
|
408
|
+
const masterConstants = args.masterConstants;
|
|
409
|
+
let totalSupply = calculatePresentValue(assetData.sRate, assetData.totalSupply, masterConstants);
|
|
410
|
+
let totalBorrow = calculatePresentValue(assetData.bRate, assetData.totalBorrow, masterConstants);
|
|
411
|
+
const currentAmount = args.amount;
|
|
412
|
+
const changeType = args.balanceChangeType;
|
|
413
|
+
if (currentAmount != null && currentAmount != 0n) {
|
|
414
|
+
if (changeType == User_1.BalanceChangeType.Borrow) {
|
|
415
|
+
totalBorrow += currentAmount;
|
|
416
|
+
}
|
|
417
|
+
else if (changeType == User_1.BalanceChangeType.Repay) {
|
|
418
|
+
totalBorrow -= currentAmount;
|
|
419
|
+
}
|
|
420
|
+
else if (changeType == User_1.BalanceChangeType.Withdraw) {
|
|
421
|
+
totalSupply -= currentAmount;
|
|
422
|
+
}
|
|
423
|
+
else if (changeType == User_1.BalanceChangeType.Supply) {
|
|
424
|
+
totalSupply += currentAmount;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return calculateInterestWithSupplyBorrow(totalSupply, totalBorrow, assetConfig, masterConstants);
|
|
428
|
+
}
|
|
429
|
+
exports.predictAPY = predictAPY;
|
package/dist/api/parser.js
CHANGED
|
@@ -24,29 +24,24 @@ function createAssetData() {
|
|
|
24
24
|
serialize: (src, buidler) => {
|
|
25
25
|
buidler.storeUint(src.sRate, 64);
|
|
26
26
|
buidler.storeUint(src.bRate, 64);
|
|
27
|
-
buidler.
|
|
28
|
-
buidler.
|
|
27
|
+
buidler.storeInt(src.totalSupply, 64);
|
|
28
|
+
buidler.storeInt(src.totalBorrow, 64);
|
|
29
29
|
buidler.storeUint(src.lastAccural, 32);
|
|
30
30
|
buidler.storeUint(src.balance, 64);
|
|
31
31
|
buidler.storeUint(src.trackingSupplyIndex, 64);
|
|
32
32
|
buidler.storeUint(src.trackingBorrowIndex, 64);
|
|
33
|
-
|
|
34
|
-
buidler.storeUint(src.awaitedSupply, 64);
|
|
35
|
-
}
|
|
33
|
+
buidler.storeUint(src.awaitedSupply, 64);
|
|
36
34
|
},
|
|
37
35
|
parse: (src) => {
|
|
38
|
-
const sRate = BigInt(src.
|
|
39
|
-
const bRate = BigInt(src.
|
|
40
|
-
const totalSupply = BigInt(src.
|
|
41
|
-
const totalBorrow = BigInt(src.
|
|
42
|
-
const lastAccural = BigInt(src.
|
|
43
|
-
const balance = BigInt(src.
|
|
44
|
-
const trackingSupplyIndex = BigInt(src.
|
|
45
|
-
const trackingBorrowIndex = BigInt(src.
|
|
46
|
-
|
|
47
|
-
if (src.remainingBits == 64) {
|
|
48
|
-
awaitedSupply = BigInt(src.loadUint(64));
|
|
49
|
-
}
|
|
36
|
+
const sRate = BigInt(src.loadUintBig(64));
|
|
37
|
+
const bRate = BigInt(src.loadUintBig(64));
|
|
38
|
+
const totalSupply = BigInt(src.loadIntBig(64));
|
|
39
|
+
const totalBorrow = BigInt(src.loadIntBig(64));
|
|
40
|
+
const lastAccural = BigInt(src.loadUintBig(32));
|
|
41
|
+
const balance = BigInt(src.loadUintBig(64));
|
|
42
|
+
const trackingSupplyIndex = BigInt(src.loadUintBig(64));
|
|
43
|
+
const trackingBorrowIndex = BigInt(src.loadUintBig(64));
|
|
44
|
+
const awaitedSupply = BigInt(src.loadUintBig(64));
|
|
50
45
|
return { sRate, bRate, totalSupply, totalBorrow, lastAccural, balance, trackingSupplyIndex, trackingBorrowIndex, awaitedSupply };
|
|
51
46
|
},
|
|
52
47
|
};
|
|
@@ -181,14 +176,15 @@ function parseMasterData(masterDataBOC, poolAssetsConfig, masterConstants) {
|
|
|
181
176
|
};
|
|
182
177
|
}
|
|
183
178
|
exports.parseMasterData = parseMasterData;
|
|
184
|
-
function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, applyDust =
|
|
179
|
+
function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, applyDust = false) {
|
|
185
180
|
const poolAssetsConfig = poolConfig.poolAssetsConfig;
|
|
186
181
|
const masterConstants = poolConfig.masterConstants;
|
|
187
182
|
const userSlice = core_1.Cell.fromBase64(userDataBOC).beginParse();
|
|
188
183
|
const codeVersion = userSlice.loadCoins();
|
|
189
184
|
const masterAddress = userSlice.loadAddress();
|
|
190
185
|
const userAddress = userSlice.loadAddress();
|
|
191
|
-
const
|
|
186
|
+
const realPrincipals = userSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigInt(64));
|
|
187
|
+
const principalsDict = core_1.Dictionary.empty(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigInt(64));
|
|
192
188
|
const userState = userSlice.loadInt(64);
|
|
193
189
|
let trackingSupplyIndex = 0n;
|
|
194
190
|
let trackingBorrowIndex = 0n;
|
|
@@ -214,7 +210,7 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, ap
|
|
|
214
210
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
215
211
|
const assetData = assetsData.get(asset.assetId);
|
|
216
212
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
217
|
-
let principal =
|
|
213
|
+
let principal = realPrincipals.get(asset.assetId) || 0n;
|
|
218
214
|
let balance = (0, math_1.presentValue)(assetData.sRate, assetData.bRate, principal, masterConstants);
|
|
219
215
|
if (applyDust && (principal > 0 && (principal < assetConfig.dust))) {
|
|
220
216
|
principal = 0n;
|
|
@@ -224,6 +220,9 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, ap
|
|
|
224
220
|
};
|
|
225
221
|
principalsDict.set(asset.assetId, 0n);
|
|
226
222
|
}
|
|
223
|
+
else {
|
|
224
|
+
principalsDict.set(asset.assetId, principal);
|
|
225
|
+
}
|
|
227
226
|
userBalances.set(asset.assetId, balance);
|
|
228
227
|
}
|
|
229
228
|
return {
|
|
@@ -232,25 +231,37 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, ap
|
|
|
232
231
|
masterAddress: masterAddress,
|
|
233
232
|
ownerAddress: userAddress,
|
|
234
233
|
principals: principalsDict,
|
|
234
|
+
realPrincipals: realPrincipals,
|
|
235
235
|
state: userState,
|
|
236
236
|
balances: userBalances,
|
|
237
237
|
trackingSupplyIndex: trackingSupplyIndex,
|
|
238
238
|
trackingBorrowIndex: trackingBorrowIndex,
|
|
239
239
|
dutchAuctionStart: dutchAuctionStart,
|
|
240
240
|
backupCell: backupCell,
|
|
241
|
+
fullyParsed: false,
|
|
241
242
|
rewards: rewards,
|
|
242
243
|
backupCell1: backupCell1,
|
|
243
244
|
backupCell2: backupCell2,
|
|
244
245
|
};
|
|
245
246
|
}
|
|
246
247
|
exports.parseUserLiteData = parseUserLiteData;
|
|
247
|
-
function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfig, applyDust =
|
|
248
|
+
function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfig, applyDust = false) {
|
|
249
|
+
userLiteData.fullyParsed = true;
|
|
250
|
+
let havePrincipalWithoutPrice = false;
|
|
248
251
|
const poolAssetsConfig = poolConfig.poolAssetsConfig;
|
|
249
252
|
const masterConstants = poolConfig.masterConstants;
|
|
250
253
|
const withdrawalLimits = core_1.Dictionary.empty();
|
|
251
254
|
const borrowLimits = core_1.Dictionary.empty();
|
|
252
255
|
let supplyBalance = 0n;
|
|
253
256
|
let borrowBalance = 0n;
|
|
257
|
+
for (const [assetId, principal] of userLiteData.realPrincipals) {
|
|
258
|
+
if (!prices.has(assetId)) {
|
|
259
|
+
userLiteData.fullyParsed = false;
|
|
260
|
+
if (principal != 0n) {
|
|
261
|
+
havePrincipalWithoutPrice = true;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
254
265
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
255
266
|
const assetData = assetsData.get(asset.assetId);
|
|
256
267
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
@@ -263,6 +274,9 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfi
|
|
|
263
274
|
userLiteData.balances.set(asset.assetId, balance);
|
|
264
275
|
}
|
|
265
276
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
277
|
+
if (!prices.has(asset.assetId)) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
266
280
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
267
281
|
const balance = userLiteData.balances.get(asset.assetId);
|
|
268
282
|
if (balance.type === User_1.BalanceType.supply) {
|
|
@@ -272,13 +286,17 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfi
|
|
|
272
286
|
borrowBalance += (balance.amount * prices.get(asset.assetId)) / 10n ** assetConfig.decimals;
|
|
273
287
|
}
|
|
274
288
|
}
|
|
275
|
-
const availableToBorrow = (0, math_1.getAvailableToBorrow)(assetsConfig, assetsData, userLiteData.
|
|
289
|
+
const availableToBorrow = (0, math_1.getAvailableToBorrow)(assetsConfig, assetsData, userLiteData.realPrincipals, prices, masterConstants);
|
|
276
290
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
291
|
+
const balance = userLiteData.balances.get(asset.assetId);
|
|
277
292
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
278
293
|
const assetData = assetsData.get(asset.assetId);
|
|
279
|
-
const balance = userLiteData.balances.get(asset.assetId);
|
|
280
294
|
if (balance.type === User_1.BalanceType.supply) {
|
|
281
|
-
withdrawalLimits.set(asset.assetId, (0, math_1.bigIntMin)((0, math_1.calculateMaximumWithdrawAmount)(assetsConfig, assetsData, userLiteData.
|
|
295
|
+
withdrawalLimits.set(asset.assetId, (0, math_1.bigIntMin)((0, math_1.calculateMaximumWithdrawAmount)(assetsConfig, assetsData, userLiteData.realPrincipals, prices, masterConstants, asset.assetId), assetData.balance));
|
|
296
|
+
}
|
|
297
|
+
if (!prices.has(asset.assetId)) {
|
|
298
|
+
borrowLimits.set(asset.assetId, 0n);
|
|
299
|
+
continue;
|
|
282
300
|
}
|
|
283
301
|
borrowLimits.set(asset.assetId, (0, math_1.bigIntMax)(0n, (0, math_1.bigIntMin)((availableToBorrow * 10n ** assetConfig.decimals) / prices.get(asset.assetId), assetData.balance, assetData.totalSupply - assetData.totalBorrow)));
|
|
284
302
|
}
|
|
@@ -286,10 +304,13 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfi
|
|
|
286
304
|
const limitUsedPercent = limitUsed === 0n
|
|
287
305
|
? 0
|
|
288
306
|
: Number(BigInt(1e9) - (availableToBorrow * BigInt(1e9)) / (borrowBalance + availableToBorrow)) / 1e7;
|
|
289
|
-
const liquidationData = (0, math_1.calculateLiquidationData)(assetsConfig, assetsData, userLiteData.principals, prices, poolConfig);
|
|
290
307
|
let healthFactor = 1;
|
|
291
|
-
|
|
292
|
-
|
|
308
|
+
let liquidationData;
|
|
309
|
+
if (!havePrincipalWithoutPrice) {
|
|
310
|
+
liquidationData = (0, math_1.calculateLiquidationData)(assetsConfig, assetsData, userLiteData.realPrincipals, prices, poolConfig);
|
|
311
|
+
if (liquidationData.totalLimit != 0n) {
|
|
312
|
+
healthFactor = 1 - Number(liquidationData.totalDebt) / Number(liquidationData.totalLimit);
|
|
313
|
+
}
|
|
293
314
|
}
|
|
294
315
|
return {
|
|
295
316
|
...userLiteData,
|
|
@@ -302,6 +323,7 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfi
|
|
|
302
323
|
limitUsed: limitUsed,
|
|
303
324
|
liquidationData: liquidationData,
|
|
304
325
|
healthFactor: healthFactor,
|
|
326
|
+
havePrincipalWithoutPrice: havePrincipalWithoutPrice
|
|
305
327
|
};
|
|
306
328
|
}
|
|
307
329
|
exports.parseUserData = parseUserData;
|
package/dist/api/prices.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { PriceData } from '../types/Common';
|
|
2
1
|
import { PoolConfig } from '../types/Master';
|
|
3
|
-
|
|
2
|
+
import { PriceData } from '../prices';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use PriceCollector istead of getPrices
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPrices(endpoints?: string[], poolConfig?: PoolConfig): Promise<PriceData>;
|
package/dist/api/prices.js
CHANGED
|
@@ -1,35 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPrices = void 0;
|
|
4
|
-
const core_1 = require("@ton/core");
|
|
5
|
-
const priceUtils_1 = require("../utils/priceUtils");
|
|
6
4
|
const pools_1 = require("../constants/pools");
|
|
7
|
-
|
|
5
|
+
const prices_1 = require("../prices");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use PriceCollector istead of getPrices
|
|
8
|
+
*/
|
|
9
|
+
async function getPrices(endpoints = ["api.stardust-mainnet.iotaledger.net"], poolConfig = pools_1.MAINNET_POOL_CONFIG) {
|
|
8
10
|
if (endpoints.length == 0) {
|
|
9
11
|
throw new Error("Empty endpoint list");
|
|
10
12
|
}
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
+
const sources = {
|
|
14
|
+
iotaEndpoints: endpoints,
|
|
15
|
+
icpEndpoints: prices_1.DefaultPriceSourcesConfig.icpEndpoints,
|
|
16
|
+
backendEndpoints: prices_1.DefaultPriceSourcesConfig.backendEndpoints,
|
|
17
|
+
};
|
|
18
|
+
const priceCollector = new prices_1.PricesCollector(poolConfig, sources);
|
|
19
|
+
const prices = await priceCollector.getPrices();
|
|
20
|
+
return { dict: prices.dict, dataCell: prices.dataCell };
|
|
21
|
+
/*
|
|
22
|
+
Old code
|
|
23
|
+
const prices = await Promise.all(poolConfig.oracles.map(async x => await parsePrices(await loadPrices(x.address, endpoints), x.id)));
|
|
24
|
+
|
|
25
|
+
let acceptedPrices: RawPriceData[] = prices.filter(verifyPrices(poolConfig.poolAssetsConfig));
|
|
26
|
+
|
|
27
|
+
|
|
13
28
|
if (acceptedPrices.length < poolConfig.minimalOracles) {
|
|
14
29
|
throw new Error("Prices are outdated");
|
|
15
30
|
}
|
|
31
|
+
|
|
16
32
|
if (acceptedPrices.length > poolConfig.minimalOracles && acceptedPrices.length % 2 == 0) {
|
|
17
|
-
acceptedPrices = acceptedPrices.slice(0, acceptedPrices.length - 1);
|
|
33
|
+
acceptedPrices = acceptedPrices.slice(0, acceptedPrices.length - 1); // to reduce fees, MINIMAL_ORACLES_NUMBER is odd
|
|
18
34
|
}
|
|
35
|
+
|
|
19
36
|
if (acceptedPrices.length != poolConfig.minimalOracles) {
|
|
20
37
|
const sortedByTimestamp = acceptedPrices.slice().sort((a, b) => b.timestamp - a.timestamp);
|
|
21
38
|
const newerPrices = sortedByTimestamp.slice(0, poolConfig.minimalOracles);
|
|
22
39
|
acceptedPrices = newerPrices.sort((a, b) => a.oracleId - b.oracleId);
|
|
23
40
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const medianData = poolConfig.poolAssetsConfig.map(asset => ({ assetId: asset.assetId, medianPrice: getMedianPrice(acceptedPrices, asset.assetId)}));
|
|
44
|
+
const packedMedianData = packAssetsData(medianData);
|
|
45
|
+
|
|
46
|
+
const oraclesData = acceptedPrices.map(x => ({oracle: {id: x.oracleId, pubkey: x.pubkey}, data: {timestamp: x.timestamp, prices: x.dict}, signature: x.signature}));
|
|
47
|
+
const packedOracleData = packOraclesData(oraclesData, poolConfig.poolAssetsConfig.map(x => x.assetId));
|
|
48
|
+
|
|
49
|
+
const dict = Dictionary.empty<bigint, bigint>();
|
|
29
50
|
medianData.forEach(x => dict.set(x.assetId, x.medianPrice));
|
|
51
|
+
|
|
30
52
|
return {
|
|
31
53
|
dict: dict,
|
|
32
|
-
dataCell:
|
|
33
|
-
}
|
|
54
|
+
dataCell: packPrices(packedMedianData, packedOracleData)
|
|
55
|
+
};*/
|
|
34
56
|
}
|
|
35
57
|
exports.getPrices = getPrices;
|
|
@@ -6,10 +6,14 @@ export declare const ASSET_ID: {
|
|
|
6
6
|
jUSDC: bigint;
|
|
7
7
|
stTON: bigint;
|
|
8
8
|
tsTON: bigint;
|
|
9
|
+
uTON: bigint;
|
|
9
10
|
TONUSDT_DEDUST: bigint;
|
|
10
11
|
TONUSDT_STONFI: bigint;
|
|
11
12
|
TON_STORM: bigint;
|
|
12
13
|
USDT_STORM: bigint;
|
|
14
|
+
NOT: bigint;
|
|
15
|
+
DOGS: bigint;
|
|
16
|
+
CATI: bigint;
|
|
13
17
|
};
|
|
14
18
|
export declare const UNDEFINED_ASSET: PoolAssetConfig;
|
|
15
19
|
export declare const TON_MAINNET: PoolAssetConfig;
|
|
@@ -25,3 +29,7 @@ export declare const STTON_TESTNET: PoolAssetConfig;
|
|
|
25
29
|
export declare const TONUSDT_DEDUST_MAINNET: PoolAssetConfig;
|
|
26
30
|
export declare const TON_STORM_MAINNET: PoolAssetConfig;
|
|
27
31
|
export declare const USDT_STORM_MAINNET: PoolAssetConfig;
|
|
32
|
+
export declare const CATI_MAINNET: PoolAssetConfig;
|
|
33
|
+
export declare const DOGS_MAINNET: PoolAssetConfig;
|
|
34
|
+
export declare const NOT_MAINNET: PoolAssetConfig;
|
|
35
|
+
export declare const UTON_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.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.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");
|
|
@@ -11,10 +11,16 @@ exports.ASSET_ID = {
|
|
|
11
11
|
jUSDC: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
|
|
12
12
|
stTON: (0, sha256BigInt_1.sha256Hash)('stTON'),
|
|
13
13
|
tsTON: (0, sha256BigInt_1.sha256Hash)('tsTON'),
|
|
14
|
+
uTON: (0, sha256BigInt_1.sha256Hash)('uTON'),
|
|
15
|
+
// LP
|
|
14
16
|
TONUSDT_DEDUST: (0, sha256BigInt_1.sha256Hash)('TONUSDT_DEDUST'),
|
|
15
17
|
TONUSDT_STONFI: (0, sha256BigInt_1.sha256Hash)('TONUSDT_STONFI'),
|
|
16
18
|
TON_STORM: (0, sha256BigInt_1.sha256Hash)('TON_STORM'),
|
|
17
19
|
USDT_STORM: (0, sha256BigInt_1.sha256Hash)('USDT_STORM'),
|
|
20
|
+
// ALTS
|
|
21
|
+
NOT: (0, sha256BigInt_1.sha256Hash)('NOT'),
|
|
22
|
+
DOGS: (0, sha256BigInt_1.sha256Hash)('DOGS'),
|
|
23
|
+
CATI: (0, sha256BigInt_1.sha256Hash)('CATI'),
|
|
18
24
|
};
|
|
19
25
|
exports.UNDEFINED_ASSET = {
|
|
20
26
|
name: 'undefined_asset',
|
|
@@ -95,3 +101,27 @@ exports.USDT_STORM_MAINNET = {
|
|
|
95
101
|
jettonMasterAddress: core_1.Address.parse('EQCup4xxCulCcNwmOocM9HtDYPU8xe0449tQLp6a-5BLEegW'),
|
|
96
102
|
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7241021301000380000114ff00f4a413f4bcf2c80b0102016202100202cd030f04add106380792000e8698180b8d8474289af81ed9e707d207d2018fd0018b8eb90fd0018fd001839d4da0001698f90c10807c53f52dd4742989a2ced9e7010c1080bc6a28cdd474318a22201ed9e701a9041082caf83de5d40405080c00888020d721ed44d0fa00fa40fa40d74c04d31f8200fff0228210178d4519ba0382107bdd97deba13b112f2f4d33f31fa003013a05023c85004fa0258cf1601cf16ccc9ed5401f603d33ffa00fa4021f007ed44d0fa00fa40fa40d74c5136a1522ac705f2e2c128c2fff2e2c2545255705202541304c85004fa0258cf1601cf16ccc921c8cb0113f40012f400cb00c97021f90074c8cb0212cb07cbffc9d004fa40f40431fa0020d749c200f2e2c48210178d4519c8cb1f1acb3f5008fa0223cf1601060176cf1626fa025007cf162591729171e2500aa815a0820a43d580a016bcf2e2c57007c9103741408040db3c4300c85004fa0258cf1601cf16ccc9ed5407002e778018c8cb055005cf165005fa0213cb6bccccc901fb0002f6ed44d0fa00fa40fa40d74c08d33ffa005151a005fa40fa40547c25705202541304c85004fa0258cf1601cf16ccc921c8cb0113f40012f400cb00c97021f90074c8cb0212cb07cbffc9d031536cc7050dc7051cb1f2e2c30afa0051a8a12195104a395f04e30d048208989680b60972fb0225d70b01c30003c20013090a014c521aa018a182107362d09cc8cb1f5240cb3f5003fa0201cf165008cf16c954253071db3c10350e0158b08e948210d53276dbc8cb1f14cb3f704055810082db3c923333e25003c85004fa0258cf1601cf16ccc9ed540b0030708018c8cb055004cf165004fa0212cb6a01cf17c901fb0002a08e843059db3ce06c22ed44d0fa00fa40fa40d74c10235f030182106d8e5e3cba8ea75202c705f2e2c1820898968070fb0201d70b3f8210d53276dbc8cb1fcb3f7001c912810082db3ce05f03840ff2f00d0e01bc30ed44d0fa00fa40fa40d74c06d33ffa00fa40305151a15248c705f2e2c126c2fff2e2c20582100ee6b280b9f2d2c782107bdd97dec8cb1fcb3f5004fa0221cf1658cf167001c952308040db3c4013c85004fa0258cf1601cf16ccc9ed540e002c718018c8cb055004cf165004fa0212cb6accc901fb000011f7d22186000797163402016611120021b5fe7da89a1f401f481f481ae9826be070001bb7605da89a1f401f481f481ae990c6f31b9d', 'hex'))[0],
|
|
97
103
|
};
|
|
104
|
+
exports.CATI_MAINNET = {
|
|
105
|
+
name: 'CATI',
|
|
106
|
+
assetId: exports.ASSET_ID.CATI,
|
|
107
|
+
jettonMasterAddress: core_1.Address.parse('EQD-cvR0Nz6XAyRBvbhz-abTrRC6sI5tvHvvpeQraV9UAAD7'),
|
|
108
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7241021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5495eaedd7', 'hex'))[0],
|
|
109
|
+
};
|
|
110
|
+
exports.DOGS_MAINNET = {
|
|
111
|
+
name: 'DOGS',
|
|
112
|
+
assetId: exports.ASSET_ID.DOGS,
|
|
113
|
+
jettonMasterAddress: core_1.Address.parse('EQCvxJy4eG8hyHBFsZ7eePxrRsUQSFE_jpptRAYBmcG_DOGS'),
|
|
114
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7241010101002300084202ba2918c8947e9b25af9ac1b883357754173e5812f807a3d6e642a14709595395237ae3c3', 'hex'))[0],
|
|
115
|
+
};
|
|
116
|
+
exports.NOT_MAINNET = {
|
|
117
|
+
name: 'NOT',
|
|
118
|
+
assetId: exports.ASSET_ID.NOT,
|
|
119
|
+
jettonMasterAddress: core_1.Address.parse('EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT'),
|
|
120
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201010101002300084202ba2918c8947e9b25af9ac1b883357754173e5812f807a3d6e642a14709595395', 'hex'))[0],
|
|
121
|
+
};
|
|
122
|
+
exports.UTON_MAINNET = {
|
|
123
|
+
name: 'uTON',
|
|
124
|
+
assetId: exports.ASSET_ID.uTON,
|
|
125
|
+
jettonMasterAddress: core_1.Address.parse('EQAfF5j3JMIpZlLmACv7Ub7RH7WmiVMuV4ivcgNYHvNnqHTz'),
|
|
126
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000439000114ff00f4a413f4bcf2c80b0102016202030202cc0405020120111200bbd906380492f827000e8698180b8d84a89af81f807707d207d2018fd0018b8eb90fd0018fd001801698f90c10807c53f52dd4a989a2cf805f010c1080bc6a28cdd4b18a22201f8067000c1082caf83de5d4aa22201f806f02f82c207f9784020120060701f7f01e99ffd007d20381140816000fd23182c5d797a76a2687d00699ffd207d206a18027c30817c317c31fc327c32fc2091d0fc30fc21a8036382f97160fc20e17ff971617c227c22b82a300209aa0a82e42802fd0109e59f80e78b00e78b666490e4658089fa00097a00658064907c80383a6465816503e5ffe4e802c080201200a0b01fefa40f40431fa0020d749c200f2e2c4778018c8cb055009cf1670fa0218cb6b13cc8210178d4519c8cb1f15cb3f5003fa02f843cf1658cf1621fa025004cf16c901cc2291729171e25004a812a08208989680a08208989680a08208989680a0bcf2e2c5f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed5409000ac98040fb000201200c0d00b948020d721ed44d0fa00d33ffa40fa40d43004f86102f862f863f864f865d31f218210178d4519ba0282107bdd97deba12b1f2e2c5d33f31fa0030f84101a0f861f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed54801f53b51343e8034cffe903e90350c013e1840be18be18fe193e194134cffe803e1048a83e187e903e903e113e1149165c15180104d505417214017e8084f2cfc073c58073c5b332487232c044fd0004bd0032c0327e401c1d3232c0b281f2fff2740a31c17e11140271c1462c7cb8b0c1be80145a2860822625a019a00e01f73b51343e8034cffe903e90350c013e1840be18be18fe193e194134cffe803e903d010c1c0060083d03dbe87cb8b13434c7fe80204c0048b0803cbd350c3e10be10a93e18be1049a87e187e10d402b1c17cb8b07e1070bffcb8b0945e6860822625a019ad82284820822625a0281401e820822625a028086814a42f201001f2b608a18208989680a018a1278e355275a014a182107362d09cc8cb1f5230cb3f58fa025003cf165003cf16c9718018c8cb05f843cf165006fa0215cb6a14ccc971fb0094375b6c21e221d70b01c30023c200b08e208210d53276db708010c8cb055004cf165004fa0212cb6a12cb1fcb3fc972fb00925f03e20f0038f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed5400c0f2e2c5058208989680a018a1f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed5482107bdd97dec8cb1f14cb3ff843cf1616cb3f01fa0215cb1f5003cf1658fa02ccc9718018c8cb05f844cf165003fa0212cb6accc970fb000047bfd8176a2687d00699ffd207d206a18027c30817c317c31fc327c32fc20fc21fc227c22c004bbdd79f6a2687d00699ffd207d206a18027c30817c317c31fc327c32fc20fc217c21fc227c22c', 'hex'))[0],
|
|
127
|
+
};
|
|
@@ -17,12 +17,15 @@ export declare const NULL_ADDRESS: Address;
|
|
|
17
17
|
export declare const EVAA_MASTER_MAINNET: Address;
|
|
18
18
|
export declare const MAINNET_VERSION = 6;
|
|
19
19
|
export declare const EVAA_MASTER_TESTNET: Address;
|
|
20
|
-
export declare const TESTNET_VERSION =
|
|
20
|
+
export declare const TESTNET_VERSION = 1;
|
|
21
21
|
export declare const EVAA_LP_MAINNET: Address;
|
|
22
|
-
export declare const EVAA_LP_MAINNET_VERSION =
|
|
22
|
+
export declare const EVAA_LP_MAINNET_VERSION = 3;
|
|
23
|
+
export declare const EVAA_ALTS_MAINNET: Address;
|
|
24
|
+
export declare const EVAA_ALTS_MAINNET_VERSION = 0;
|
|
23
25
|
export declare const ORACLES_MAINNET: OracleNFT[];
|
|
24
26
|
export declare const ORACLES_TESTNET: OracleNFT[];
|
|
25
27
|
export declare const ORACLES_LP: OracleNFT[];
|
|
28
|
+
export declare const ORACLES_ALTS: OracleNFT[];
|
|
26
29
|
export declare const LENDING_CODE: Cell;
|
|
27
30
|
export declare const JETTON_WALLET_STANDART_CODE: Cell;
|
|
28
31
|
export declare const JETTON_WALLET_STANDART_CODE_TESTNET: Cell;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FEES = exports.OPCODES = exports.JETTON_WALLET_STANDART_CODE_TESTNET = exports.JETTON_WALLET_STANDART_CODE = exports.LENDING_CODE = exports.ORACLES_LP = exports.ORACLES_TESTNET = exports.ORACLES_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.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_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 = {
|
|
@@ -20,30 +20,20 @@ exports.NULL_ADDRESS = core_1.Address.parse('UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
20
20
|
exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
21
21
|
exports.MAINNET_VERSION = 6;
|
|
22
22
|
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('EQDLsg3w-iBj26Gww7neYoJAxiT2t77Zo8ro56b0yuHsPp3C');
|
|
23
|
-
exports.TESTNET_VERSION =
|
|
23
|
+
exports.TESTNET_VERSION = 1;
|
|
24
24
|
exports.EVAA_LP_MAINNET = core_1.Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLww-hdWk2G37Jc6N');
|
|
25
|
-
exports.EVAA_LP_MAINNET_VERSION =
|
|
25
|
+
exports.EVAA_LP_MAINNET_VERSION = 3;
|
|
26
|
+
exports.EVAA_ALTS_MAINNET = core_1.Address.parse('EQANURVS3fhBO9bivig34iyJQi97FhMbpivo1aUEAS2GYSu-');
|
|
27
|
+
exports.EVAA_ALTS_MAINNET_VERSION = 0;
|
|
26
28
|
exports.ORACLES_MAINNET = [
|
|
27
|
-
{ id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d' },
|
|
28
|
-
{ id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191' },
|
|
29
|
-
{ id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0' },
|
|
30
|
-
{ id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52' },
|
|
31
|
-
];
|
|
32
|
-
exports.ORACLES_TESTNET = [
|
|
33
|
-
{ id: 0, address: '0x3bb147a37b7a7f874c39320440f352bddd2c9337e31a778731910f0266391650' },
|
|
34
|
-
{ id: 1, address: '0x676767e93b05a21aec9023a65f73cffe1c725709c3c964a7c3f0fd4229089bfe' },
|
|
35
|
-
{ id: 2, address: '0x9c9e65951b0c5920c286bdb3410babcaf21f85bc9c90c13172988630f1244e0f' },
|
|
36
|
-
{ id: 3, address: '0x9dcf880229bfb68d7344fd294624b64f1e0b43b9d858f0fdb1bc6434616c08f5' },
|
|
37
|
-
{ id: 4, address: '0x4d1afcf7c0426ca61c405c8cfaef0053a0f0d143740ffed04c8716beb99cd614' },
|
|
38
|
-
{ id: 5, address: '0x11c6baa608ed10733051fd74134441d384e471722fbc496b43ea4e3c6652485f' },
|
|
39
|
-
{ id: 6, address: '0x2b685672f38dc2fce59013bb740bf24c6037049a1c267bb3b5f6f55d5b195f5f' },
|
|
40
|
-
];
|
|
41
|
-
exports.ORACLES_LP = [
|
|
42
|
-
{ id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d' },
|
|
43
|
-
{ id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191' },
|
|
44
|
-
{ id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0' },
|
|
45
|
-
{ id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52' },
|
|
29
|
+
{ id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d', pubkey: Buffer.from('b404f4a2ebb62f2623b370c89189748a0276c071965b1646b996407f10d72eb9', 'hex') },
|
|
30
|
+
{ id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191', pubkey: Buffer.from('9ad115087520d91b6b45d6a8521eb4616ee6914af07fabdc2e9d1826dbb17078', 'hex') },
|
|
31
|
+
{ id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0', pubkey: Buffer.from('e503e02e8a9226b34e7c9deb463cbf7f19bce589362eb448a69a8ee7b2fca631', 'hex') },
|
|
32
|
+
{ id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52', pubkey: Buffer.from('9cbf8374cf1f2cf17110134871d580198416e101683f4a61f54cf2a3e4e32070', 'hex') },
|
|
46
33
|
];
|
|
34
|
+
exports.ORACLES_TESTNET = exports.ORACLES_MAINNET;
|
|
35
|
+
exports.ORACLES_LP = exports.ORACLES_MAINNET;
|
|
36
|
+
exports.ORACLES_ALTS = exports.ORACLES_MAINNET;
|
|
47
37
|
exports.LENDING_CODE = core_1.Cell.fromBoc(Buffer.from('b5ee9c72c1010e0100fd000d12182a555a6065717691969efd0114ff00f4a413f4bcf2c80b010202c8050202039f740403001ff2f8276a2687d2018fd201800f883b840051d38642c678b64e4400780e58fc10802faf07f80e59fa801e78b096664c02078067c07c100627a7978402014807060007a0ddb0c60201c709080013a0fd007a026900aa90400201200b0a0031b8e1002191960aa00b9e2ca007f4042796d225e8019203f6010201200d0c000bf7c147d2218400b9d10e86981fd201840b07f8138d809797976a2687d2029116382f970fd9178089910374daf81b619fd20182c7883b8701981684100627910eba56001797a6a6ba610fd8200e8768f76a9f6aa00cc2a32a8292878809bef2f1889f883bbcdeb86f01', 'hex'))[0];
|
|
48
38
|
exports.JETTON_WALLET_STANDART_CODE = core_1.Cell.fromBase64('te6cckECEwEAA4UAART/APSkE/S88sgLAQIBYgIDAgLLBAUAG6D2BdqJofQB9IH0gamjAgHOBgcCAVgKCwL3CDHAJJfBOAB0NMDAXGwlRNfA/Ad4PpA+kAx+gAxcdch+gAx+gAwc6m0AALTHwHbPFsyNDQ0JIIQD4p+pbqaMGwiNl4xECPwGuAkghAXjUUZupswbCJeMhAkQwDwG+A3WzaCEFlfB7y6nwJxsPLSwFAjuvLixgHwHOBfBYAgJABE+kQwwADy4U2AAXIBP+DMgbpUwgLH4M94gbvLSmtDTBzHT/9P/9ATTB9Qw0PoA+gD6APoA+gD6ADAACIQP8vACAVgMDQIBSBESAfcBdM/AQH6APpAIfAB7UTQ+gD6QPpA1NFRNqFSLMcF8uLBKsL/8uLCVDRCcFQgE1QUA8hQBPoCWM8WAc8WzMkiyMsBEvQA9ADLAMkgcAH5AHTIywISygfL/8nQBPpA9AQx+gAg10nCAPLixMiAGAHLBVAHzxZw+gJ3ActrgDgLzO1E0PoA+kD6QNTRCtM/AQH6AFFRoAX6QPpAU13HBVRzb3BUIBNUFAPIUAT6AljPFgHPFszJIsjLARL0APQAywDJcAH5AHTIywISygfL/8nQUA/HBR6x8uLDDPoAUcqhKbYIGaFQB6AYoSaSbFXjDSXXCwHDACHCALCAPEACqE8zIghAXjUUZWAoCyx/LP1AH+gIizxZQBs8WJfoCUAPPFslQBcwjkXKRceJQB6gToAiqAFAEoBegFLzy4sUByYBA+wBDAMhQBPoCWM8WAc8WzMntVAByUmmgGKHIghBzYtCcKQLLH8s/UAf6AlAEzxZQB88WyciAEAHLBSfPFlAE+gJxActqE8zJcfsAUEITAHSOI8iAEAHLBVAGzxZQBfoCcAHLaoIQ1TJ221gFAssfyz/JcvsAklsz4kADyFAE+gJYzxYBzxbMye1UAOs7UTQ+gD6QPpA1NEF0z8BAfoAIcIA8uLC+kD0BAHQ05/RAdFRYqFSWMcF8uLBJsL/8uLCyIIQe92X3lgEAssfyz8B+gIjzxYBzxYTy5/JyIAYAcsFI88WcPoCcQHLaszJgED7AEATyFAE+gJYzxYBzxbMye1UgAIcgCDXIe1E0PoA+kD6QNTRBNMfAYQPIYIQF41FGboCghB73ZfeuhKx8vTTPwEw+gAwE6BQI8hQBPoCWM8WAc8WzMntVINjFu1o=');
|
|
49
39
|
exports.JETTON_WALLET_STANDART_CODE_TESTNET = core_1.Cell.fromBase64('te6cckECEQEAAyMAART/APSkE/S88sgLAQIBYgIDAgLMBAUAG6D2BdqJofQB9IH0gahhAgHUBgcCASAICQDDCDHAJJfBOAB0NMDAXGwlRNfA/AM4PpA+kAx+gAxcdch+gAx+gAwc6m0AALTH4IQD4p+pVIgupUxNFnwCeCCEBeNRRlSILqWMUREA/AK4DWCEFlfB7y6k1nwC+BfBIQP8vCAAET6RDBwuvLhTYAIBIAoLAIPUAQa5D2omh9AH0gfSBqGAJpj8EIC8aijKkQXUEIPe7L7wndCVj5cWLpn5j9ABgJ0CgR5CgCfQEsZ4sA54tmZPaqQB8VA9M/+gD6QCHwAe1E0PoA+kD6QNQwUTahUirHBfLiwSjC//LiwlQ0QnBUIBNUFAPIUAT6AljPFgHPFszJIsjLARL0APQAywDJIPkAcHTIywLKB8v/ydAE+kD0BDH6ACDXScIA8uLEd4AYyMsFUAjPFnD6AhfLaxPMgMAgEgDQ4AnoIQF41FGcjLHxnLP1AH+gIizxZQBs8WJfoCUAPPFslQBcwjkXKRceJQCKgToIIJycOAoBS88uLFBMmAQPsAECPIUAT6AljPFgHPFszJ7VQC9ztRND6APpA+kDUMAjTP/oAUVGgBfpA+kBTW8cFVHNtcFQgE1QUA8hQBPoCWM8WAc8WzMkiyMsBEvQA9ADLAMn5AHB0yMsCygfL/8nQUA3HBRyx8uLDCvoAUaihggiYloBmtgihggiYloCgGKEnlxBJEDg3XwTjDSXXCwGAPEADXO1E0PoA+kD6QNQwB9M/+gD6QDBRUaFSSccF8uLBJ8L/8uLCBYIJMS0AoBa88uLDghB73ZfeyMsfFcs/UAP6AiLPFgHPFslxgBjIywUkzxZw+gLLaszJgED7AEATyFAE+gJYzxYBzxbMye1UgAHBSeaAYoYIQc2LQnMjLH1Iwyz9Y+gJQB88WUAfPFslxgBDIywUkzxZQBvoCFctqFMzJcfsAECQQIwB8wwAjwgCwjiGCENUydttwgBDIywVQCM8WUAT6AhbLahLLHxLLP8ly+wCTNWwh4gPIUAT6AljPFgHPFszJ7VSV6u3X');
|
|
@@ -2,3 +2,4 @@ import { PoolConfig } from "../types/Master";
|
|
|
2
2
|
export declare const MAINNET_POOL_CONFIG: PoolConfig;
|
|
3
3
|
export declare const TESTNET_POOL_CONFIG: PoolConfig;
|
|
4
4
|
export declare const MAINNET_LP_POOL_CONFIG: PoolConfig;
|
|
5
|
+
export declare const MAINNET_ALTS_POOL_CONFIG: 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_LP_POOL_CONFIG = exports.TESTNET_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = void 0;
|
|
3
|
+
exports.MAINNET_ALTS_POOL_CONFIG = exports.MAINNET_LP_POOL_CONFIG = exports.TESTNET_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = void 0;
|
|
4
4
|
const assets_1 = require("./assets");
|
|
5
5
|
const general_1 = require("./general");
|
|
6
6
|
exports.MAINNET_POOL_CONFIG = {
|
|
@@ -15,7 +15,8 @@ exports.MAINNET_POOL_CONFIG = {
|
|
|
15
15
|
assets_1.JUSDC_MAINNET,
|
|
16
16
|
assets_1.STTON_MAINNET,
|
|
17
17
|
assets_1.TSTON_MAINNET,
|
|
18
|
-
assets_1.USDT_MAINNET
|
|
18
|
+
assets_1.USDT_MAINNET,
|
|
19
|
+
// UTON_MAINNET // announce
|
|
19
20
|
],
|
|
20
21
|
lendingCode: general_1.LENDING_CODE
|
|
21
22
|
};
|
|
@@ -24,7 +25,7 @@ exports.TESTNET_POOL_CONFIG = {
|
|
|
24
25
|
masterVersion: general_1.TESTNET_VERSION,
|
|
25
26
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
26
27
|
oracles: general_1.ORACLES_TESTNET,
|
|
27
|
-
minimalOracles:
|
|
28
|
+
minimalOracles: 3,
|
|
28
29
|
poolAssetsConfig: [
|
|
29
30
|
assets_1.TON_MAINNET,
|
|
30
31
|
assets_1.JUSDT_TESTNET,
|
|
@@ -48,3 +49,18 @@ exports.MAINNET_LP_POOL_CONFIG = {
|
|
|
48
49
|
],
|
|
49
50
|
lendingCode: general_1.LENDING_CODE
|
|
50
51
|
};
|
|
52
|
+
exports.MAINNET_ALTS_POOL_CONFIG = {
|
|
53
|
+
masterAddress: general_1.EVAA_ALTS_MAINNET,
|
|
54
|
+
masterVersion: general_1.EVAA_ALTS_MAINNET_VERSION,
|
|
55
|
+
masterConstants: general_1.MASTER_CONSTANTS,
|
|
56
|
+
oracles: general_1.ORACLES_ALTS,
|
|
57
|
+
minimalOracles: 3,
|
|
58
|
+
poolAssetsConfig: [
|
|
59
|
+
assets_1.TON_MAINNET,
|
|
60
|
+
assets_1.USDT_MAINNET,
|
|
61
|
+
assets_1.CATI_MAINNET,
|
|
62
|
+
assets_1.NOT_MAINNET,
|
|
63
|
+
assets_1.DOGS_MAINNET
|
|
64
|
+
],
|
|
65
|
+
lendingCode: general_1.LENDING_CODE
|
|
66
|
+
};
|