@evaafi/sdk 0.3.1 → 0.4.0
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/parser.d.ts +3 -3
- package/dist/api/parser.js +18 -12
- package/dist/constants.d.ts +25 -4
- package/dist/constants.js +36 -13
- package/dist/contracts/MasterContract.d.ts +5 -0
- package/dist/contracts/MasterContract.js +17 -2
- package/dist/contracts/UserContract.d.ts +9 -2
- package/dist/contracts/UserContract.js +27 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -3
- package/dist/types/Master.d.ts +1 -0
- package/dist/utils/userJettonWallet.js +28 -7
- package/package.json +1 -1
- package/src/api/parser.ts +287 -279
- package/src/constants.ts +77 -14
- package/src/contracts/MasterContract.ts +409 -387
- package/src/contracts/UserContract.ts +160 -125
- package/src/index.ts +76 -78
- package/src/types/Master.ts +72 -71
- package/src/utils/userJettonWallet.ts +29 -9
package/dist/api/parser.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { AssetConfig, AssetData, ExtendedAssetData, MasterData } from '../types/
|
|
|
3
3
|
import { UserData, UserLiteData } from '../types/User';
|
|
4
4
|
export declare function createAssetData(): DictionaryValue<AssetData>;
|
|
5
5
|
export declare function createAssetConfig(): DictionaryValue<AssetConfig>;
|
|
6
|
-
export declare function parseMasterData(masterDataBOC: string): MasterData;
|
|
7
|
-
export declare function parseUserLiteData(userDataBOC: string, assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig
|
|
8
|
-
export declare function parseUserData(userLiteData: UserLiteData, assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig>, prices: Dictionary<bigint, bigint
|
|
6
|
+
export declare function parseMasterData(masterDataBOC: string, testnet?: boolean): MasterData;
|
|
7
|
+
export declare function parseUserLiteData(userDataBOC: string, assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig>, testnet?: boolean): UserLiteData;
|
|
8
|
+
export declare function parseUserData(userLiteData: UserLiteData, assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig>, prices: Dictionary<bigint, bigint>, testnet?: boolean): UserData;
|
package/dist/api/parser.js
CHANGED
|
@@ -9,8 +9,8 @@ const User_1 = require("../types/User");
|
|
|
9
9
|
function createAssetData() {
|
|
10
10
|
return {
|
|
11
11
|
serialize: (src, buidler) => {
|
|
12
|
-
buidler.storeUint(src.
|
|
13
|
-
buidler.storeUint(src.
|
|
12
|
+
buidler.storeUint(src.sRate, 64);
|
|
13
|
+
buidler.storeUint(src.bRate, 64);
|
|
14
14
|
buidler.storeUint(src.totalSupply, 64);
|
|
15
15
|
buidler.storeUint(src.totalBorrow, 64);
|
|
16
16
|
buidler.storeUint(src.lastAccural, 32);
|
|
@@ -36,7 +36,7 @@ function createAssetConfig() {
|
|
|
36
36
|
const refBuild = (0, core_1.beginCell)();
|
|
37
37
|
refBuild.storeUint(src.collateralFactor, 16);
|
|
38
38
|
refBuild.storeUint(src.liquidationThreshold, 16);
|
|
39
|
-
refBuild.storeUint(src.
|
|
39
|
+
refBuild.storeUint(src.liquidationBonus, 16);
|
|
40
40
|
refBuild.storeUint(src.baseBorrowRate, 64);
|
|
41
41
|
refBuild.storeUint(src.borrowRateSlopeLow, 64);
|
|
42
42
|
refBuild.storeUint(src.borrowRateSlopeHigh, 64);
|
|
@@ -44,6 +44,7 @@ function createAssetConfig() {
|
|
|
44
44
|
refBuild.storeUint(src.supplyRateSlopeHigh, 64);
|
|
45
45
|
refBuild.storeUint(src.targetUtilization, 64);
|
|
46
46
|
refBuild.storeUint(src.originationFee, 64);
|
|
47
|
+
refBuild.storeUint(src.maxTotalSupply, 64);
|
|
47
48
|
builder.storeRef(refBuild.endCell());
|
|
48
49
|
},
|
|
49
50
|
parse: (src) => {
|
|
@@ -61,6 +62,7 @@ function createAssetConfig() {
|
|
|
61
62
|
const targetUtilization = ref.loadUintBig(64);
|
|
62
63
|
const originationFee = ref.loadUintBig(64);
|
|
63
64
|
const dust = ref.loadUintBig(64);
|
|
65
|
+
const maxTotalSupply = ref.loadUintBig(64);
|
|
64
66
|
return {
|
|
65
67
|
oracle,
|
|
66
68
|
decimals,
|
|
@@ -75,12 +77,14 @@ function createAssetConfig() {
|
|
|
75
77
|
targetUtilization,
|
|
76
78
|
originationFee,
|
|
77
79
|
dust,
|
|
80
|
+
maxTotalSupply,
|
|
78
81
|
};
|
|
79
82
|
},
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
exports.createAssetConfig = createAssetConfig;
|
|
83
|
-
function parseMasterData(masterDataBOC) {
|
|
86
|
+
function parseMasterData(masterDataBOC, testnet = false) {
|
|
87
|
+
const ASSETS_ID = testnet ? constants_1.TESTNET_ASSETS_ID : constants_1.MAINNET_ASSETS_ID;
|
|
84
88
|
const masterSlice = core_1.Cell.fromBase64(masterDataBOC).beginParse();
|
|
85
89
|
const meta = masterSlice.loadRef().beginParse().loadStringTail();
|
|
86
90
|
const upgradeConfigParser = masterSlice.loadRef().beginParse();
|
|
@@ -105,7 +109,7 @@ function parseMasterData(masterDataBOC) {
|
|
|
105
109
|
supply: core_1.Dictionary.empty(),
|
|
106
110
|
borrow: core_1.Dictionary.empty(),
|
|
107
111
|
};
|
|
108
|
-
for (const [tokenSymbol, assetID] of Object.entries(
|
|
112
|
+
for (const [tokenSymbol, assetID] of Object.entries(ASSETS_ID)) {
|
|
109
113
|
const assetData = (0, math_1.calculateAssetData)(assetsConfigDict, assetsDataDict, assetID);
|
|
110
114
|
assetsExtendedData.set(assetID, assetData);
|
|
111
115
|
}
|
|
@@ -117,7 +121,7 @@ function parseMasterData(masterDataBOC) {
|
|
|
117
121
|
walletToMaster: (0, helpers_1.loadMaybeMyRef)(masterConfigSlice),
|
|
118
122
|
};
|
|
119
123
|
masterConfigSlice.endParse();
|
|
120
|
-
for (const [_, assetID] of Object.entries(
|
|
124
|
+
for (const [_, assetID] of Object.entries(ASSETS_ID)) {
|
|
121
125
|
const assetData = assetsExtendedData.get(assetID);
|
|
122
126
|
const totalSupply = (0, math_1.calculatePresentValue)(assetData.sRate, assetData.totalSupply);
|
|
123
127
|
const totalBorrow = (0, math_1.calculatePresentValue)(assetData.bRate, assetData.totalBorrow);
|
|
@@ -136,7 +140,8 @@ function parseMasterData(masterDataBOC) {
|
|
|
136
140
|
};
|
|
137
141
|
}
|
|
138
142
|
exports.parseMasterData = parseMasterData;
|
|
139
|
-
function parseUserLiteData(userDataBOC, assetsData, assetsConfig) {
|
|
143
|
+
function parseUserLiteData(userDataBOC, assetsData, assetsConfig, testnet = false) {
|
|
144
|
+
const ASSETS_ID = testnet ? constants_1.TESTNET_ASSETS_ID : constants_1.MAINNET_ASSETS_ID;
|
|
140
145
|
const userSlice = core_1.Cell.fromBase64(userDataBOC).beginParse();
|
|
141
146
|
const codeVersion = userSlice.loadCoins();
|
|
142
147
|
const masterAddress = userSlice.loadAddress();
|
|
@@ -149,7 +154,7 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig) {
|
|
|
149
154
|
const backupCell = (0, helpers_1.loadMyRef)(userSlice);
|
|
150
155
|
userSlice.endParse();
|
|
151
156
|
const userBalances = core_1.Dictionary.empty();
|
|
152
|
-
for (const [_, assetID] of Object.entries(
|
|
157
|
+
for (const [_, assetID] of Object.entries(ASSETS_ID)) {
|
|
153
158
|
const assetData = assetsData.get(assetID);
|
|
154
159
|
const assetConfig = assetsConfig.get(assetID);
|
|
155
160
|
const balance = (0, math_1.presentValue)(assetData.sRate, assetData.bRate, principalsDict.get(assetID) || 0n);
|
|
@@ -170,18 +175,19 @@ function parseUserLiteData(userDataBOC, assetsData, assetsConfig) {
|
|
|
170
175
|
};
|
|
171
176
|
}
|
|
172
177
|
exports.parseUserLiteData = parseUserLiteData;
|
|
173
|
-
function parseUserData(userLiteData, assetsData, assetsConfig, prices) {
|
|
178
|
+
function parseUserData(userLiteData, assetsData, assetsConfig, prices, testnet = false) {
|
|
179
|
+
const ASSETS_ID = testnet ? constants_1.TESTNET_ASSETS_ID : constants_1.MAINNET_ASSETS_ID;
|
|
174
180
|
const withdrawalLimits = core_1.Dictionary.empty();
|
|
175
181
|
const borrowLimits = core_1.Dictionary.empty();
|
|
176
182
|
let supplyBalance = 0n;
|
|
177
183
|
let borrowBalance = 0n;
|
|
178
|
-
for (const [_, assetID] of Object.entries(
|
|
184
|
+
for (const [_, assetID] of Object.entries(ASSETS_ID)) {
|
|
179
185
|
const assetData = assetsData.get(assetID);
|
|
180
186
|
const assetConfig = assetsConfig.get(assetID);
|
|
181
187
|
const balance = (0, math_1.presentValue)(assetData.sRate, assetData.bRate, userLiteData.principals.get(assetID) || 0n);
|
|
182
188
|
userLiteData.balances.set(assetID, balance);
|
|
183
189
|
}
|
|
184
|
-
for (const [_, assetID] of Object.entries(
|
|
190
|
+
for (const [_, assetID] of Object.entries(ASSETS_ID)) {
|
|
185
191
|
const assetConfig = assetsConfig.get(assetID);
|
|
186
192
|
const balance = userLiteData.balances.get(assetID);
|
|
187
193
|
if (balance.type === User_1.BalanceType.supply) {
|
|
@@ -192,7 +198,7 @@ function parseUserData(userLiteData, assetsData, assetsConfig, prices) {
|
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
const availableToBorrow = (0, math_1.getAvailableToBorrow)(assetsConfig, assetsData, userLiteData.principals, prices);
|
|
195
|
-
for (const [_, assetID] of Object.entries(
|
|
201
|
+
for (const [_, assetID] of Object.entries(ASSETS_ID)) {
|
|
196
202
|
const assetConfig = assetsConfig.get(assetID);
|
|
197
203
|
const assetData = assetsData.get(assetID);
|
|
198
204
|
const balance = userLiteData.balances.get(assetID);
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { Address, Cell } from '@ton/core';
|
|
2
2
|
export declare const EVAA_MASTER_MAINNET: Address;
|
|
3
|
-
export declare const MAINNET_VERSION =
|
|
3
|
+
export declare const MAINNET_VERSION = 4;
|
|
4
4
|
export declare const EVAA_MASTER_TESTNET: Address;
|
|
5
|
-
export declare const TESTNET_VERSION =
|
|
5
|
+
export declare const TESTNET_VERSION = 4;
|
|
6
6
|
export declare const NFT_ID = "0xfb9874544d76ca49c5db9cc3e5121e4c018bc8a2fb2bfe8f2a38c5b9963492f5";
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const MAINNET_ASSETS_ID: {
|
|
8
8
|
TON: bigint;
|
|
9
9
|
jUSDT: bigint;
|
|
10
10
|
jUSDC: bigint;
|
|
11
11
|
stTON: bigint;
|
|
12
12
|
tsTON: bigint;
|
|
13
|
+
USDT: bigint;
|
|
14
|
+
};
|
|
15
|
+
export declare const TESTNET_ASSETS_ID: {
|
|
16
|
+
TON: bigint;
|
|
17
|
+
jUSDT: bigint;
|
|
18
|
+
jUSDC: bigint;
|
|
19
|
+
stTON: bigint;
|
|
13
20
|
};
|
|
14
21
|
export declare const JETTON_MASTER_ADDRESSES: {
|
|
15
22
|
jUSDT_MAINNET: Address;
|
|
@@ -20,6 +27,8 @@ export declare const JETTON_MASTER_ADDRESSES: {
|
|
|
20
27
|
stTON_TESTNET: Address;
|
|
21
28
|
tsTON_MAINNET: Address;
|
|
22
29
|
tsTON_TESTNET: null;
|
|
30
|
+
USDT_MAINNET: Address;
|
|
31
|
+
USDT_TESTNET: null;
|
|
23
32
|
};
|
|
24
33
|
export declare const MASTER_CONSTANTS: {
|
|
25
34
|
FACTOR_SCALE: bigint;
|
|
@@ -27,12 +36,24 @@ export declare const MASTER_CONSTANTS: {
|
|
|
27
36
|
ASSET_PRICE_SCALE: bigint;
|
|
28
37
|
};
|
|
29
38
|
export declare const LENDING_CODE: Cell;
|
|
30
|
-
export declare const
|
|
39
|
+
export declare const JETTON_WALLETS_CODE: {
|
|
40
|
+
jUSDT_MAINNET: Cell;
|
|
41
|
+
jUSDT_TESTNET: Cell;
|
|
42
|
+
jUSDC_MAINNET: Cell;
|
|
43
|
+
jUSDC_TESTNET: Cell;
|
|
44
|
+
stTON_MAINNET: Cell;
|
|
45
|
+
stTON_TESTNET: Cell;
|
|
46
|
+
tsTON_MAINNET: Cell;
|
|
47
|
+
tsTON_TESTNET: null;
|
|
48
|
+
USDT_MAINNET: Cell;
|
|
49
|
+
USDT_TESTNET: null;
|
|
50
|
+
};
|
|
31
51
|
export declare const OPCODES: {
|
|
32
52
|
SUPPLY: number;
|
|
33
53
|
WITHDRAW: number;
|
|
34
54
|
LIQUIDATE: number;
|
|
35
55
|
JETTON_TRANSFER: number;
|
|
56
|
+
ONCHAIN_GETTER: number;
|
|
36
57
|
};
|
|
37
58
|
export declare const FEES: {
|
|
38
59
|
SUPPLY: bigint;
|
package/dist/constants.js
CHANGED
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FEES = exports.OPCODES = exports.
|
|
3
|
+
exports.FEES = exports.OPCODES = exports.JETTON_WALLETS_CODE = exports.LENDING_CODE = exports.MASTER_CONSTANTS = exports.JETTON_MASTER_ADDRESSES = exports.TESTNET_ASSETS_ID = exports.MAINNET_ASSETS_ID = exports.NFT_ID = exports.TESTNET_VERSION = exports.EVAA_MASTER_TESTNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const sha256BigInt_1 = require("./utils/sha256BigInt");
|
|
6
6
|
exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
7
|
-
exports.MAINNET_VERSION =
|
|
8
|
-
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('
|
|
9
|
-
exports.TESTNET_VERSION =
|
|
7
|
+
exports.MAINNET_VERSION = 4;
|
|
8
|
+
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('kQCj7qf3i2Cbf1GVtZCinla7lIvE7l3MBMsJMTfAja3BdoRP');
|
|
9
|
+
exports.TESTNET_VERSION = 4;
|
|
10
10
|
exports.NFT_ID = '0xfb9874544d76ca49c5db9cc3e5121e4c018bc8a2fb2bfe8f2a38c5b9963492f5';
|
|
11
|
-
exports.
|
|
11
|
+
exports.MAINNET_ASSETS_ID = {
|
|
12
12
|
TON: (0, sha256BigInt_1.sha256Hash)('TON'),
|
|
13
13
|
jUSDT: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
|
|
14
14
|
jUSDC: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
|
|
15
15
|
stTON: (0, sha256BigInt_1.sha256Hash)('stTON'),
|
|
16
16
|
tsTON: (0, sha256BigInt_1.sha256Hash)('tsTON'),
|
|
17
|
+
USDT: (0, sha256BigInt_1.sha256Hash)('USDT'),
|
|
18
|
+
};
|
|
19
|
+
exports.TESTNET_ASSETS_ID = {
|
|
20
|
+
TON: (0, sha256BigInt_1.sha256Hash)('TON'),
|
|
21
|
+
jUSDT: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
|
|
22
|
+
jUSDC: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
|
|
23
|
+
stTON: (0, sha256BigInt_1.sha256Hash)('stTON'),
|
|
24
|
+
// tsTON: sha256Hash('tsTON'),
|
|
25
|
+
// USDT: sha256Hash('USDT'),
|
|
17
26
|
};
|
|
18
27
|
exports.JETTON_MASTER_ADDRESSES = {
|
|
19
|
-
jUSDT_MAINNET: core_1.Address.parse('
|
|
20
|
-
jUSDT_TESTNET: core_1.Address.parse('
|
|
21
|
-
jUSDC_MAINNET: core_1.Address.parse('
|
|
22
|
-
jUSDC_TESTNET: core_1.Address.parse('
|
|
23
|
-
stTON_MAINNET: core_1.Address.parse('
|
|
24
|
-
stTON_TESTNET: core_1.Address.parse('
|
|
25
|
-
tsTON_MAINNET: core_1.Address.parse('
|
|
28
|
+
jUSDT_MAINNET: core_1.Address.parse('EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA'),
|
|
29
|
+
jUSDT_TESTNET: core_1.Address.parse('kQBe4gtSQMxM5RpMYLr4ydNY72F8JkY-icZXG1NJcsju8XM7'),
|
|
30
|
+
jUSDC_MAINNET: core_1.Address.parse('EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728'),
|
|
31
|
+
jUSDC_TESTNET: core_1.Address.parse('kQDaY5yUatYnHei73HBqRX_Ox9LK2XnR7XuCY9MFC2INbfYI'),
|
|
32
|
+
stTON_MAINNET: core_1.Address.parse('EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k'),
|
|
33
|
+
stTON_TESTNET: core_1.Address.parse('kQC3Duw3dg8k98xf5S7Bm7YOWVJ5QW8hm3iLqFfJfa_g9h07'),
|
|
34
|
+
tsTON_MAINNET: core_1.Address.parse('EQC98_qAmNEptUtPc7W6xdHh_ZHrBUFpw5Ft_IzNU20QAJav'),
|
|
26
35
|
tsTON_TESTNET: null,
|
|
36
|
+
USDT_MAINNET: core_1.Address.parse('EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'),
|
|
37
|
+
USDT_TESTNET: null,
|
|
27
38
|
};
|
|
28
39
|
exports.MASTER_CONSTANTS = {
|
|
29
40
|
FACTOR_SCALE: BigInt(1e12),
|
|
@@ -31,12 +42,24 @@ exports.MASTER_CONSTANTS = {
|
|
|
31
42
|
ASSET_PRICE_SCALE: BigInt(1e8),
|
|
32
43
|
};
|
|
33
44
|
exports.LENDING_CODE = core_1.Cell.fromBoc(Buffer.from('b5ee9c72c1010e0100fd000d12182a555a6065717691969efd0114ff00f4a413f4bcf2c80b010202c8050202039f740403001ff2f8276a2687d2018fd201800f883b840051d38642c678b64e4400780e58fc10802faf07f80e59fa801e78b096664c02078067c07c100627a7978402014807060007a0ddb0c60201c709080013a0fd007a026900aa90400201200b0a0031b8e1002191960aa00b9e2ca007f4042796d225e8019203f6010201200d0c000bf7c147d2218400b9d10e86981fd201840b07f8138d809797976a2687d2029116382f970fd9178089910374daf81b619fd20182c7883b8701981684100627910eba56001797a6a6ba610fd8200e8768f76a9f6aa00cc2a32a8292878809bef2f1889f883bbcdeb86f01', 'hex'))[0];
|
|
34
|
-
exports.
|
|
45
|
+
exports.JETTON_WALLETS_CODE = {
|
|
46
|
+
jUSDT_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000385000114ff00f4a413f4bcf2c80b0102016202030202cb0405001ba0f605da89a1f401f481f481a9a30201ce06070201580a0b02f70831c02497c138007434c0c05c6c2544d7c0fc07783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c076cf16cc8d0d0d09208403e29fa96ea68c1b088d978c4408fc06b809208405e351466ea6cc1b08978c840910c03c06f80dd6cda0841657c1ef2ea7c09c6c3cb4b01408eebcb8b1807c073817c160080900113e910c30003cb85360005c804ff833206e953080b1f833de206ef2d29ad0d30731d3ffd3fff404d307d430d0fa00fa00fa00fa00fa00fa00300008840ff2f00201580c0d020148111201f70174cfc0407e803e90087c007b51343e803e903e903534544da8548b31c17cb8b04ab0bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032481c007e401d3232c084b281f2fff274013e903d010c7e800835d270803cb8b13220060072c15401f3c59c3e809dc072dae00e02f33b51343e803e903e90353442b4cfc0407e80145468017e903e9014d771c1551cdbdc150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0325c007e401d3232c084b281f2fff2741403f1c147ac7cb8b0c33e801472a84a6d8206685401e8062849a49b1578c34975c2c070c00870802c200f1000aa13ccc88210178d4519580a02cb1fcb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25007a813a008aa005004a017a014bcf2e2c501c98040fb004300c85004fa0258cf1601cf16ccc9ed5400725269a018a1c882107362d09c2902cb1fcb3f5007fa025004cf165007cf16c9c8801001cb0527cf165004fa027101cb6a13ccc971fb0050421300748e23c8801001cb055006cf165005fa027001cb6a8210d53276db580502cb1fcb3fc972fb00925b33e24003c85004fa0258cf1601cf16ccc9ed5400eb3b51343e803e903e9035344174cfc0407e800870803cb8b0be903d01007434e7f440745458a8549631c17cb8b049b0bffcb8b0b220841ef765f7960100b2c7f2cfc07e8088f3c58073c584f2e7f27220060072c148f3c59c3e809c4072dab33260103ec01004f214013e809633c58073c5b3327b55200087200835c87b51343e803e903e9035344134c7c06103c8608405e351466e80a0841ef765f7ae84ac7cbd34cfc04c3e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
47
|
+
jUSDT_TESTNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
48
|
+
jUSDC_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000385000114ff00f4a413f4bcf2c80b0102016202030202cb0405001ba0f605da89a1f401f481f481a9a30201ce06070201580a0b02f70831c02497c138007434c0c05c6c2544d7c0fc07783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c076cf16cc8d0d0d09208403e29fa96ea68c1b088d978c4408fc06b809208405e351466ea6cc1b08978c840910c03c06f80dd6cda0841657c1ef2ea7c09c6c3cb4b01408eebcb8b1807c073817c160080900113e910c30003cb85360005c804ff833206e953080b1f833de206ef2d29ad0d30731d3ffd3fff404d307d430d0fa00fa00fa00fa00fa00fa00300008840ff2f00201580c0d020148111201f70174cfc0407e803e90087c007b51343e803e903e903534544da8548b31c17cb8b04ab0bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032481c007e401d3232c084b281f2fff274013e903d010c7e800835d270803cb8b13220060072c15401f3c59c3e809dc072dae00e02f33b51343e803e903e90353442b4cfc0407e80145468017e903e9014d771c1551cdbdc150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0325c007e401d3232c084b281f2fff2741403f1c147ac7cb8b0c33e801472a84a6d8206685401e8062849a49b1578c34975c2c070c00870802c200f1000aa13ccc88210178d4519580a02cb1fcb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25007a813a008aa005004a017a014bcf2e2c501c98040fb004300c85004fa0258cf1601cf16ccc9ed5400725269a018a1c882107362d09c2902cb1fcb3f5007fa025004cf165007cf16c9c8801001cb0527cf165004fa027101cb6a13ccc971fb0050421300748e23c8801001cb055006cf165005fa027001cb6a8210d53276db580502cb1fcb3fc972fb00925b33e24003c85004fa0258cf1601cf16ccc9ed5400eb3b51343e803e903e9035344174cfc0407e800870803cb8b0be903d01007434e7f440745458a8549631c17cb8b049b0bffcb8b0b220841ef765f7960100b2c7f2cfc07e8088f3c58073c584f2e7f27220060072c148f3c59c3e809c4072dab33260103ec01004f214013e809633c58073c5b3327b55200087200835c87b51343e803e903e9035344134c7c06103c8608405e351466e80a0841ef765f7ae84ac7cbd34cfc04c3e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
49
|
+
jUSDC_TESTNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
50
|
+
stTON_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000362000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120090a01cf0831c02497c138007434c0c05c6c2544d7c0fc03783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c8608403e29fa96ea54c4d167c02b808608405e351466ea58c511100fc02f80860841657c1ef2ea54c4d167c03380517c1300138c08c2103fcbc200800113e910c30003cb85360007ced44d0fa00fa40fa40d43010235f03018208989680a16d801072226eb32091719170e203c8cb055006cf165004fa02cb6a039358cc019130e201c901fb000201580b0c020148101101f100f4cffe803e90087c007b51343e803e903e90350c144da8548ab1c17cb8b04a30bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032483e401c1d3232c0b281f2fff274013e903d010c7e800835d270803cb8b11de0063232c1540233c59c3e8085f2dac4f3200d02f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad8228608239387028062849e5c412440e0dd7c138c34975c2c0600e0f009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a0820a625a00a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5400705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5400c90c3b51343e803e903e90350c01b4cffe800c145128548df1c17cb8b04970bffcb8b0812082e4e1c02fbcb8b160841ef765f7b232c7c532cfd63e808873c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b55200081200835c87b51343e803e903e90350c0134c7c8608405e351466e80a0841ef765f7ae84ac7cb83234cfcc7e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
51
|
+
stTON_TESTNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000362000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120090a01cf0831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c8608403e29fa96ea54c4d167c027808608405e351466ea58c511100fc02b80860841657c1ef2ea54c4d167c02f80517c1300138c08c2103fcbc200800113e910c30003cb85360007ced44d0fa00fa40fa40d43010235f03018208989680a16d801072226eb32091719170e203c8cb055006cf165004fa02cb6a039358cc019130e201c901fb000201200b0c0081d40106b90f6a2687d007d207d206a1802698f90c1080bc6a28cdd0141083deecbef5d0958f97064699f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80d0201200e0f009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a0820a625a00a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad8228608239387028062849e5c412440e0dd7c138c34975c2c060101100c90c3b51343e803e903e90350c01b4cffe800c145128548df1c17cb8b04970bffcb8b0812082e4e1c02fbcb8b160841ef765f7b232c7c532cfd63e808873c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
52
|
+
tsTON_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c720101010100230000420212bebb0dc8e202b7e26f721e2547e16bb9ebaec934f657d19f22e76d62bec878', 'hex'))[0],
|
|
53
|
+
tsTON_TESTNET: null,
|
|
54
|
+
USDT_MAINNET: core_1.Cell.fromBoc(Buffer.from('b5ee9c72010101010023000042028f452d7a4dfd74066b682365177259ed05734435be76b5fd4bd5d8af2b7c3d68', 'hex'))[0],
|
|
55
|
+
USDT_TESTNET: null,
|
|
56
|
+
};
|
|
35
57
|
exports.OPCODES = {
|
|
36
58
|
SUPPLY: 0x1,
|
|
37
59
|
WITHDRAW: 0x2,
|
|
38
60
|
LIQUIDATE: 0x3,
|
|
39
61
|
JETTON_TRANSFER: 0xf8a7ea5,
|
|
62
|
+
ONCHAIN_GETTER: 0x9998,
|
|
40
63
|
};
|
|
41
64
|
exports.FEES = {
|
|
42
65
|
SUPPLY: (0, core_1.toNano)('0.3'),
|
|
@@ -159,6 +159,11 @@ export declare class Evaa implements Contract {
|
|
|
159
159
|
sendSupply(provider: ContractProvider, via: Sender, value: bigint, parameters: TonSupplyParameters | JettonSupplyParameters): Promise<void>;
|
|
160
160
|
sendWithdraw(provider: ContractProvider, via: Sender, value: bigint, parameters: WithdrawParameters): Promise<void>;
|
|
161
161
|
sendLiquidation(provider: ContractProvider, via: Sender, value: bigint, parameters: TonLiquidationParameters | JettonLiquidationParameters): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Open user contract wrapper
|
|
164
|
+
* @param forwardPayload - payload that will be forwarded to the address which requested the data
|
|
165
|
+
*/
|
|
166
|
+
sendOnchainGetter(provider: ContractProvider, via: Sender, value: bigint, queryID: bigint, forwardPayload: Cell): Promise<void>;
|
|
162
167
|
/**
|
|
163
168
|
* Sync master contract data
|
|
164
169
|
*/
|
|
@@ -141,7 +141,7 @@ class Evaa {
|
|
|
141
141
|
* @returns user contract
|
|
142
142
|
*/
|
|
143
143
|
openUserContract(userAddress) {
|
|
144
|
-
return UserContract_1.EvaaUser.createFromAddress(this.calculateUserSCAddr(userAddress));
|
|
144
|
+
return UserContract_1.EvaaUser.createFromAddress(this.calculateUserSCAddr(userAddress), this.network === 'testnet');
|
|
145
145
|
}
|
|
146
146
|
getOpenedUserContract(provider, userAddress) {
|
|
147
147
|
return provider.open(this.openUserContract(userAddress));
|
|
@@ -194,13 +194,28 @@ class Evaa {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Open user contract wrapper
|
|
199
|
+
* @param forwardPayload - payload that will be forwarded to the address which requested the data
|
|
200
|
+
*/
|
|
201
|
+
async sendOnchainGetter(provider, via, value, queryID, forwardPayload) {
|
|
202
|
+
await provider.internal(via, {
|
|
203
|
+
value,
|
|
204
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
205
|
+
body: (0, core_1.beginCell)()
|
|
206
|
+
.storeUint(constants_1.OPCODES.ONCHAIN_GETTER, 32)
|
|
207
|
+
.storeUint(queryID, 64)
|
|
208
|
+
.storeRef(forwardPayload)
|
|
209
|
+
.endCell(),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
197
212
|
/**
|
|
198
213
|
* Sync master contract data
|
|
199
214
|
*/
|
|
200
215
|
async getSync(provider) {
|
|
201
216
|
const state = (await provider.getState()).state;
|
|
202
217
|
if (state.type === 'active') {
|
|
203
|
-
this._data = (0, parser_1.parseMasterData)(state.data.toString('base64url'));
|
|
218
|
+
this._data = (0, parser_1.parseMasterData)(state.data.toString('base64url'), this.network === 'testnet');
|
|
204
219
|
if (this.network === 'testnet' && this._data.upgradeConfig.masterCodeVersion !== constants_1.TESTNET_VERSION) {
|
|
205
220
|
throw Error(`Outdated SDK version. It supports only master code version ${constants_1.TESTNET_VERSION} on testnet, but the current master code version is ${this._data.upgradeConfig.masterCodeVersion}`);
|
|
206
221
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, Contract, ContractProvider, Dictionary } from '@ton/core';
|
|
1
|
+
import { Address, Cell, Contract, ContractProvider, Dictionary, Sender } from '@ton/core';
|
|
2
2
|
import { UserData, UserLiteData } from '../types/User';
|
|
3
3
|
import { AssetConfig, ExtendedAssetData } from '../types/Master';
|
|
4
4
|
import { LiquidationBaseData } from './MasterContract';
|
|
@@ -7,14 +7,16 @@ import { LiquidationBaseData } from './MasterContract';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class EvaaUser implements Contract {
|
|
9
9
|
readonly address: Address;
|
|
10
|
+
readonly testnet: boolean;
|
|
10
11
|
private lastSync;
|
|
11
12
|
private _liteData?;
|
|
12
13
|
private _data?;
|
|
13
14
|
/**
|
|
14
15
|
* Create user contract wrapper from address
|
|
15
16
|
* @param address user contract address
|
|
17
|
+
* @param testnet testnet flag
|
|
16
18
|
*/
|
|
17
|
-
static createFromAddress(address: Address): EvaaUser;
|
|
19
|
+
static createFromAddress(address: Address, testnet?: boolean): EvaaUser;
|
|
18
20
|
private constructor();
|
|
19
21
|
getSyncLite(provider: ContractProvider, assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig>): Promise<void>;
|
|
20
22
|
/**
|
|
@@ -25,6 +27,11 @@ export declare class EvaaUser implements Contract {
|
|
|
25
27
|
* @returns true if user data was calculated
|
|
26
28
|
*/
|
|
27
29
|
calculateUserData(assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig>, prices: Dictionary<bigint, bigint>): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Open user contract wrapper
|
|
32
|
+
* @param forwardPayload - payload that will be forwarded to the address which requested the data
|
|
33
|
+
*/
|
|
34
|
+
sendOnchainGetter(provider: ContractProvider, via: Sender, value: bigint, queryID: bigint, forwardPayload: Cell): Promise<void>;
|
|
28
35
|
getSync(provider: ContractProvider, assetsData: Dictionary<bigint, ExtendedAssetData>, assetsConfig: Dictionary<bigint, AssetConfig>, prices: Dictionary<bigint, bigint>): Promise<void>;
|
|
29
36
|
/**
|
|
30
37
|
* Get user contract lite data
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EvaaUser = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
4
5
|
const parser_1 = require("../api/parser");
|
|
5
6
|
const constants_1 = require("../constants");
|
|
6
7
|
/**
|
|
@@ -10,18 +11,21 @@ class EvaaUser {
|
|
|
10
11
|
/**
|
|
11
12
|
* Create user contract wrapper from address
|
|
12
13
|
* @param address user contract address
|
|
14
|
+
* @param testnet testnet flag
|
|
13
15
|
*/
|
|
14
|
-
static createFromAddress(address) {
|
|
15
|
-
return new EvaaUser(address);
|
|
16
|
+
static createFromAddress(address, testnet = false) {
|
|
17
|
+
return new EvaaUser(address, testnet);
|
|
16
18
|
}
|
|
17
|
-
constructor(address) {
|
|
19
|
+
constructor(address, testnet = false) {
|
|
20
|
+
this.testnet = false;
|
|
18
21
|
this.lastSync = 0;
|
|
19
22
|
this.address = address;
|
|
23
|
+
this.testnet = testnet;
|
|
20
24
|
}
|
|
21
25
|
async getSyncLite(provider, assetsData, assetsConfig) {
|
|
22
26
|
const state = (await provider.getState()).state;
|
|
23
27
|
if (state.type === 'active') {
|
|
24
|
-
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64url'), assetsData, assetsConfig);
|
|
28
|
+
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64url'), assetsData, assetsConfig, this.testnet);
|
|
25
29
|
this.lastSync = Math.floor(Date.now() / 1000);
|
|
26
30
|
}
|
|
27
31
|
else {
|
|
@@ -38,16 +42,31 @@ class EvaaUser {
|
|
|
38
42
|
*/
|
|
39
43
|
calculateUserData(assetsData, assetsConfig, prices) {
|
|
40
44
|
if (this._liteData) {
|
|
41
|
-
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices);
|
|
45
|
+
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices, this.testnet);
|
|
42
46
|
return true;
|
|
43
47
|
}
|
|
44
48
|
return false;
|
|
45
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Open user contract wrapper
|
|
52
|
+
* @param forwardPayload - payload that will be forwarded to the address which requested the data
|
|
53
|
+
*/
|
|
54
|
+
async sendOnchainGetter(provider, via, value, queryID, forwardPayload) {
|
|
55
|
+
await provider.internal(via, {
|
|
56
|
+
value,
|
|
57
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
58
|
+
body: (0, core_1.beginCell)()
|
|
59
|
+
.storeCoins(BigInt(constants_1.OPCODES.ONCHAIN_GETTER))
|
|
60
|
+
.storeUint(queryID, 64)
|
|
61
|
+
.storeRef(forwardPayload)
|
|
62
|
+
.endCell(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
46
65
|
async getSync(provider, assetsData, assetsConfig, prices) {
|
|
47
66
|
const state = (await provider.getState()).state;
|
|
48
67
|
if (state.type === 'active') {
|
|
49
|
-
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64url'), assetsData, assetsConfig);
|
|
50
|
-
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices);
|
|
68
|
+
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64url'), assetsData, assetsConfig, this.testnet);
|
|
69
|
+
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices, this.testnet);
|
|
51
70
|
this.lastSync = Math.floor(Date.now() / 1000);
|
|
52
71
|
}
|
|
53
72
|
else {
|
|
@@ -92,7 +111,7 @@ class EvaaUser {
|
|
|
92
111
|
collateralAsset: this._data.liquidationData.greatestCollateralAsset,
|
|
93
112
|
minCollateralAmount: this._data.liquidationData.minCollateralAmount,
|
|
94
113
|
liquidationAmount: this._data.liquidationData.liquidationAmount,
|
|
95
|
-
tonLiquidation: this._data.liquidationData.greatestLoanAsset === constants_1.
|
|
114
|
+
tonLiquidation: this._data.liquidationData.greatestLoanAsset === constants_1.MAINNET_ASSETS_ID.TON,
|
|
96
115
|
};
|
|
97
116
|
}
|
|
98
117
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { mulFactor, mulDiv, bigIntMin, bigIntMax, calculatePresentValue, calculateCurrentRates, calculateAssetData, calculateAssetInterest, getAvailableToBorrow, presentValue, calculateLiquidationData, } from './api/math';
|
|
2
|
-
export { createAssetData, createAssetConfig, parseMasterData, parseUserData } from './api/parser';
|
|
2
|
+
export { createAssetData, createAssetConfig, parseMasterData, parseUserData, parseUserLiteData } from './api/parser';
|
|
3
3
|
export { getPrices } from './api/prices';
|
|
4
4
|
export { JettonWallet } from './contracts/JettonWallet';
|
|
5
5
|
export { EvaaParameters, JettonMessageParameters, TonSupplyParameters, JettonSupplyParameters, WithdrawParameters, LiquidationBaseData, TonLiquidationParameters, JettonLiquidationParameters, Evaa, } from './contracts/MasterContract';
|
|
@@ -7,6 +7,6 @@ export { EvaaUser } from './contracts/UserContract';
|
|
|
7
7
|
export { PriceData } from './types/Common';
|
|
8
8
|
export { UpgradeConfig, AssetConfig, MasterConfig, AssetData, AssetInterest, AssetApy, ExtendedAssetData, MasterData, } from './types/Master';
|
|
9
9
|
export { BalanceType, UserBalance, UserLiqudationData, LiquidableData, NonLiquidableData, LiquidationData, UserDataInactive, UserDataActive, UserData, } from './types/User';
|
|
10
|
-
export { EVAA_MASTER_MAINNET, MAINNET_VERSION, EVAA_MASTER_TESTNET, TESTNET_VERSION,
|
|
10
|
+
export { EVAA_MASTER_MAINNET, MAINNET_VERSION, EVAA_MASTER_TESTNET, TESTNET_VERSION, JETTON_MASTER_ADDRESSES, MASTER_CONSTANTS, LENDING_CODE, OPCODES, FEES, } from './constants';
|
|
11
11
|
export { getLastSentBoc, getTonConnectSender } from './utils/tonConnectSender';
|
|
12
12
|
export { getUserJettonWallet } from './utils/userJettonWallet';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserJettonWallet = exports.getTonConnectSender = exports.getLastSentBoc = exports.FEES = exports.OPCODES = exports.
|
|
3
|
+
exports.getUserJettonWallet = exports.getTonConnectSender = exports.getLastSentBoc = exports.FEES = exports.OPCODES = exports.LENDING_CODE = exports.MASTER_CONSTANTS = exports.JETTON_MASTER_ADDRESSES = exports.TESTNET_VERSION = exports.EVAA_MASTER_TESTNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = exports.BalanceType = exports.EvaaUser = exports.Evaa = exports.JettonWallet = exports.getPrices = exports.parseUserLiteData = exports.parseUserData = exports.parseMasterData = exports.createAssetConfig = exports.createAssetData = exports.calculateLiquidationData = exports.presentValue = exports.getAvailableToBorrow = exports.calculateAssetInterest = exports.calculateAssetData = exports.calculateCurrentRates = exports.calculatePresentValue = exports.bigIntMax = exports.bigIntMin = exports.mulDiv = exports.mulFactor = void 0;
|
|
4
4
|
// Math
|
|
5
5
|
var math_1 = require("./api/math");
|
|
6
6
|
Object.defineProperty(exports, "mulFactor", { enumerable: true, get: function () { return math_1.mulFactor; } });
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "createAssetData", { enumerable: true, get: funct
|
|
|
20
20
|
Object.defineProperty(exports, "createAssetConfig", { enumerable: true, get: function () { return parser_1.createAssetConfig; } });
|
|
21
21
|
Object.defineProperty(exports, "parseMasterData", { enumerable: true, get: function () { return parser_1.parseMasterData; } });
|
|
22
22
|
Object.defineProperty(exports, "parseUserData", { enumerable: true, get: function () { return parser_1.parseUserData; } });
|
|
23
|
+
Object.defineProperty(exports, "parseUserLiteData", { enumerable: true, get: function () { return parser_1.parseUserLiteData; } });
|
|
23
24
|
// Prices
|
|
24
25
|
var prices_1 = require("./api/prices");
|
|
25
26
|
Object.defineProperty(exports, "getPrices", { enumerable: true, get: function () { return prices_1.getPrices; } });
|
|
@@ -38,11 +39,9 @@ Object.defineProperty(exports, "EVAA_MASTER_MAINNET", { enumerable: true, get: f
|
|
|
38
39
|
Object.defineProperty(exports, "MAINNET_VERSION", { enumerable: true, get: function () { return constants_1.MAINNET_VERSION; } });
|
|
39
40
|
Object.defineProperty(exports, "EVAA_MASTER_TESTNET", { enumerable: true, get: function () { return constants_1.EVAA_MASTER_TESTNET; } });
|
|
40
41
|
Object.defineProperty(exports, "TESTNET_VERSION", { enumerable: true, get: function () { return constants_1.TESTNET_VERSION; } });
|
|
41
|
-
Object.defineProperty(exports, "ASSET_ID", { enumerable: true, get: function () { return constants_1.ASSET_ID; } });
|
|
42
42
|
Object.defineProperty(exports, "JETTON_MASTER_ADDRESSES", { enumerable: true, get: function () { return constants_1.JETTON_MASTER_ADDRESSES; } });
|
|
43
43
|
Object.defineProperty(exports, "MASTER_CONSTANTS", { enumerable: true, get: function () { return constants_1.MASTER_CONSTANTS; } });
|
|
44
44
|
Object.defineProperty(exports, "LENDING_CODE", { enumerable: true, get: function () { return constants_1.LENDING_CODE; } });
|
|
45
|
-
Object.defineProperty(exports, "JETTON_WALLET_CODE", { enumerable: true, get: function () { return constants_1.JETTON_WALLET_CODE; } });
|
|
46
45
|
Object.defineProperty(exports, "OPCODES", { enumerable: true, get: function () { return constants_1.OPCODES; } });
|
|
47
46
|
Object.defineProperty(exports, "FEES", { enumerable: true, get: function () { return constants_1.FEES; } });
|
|
48
47
|
// Utils
|
package/dist/types/Master.d.ts
CHANGED
|
@@ -5,46 +5,67 @@ const core_1 = require("@ton/core");
|
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function getUserJettonWallet(ownerAddress, assetID, network) {
|
|
7
7
|
const builder = (0, core_1.beginCell)().storeCoins(0).storeAddress(ownerAddress);
|
|
8
|
+
let jettonWalletCode;
|
|
8
9
|
switch (assetID) {
|
|
9
|
-
case constants_1.
|
|
10
|
+
case constants_1.MAINNET_ASSETS_ID.jUSDT:
|
|
10
11
|
if (network === 'mainnet') {
|
|
11
12
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.jUSDT_MAINNET);
|
|
13
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.jUSDT_MAINNET;
|
|
12
14
|
}
|
|
13
15
|
else {
|
|
14
16
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.jUSDT_TESTNET);
|
|
17
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.jUSDT_TESTNET;
|
|
15
18
|
}
|
|
16
19
|
break;
|
|
17
|
-
case constants_1.
|
|
20
|
+
case constants_1.MAINNET_ASSETS_ID.jUSDC:
|
|
18
21
|
if (network === 'mainnet') {
|
|
19
22
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.jUSDC_MAINNET);
|
|
23
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.jUSDC_MAINNET;
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
22
26
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.jUSDC_TESTNET);
|
|
27
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.jUSDC_TESTNET;
|
|
23
28
|
}
|
|
24
29
|
break;
|
|
25
|
-
case constants_1.
|
|
30
|
+
case constants_1.MAINNET_ASSETS_ID.stTON:
|
|
26
31
|
if (network === 'mainnet') {
|
|
27
32
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.stTON_MAINNET);
|
|
33
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.stTON_MAINNET;
|
|
28
34
|
}
|
|
29
35
|
else {
|
|
30
36
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.stTON_TESTNET);
|
|
37
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.stTON_TESTNET;
|
|
31
38
|
}
|
|
32
39
|
break;
|
|
33
|
-
case constants_1.
|
|
40
|
+
case constants_1.MAINNET_ASSETS_ID.tsTON:
|
|
34
41
|
if (network === 'mainnet') {
|
|
35
42
|
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.tsTON_MAINNET);
|
|
43
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.tsTON_MAINNET;
|
|
36
44
|
}
|
|
37
45
|
else {
|
|
38
|
-
builder.storeAddress(
|
|
46
|
+
// builder.storeAddress(JETTON_MASTER_ADDRESSES.tsTON_TESTNET);
|
|
47
|
+
// jettonWalletCode = JETTON_WALLETS_CODE.tsTON_TESTNET;
|
|
48
|
+
throw new Error('tsTON is not supported on testnet');
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case constants_1.MAINNET_ASSETS_ID.USDT:
|
|
52
|
+
if (network === 'mainnet') {
|
|
53
|
+
builder.storeAddress(constants_1.JETTON_MASTER_ADDRESSES.USDT_MAINNET);
|
|
54
|
+
jettonWalletCode = constants_1.JETTON_WALLETS_CODE.USDT_MAINNET;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// builder.storeAddress(JETTON_MASTER_ADDRESSES.USDT_TESTNET);
|
|
58
|
+
// jettonWalletCode = JETTON_WALLETS_CODE.USDT_TESTNET;
|
|
59
|
+
throw new Error('USDT is not supported on testnet');
|
|
39
60
|
}
|
|
40
61
|
break;
|
|
41
62
|
default:
|
|
42
63
|
throw new Error('Unsupported asset');
|
|
43
64
|
}
|
|
44
|
-
const data = builder.storeRef(
|
|
65
|
+
const data = builder.storeRef(jettonWalletCode).endCell();
|
|
45
66
|
const stateInit = (0, core_1.beginCell)()
|
|
46
67
|
.store((0, core_1.storeStateInit)({
|
|
47
|
-
code:
|
|
68
|
+
code: jettonWalletCode,
|
|
48
69
|
data: data,
|
|
49
70
|
}))
|
|
50
71
|
.endCell();
|