@evaafi/sdk 0.5.6-a → 0.6.0-a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/math.d.ts +1 -10
- package/dist/api/math.js +11 -63
- package/dist/api/parser.d.ts +2 -1
- package/dist/api/parser.js +41 -53
- package/dist/api/prices.d.ts +2 -1
- package/dist/api/prices.js +28 -19
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/constants/general.d.ts +7 -5
- package/dist/constants/general.js +29 -10
- package/dist/constants/pools.js +6 -3
- package/dist/contracts/MasterContract.d.ts +9 -3
- package/dist/contracts/MasterContract.js +13 -8
- package/dist/contracts/UserContract.d.ts +2 -2
- package/dist/contracts/UserContract.js +5 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1
- package/dist/types/Common.d.ts +9 -0
- package/dist/types/Master.d.ts +23 -4
- package/dist/types/User.d.ts +4 -1
- package/package.json +2 -2
- package/src/api/math.ts +17 -84
- package/src/api/parser.ts +37 -52
- package/src/api/prices.ts +33 -57
- package/src/config.ts +1 -0
- package/src/constants/general.ts +32 -9
- package/src/constants/pools.ts +7 -4
- package/src/contracts/MasterContract.ts +23 -17
- package/src/contracts/UserContract.ts +7 -3
- package/src/index.ts +4 -0
- package/src/types/Common.ts +10 -0
- package/src/types/Master.ts +23 -9
- package/src/types/User.ts +2 -3
- package/src/utils/merkleProof.ts +141 -0
- package/src/utils/priceUtils.ts +177 -0
package/dist/api/math.d.ts
CHANGED
|
@@ -18,16 +18,7 @@ export declare function calculateAssetData(assetsConfigDict: ExtendedAssetsConfi
|
|
|
18
18
|
export declare function calculateAssetInterest(assetConfig: AssetConfig, assetData: AssetData, masterConstants: MasterConstants): AssetInterest;
|
|
19
19
|
export declare function checkNotInDebtAtAll(principals: Dictionary<bigint, bigint>): boolean;
|
|
20
20
|
export declare function getAgregatedBalances(assetsData: ExtendedAssetsData, assetsConfig: ExtendedAssetsConfig, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants): AgregatedBalances;
|
|
21
|
-
|
|
22
|
-
* @deprecated The method should be used only for main contract v5
|
|
23
|
-
*/
|
|
24
|
-
export declare function isV5MainPoolContract(poolConfig: PoolConfig): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated The method should be used only for main contract v5
|
|
27
|
-
*/
|
|
28
|
-
export declare function calculateMaximumWithdrawAmountOld(assetsConfig: ExtendedAssetsConfig, assetsData: ExtendedAssetsData, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants, assetId: bigint): bigint;
|
|
29
|
-
export declare function calculateMaximumWithdrawAmount(// todo v6 ifelse dust not debt at all is fixed?
|
|
30
|
-
assetsConfig: ExtendedAssetsConfig, assetsData: ExtendedAssetsData, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants, assetId: bigint): bigint;
|
|
21
|
+
export declare function calculateMaximumWithdrawAmount(assetsConfig: ExtendedAssetsConfig, assetsData: ExtendedAssetsData, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants, assetId: bigint): bigint;
|
|
31
22
|
export declare function getAvailableToBorrow(assetsConfig: ExtendedAssetsConfig, assetsData: ExtendedAssetsData, principals: Dictionary<bigint, bigint>, prices: Dictionary<bigint, bigint>, masterConstants: MasterConstants): bigint;
|
|
32
23
|
export declare function presentValue(sRate: bigint, bRate: bigint, principalValue: bigint, masterConstants: MasterConstants): UserBalance;
|
|
33
24
|
/**
|
package/dist/api/math.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.predictHealthFactor = exports.calculateLiquidationData = exports.presentValue = exports.getAvailableToBorrow = exports.calculateMaximumWithdrawAmount = exports.
|
|
3
|
+
exports.predictHealthFactor = exports.calculateLiquidationData = exports.presentValue = exports.getAvailableToBorrow = exports.calculateMaximumWithdrawAmount = exports.getAgregatedBalances = exports.checkNotInDebtAtAll = exports.calculateAssetInterest = exports.calculateAssetData = exports.calculateCurrentRates = exports.calculatePresentValue = exports.bigIntMin = exports.bigIntMax = exports.mulDivC = exports.mulDiv = exports.mulFactor = void 0;
|
|
4
4
|
const User_1 = require("../types/User");
|
|
5
|
-
const sha256BigInt_1 = require("../utils/sha256BigInt");
|
|
6
5
|
const assets_1 = require("../constants/assets");
|
|
7
|
-
const __1 = require("..");
|
|
8
6
|
function mulFactor(decimal, a, b) {
|
|
9
7
|
return (a * b) / decimal;
|
|
10
8
|
}
|
|
@@ -129,59 +127,7 @@ function getAgregatedBalances(assetsData, assetsConfig, principals, prices, mast
|
|
|
129
127
|
return { totalSupply: user_total_supply, totalBorrow: user_total_borrow };
|
|
130
128
|
}
|
|
131
129
|
exports.getAgregatedBalances = getAgregatedBalances;
|
|
132
|
-
|
|
133
|
-
* @deprecated The method should be used only for main contract v5
|
|
134
|
-
*/
|
|
135
|
-
function isV5MainPoolContract(poolConfig) {
|
|
136
|
-
if ((poolConfig.masterAddress == __1.MAINNET_POOL_CONFIG.masterAddress && poolConfig.masterVersion == 5) ||
|
|
137
|
-
(poolConfig.masterAddress == __1.TESTNET_POOL_CONFIG.masterAddress && poolConfig.masterVersion == 5)) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
exports.isV5MainPoolContract = isV5MainPoolContract;
|
|
145
|
-
/**
|
|
146
|
-
* @deprecated The method should be used only for main contract v5
|
|
147
|
-
*/
|
|
148
|
-
function calculateMaximumWithdrawAmountOld(assetsConfig, assetsData, principals, prices, masterConstants, assetId) {
|
|
149
|
-
let withdrawAmountMax = 0n;
|
|
150
|
-
const assetConfig = assetsConfig.get(assetId);
|
|
151
|
-
const assetData = assetsData.get(assetId);
|
|
152
|
-
const oldPrincipal = principals.get(assetId);
|
|
153
|
-
const oldPresentValue = presentValue(assetData.sRate, assetData.bRate, oldPrincipal, masterConstants);
|
|
154
|
-
if (oldPresentValue.amount > assetConfig.dust) {
|
|
155
|
-
if (checkNotInDebtAtAll(principals)) {
|
|
156
|
-
withdrawAmountMax = oldPresentValue.amount;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
if (!prices.has(assetId)) {
|
|
160
|
-
return 0n;
|
|
161
|
-
}
|
|
162
|
-
//const borrowable = getAvailableToBorrow(assetsConfig, assetsData, principals, prices, masterConstants);
|
|
163
|
-
const price = prices.get(assetId);
|
|
164
|
-
const agregatedBalances = getAgregatedBalances(assetsData, assetsConfig, principals, prices, masterConstants);
|
|
165
|
-
let maxAmountToReclaim = mulDiv(agregatedBalances.totalSupply - mulDivC(agregatedBalances.totalBorrow, masterConstants.ASSET_COEFFICIENT_SCALE, assetConfig.collateralFactor), 10n ** assetConfig.decimals, price);
|
|
166
|
-
withdrawAmountMax = bigIntMin(maxAmountToReclaim, oldPresentValue.amount);
|
|
167
|
-
//console.log('agregatedBalances', agregatedBalances);
|
|
168
|
-
//console.log('masterConstants.ASSET_COEFFICIENT_SCALE', masterConstants.ASSET_COEFFICIENT_SCALE);
|
|
169
|
-
//console.log('assetConfig.collateralFactor', assetConfig.collateralFactor);
|
|
170
|
-
//console.log('sekay', maxAmountToReclaim, oldPresentValue.amount);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
if (!prices.has(assetId)) {
|
|
175
|
-
return 0n;
|
|
176
|
-
}
|
|
177
|
-
const price = prices.get(assetId);
|
|
178
|
-
return getAvailableToBorrow(assetsConfig, assetsData, principals, prices, masterConstants) * (10n ** assetConfig.decimals) / price;
|
|
179
|
-
}
|
|
180
|
-
return withdrawAmountMax;
|
|
181
|
-
}
|
|
182
|
-
exports.calculateMaximumWithdrawAmountOld = calculateMaximumWithdrawAmountOld;
|
|
183
|
-
function calculateMaximumWithdrawAmount(// todo v6 ifelse dust not debt at all is fixed?
|
|
184
|
-
assetsConfig, assetsData, principals, prices, masterConstants, assetId) {
|
|
130
|
+
function calculateMaximumWithdrawAmount(assetsConfig, assetsData, principals, prices, masterConstants, assetId) {
|
|
185
131
|
let withdrawAmountMax = 0n;
|
|
186
132
|
const assetConfig = assetsConfig.get(assetId);
|
|
187
133
|
const assetData = assetsData.get(assetId);
|
|
@@ -203,7 +149,8 @@ assetsConfig, assetsData, principals, prices, masterConstants, assetId) {
|
|
|
203
149
|
}
|
|
204
150
|
else if (price > 0) {
|
|
205
151
|
maxAmountToReclaim =
|
|
206
|
-
mulDiv(
|
|
152
|
+
bigIntMax(0n, mulDiv(mulDiv(borrowable, masterConstants.ASSET_COEFFICIENT_SCALE, assetConfig.collateralFactor), 10n ** assetConfig.decimals, price)
|
|
153
|
+
- calculatePresentValue(assetData.sRate, assetConfig.dust, masterConstants) / 2n);
|
|
207
154
|
}
|
|
208
155
|
withdrawAmountMax = bigIntMin(maxAmountToReclaim, oldPresentValue.amount);
|
|
209
156
|
}
|
|
@@ -227,11 +174,11 @@ function getAvailableToBorrow(assetsConfig, assetsData, principals, prices, mast
|
|
|
227
174
|
const price = prices.get(assetID);
|
|
228
175
|
const principal = principals.get(assetID);
|
|
229
176
|
if (principal < 0) {
|
|
230
|
-
borrowAmount += (calculatePresentValue(assetData.bRate, -principal, masterConstants)
|
|
177
|
+
borrowAmount += mulDiv(calculatePresentValue(assetData.bRate, -principal, masterConstants), price, 10n ** assetConfig.decimals);
|
|
231
178
|
}
|
|
232
179
|
else if (principal > 0) {
|
|
233
180
|
borrowLimit +=
|
|
234
|
-
|
|
181
|
+
mulDiv(mulDiv(calculatePresentValue(assetData.sRate, principal, masterConstants), price, 10n ** assetConfig.decimals), assetConfig.collateralFactor, masterConstants.ASSET_COEFFICIENT_SCALE);
|
|
235
182
|
}
|
|
236
183
|
}
|
|
237
184
|
return borrowLimit - borrowAmount;
|
|
@@ -320,7 +267,7 @@ function calculateLiquidationData(assetsConfig, assetsData, principals, prices,
|
|
|
320
267
|
loanScale -
|
|
321
268
|
10n;
|
|
322
269
|
minCollateralAmount = (minCollateralAmount * 97n) / 100n;
|
|
323
|
-
if (minCollateralAmount / collateralDecimal >=
|
|
270
|
+
if (minCollateralAmount / collateralDecimal >= 0n) { // todo back to 1
|
|
324
271
|
return {
|
|
325
272
|
greatestCollateralAsset: collateralAsset,
|
|
326
273
|
greatestCollateralValue: collateralValue,
|
|
@@ -347,9 +294,10 @@ function calculateLiquidationData(assetsConfig, assetsData, principals, prices,
|
|
|
347
294
|
exports.calculateLiquidationData = calculateLiquidationData;
|
|
348
295
|
function predictHealthFactor(args) {
|
|
349
296
|
const liquidationData = calculateLiquidationData(args.assetsConfig, args.assetsData, args.principals, args.prices, args.poolConfig);
|
|
350
|
-
const
|
|
351
|
-
const assetConfig = args.assetsConfig.get(
|
|
352
|
-
const assetPrice = Number(args.prices.get(
|
|
297
|
+
const assetId = args.asset.assetId;
|
|
298
|
+
const assetConfig = args.assetsConfig.get(assetId);
|
|
299
|
+
const assetPrice = Number(args.prices.get(assetId));
|
|
300
|
+
const assetData = args.assetsData.get(assetId);
|
|
353
301
|
let totalLimit = Number(liquidationData.totalLimit);
|
|
354
302
|
let totalBorrow = Number(liquidationData.totalDebt);
|
|
355
303
|
const currentAmount = args.amount;
|
package/dist/api/parser.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dictionary, DictionaryValue } from '@ton/core';
|
|
2
2
|
import { AssetConfig, AssetData, ExtendedAssetsConfig, ExtendedAssetsData, MasterConstants, MasterData, PoolAssetsConfig, PoolConfig } from '../types/Master';
|
|
3
|
-
import { UserData, UserLiteData } from '../types/User';
|
|
3
|
+
import { UserData, UserLiteData, UserRewards } from '../types/User';
|
|
4
|
+
export declare function createUserRewards(): DictionaryValue<UserRewards>;
|
|
4
5
|
export declare function createAssetData(): DictionaryValue<AssetData>;
|
|
5
6
|
export declare function createAssetConfig(): DictionaryValue<AssetConfig>;
|
|
6
7
|
export declare function parseMasterData(masterDataBOC: string, poolAssetsConfig: PoolAssetsConfig, masterConstants: MasterConstants): MasterData;
|
package/dist/api/parser.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseUserData = exports.parseUserLiteData = exports.parseMasterData = exports.createAssetConfig = exports.createAssetData = void 0;
|
|
3
|
+
exports.parseUserData = exports.parseUserLiteData = exports.parseMasterData = exports.createAssetConfig = exports.createAssetData = exports.createUserRewards = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const math_1 = require("./math");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
7
7
|
const User_1 = require("../types/User");
|
|
8
|
-
|
|
9
|
-
/* export function createUserRewards(): DictionaryValue<UserRewards> {
|
|
8
|
+
function createUserRewards() {
|
|
10
9
|
return {
|
|
11
|
-
serialize: (src
|
|
10
|
+
serialize: (src, buidler) => {
|
|
12
11
|
buidler.storeUint(src.trackingIndex, 64);
|
|
13
12
|
buidler.storeUint(src.trackingAccured, 64);
|
|
14
|
-
|
|
15
|
-
parse: (src
|
|
13
|
+
},
|
|
14
|
+
parse: (src) => {
|
|
16
15
|
const trackingIndex = BigInt(src.loadUint(64));
|
|
17
16
|
const trackingAccured = BigInt(src.loadUint(64));
|
|
18
17
|
return { trackingIndex, trackingAccured };
|
|
19
18
|
},
|
|
20
19
|
};
|
|
21
|
-
}
|
|
20
|
+
}
|
|
21
|
+
exports.createUserRewards = createUserRewards;
|
|
22
22
|
function createAssetData() {
|
|
23
23
|
return {
|
|
24
24
|
serialize: (src, buidler) => {
|
|
@@ -28,10 +28,11 @@ function createAssetData() {
|
|
|
28
28
|
buidler.storeUint(src.totalBorrow, 64);
|
|
29
29
|
buidler.storeUint(src.lastAccural, 32);
|
|
30
30
|
buidler.storeUint(src.balance, 64);
|
|
31
|
-
/* Will be in v6
|
|
32
31
|
buidler.storeUint(src.trackingSupplyIndex, 64);
|
|
33
32
|
buidler.storeUint(src.trackingBorrowIndex, 64);
|
|
34
|
-
|
|
33
|
+
if (src.awaitedSupply) {
|
|
34
|
+
buidler.storeUint(src.awaitedSupply, 64);
|
|
35
|
+
}
|
|
35
36
|
},
|
|
36
37
|
parse: (src) => {
|
|
37
38
|
const sRate = BigInt(src.loadInt(64));
|
|
@@ -40,13 +41,13 @@ function createAssetData() {
|
|
|
40
41
|
const totalBorrow = BigInt(src.loadInt(64));
|
|
41
42
|
const lastAccural = BigInt(src.loadInt(32));
|
|
42
43
|
const balance = BigInt(src.loadInt(64));
|
|
43
|
-
/* Will be in v6
|
|
44
44
|
const trackingSupplyIndex = BigInt(src.loadUint(64));
|
|
45
45
|
const trackingBorrowIndex = BigInt(src.loadUint(64));
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
let awaitedSupply = undefined;
|
|
47
|
+
if (src.remainingBits == 64) {
|
|
48
|
+
awaitedSupply = BigInt(src.loadUint(64));
|
|
49
|
+
}
|
|
50
|
+
return { sRate, bRate, totalSupply, totalBorrow, lastAccural, balance, trackingSupplyIndex, trackingBorrowIndex, awaitedSupply };
|
|
50
51
|
},
|
|
51
52
|
};
|
|
52
53
|
}
|
|
@@ -71,10 +72,9 @@ function createAssetConfig() {
|
|
|
71
72
|
refBuild.storeUint(src.maxTotalSupply, 64);
|
|
72
73
|
refBuild.storeUint(src.reserveFactor, 16);
|
|
73
74
|
refBuild.storeUint(src.liquidationReserveFactor, 16);
|
|
74
|
-
/* Will be in v6
|
|
75
75
|
refBuild.storeUint(src.minPrincipalForRewards, 64);
|
|
76
76
|
refBuild.storeUint(src.baseTrackingSupplySpeed, 64);
|
|
77
|
-
refBuild.storeUint(src.baseTrackingBorrowSpeed, 64);
|
|
77
|
+
refBuild.storeUint(src.baseTrackingBorrowSpeed, 64);
|
|
78
78
|
builder.storeRef(refBuild.endCell());
|
|
79
79
|
},
|
|
80
80
|
parse: (src) => {
|
|
@@ -95,10 +95,9 @@ function createAssetConfig() {
|
|
|
95
95
|
const maxTotalSupply = ref.loadUintBig(64);
|
|
96
96
|
const reserveFactor = ref.loadUintBig(16);
|
|
97
97
|
const liquidationReserveFactor = ref.loadUintBig(16);
|
|
98
|
-
/* Will be in v6
|
|
99
98
|
const minPrincipalForRewards = ref.loadUintBig(64);
|
|
100
99
|
const baseTrackingSupplySpeed = ref.loadUintBig(64);
|
|
101
|
-
const baseTrackingBorrowSpeed = ref.loadUintBig(64);
|
|
100
|
+
const baseTrackingBorrowSpeed = ref.loadUintBig(64);
|
|
102
101
|
return {
|
|
103
102
|
oracle,
|
|
104
103
|
decimals,
|
|
@@ -116,10 +115,9 @@ function createAssetConfig() {
|
|
|
116
115
|
maxTotalSupply,
|
|
117
116
|
reserveFactor,
|
|
118
117
|
liquidationReserveFactor,
|
|
119
|
-
/* Will be in v6
|
|
120
118
|
minPrincipalForRewards,
|
|
121
119
|
baseTrackingSupplySpeed,
|
|
122
|
-
baseTrackingBorrowSpeed
|
|
120
|
+
baseTrackingBorrowSpeed
|
|
123
121
|
};
|
|
124
122
|
},
|
|
125
123
|
};
|
|
@@ -136,11 +134,10 @@ function parseMasterData(masterDataBOC, poolAssetsConfig, masterConstants) {
|
|
|
136
134
|
updateTime: upgradeConfigParser.loadUint(64),
|
|
137
135
|
freezeTime: upgradeConfigParser.loadUint(64),
|
|
138
136
|
userCode: (0, helpers_1.loadMyRef)(upgradeConfigParser),
|
|
139
|
-
blankCode: (0, helpers_1.loadMyRef)(upgradeConfigParser),
|
|
140
137
|
newMasterCode: (0, helpers_1.loadMaybeMyRef)(upgradeConfigParser),
|
|
141
138
|
newUserCode: (0, helpers_1.loadMaybeMyRef)(upgradeConfigParser),
|
|
142
139
|
};
|
|
143
|
-
upgradeConfigParser.endParse();
|
|
140
|
+
// upgradeConfigParser.endParse(); todo fix with new testnet contract
|
|
144
141
|
const masterConfigSlice = masterSlice.loadRef().beginParse();
|
|
145
142
|
const assetsConfigDict = masterConfigSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), createAssetConfig());
|
|
146
143
|
const assetsDataDict = masterSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), createAssetData());
|
|
@@ -157,9 +154,12 @@ function parseMasterData(masterDataBOC, poolAssetsConfig, masterConstants) {
|
|
|
157
154
|
const masterConfig = {
|
|
158
155
|
ifActive: masterConfigSlice.loadInt(8),
|
|
159
156
|
admin: masterConfigSlice.loadAddress(),
|
|
160
|
-
|
|
157
|
+
oraclesInfo: {
|
|
158
|
+
numOracles: masterConfigSlice.loadUint(16),
|
|
159
|
+
threshold: masterConfigSlice.loadUint(16),
|
|
160
|
+
oracles: (0, helpers_1.loadMaybeMyRef)(masterConfigSlice)
|
|
161
|
+
},
|
|
161
162
|
tokenKeys: (0, helpers_1.loadMaybeMyRef)(masterConfigSlice),
|
|
162
|
-
walletToMaster: (0, helpers_1.loadMaybeMyRef)(masterConfigSlice),
|
|
163
163
|
};
|
|
164
164
|
masterConfigSlice.endParse();
|
|
165
165
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
@@ -190,40 +190,33 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, ap
|
|
|
190
190
|
const userAddress = userSlice.loadAddress();
|
|
191
191
|
const principalsDict = userSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigInt(64));
|
|
192
192
|
const userState = userSlice.loadInt(64);
|
|
193
|
-
const trackingSupplyIndex = userSlice.loadUintBig(64);
|
|
194
|
-
const trackingBorrowIndex = userSlice.loadUintBig(64);
|
|
195
|
-
const dutchAuctionStart = userSlice.loadUint(32);
|
|
196
|
-
const backupCell = (0, helpers_1.loadMyRef)(userSlice);
|
|
197
|
-
/* Will be in v6
|
|
198
193
|
let trackingSupplyIndex = 0n;
|
|
199
194
|
let trackingBorrowIndex = 0n;
|
|
200
195
|
let dutchAuctionStart = 0;
|
|
201
|
-
let backupCell = Cell.EMPTY;
|
|
202
|
-
let rewards = Dictionary.empty(Dictionary.Keys.BigUint(256), createUserRewards());
|
|
203
|
-
let backupCell1
|
|
204
|
-
let backupCell2
|
|
196
|
+
let backupCell = core_1.Cell.EMPTY;
|
|
197
|
+
let rewards = core_1.Dictionary.empty(core_1.Dictionary.Keys.BigUint(256), createUserRewards());
|
|
198
|
+
let backupCell1 = null;
|
|
199
|
+
let backupCell2 = null;
|
|
205
200
|
const bitsLeft = userSlice.remainingBits;
|
|
206
201
|
if (bitsLeft > 32) {
|
|
207
202
|
trackingSupplyIndex = userSlice.loadUintBig(64);
|
|
208
203
|
trackingBorrowIndex = userSlice.loadUintBig(64);
|
|
209
204
|
dutchAuctionStart = userSlice.loadUint(32);
|
|
210
|
-
backupCell = loadMyRef(userSlice);
|
|
211
|
-
}
|
|
212
|
-
|
|
205
|
+
backupCell = (0, helpers_1.loadMyRef)(userSlice);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
rewards = userSlice.loadDict(core_1.Dictionary.Keys.BigUint(256), createUserRewards());
|
|
213
209
|
backupCell1 = userSlice.loadMaybeRef();
|
|
214
210
|
backupCell2 = userSlice.loadMaybeRef();
|
|
215
211
|
}
|
|
216
|
-
*/
|
|
217
212
|
userSlice.endParse();
|
|
218
|
-
const isV5Main = (0, math_1.isV5MainPoolContract)(poolConfig);
|
|
219
213
|
const userBalances = core_1.Dictionary.empty();
|
|
220
214
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
221
215
|
const assetData = assetsData.get(asset.assetId);
|
|
222
216
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
223
217
|
let principal = principalsDict.get(asset.assetId) || 0n;
|
|
224
218
|
let balance = (0, math_1.presentValue)(assetData.sRate, assetData.bRate, principal, masterConstants);
|
|
225
|
-
|
|
226
|
-
if (applyDust && (principal > 0 && (leftBorder < assetConfig.dust))) { // v6 will be abs(principals) < dust
|
|
219
|
+
if (applyDust && (principal > 0 && (principal < assetConfig.dust))) {
|
|
227
220
|
principal = 0n;
|
|
228
221
|
balance = {
|
|
229
222
|
amount: 0n,
|
|
@@ -245,10 +238,9 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig, poolConfig, ap
|
|
|
245
238
|
trackingBorrowIndex: trackingBorrowIndex,
|
|
246
239
|
dutchAuctionStart: dutchAuctionStart,
|
|
247
240
|
backupCell: backupCell,
|
|
248
|
-
/* Will be in v6
|
|
249
241
|
rewards: rewards,
|
|
250
242
|
backupCell1: backupCell1,
|
|
251
|
-
backupCell2: backupCell2,
|
|
243
|
+
backupCell2: backupCell2,
|
|
252
244
|
};
|
|
253
245
|
}
|
|
254
246
|
exports.parseUserLiteData = parseUserLiteData;
|
|
@@ -259,14 +251,12 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfi
|
|
|
259
251
|
const borrowLimits = core_1.Dictionary.empty();
|
|
260
252
|
let supplyBalance = 0n;
|
|
261
253
|
let borrowBalance = 0n;
|
|
262
|
-
const isV5Main = (0, math_1.isV5MainPoolContract)(poolConfig);
|
|
263
254
|
for (const [_, asset] of Object.entries(poolAssetsConfig)) {
|
|
264
255
|
const assetData = assetsData.get(asset.assetId);
|
|
265
256
|
const assetConfig = assetsConfig.get(asset.assetId);
|
|
266
257
|
let principal = userLiteData.principals.get(asset.assetId) || 0n;
|
|
267
258
|
const balance = (0, math_1.presentValue)(assetData.sRate, assetData.bRate, principal, masterConstants);
|
|
268
|
-
|
|
269
|
-
if (applyDust && (principal > 0 && (leftBorder < assetConfig.dust))) { // v6 will be abs(principals) < dust
|
|
259
|
+
if (applyDust && (principal > 0 && (principal < assetConfig.dust))) {
|
|
270
260
|
principal = 0n;
|
|
271
261
|
userLiteData.principals.set(asset.assetId, 0n);
|
|
272
262
|
}
|
|
@@ -288,21 +278,19 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices, poolConfi
|
|
|
288
278
|
const assetData = assetsData.get(asset.assetId);
|
|
289
279
|
const balance = userLiteData.balances.get(asset.assetId);
|
|
290
280
|
if (balance.type === User_1.BalanceType.supply) {
|
|
291
|
-
|
|
292
|
-
withdrawalLimits.set(asset.assetId, (0, math_1.calculateMaximumWithdrawAmountOld)(assetsConfig, assetsData, userLiteData.principals, prices, masterConstants, asset.assetId));
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
withdrawalLimits.set(asset.assetId, (0, math_1.calculateMaximumWithdrawAmount)(assetsConfig, assetsData, userLiteData.principals, prices, masterConstants, asset.assetId));
|
|
296
|
-
}
|
|
281
|
+
withdrawalLimits.set(asset.assetId, (0, math_1.bigIntMin)((0, math_1.calculateMaximumWithdrawAmount)(assetsConfig, assetsData, userLiteData.principals, prices, masterConstants, asset.assetId), assetData.balance));
|
|
297
282
|
}
|
|
298
|
-
borrowLimits.set(asset.assetId, (0, math_1.bigIntMin)((availableToBorrow * 10n ** assetConfig.decimals) / prices.get(asset.assetId), assetData.balance));
|
|
283
|
+
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)));
|
|
299
284
|
}
|
|
300
285
|
const limitUsed = borrowBalance + availableToBorrow;
|
|
301
286
|
const limitUsedPercent = limitUsed === 0n
|
|
302
287
|
? 0
|
|
303
288
|
: Number(BigInt(1e9) - (availableToBorrow * BigInt(1e9)) / (borrowBalance + availableToBorrow)) / 1e7;
|
|
304
289
|
const liquidationData = (0, math_1.calculateLiquidationData)(assetsConfig, assetsData, userLiteData.principals, prices, poolConfig);
|
|
305
|
-
|
|
290
|
+
let healthFactor = 1;
|
|
291
|
+
if (liquidationData.totalLimit != 0n) {
|
|
292
|
+
healthFactor = 1 - Number(liquidationData.totalDebt) / Number(liquidationData.totalLimit);
|
|
293
|
+
}
|
|
306
294
|
return {
|
|
307
295
|
...userLiteData,
|
|
308
296
|
withdrawalLimits: withdrawalLimits,
|
package/dist/api/prices.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { PriceData } from '../types/Common';
|
|
2
|
-
|
|
2
|
+
import { PoolConfig } from '../types/Master';
|
|
3
|
+
export declare function getPrices(endpoints?: String[], poolConfig?: PoolConfig): Promise<PriceData>;
|
package/dist/api/prices.js
CHANGED
|
@@ -2,25 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPrices = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
const priceUtils_1 = require("../utils/priceUtils");
|
|
6
|
+
const pools_1 = require("../constants/pools");
|
|
7
|
+
async function getPrices(endpoints = ["api.stardust-mainnet.iotaledger.net", "iota.evaa.finance"], poolConfig = pools_1.MAINNET_POOL_CONFIG) {
|
|
8
|
+
if (endpoints.length == 0) {
|
|
9
|
+
throw new Error("Empty endpoint list");
|
|
10
|
+
}
|
|
11
|
+
const prices = await Promise.all(poolConfig.oracles.map(async (x) => await (0, priceUtils_1.parsePrices)(await (0, priceUtils_1.loadPrices)(x.address, endpoints), x.id)));
|
|
12
|
+
let acceptedPrices = prices.filter((0, priceUtils_1.verifyPrices)(poolConfig.poolAssetsConfig));
|
|
13
|
+
if (acceptedPrices.length < poolConfig.minimalOracles) {
|
|
14
|
+
throw new Error("Prices are outdated");
|
|
15
|
+
}
|
|
16
|
+
if (acceptedPrices.length > poolConfig.minimalOracles && acceptedPrices.length % 2 == 0) {
|
|
17
|
+
acceptedPrices = acceptedPrices.slice(0, acceptedPrices.length - 1); // to reduce fees, MINIMAL_ORACLES_NUMBER is odd
|
|
18
|
+
}
|
|
19
|
+
if (acceptedPrices.length != poolConfig.minimalOracles) {
|
|
20
|
+
const sortedByTimestamp = acceptedPrices.slice().sort((a, b) => b.timestamp - a.timestamp);
|
|
21
|
+
const newerPrices = sortedByTimestamp.slice(0, poolConfig.minimalOracles);
|
|
22
|
+
acceptedPrices = newerPrices.sort((a, b) => a.oracleId - b.oracleId);
|
|
23
|
+
}
|
|
24
|
+
const medianData = poolConfig.poolAssetsConfig.map(asset => ({ assetId: asset.assetId, medianPrice: (0, priceUtils_1.getMedianPrice)(acceptedPrices, asset.assetId) }));
|
|
25
|
+
const packedMedianData = (0, priceUtils_1.packAssetsData)(medianData);
|
|
26
|
+
const oraclesData = acceptedPrices.map(x => ({ oracle: { id: x.oracleId, pubkey: x.pubkey }, data: { timestamp: x.timestamp, prices: x.dict }, signature: x.signature }));
|
|
27
|
+
const packedOracleData = (0, priceUtils_1.packOraclesData)(oraclesData, poolConfig.poolAssetsConfig.map(x => x.assetId));
|
|
28
|
+
const dict = core_1.Dictionary.empty();
|
|
29
|
+
medianData.forEach(x => dict.set(x.assetId, x.medianPrice));
|
|
22
30
|
return {
|
|
23
|
-
dict:
|
|
24
|
-
dataCell: (0,
|
|
31
|
+
dict: dict,
|
|
32
|
+
dataCell: (0, priceUtils_1.packPrices)(packedMedianData, packedOracleData)
|
|
25
33
|
};
|
|
26
34
|
}
|
|
35
|
+
exports.getPrices = getPrices;
|
package/dist/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const TTL_ORACLE_DATA_SEC =
|
|
1
|
+
export declare const TTL_ORACLE_DATA_SEC = 120;
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, Cell } from '@ton/core';
|
|
2
|
+
import { OracleNFT } from '../types/Master';
|
|
2
3
|
export declare const MASTER_CONSTANTS: {
|
|
3
4
|
FACTOR_SCALE: bigint;
|
|
4
5
|
ASSET_COEFFICIENT_SCALE: bigint;
|
|
@@ -11,13 +12,14 @@ export declare const MASTER_CONSTANTS: {
|
|
|
11
12
|
};
|
|
12
13
|
export declare const NULL_ADDRESS: Address;
|
|
13
14
|
export declare const EVAA_MASTER_MAINNET: Address;
|
|
14
|
-
export declare const MAINNET_VERSION =
|
|
15
|
+
export declare const MAINNET_VERSION = 6;
|
|
15
16
|
export declare const EVAA_MASTER_TESTNET: Address;
|
|
16
|
-
export declare const TESTNET_VERSION =
|
|
17
|
+
export declare const TESTNET_VERSION = 0;
|
|
17
18
|
export declare const EVAA_LP_MAINNET: Address;
|
|
18
|
-
export declare const EVAA_LP_MAINNET_VERSION =
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
19
|
+
export declare const EVAA_LP_MAINNET_VERSION = 2;
|
|
20
|
+
export declare const ORACLES_MAINNET: OracleNFT[];
|
|
21
|
+
export declare const ORACLES_TESTNET: OracleNFT[];
|
|
22
|
+
export declare const ORACLES_LP: OracleNFT[];
|
|
21
23
|
export declare const LENDING_CODE: Cell;
|
|
22
24
|
export declare const JETTON_WALLET_STANDART_CODE: Cell;
|
|
23
25
|
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.
|
|
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;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
exports.MASTER_CONSTANTS = {
|
|
6
6
|
FACTOR_SCALE: BigInt(1e12),
|
|
@@ -14,13 +14,32 @@ exports.MASTER_CONSTANTS = {
|
|
|
14
14
|
};
|
|
15
15
|
exports.NULL_ADDRESS = core_1.Address.parse('UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJKZ');
|
|
16
16
|
exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
17
|
-
exports.MAINNET_VERSION =
|
|
18
|
-
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('
|
|
19
|
-
exports.TESTNET_VERSION =
|
|
17
|
+
exports.MAINNET_VERSION = 6;
|
|
18
|
+
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('EQDLsg3w-iBj26Gww7neYoJAxiT2t77Zo8ro56b0yuHsPp3C');
|
|
19
|
+
exports.TESTNET_VERSION = 0;
|
|
20
20
|
exports.EVAA_LP_MAINNET = core_1.Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLww-hdWk2G37Jc6N');
|
|
21
|
-
exports.EVAA_LP_MAINNET_VERSION =
|
|
22
|
-
exports.
|
|
23
|
-
|
|
21
|
+
exports.EVAA_LP_MAINNET_VERSION = 2;
|
|
22
|
+
exports.ORACLES_MAINNET = [
|
|
23
|
+
{ id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d' },
|
|
24
|
+
{ id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191' },
|
|
25
|
+
{ id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0' },
|
|
26
|
+
{ id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52' },
|
|
27
|
+
];
|
|
28
|
+
exports.ORACLES_TESTNET = [
|
|
29
|
+
{ id: 0, address: '0x3bb147a37b7a7f874c39320440f352bddd2c9337e31a778731910f0266391650' },
|
|
30
|
+
{ id: 1, address: '0x676767e93b05a21aec9023a65f73cffe1c725709c3c964a7c3f0fd4229089bfe' },
|
|
31
|
+
{ id: 2, address: '0x9c9e65951b0c5920c286bdb3410babcaf21f85bc9c90c13172988630f1244e0f' },
|
|
32
|
+
{ id: 3, address: '0x9dcf880229bfb68d7344fd294624b64f1e0b43b9d858f0fdb1bc6434616c08f5' },
|
|
33
|
+
{ id: 4, address: '0x4d1afcf7c0426ca61c405c8cfaef0053a0f0d143740ffed04c8716beb99cd614' },
|
|
34
|
+
{ id: 5, address: '0x11c6baa608ed10733051fd74134441d384e471722fbc496b43ea4e3c6652485f' },
|
|
35
|
+
{ id: 6, address: '0x2b685672f38dc2fce59013bb740bf24c6037049a1c267bb3b5f6f55d5b195f5f' },
|
|
36
|
+
];
|
|
37
|
+
exports.ORACLES_LP = [
|
|
38
|
+
{ id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d' },
|
|
39
|
+
{ id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191' },
|
|
40
|
+
{ id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0' },
|
|
41
|
+
{ id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52' },
|
|
42
|
+
];
|
|
24
43
|
exports.LENDING_CODE = core_1.Cell.fromBoc(Buffer.from('b5ee9c72c1010e0100fd000d12182a555a6065717691969efd0114ff00f4a413f4bcf2c80b010202c8050202039f740403001ff2f8276a2687d2018fd201800f883b840051d38642c678b64e4400780e58fc10802faf07f80e59fa801e78b096664c02078067c07c100627a7978402014807060007a0ddb0c60201c709080013a0fd007a026900aa90400201200b0a0031b8e1002191960aa00b9e2ca007f4042796d225e8019203f6010201200d0c000bf7c147d2218400b9d10e86981fd201840b07f8138d809797976a2687d2029116382f970fd9178089910374daf81b619fd20182c7883b8701981684100627910eba56001797a6a6ba610fd8200e8768f76a9f6aa00cc2a32a8292878809bef2f1889f883bbcdeb86f01', 'hex'))[0];
|
|
25
44
|
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=');
|
|
26
45
|
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');
|
|
@@ -33,9 +52,9 @@ exports.OPCODES = {
|
|
|
33
52
|
};
|
|
34
53
|
exports.FEES = {
|
|
35
54
|
SUPPLY: (0, core_1.toNano)('0.3'),
|
|
36
|
-
WITHDRAW: (0, core_1.toNano)('0.
|
|
37
|
-
SUPPLY_JETTON: (0, core_1.toNano)('0.
|
|
38
|
-
SUPPLY_JETTON_FWD: (0, core_1.toNano)('0.
|
|
55
|
+
WITHDRAW: (0, core_1.toNano)('0.35'),
|
|
56
|
+
SUPPLY_JETTON: (0, core_1.toNano)('0.35'),
|
|
57
|
+
SUPPLY_JETTON_FWD: (0, core_1.toNano)('0.3'),
|
|
39
58
|
LIQUIDATION: (0, core_1.toNano)('0.8'),
|
|
40
59
|
LIQUIDATION_JETTON: (0, core_1.toNano)('1'),
|
|
41
60
|
LIQUIDATION_JETTON_FWD: (0, core_1.toNano)('0.8'),
|
package/dist/constants/pools.js
CHANGED
|
@@ -7,7 +7,8 @@ exports.MAINNET_POOL_CONFIG = {
|
|
|
7
7
|
masterAddress: general_1.EVAA_MASTER_MAINNET,
|
|
8
8
|
masterVersion: general_1.MAINNET_VERSION,
|
|
9
9
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
10
|
-
|
|
10
|
+
oracles: general_1.ORACLES_MAINNET,
|
|
11
|
+
minimalOracles: 3,
|
|
11
12
|
poolAssetsConfig: [
|
|
12
13
|
assets_1.TON_MAINNET,
|
|
13
14
|
assets_1.JUSDT_MAINNET,
|
|
@@ -22,7 +23,8 @@ exports.TESTNET_POOL_CONFIG = {
|
|
|
22
23
|
masterAddress: general_1.EVAA_MASTER_TESTNET,
|
|
23
24
|
masterVersion: general_1.TESTNET_VERSION,
|
|
24
25
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
25
|
-
|
|
26
|
+
oracles: general_1.ORACLES_TESTNET,
|
|
27
|
+
minimalOracles: 5,
|
|
26
28
|
poolAssetsConfig: [
|
|
27
29
|
assets_1.TON_MAINNET,
|
|
28
30
|
assets_1.JUSDT_TESTNET,
|
|
@@ -35,7 +37,8 @@ exports.MAINNET_LP_POOL_CONFIG = {
|
|
|
35
37
|
masterAddress: general_1.EVAA_LP_MAINNET,
|
|
36
38
|
masterVersion: general_1.EVAA_LP_MAINNET_VERSION,
|
|
37
39
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
38
|
-
|
|
40
|
+
oracles: general_1.ORACLES_LP,
|
|
41
|
+
minimalOracles: 3,
|
|
39
42
|
poolAssetsConfig: [
|
|
40
43
|
assets_1.TON_MAINNET,
|
|
41
44
|
assets_1.USDT_MAINNET,
|
|
@@ -27,6 +27,8 @@ export type SupplyParameters = {
|
|
|
27
27
|
userAddress: Address;
|
|
28
28
|
responseAddress?: Address;
|
|
29
29
|
forwardAmount?: bigint;
|
|
30
|
+
amountToTransfer: bigint;
|
|
31
|
+
payload: Cell;
|
|
30
32
|
};
|
|
31
33
|
/**
|
|
32
34
|
* Parameters for the withdraw message
|
|
@@ -43,8 +45,10 @@ export type WithdrawParameters = {
|
|
|
43
45
|
amount: bigint;
|
|
44
46
|
userAddress: Address;
|
|
45
47
|
includeUserCode: boolean;
|
|
46
|
-
priceData: Cell;
|
|
47
48
|
asset: PoolAssetConfig;
|
|
49
|
+
priceData: Cell;
|
|
50
|
+
amountToTransfer: bigint;
|
|
51
|
+
payload: Cell;
|
|
48
52
|
};
|
|
49
53
|
/**
|
|
50
54
|
* Base data for liquidation. Can be obtained from the user contract liquidationParameters getter
|
|
@@ -62,6 +66,7 @@ export type LiquidationBaseData = {
|
|
|
62
66
|
minCollateralAmount: bigint;
|
|
63
67
|
liquidationAmount: bigint;
|
|
64
68
|
tonLiquidation: boolean;
|
|
69
|
+
forwardAmount?: bigint;
|
|
65
70
|
};
|
|
66
71
|
/**
|
|
67
72
|
* Base parameters for liquidation
|
|
@@ -74,10 +79,11 @@ export type LiquidationParameters = LiquidationBaseData & {
|
|
|
74
79
|
asset: PoolAssetConfig;
|
|
75
80
|
queryID: bigint;
|
|
76
81
|
liquidatorAddress: Address;
|
|
82
|
+
responseAddress: Address;
|
|
77
83
|
includeUserCode: boolean;
|
|
78
84
|
priceData: Cell;
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
payload: Cell;
|
|
86
|
+
payloadForwardAmount: bigint;
|
|
81
87
|
};
|
|
82
88
|
/**
|
|
83
89
|
* Evaa master contract wrapper
|