@evaafi/sdk 0.6.1 → 0.6.2
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/CHANGELOG.md +240 -0
- package/LICENSE.md +7 -0
- package/dist/api/liquidation.js +1 -3
- package/dist/api/math.js +0 -2
- package/dist/api/parser.js +4 -9
- 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 +4 -1
- package/dist/constants/general.js +11 -21
- 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 +3 -3
- package/dist/index.js +7 -1
- 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 +121 -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/utils/userJettonWallet.js +42 -43
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +5 -1
- package/package.json +4 -2
- package/src/api/liquidation.ts +0 -1
- package/src/api/math.ts +1 -2
- package/src/api/parser.ts +4 -11
- package/src/api/prices.ts +20 -7
- package/src/constants/assets.ts +57 -0
- package/src/constants/general.ts +10 -22
- package/src/constants/pools.ts +21 -5
- package/src/contracts/MasterContract.ts +8 -1
- package/src/index.ts +7 -2
- package/src/prices/Prices.ts +32 -0
- package/src/prices/PricesCollector.ts +135 -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/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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyRawPriceDataSign = exports.unpackMedianPrices = exports.collectAndFilterPrices = exports.generatePriceSources = exports.sumDicts = exports.packOraclesData = exports.createOracleDataProof = exports.packPrices = exports.packAssetsData = exports.getMedianPrice = exports.verifyPricesSign = exports.verifyPricesTimestamp = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const merkleProof_1 = require("../utils/merkleProof");
|
|
7
|
+
const crypto_1 = require("@ton/crypto");
|
|
8
|
+
function verifyPricesTimestamp() {
|
|
9
|
+
return function (priceData) {
|
|
10
|
+
const timestamp = Date.now() / 1000;
|
|
11
|
+
const pricesTime = priceData.timestamp;
|
|
12
|
+
//console.debug('timestamp - pricesTime, pricesTime', timestamp - pricesTime, pricesTime);
|
|
13
|
+
return timestamp - pricesTime < __1.TTL_ORACLE_DATA_SEC;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.verifyPricesTimestamp = verifyPricesTimestamp;
|
|
17
|
+
function verifyPricesSign(nfts) {
|
|
18
|
+
return function (priceData) {
|
|
19
|
+
if (nfts.findIndex(x => x.pubkey.equals(priceData.pubkey)) == -1) {
|
|
20
|
+
//console.debug('[verifyPricesSign] nft not found');
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return verifyRawPriceDataSign(priceData);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.verifyPricesSign = verifyPricesSign;
|
|
27
|
+
/* export function verifyPricesAssets(assets: PoolAssetsConfig) {
|
|
28
|
+
return function(priceData: RawPriceData): boolean {
|
|
29
|
+
for (const asset of assets) {
|
|
30
|
+
if(!priceData.dict.has(asset.assetId)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
} */
|
|
37
|
+
function getMedianPrice(pricesData, asset) {
|
|
38
|
+
try {
|
|
39
|
+
const usingPrices = pricesData.filter(x => x.dict.has(asset));
|
|
40
|
+
const sorted = usingPrices.map(x => x.dict.get(asset)).sort((a, b) => Number(a) - Number(b));
|
|
41
|
+
if (sorted.length == 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const mid = Math.floor(sorted.length / 2);
|
|
45
|
+
if (sorted.length % 2 === 0) {
|
|
46
|
+
return (sorted[mid - 1] + sorted[mid]) / 2n;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return sorted[mid];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.getMedianPrice = getMedianPrice;
|
|
57
|
+
function packAssetsData(assetsData) {
|
|
58
|
+
if (assetsData.length == 0) {
|
|
59
|
+
throw new Error("No assets data to pack");
|
|
60
|
+
}
|
|
61
|
+
return assetsData.reduceRight((acc, { assetId, medianPrice }) => (0, core_1.beginCell)()
|
|
62
|
+
.storeUint(assetId, 256)
|
|
63
|
+
.storeCoins(medianPrice)
|
|
64
|
+
.storeMaybeRef(acc)
|
|
65
|
+
.endCell(), null);
|
|
66
|
+
}
|
|
67
|
+
exports.packAssetsData = packAssetsData;
|
|
68
|
+
function packPrices(assetsDataCell, oraclesDataCell) {
|
|
69
|
+
let pricesCell = (0, core_1.beginCell)()
|
|
70
|
+
.storeRef(assetsDataCell)
|
|
71
|
+
.storeRef(oraclesDataCell)
|
|
72
|
+
.endCell();
|
|
73
|
+
return pricesCell;
|
|
74
|
+
}
|
|
75
|
+
exports.packPrices = packPrices;
|
|
76
|
+
function createOracleDataProof(oracle, data, signature, assets) {
|
|
77
|
+
let prunedDict = (0, merkleProof_1.generateMerkleProofDirect)(data.prices, assets, core_1.Dictionary.Keys.BigUint(256));
|
|
78
|
+
let prunedData = (0, core_1.beginCell)().storeUint(data.timestamp, 32).storeMaybeRef(prunedDict).endCell();
|
|
79
|
+
let merkleProof = (0, merkleProof_1.convertToMerkleProof)(prunedData);
|
|
80
|
+
let oracleDataProof = (0, core_1.beginCell)().storeUint(oracle.id, 32).storeRef(merkleProof).storeBuffer(signature).asSlice();
|
|
81
|
+
return oracleDataProof;
|
|
82
|
+
}
|
|
83
|
+
exports.createOracleDataProof = createOracleDataProof;
|
|
84
|
+
function packOraclesData(oraclesData, assets) {
|
|
85
|
+
if (oraclesData.length == 0) {
|
|
86
|
+
throw new Error("no oracles data to pack");
|
|
87
|
+
}
|
|
88
|
+
let proofs = oraclesData.sort((d1, d2) => d1.oracle.id - d2.oracle.id).map(({ oracle, data, signature }) => createOracleDataProof(oracle, data, signature, assets));
|
|
89
|
+
return proofs.reduceRight((acc, val) => (0, core_1.beginCell)().storeSlice(val).storeMaybeRef(acc).endCell(), null);
|
|
90
|
+
}
|
|
91
|
+
exports.packOraclesData = packOraclesData;
|
|
92
|
+
function sumDicts(result, addendum) {
|
|
93
|
+
for (const key of addendum.keys()) {
|
|
94
|
+
const current = result.get(key);
|
|
95
|
+
const value = addendum.get(key);
|
|
96
|
+
if (current === undefined) {
|
|
97
|
+
result.set(key, value);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
result.set(key, current + value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.sumDicts = sumDicts;
|
|
104
|
+
function generatePriceSources(config = __1.DefaultPriceSourcesConfig, nfts = __1.MAINNET_POOL_CONFIG.oracles) {
|
|
105
|
+
let result = config.backendEndpoints.map(x => new __1.BackendPriceSource(x, nfts));
|
|
106
|
+
result.push(...config.icpEndpoints.map(x => new __1.IcpPriceSource(x, nfts)));
|
|
107
|
+
result.push(...config.iotaEndpoints.map(x => new __1.IotaPriceSource(x, nfts)));
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
exports.generatePriceSources = generatePriceSources;
|
|
111
|
+
async function collectAndFilterPrices(priceSource, poolConfig) {
|
|
112
|
+
const prices = await priceSource.getPrices();
|
|
113
|
+
//console.debug('[FILTERING] before filtering prices len ', priceSource.sourceName, prices.length);
|
|
114
|
+
return await (async () => {
|
|
115
|
+
const acceptedPrices = prices.filter(price => verifyPricesTimestamp()(price) && verifyPricesSign(poolConfig.oracles)(price));
|
|
116
|
+
//console.debug('[FILTERING] after filtering prices len ', priceSource.sourceName, acceptedPrices.length);
|
|
117
|
+
if (acceptedPrices.length < poolConfig.minimalOracles) {
|
|
118
|
+
throw new Error("Prices are outdated");
|
|
119
|
+
}
|
|
120
|
+
return acceptedPrices;
|
|
121
|
+
})();
|
|
122
|
+
}
|
|
123
|
+
exports.collectAndFilterPrices = collectAndFilterPrices;
|
|
124
|
+
function unpackMedianPrices(pricesCell) {
|
|
125
|
+
if (!pricesCell)
|
|
126
|
+
return undefined;
|
|
127
|
+
const slice = pricesCell.beginParse();
|
|
128
|
+
let assetCell = slice.loadRef();
|
|
129
|
+
const res = core_1.Dictionary.empty();
|
|
130
|
+
while (assetCell != core_1.Cell.EMPTY && assetCell !== null) {
|
|
131
|
+
const slice = assetCell.beginParse();
|
|
132
|
+
const assetId = slice.loadUintBig(256);
|
|
133
|
+
const medianPrice = slice.loadCoins();
|
|
134
|
+
res.set(assetId, medianPrice);
|
|
135
|
+
assetCell = slice.loadMaybeRef();
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
exports.unpackMedianPrices = unpackMedianPrices;
|
|
140
|
+
function verifyRawPriceDataSign(priceData) {
|
|
141
|
+
const message = priceData.dataCell.refs[0].hash();
|
|
142
|
+
const signature = priceData.signature;
|
|
143
|
+
const publicKey = priceData.pubkey;
|
|
144
|
+
const valid = (0, crypto_1.signVerify)(message, signature, publicKey);
|
|
145
|
+
//console.debug('[verifyRawPriceDataSign] sign is valid:', valid);
|
|
146
|
+
return valid;
|
|
147
|
+
}
|
|
148
|
+
exports.verifyRawPriceDataSign = verifyRawPriceDataSign;
|
package/dist/types/Master.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export type AssetData = {
|
|
|
80
80
|
balance: bigint;
|
|
81
81
|
trackingSupplyIndex: bigint;
|
|
82
82
|
trackingBorrowIndex: bigint;
|
|
83
|
-
awaitedSupply
|
|
83
|
+
awaitedSupply: bigint;
|
|
84
84
|
};
|
|
85
85
|
export type AssetInterest = {
|
|
86
86
|
supplyInterest: bigint;
|
|
@@ -112,6 +112,7 @@ export type AgregatedBalances = {
|
|
|
112
112
|
export type OracleNFT = {
|
|
113
113
|
id: number;
|
|
114
114
|
address: string;
|
|
115
|
+
pubkey: Buffer;
|
|
115
116
|
};
|
|
116
117
|
export type Oracle = {
|
|
117
118
|
id: number;
|
|
@@ -3,54 +3,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getUserJettonWallet = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const assets_1 = require("../constants/assets");
|
|
6
|
+
function getUserJettonData(ownerAddress, assetName, jettonWalletCode, jettonMasterAddress) {
|
|
7
|
+
switch (assetName) {
|
|
8
|
+
case 'uTON':
|
|
9
|
+
return (0, core_1.beginCell)()
|
|
10
|
+
.storeCoins(0)
|
|
11
|
+
.storeUint(0, 64)
|
|
12
|
+
.storeAddress(ownerAddress)
|
|
13
|
+
.storeAddress(jettonMasterAddress)
|
|
14
|
+
.storeRef(jettonWalletCode)
|
|
15
|
+
.endCell();
|
|
16
|
+
case 'DOGS':
|
|
17
|
+
case 'NOT':
|
|
18
|
+
case 'USDT':
|
|
19
|
+
return (0, core_1.beginCell)()
|
|
20
|
+
.storeUint(0, 4)
|
|
21
|
+
.storeCoins(0)
|
|
22
|
+
.storeAddress(ownerAddress)
|
|
23
|
+
.storeAddress(jettonMasterAddress)
|
|
24
|
+
.endCell();
|
|
25
|
+
case 'tsTON':
|
|
26
|
+
return (0, core_1.beginCell)()
|
|
27
|
+
.storeCoins(0)
|
|
28
|
+
.storeAddress(ownerAddress)
|
|
29
|
+
.storeAddress(jettonMasterAddress)
|
|
30
|
+
.storeRef(jettonWalletCode)
|
|
31
|
+
.storeCoins(0)
|
|
32
|
+
.storeUint(0, 48)
|
|
33
|
+
.endCell();
|
|
34
|
+
default:
|
|
35
|
+
return (0, core_1.beginCell)().storeCoins(0)
|
|
36
|
+
.storeAddress(ownerAddress)
|
|
37
|
+
.storeAddress(jettonMasterAddress)
|
|
38
|
+
.storeRef(jettonWalletCode)
|
|
39
|
+
.endCell();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
6
42
|
function getUserJettonWallet(ownerAddress, poolAssetConfig) {
|
|
7
|
-
|
|
43
|
+
const assetName = poolAssetConfig.name;
|
|
44
|
+
if (assetName == 'TON' || poolAssetConfig.assetId === assets_1.UNDEFINED_ASSET.assetId) {
|
|
8
45
|
throw new Error(`Cant getUserJettonWallet for ${poolAssetConfig.name} asset`);
|
|
9
46
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (poolAssetConfig.name === 'USDT') {
|
|
47
|
+
let jettonWalletCode = poolAssetConfig.jettonWalletCode;
|
|
48
|
+
if (assetName === 'USDT' || assetName === 'tsTON') {
|
|
13
49
|
const lib_prep = (0, core_1.beginCell)().storeUint(2, 8).storeBuffer(jettonWalletCode.hash()).endCell();
|
|
14
|
-
|
|
15
|
-
const jettonData = (0, core_1.beginCell)()
|
|
16
|
-
.storeUint(0, 4)
|
|
17
|
-
.storeCoins(0)
|
|
18
|
-
.storeAddress(ownerAddress)
|
|
19
|
-
.storeAddress(jettonMasterAddress)
|
|
20
|
-
.endCell();
|
|
21
|
-
const stateInit = (0, core_1.beginCell)()
|
|
22
|
-
.store((0, core_1.storeStateInit)({
|
|
23
|
-
code: jwallet_code,
|
|
24
|
-
data: jettonData
|
|
25
|
-
}))
|
|
26
|
-
.endCell();
|
|
27
|
-
return new core_1.Address(0, stateInit.hash());
|
|
50
|
+
jettonWalletCode = new core_1.Cell({ exotic: true, bits: lib_prep.bits, refs: lib_prep.refs });
|
|
28
51
|
}
|
|
29
|
-
|
|
30
|
-
const lib_prep = (0, core_1.beginCell)().storeUint(2, 8).storeBuffer(jettonWalletCode.hash()).endCell();
|
|
31
|
-
const jwallet_code = new core_1.Cell({ exotic: true, bits: lib_prep.bits, refs: lib_prep.refs });
|
|
32
|
-
const jettonData = (0, core_1.beginCell)()
|
|
33
|
-
.storeCoins(0)
|
|
34
|
-
.storeAddress(ownerAddress)
|
|
35
|
-
.storeAddress(jettonMasterAddress)
|
|
36
|
-
.storeRef(jwallet_code)
|
|
37
|
-
.storeCoins(0)
|
|
38
|
-
.storeUint(0, 48)
|
|
39
|
-
.endCell();
|
|
40
|
-
const stateInit = (0, core_1.beginCell)()
|
|
41
|
-
.store((0, core_1.storeStateInit)({
|
|
42
|
-
code: jwallet_code,
|
|
43
|
-
data: jettonData
|
|
44
|
-
}))
|
|
45
|
-
.endCell();
|
|
46
|
-
return new core_1.Address(0, stateInit.hash());
|
|
47
|
-
}
|
|
48
|
-
const jettonData = (0, core_1.beginCell)()
|
|
49
|
-
.storeCoins(0)
|
|
50
|
-
.storeAddress(ownerAddress)
|
|
51
|
-
.storeAddress(jettonMasterAddress)
|
|
52
|
-
.storeRef(jettonWalletCode)
|
|
53
|
-
.endCell();
|
|
52
|
+
const jettonData = getUserJettonData(ownerAddress, assetName, jettonWalletCode, poolAssetConfig.jettonMasterAddress);
|
|
54
53
|
const stateInit = (0, core_1.beginCell)()
|
|
55
54
|
.store((0, core_1.storeStateInit)({
|
|
56
55
|
code: jettonWalletCode,
|
package/dist/utils/utils.d.ts
CHANGED
package/dist/utils/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTonAssetId = exports.isTonAsset = void 0;
|
|
3
|
+
exports.delay = exports.isTonAssetId = exports.isTonAsset = void 0;
|
|
4
4
|
const assets_1 = require("../constants/assets");
|
|
5
5
|
function isTonAsset(asset) {
|
|
6
6
|
return asset.name === 'TON';
|
|
@@ -10,3 +10,7 @@ function isTonAssetId(assetId) {
|
|
|
10
10
|
return assetId === assets_1.ASSET_ID.TON;
|
|
11
11
|
}
|
|
12
12
|
exports.isTonAssetId = isTonAssetId;
|
|
13
|
+
function delay(ms) {
|
|
14
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
15
|
+
}
|
|
16
|
+
exports.delay = delay;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evaafi/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "The EVAA SDK is designed to easily integrate with the EVAA lending protocol on TON blockchain.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsc --declaration"
|
|
11
|
+
"build": "tsc --declaration",
|
|
12
|
+
"test": "jest"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
"prettier": "^3.2.4",
|
|
29
30
|
"ts-jest": "^29.2.4",
|
|
30
31
|
"ts-node": "^10.9.1",
|
|
32
|
+
"typedoc": "^0.27.4",
|
|
31
33
|
"typescript": "^5.3.3"
|
|
32
34
|
},
|
|
33
35
|
"peerDependencies": {
|
package/src/api/liquidation.ts
CHANGED
|
@@ -179,7 +179,6 @@ export function calculateLiquidationAmounts(
|
|
|
179
179
|
|
|
180
180
|
const loanValue = toAssetWorth(loanInfo.balance, loanInfo.scale, loanInfo.price);
|
|
181
181
|
const baseLiquidationValue = BigMath.min(
|
|
182
|
-
// deductReserve(loanValue, reserveFactor, reserveFactorScale),
|
|
183
182
|
loanValue,
|
|
184
183
|
deductLiquidationBonus(allowedCollateralValue, liquidationBonus, liquidationBonusScale)
|
|
185
184
|
);
|
package/src/api/math.ts
CHANGED
|
@@ -170,13 +170,12 @@ export function getAgregatedBalances(
|
|
|
170
170
|
const price = prices.get(assetId)!;
|
|
171
171
|
const assetData = assetsData.get(assetId)!;
|
|
172
172
|
const assetConfig = assetsConfig.get(assetId)!;
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
if (principal < 0) {
|
|
175
175
|
user_total_borrow += presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price / 10n ** assetConfig.decimals;
|
|
176
176
|
} else {
|
|
177
177
|
user_total_supply += presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price / 10n ** assetConfig.decimals;
|
|
178
178
|
}
|
|
179
|
-
// console.log('aggregated', assetId, presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).type, presentValue(assetData.sRate, assetData.bRate, principal, masterConstants).amount * price / 10n ** assetConfig.decimals)
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
return { totalSupply: user_total_supply, totalBorrow: user_total_borrow };
|
package/src/api/parser.ts
CHANGED
|
@@ -12,8 +12,6 @@ import {
|
|
|
12
12
|
} from './math';
|
|
13
13
|
import { loadMaybeMyRef, loadMyRef } from './helpers';
|
|
14
14
|
import { BalanceType, UserBalance, UserData, UserLiteData, UserRewards } from '../types/User';
|
|
15
|
-
import { MAINNET_POOL_CONFIG, TESTNET_POOL_CONFIG } from '../constants/pools';
|
|
16
|
-
import { basename } from 'path';
|
|
17
15
|
|
|
18
16
|
export function createUserRewards(): DictionaryValue<UserRewards> {
|
|
19
17
|
return {
|
|
@@ -40,9 +38,7 @@ export function createAssetData(): DictionaryValue<AssetData> {
|
|
|
40
38
|
buidler.storeUint(src.balance, 64);
|
|
41
39
|
buidler.storeUint(src.trackingSupplyIndex, 64);
|
|
42
40
|
buidler.storeUint(src.trackingBorrowIndex, 64);
|
|
43
|
-
|
|
44
|
-
buidler.storeUint(src.awaitedSupply, 64);
|
|
45
|
-
}
|
|
41
|
+
buidler.storeUint(src.awaitedSupply, 64);
|
|
46
42
|
},
|
|
47
43
|
parse: (src: Slice) => {
|
|
48
44
|
const sRate = BigInt(src.loadInt(64));
|
|
@@ -53,10 +49,7 @@ export function createAssetData(): DictionaryValue<AssetData> {
|
|
|
53
49
|
const balance = BigInt(src.loadInt(64));
|
|
54
50
|
const trackingSupplyIndex = BigInt(src.loadUint(64));
|
|
55
51
|
const trackingBorrowIndex = BigInt(src.loadUint(64));
|
|
56
|
-
|
|
57
|
-
if (src.remainingBits == 64) {
|
|
58
|
-
awaitedSupply = BigInt(src.loadUint(64));
|
|
59
|
-
}
|
|
52
|
+
const awaitedSupply = BigInt(src.loadUint(64));
|
|
60
53
|
|
|
61
54
|
return { sRate, bRate, totalSupply, totalBorrow, lastAccural, balance, trackingSupplyIndex, trackingBorrowIndex, awaitedSupply};
|
|
62
55
|
},
|
|
@@ -205,7 +198,7 @@ export function parseUserLiteData(
|
|
|
205
198
|
assetsData: ExtendedAssetsData,
|
|
206
199
|
assetsConfig: ExtendedAssetsConfig,
|
|
207
200
|
poolConfig: PoolConfig,
|
|
208
|
-
applyDust: boolean =
|
|
201
|
+
applyDust: boolean = false
|
|
209
202
|
): UserLiteData {
|
|
210
203
|
const poolAssetsConfig = poolConfig.poolAssetsConfig;
|
|
211
204
|
const masterConstants = poolConfig.masterConstants;
|
|
@@ -283,7 +276,7 @@ export function parseUserData(
|
|
|
283
276
|
assetsConfig: ExtendedAssetsConfig,
|
|
284
277
|
prices: Dictionary<bigint, bigint>,
|
|
285
278
|
poolConfig: PoolConfig,
|
|
286
|
-
applyDust: boolean =
|
|
279
|
+
applyDust: boolean = false
|
|
287
280
|
): UserData {
|
|
288
281
|
const poolAssetsConfig = poolConfig.poolAssetsConfig;
|
|
289
282
|
const masterConstants = poolConfig.masterConstants;
|
package/src/api/prices.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PriceData, RawPriceData } from '../types/Common';
|
|
3
|
-
import { getMedianPrice, loadPrices, packAssetsData, packOraclesData, packPrices, parsePrices, verifyPrices } from '../utils/priceUtils';
|
|
4
|
-
import { OracleNFT, PoolConfig } from '../types/Master';
|
|
1
|
+
import { PoolConfig } from '../types/Master';
|
|
5
2
|
import { MAINNET_POOL_CONFIG } from '../constants/pools';
|
|
3
|
+
import { DefaultPriceSourcesConfig, PriceData, PricesCollector, PriceSource, PriceSourcesConfig } from '../prices';
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use PriceCollector istead of getPrices
|
|
7
|
+
*/
|
|
8
|
+
export async function getPrices(endpoints: string[] = ["api.stardust-mainnet.iotaledger.net"], poolConfig: PoolConfig = MAINNET_POOL_CONFIG): Promise<PriceData> {
|
|
8
9
|
if (endpoints.length == 0) {
|
|
9
10
|
throw new Error("Empty endpoint list");
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
const sources: PriceSourcesConfig = {
|
|
14
|
+
iotaEndpoints: endpoints,
|
|
15
|
+
icpEndpoints: DefaultPriceSourcesConfig.icpEndpoints,
|
|
16
|
+
backendEndpoints: DefaultPriceSourcesConfig.backendEndpoints,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const priceCollector = new PricesCollector(poolConfig, sources);
|
|
20
|
+
const prices = await priceCollector.getPrices();
|
|
21
|
+
|
|
22
|
+
return { dict: prices.dict, dataCell: prices.dataCell };
|
|
23
|
+
/*
|
|
24
|
+
Old code
|
|
12
25
|
const prices = await Promise.all(poolConfig.oracles.map(async x => await parsePrices(await loadPrices(x.address, endpoints), x.id)));
|
|
13
26
|
|
|
14
27
|
let acceptedPrices: RawPriceData[] = prices.filter(verifyPrices(poolConfig.poolAssetsConfig));
|
|
@@ -41,5 +54,5 @@ export async function getPrices(endpoints: String[] = ["api.stardust-mainnet.iot
|
|
|
41
54
|
return {
|
|
42
55
|
dict: dict,
|
|
43
56
|
dataCell: packPrices(packedMedianData, packedOracleData)
|
|
44
|
-
}
|
|
57
|
+
};*/
|
|
45
58
|
}
|
package/src/constants/assets.ts
CHANGED
|
@@ -10,10 +10,18 @@ export const ASSET_ID = {
|
|
|
10
10
|
jUSDC: sha256Hash('jUSDC'),
|
|
11
11
|
stTON: sha256Hash('stTON'),
|
|
12
12
|
tsTON: sha256Hash('tsTON'),
|
|
13
|
+
uTON: sha256Hash('uTON'),
|
|
14
|
+
|
|
15
|
+
// LP
|
|
13
16
|
TONUSDT_DEDUST: sha256Hash('TONUSDT_DEDUST'),
|
|
14
17
|
TONUSDT_STONFI: sha256Hash('TONUSDT_STONFI'),
|
|
15
18
|
TON_STORM: sha256Hash('TON_STORM'),
|
|
16
19
|
USDT_STORM: sha256Hash('USDT_STORM'),
|
|
20
|
+
|
|
21
|
+
// ALTS
|
|
22
|
+
NOT: sha256Hash('NOT'),
|
|
23
|
+
DOGS: sha256Hash('DOGS'),
|
|
24
|
+
CATI: sha256Hash('CATI'),
|
|
17
25
|
};
|
|
18
26
|
|
|
19
27
|
export const UNDEFINED_ASSET: PoolAssetConfig = {
|
|
@@ -137,3 +145,52 @@ export const USDT_STORM_MAINNET: PoolAssetConfig = {
|
|
|
137
145
|
),
|
|
138
146
|
)[0],
|
|
139
147
|
}
|
|
148
|
+
|
|
149
|
+
export const CATI_MAINNET: PoolAssetConfig = {
|
|
150
|
+
name: 'CATI',
|
|
151
|
+
assetId: ASSET_ID.CATI,
|
|
152
|
+
jettonMasterAddress: Address.parse('EQD-cvR0Nz6XAyRBvbhz-abTrRC6sI5tvHvvpeQraV9UAAD7'),
|
|
153
|
+
jettonWalletCode: Cell.fromBoc(
|
|
154
|
+
Buffer.from(
|
|
155
|
+
'b5ee9c7241021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5495eaedd7',
|
|
156
|
+
'hex',
|
|
157
|
+
),
|
|
158
|
+
)[0],
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const DOGS_MAINNET: PoolAssetConfig = {
|
|
162
|
+
name: 'DOGS',
|
|
163
|
+
assetId: ASSET_ID.DOGS,
|
|
164
|
+
jettonMasterAddress: Address.parse('EQCvxJy4eG8hyHBFsZ7eePxrRsUQSFE_jpptRAYBmcG_DOGS'),
|
|
165
|
+
jettonWalletCode: Cell.fromBoc(
|
|
166
|
+
Buffer.from(
|
|
167
|
+
'b5ee9c7241010101002300084202ba2918c8947e9b25af9ac1b883357754173e5812f807a3d6e642a14709595395237ae3c3',
|
|
168
|
+
'hex',
|
|
169
|
+
),
|
|
170
|
+
)[0],
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const NOT_MAINNET: PoolAssetConfig = {
|
|
174
|
+
name: 'NOT',
|
|
175
|
+
assetId: ASSET_ID.NOT,
|
|
176
|
+
jettonMasterAddress: Address.parse('EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT'),
|
|
177
|
+
jettonWalletCode: Cell.fromBoc(
|
|
178
|
+
Buffer.from(
|
|
179
|
+
'b5ee9c7201010101002300084202ba2918c8947e9b25af9ac1b883357754173e5812f807a3d6e642a14709595395',
|
|
180
|
+
'hex',
|
|
181
|
+
),
|
|
182
|
+
)[0],
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const UTON_MAINNET: PoolAssetConfig = {
|
|
186
|
+
name: 'uTON',
|
|
187
|
+
assetId: ASSET_ID.uTON,
|
|
188
|
+
jettonMasterAddress: Address.parse('EQAfF5j3JMIpZlLmACv7Ub7RH7WmiVMuV4ivcgNYHvNnqHTz'),
|
|
189
|
+
jettonWalletCode: Cell.fromBoc(
|
|
190
|
+
Buffer.from(
|
|
191
|
+
'b5ee9c7201021301000439000114ff00f4a413f4bcf2c80b0102016202030202cc0405020120111200bbd906380492f827000e8698180b8d84a89af81f807707d207d2018fd0018b8eb90fd0018fd001801698f90c10807c53f52dd4a989a2cf805f010c1080bc6a28cdd4b18a22201f8067000c1082caf83de5d4aa22201f806f02f82c207f9784020120060701f7f01e99ffd007d20381140816000fd23182c5d797a76a2687d00699ffd207d206a18027c30817c317c31fc327c32fc2091d0fc30fc21a8036382f97160fc20e17ff971617c227c22b82a300209aa0a82e42802fd0109e59f80e78b00e78b666490e4658089fa00097a00658064907c80383a6465816503e5ffe4e802c080201200a0b01fefa40f40431fa0020d749c200f2e2c4778018c8cb055009cf1670fa0218cb6b13cc8210178d4519c8cb1f15cb3f5003fa02f843cf1658cf1621fa025004cf16c901cc2291729171e25004a812a08208989680a08208989680a08208989680a0bcf2e2c5f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed5409000ac98040fb000201200c0d00b948020d721ed44d0fa00d33ffa40fa40d43004f86102f862f863f864f865d31f218210178d4519ba0282107bdd97deba12b1f2e2c5d33f31fa0030f84101a0f861f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed54801f53b51343e8034cffe903e90350c013e1840be18be18fe193e194134cffe803e1048a83e187e903e903e113e1149165c15180104d505417214017e8084f2cfc073c58073c5b332487232c044fd0004bd0032c0327e401c1d3232c0b281f2fff2740a31c17e11140271c1462c7cb8b0c1be80145a2860822625a019a00e01f73b51343e8034cffe903e90350c013e1840be18be18fe193e194134cffe803e903d010c1c0060083d03dbe87cb8b13434c7fe80204c0048b0803cbd350c3e10be10a93e18be1049a87e187e10d402b1c17cb8b07e1070bffcb8b0945e6860822625a019ad82284820822625a0281401e820822625a028086814a42f201001f2b608a18208989680a018a1278e355275a014a182107362d09cc8cb1f5230cb3f58fa025003cf165003cf16c9718018c8cb05f843cf165006fa0215cb6a14ccc971fb0094375b6c21e221d70b01c30023c200b08e208210d53276db708010c8cb055004cf165004fa0212cb6a12cb1fcb3fc972fb00925f03e20f0038f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed5400c0f2e2c5058208989680a018a1f841f842f843f844f845c85005fa0213cb3f01cf1601cf16ccc9ed5482107bdd97dec8cb1f14cb3ff843cf1616cb3f01fa0215cb1f5003cf1658fa02ccc9718018c8cb05f844cf165003fa0212cb6accc970fb000047bfd8176a2687d00699ffd207d206a18027c30817c317c31fc327c32fc20fc21fc227c22c004bbdd79f6a2687d00699ffd207d206a18027c30817c317c31fc327c32fc20fc217c21fc227c22c',
|
|
192
|
+
'hex',
|
|
193
|
+
),
|
|
194
|
+
)[0],
|
|
195
|
+
}
|
|
196
|
+
|
package/src/constants/general.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Address, Cell, toNano } from '@ton/core';
|
|
2
|
-
import { sha256Hash } from '../utils/sha256BigInt';
|
|
3
2
|
import { OracleNFT } from '../types/Master';
|
|
4
3
|
|
|
5
4
|
|
|
@@ -21,37 +20,26 @@ export const MASTER_CONSTANTS = {
|
|
|
21
20
|
|
|
22
21
|
export const NULL_ADDRESS = Address.parse('UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJKZ');
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
export const EVAA_MASTER_MAINNET = Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
26
24
|
export const MAINNET_VERSION = 6;
|
|
27
25
|
export const EVAA_MASTER_TESTNET = Address.parse('EQDLsg3w-iBj26Gww7neYoJAxiT2t77Zo8ro56b0yuHsPp3C');
|
|
28
26
|
export const TESTNET_VERSION = 0;
|
|
29
27
|
export const EVAA_LP_MAINNET = Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLww-hdWk2G37Jc6N');
|
|
30
|
-
export const EVAA_LP_MAINNET_VERSION =
|
|
28
|
+
export const EVAA_LP_MAINNET_VERSION = 3;
|
|
29
|
+
export const EVAA_ALTS_MAINNET = Address.parse('EQANURVS3fhBO9bivig34iyJQi97FhMbpivo1aUEAS2GYSu-');
|
|
30
|
+
export const EVAA_ALTS_MAINNET_VERSION = 0;
|
|
31
31
|
|
|
32
32
|
export const ORACLES_MAINNET: OracleNFT[] = [
|
|
33
|
-
{id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d'},
|
|
34
|
-
{id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191'},
|
|
35
|
-
{id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0'},
|
|
36
|
-
{id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52'},
|
|
33
|
+
{id: 0, address: '0xd3a8c0b9fd44fd25a49289c631e3ac45689281f2f8cf0744400b4c65bed38e5d', pubkey: Buffer.from('b404f4a2ebb62f2623b370c89189748a0276c071965b1646b996407f10d72eb9', 'hex') },
|
|
34
|
+
{id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191', pubkey: Buffer.from('9ad115087520d91b6b45d6a8521eb4616ee6914af07fabdc2e9d1826dbb17078', 'hex') },
|
|
35
|
+
{id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0', pubkey: Buffer.from('e503e02e8a9226b34e7c9deb463cbf7f19bce589362eb448a69a8ee7b2fca631', 'hex') },
|
|
36
|
+
{id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52', pubkey: Buffer.from('9cbf8374cf1f2cf17110134871d580198416e101683f4a61f54cf2a3e4e32070', 'hex') },
|
|
37
37
|
];
|
|
38
38
|
|
|
39
|
-
export const ORACLES_TESTNET: OracleNFT[] =
|
|
40
|
-
{id: 0, address: '0x3bb147a37b7a7f874c39320440f352bddd2c9337e31a778731910f0266391650'},
|
|
41
|
-
{id: 1, address: '0x676767e93b05a21aec9023a65f73cffe1c725709c3c964a7c3f0fd4229089bfe'},
|
|
42
|
-
{id: 2, address: '0x9c9e65951b0c5920c286bdb3410babcaf21f85bc9c90c13172988630f1244e0f'},
|
|
43
|
-
{id: 3, address: '0x9dcf880229bfb68d7344fd294624b64f1e0b43b9d858f0fdb1bc6434616c08f5'},
|
|
44
|
-
{id: 4, address: '0x4d1afcf7c0426ca61c405c8cfaef0053a0f0d143740ffed04c8716beb99cd614'},
|
|
45
|
-
{id: 5, address: '0x11c6baa608ed10733051fd74134441d384e471722fbc496b43ea4e3c6652485f'},
|
|
46
|
-
{id: 6, address: '0x2b685672f38dc2fce59013bb740bf24c6037049a1c267bb3b5f6f55d5b195f5f'},
|
|
47
|
-
];
|
|
39
|
+
export const ORACLES_TESTNET: OracleNFT[] = ORACLES_MAINNET;
|
|
48
40
|
|
|
49
|
-
export const ORACLES_LP: OracleNFT[] =
|
|
50
|
-
|
|
51
|
-
{id: 1, address: '0x2c21cabdaa89739de16bde7bc44e86401fac334a3c7e55305fe5e7563043e191'},
|
|
52
|
-
{id: 2, address: '0x2eb258ce7b5d02466ab8a178ad8b0ba6ffa7b58ef21de3dc3b6dd359a1e16af0'},
|
|
53
|
-
{id: 3, address: '0xf9a0769954b4430bca95149fb3d876deb7799d8f74852e0ad4ccc5778ce68b52'},
|
|
54
|
-
];
|
|
41
|
+
export const ORACLES_LP: OracleNFT[] = ORACLES_MAINNET;
|
|
42
|
+
export const ORACLES_ALTS: OracleNFT[] = ORACLES_MAINNET;
|
|
55
43
|
|
|
56
44
|
export const LENDING_CODE = Cell.fromBoc(
|
|
57
45
|
Buffer.from(
|
package/src/constants/pools.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JUSDC_MAINNET, JUSDC_TESTNET, JUSDT_MAINNET, JUSDT_TESTNET, STTON_MAINNET, STTON_TESTNET, TON_MAINNET, TON_STORM_MAINNET, TONUSDT_DEDUST_MAINNET, TSTON_MAINNET, USDT_MAINNET, USDT_STORM_MAINNET } from "./assets";
|
|
1
|
+
import { CATI_MAINNET, DOGS_MAINNET, JUSDC_MAINNET, JUSDC_TESTNET, JUSDT_MAINNET, JUSDT_TESTNET, NOT_MAINNET, STTON_MAINNET, STTON_TESTNET, TON_MAINNET, TON_STORM_MAINNET, TONUSDT_DEDUST_MAINNET, TSTON_MAINNET, USDT_MAINNET, USDT_STORM_MAINNET, UTON_MAINNET } from "./assets";
|
|
3
2
|
import { PoolConfig } from "../types/Master";
|
|
4
|
-
import { EVAA_MASTER_MAINNET, EVAA_MASTER_TESTNET, LENDING_CODE, MAINNET_VERSION, MASTER_CONSTANTS, TESTNET_VERSION, EVAA_LP_MAINNET, EVAA_LP_MAINNET_VERSION, ORACLES_MAINNET, ORACLES_LP, ORACLES_TESTNET } from "./general";
|
|
3
|
+
import { EVAA_MASTER_MAINNET, EVAA_MASTER_TESTNET, LENDING_CODE, MAINNET_VERSION, MASTER_CONSTANTS, TESTNET_VERSION, EVAA_LP_MAINNET, EVAA_LP_MAINNET_VERSION, ORACLES_MAINNET, ORACLES_LP, ORACLES_TESTNET, EVAA_ALTS_MAINNET, EVAA_ALTS_MAINNET_VERSION, ORACLES_ALTS } from "./general";
|
|
5
4
|
|
|
6
5
|
export const MAINNET_POOL_CONFIG: PoolConfig = {
|
|
7
6
|
masterAddress: EVAA_MASTER_MAINNET,
|
|
@@ -15,7 +14,8 @@ export const MAINNET_POOL_CONFIG: PoolConfig = {
|
|
|
15
14
|
JUSDC_MAINNET,
|
|
16
15
|
STTON_MAINNET,
|
|
17
16
|
TSTON_MAINNET,
|
|
18
|
-
USDT_MAINNET
|
|
17
|
+
USDT_MAINNET,
|
|
18
|
+
UTON_MAINNET // announce
|
|
19
19
|
],
|
|
20
20
|
lendingCode: LENDING_CODE
|
|
21
21
|
};
|
|
@@ -25,7 +25,7 @@ export const TESTNET_POOL_CONFIG: PoolConfig = {
|
|
|
25
25
|
masterVersion: TESTNET_VERSION,
|
|
26
26
|
masterConstants: MASTER_CONSTANTS,
|
|
27
27
|
oracles: ORACLES_TESTNET,
|
|
28
|
-
minimalOracles:
|
|
28
|
+
minimalOracles: 3,
|
|
29
29
|
poolAssetsConfig: [
|
|
30
30
|
TON_MAINNET,
|
|
31
31
|
JUSDT_TESTNET,
|
|
@@ -50,3 +50,19 @@ export const MAINNET_LP_POOL_CONFIG: PoolConfig = {
|
|
|
50
50
|
],
|
|
51
51
|
lendingCode: LENDING_CODE
|
|
52
52
|
};
|
|
53
|
+
|
|
54
|
+
export const MAINNET_ALTS_POOL_CONFIG: PoolConfig = {
|
|
55
|
+
masterAddress: EVAA_ALTS_MAINNET,
|
|
56
|
+
masterVersion: EVAA_ALTS_MAINNET_VERSION,
|
|
57
|
+
masterConstants: MASTER_CONSTANTS,
|
|
58
|
+
oracles: ORACLES_ALTS,
|
|
59
|
+
minimalOracles: 3,
|
|
60
|
+
poolAssetsConfig: [
|
|
61
|
+
TON_MAINNET,
|
|
62
|
+
USDT_MAINNET,
|
|
63
|
+
CATI_MAINNET,
|
|
64
|
+
NOT_MAINNET,
|
|
65
|
+
DOGS_MAINNET
|
|
66
|
+
],
|
|
67
|
+
lendingCode: LENDING_CODE
|
|
68
|
+
};
|
|
@@ -20,7 +20,7 @@ import { parseMasterData } from '../api/parser';
|
|
|
20
20
|
import { MasterData, PoolAssetConfig, PoolConfig} from '../types/Master';
|
|
21
21
|
import { JettonWallet } from './JettonWallet';
|
|
22
22
|
import { getUserJettonWallet } from '../utils/userJettonWallet';
|
|
23
|
-
import { getPrices, isTonAsset, isTonAssetId, MAINNET_POOL_CONFIG } from '..';
|
|
23
|
+
import { DefaultPriceSourcesConfig, getPrices, isTonAsset, isTonAssetId, MAINNET_POOL_CONFIG, PricesCollector, PriceSourcesConfig } from '..';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Parameters for the Evaa contract
|
|
@@ -393,6 +393,9 @@ export class Evaa implements Contract {
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* @deprecated Use PriceCollector (createPriceCollector) istead of getPrices
|
|
398
|
+
*/
|
|
396
399
|
async getPrices(provider: ContractProvider, endpoints?: string[]) {
|
|
397
400
|
if ((endpoints?.length ?? 0) > 0) {
|
|
398
401
|
return await getPrices(endpoints, this._poolConfig);
|
|
@@ -400,4 +403,8 @@ export class Evaa implements Contract {
|
|
|
400
403
|
return await getPrices(undefined, this._poolConfig);
|
|
401
404
|
}
|
|
402
405
|
}
|
|
406
|
+
|
|
407
|
+
createPriceCollector(priceSourcesConfig: PriceSourcesConfig = DefaultPriceSourcesConfig) : PricesCollector {
|
|
408
|
+
return new PricesCollector(this._poolConfig, priceSourcesConfig);
|
|
409
|
+
}
|
|
403
410
|
}
|