@evaafi/sdk 0.5.4 → 0.5.6
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/helpers.js +2 -3
- package/dist/api/math.d.ts +24 -2
- package/dist/api/math.js +189 -62
- package/dist/api/parser.d.ts +3 -3
- package/dist/api/parser.js +37 -25
- package/dist/api/prices.d.ts +1 -1
- package/dist/api/prices.js +3 -3
- package/dist/config.d.ts +2 -0
- package/dist/config.js +5 -0
- package/dist/constants/assets.d.ts +2 -3
- package/dist/constants/assets.js +10 -2
- package/dist/constants/general.d.ts +3 -2
- package/dist/constants/general.js +6 -5
- package/dist/constants/pools.d.ts +0 -1
- package/dist/constants/pools.js +1 -14
- package/dist/constants.d.ts +5 -34
- package/dist/constants.js +90 -37
- package/dist/contracts/MasterContract.d.ts +13 -45
- package/dist/contracts/MasterContract.js +10 -12
- package/dist/contracts/UserContract.js +7 -7
- package/dist/index.d.ts +6 -5
- package/dist/index.js +5 -3
- package/dist/types/Master.d.ts +8 -7
- package/dist/types/User.d.ts +5 -5
- package/dist/utils/merkleProof.d.ts +4 -0
- package/dist/utils/merkleProof.js +107 -0
- package/dist/utils/priceUtils.d.ts +55 -0
- package/dist/utils/priceUtils.js +117 -0
- package/dist/utils/sha256BigInt.js +1 -2
- package/dist/utils/tonConnectSender.js +2 -3
- package/dist/utils/userJettonWallet.d.ts +2 -2
- package/dist/utils/userJettonWallet.js +5 -2
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.js +6 -0
- package/package.json +2 -2
- package/src/api/math.ts +229 -50
- package/src/api/parser.ts +52 -37
- package/src/api/prices.ts +2 -1
- package/src/constants/assets.ts +11 -3
- package/src/constants/general.ts +6 -4
- package/src/constants/pools.ts +1 -15
- package/src/contracts/MasterContract.ts +25 -67
- package/src/contracts/UserContract.ts +8 -10
- package/src/index.ts +4 -7
- package/src/types/Master.ts +9 -8
- package/src/types/User.ts +5 -5
- package/src/utils/userJettonWallet.ts +6 -2
- package/src/utils/utils.ts +6 -0
|
@@ -6,13 +6,14 @@ export declare const MASTER_CONSTANTS: {
|
|
|
6
6
|
ASSET_RESERVE_FACTOR_SCALE: bigint;
|
|
7
7
|
ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: bigint;
|
|
8
8
|
ASSET_ORIGINATION_FEE_SCALE: bigint;
|
|
9
|
+
ASSET_LIQUIDATION_THRESHOLD_SCALE: bigint;
|
|
10
|
+
ASSET_LIQUIDATION_BONUS_SCALE: bigint;
|
|
9
11
|
};
|
|
12
|
+
export declare const NULL_ADDRESS: Address;
|
|
10
13
|
export declare const EVAA_MASTER_MAINNET: Address;
|
|
11
14
|
export declare const MAINNET_VERSION = 5;
|
|
12
15
|
export declare const EVAA_MASTER_TESTNET: Address;
|
|
13
16
|
export declare const TESTNET_VERSION = 5;
|
|
14
|
-
export declare const EVAA_LP_TESTNET: Address;
|
|
15
|
-
export declare const EVAA_LP_TESTNET_VERSION = 5;
|
|
16
17
|
export declare const EVAA_LP_MAINNET: Address;
|
|
17
18
|
export declare const EVAA_LP_MAINNET_VERSION = 0;
|
|
18
19
|
export declare const MAIN_POOL_NFT_ID = "0xfb9874544d76ca49c5db9cc3e5121e4c018bc8a2fb2bfe8f2a38c5b9963492f5";
|
|
@@ -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.LP_POOL_NFT_ID = exports.MAIN_POOL_NFT_ID = exports.EVAA_LP_MAINNET_VERSION = exports.EVAA_LP_MAINNET = exports.
|
|
3
|
+
exports.FEES = exports.OPCODES = exports.JETTON_WALLET_STANDART_CODE_TESTNET = exports.JETTON_WALLET_STANDART_CODE = exports.LENDING_CODE = exports.LP_POOL_NFT_ID = exports.MAIN_POOL_NFT_ID = 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),
|
|
@@ -8,14 +8,15 @@ exports.MASTER_CONSTANTS = {
|
|
|
8
8
|
ASSET_PRICE_SCALE: BigInt(1e9),
|
|
9
9
|
ASSET_RESERVE_FACTOR_SCALE: 10000n,
|
|
10
10
|
ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: 10000n,
|
|
11
|
-
ASSET_ORIGINATION_FEE_SCALE: BigInt(1e9)
|
|
11
|
+
ASSET_ORIGINATION_FEE_SCALE: BigInt(1e9),
|
|
12
|
+
ASSET_LIQUIDATION_THRESHOLD_SCALE: 10000n,
|
|
13
|
+
ASSET_LIQUIDATION_BONUS_SCALE: 10000n,
|
|
12
14
|
};
|
|
15
|
+
exports.NULL_ADDRESS = core_1.Address.parse('UQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJKZ');
|
|
13
16
|
exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
14
17
|
exports.MAINNET_VERSION = 5;
|
|
15
|
-
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('EQCoIxsE8m0Q_Ui9uM-2RPtVWXqHK0ttuW2Mccuaj4FfdkLl');
|
|
18
|
+
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('EQCoIxsE8m0Q_Ui9uM-2RPtVWXqHK0ttuW2Mccuaj4FfdkLl'); // EQBghPVKxgauOyrcyNYNwE2MRRnebaNpDGpVDQLbml_LIXnK
|
|
16
19
|
exports.TESTNET_VERSION = 5;
|
|
17
|
-
exports.EVAA_LP_TESTNET = core_1.Address.parse('EQBghPVKxgauOyrcyNYNwE2MRRnebaNpDGpVDQLbml_LIXnK');
|
|
18
|
-
exports.EVAA_LP_TESTNET_VERSION = 5;
|
|
19
20
|
exports.EVAA_LP_MAINNET = core_1.Address.parse('EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLww-hdWk2G37Jc6N');
|
|
20
21
|
exports.EVAA_LP_MAINNET_VERSION = 0;
|
|
21
22
|
exports.MAIN_POOL_NFT_ID = '0xfb9874544d76ca49c5db9cc3e5121e4c018bc8a2fb2bfe8f2a38c5b9963492f5';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PoolConfig } from "../types/Master";
|
|
2
2
|
export declare const MAINNET_POOL_CONFIG: PoolConfig;
|
|
3
3
|
export declare const TESTNET_POOL_CONFIG: PoolConfig;
|
|
4
|
-
export declare const TESTNET_LP_POOL_CONFIG: PoolConfig;
|
|
5
4
|
export declare const MAINNET_LP_POOL_CONFIG: PoolConfig;
|
package/dist/constants/pools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAINNET_LP_POOL_CONFIG = exports.
|
|
3
|
+
exports.MAINNET_LP_POOL_CONFIG = exports.TESTNET_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = void 0;
|
|
4
4
|
const assets_1 = require("./assets");
|
|
5
5
|
const general_1 = require("./general");
|
|
6
6
|
exports.MAINNET_POOL_CONFIG = {
|
|
@@ -31,19 +31,6 @@ exports.TESTNET_POOL_CONFIG = {
|
|
|
31
31
|
],
|
|
32
32
|
lendingCode: general_1.LENDING_CODE
|
|
33
33
|
};
|
|
34
|
-
exports.TESTNET_LP_POOL_CONFIG = {
|
|
35
|
-
masterAddress: general_1.EVAA_LP_TESTNET,
|
|
36
|
-
masterVersion: general_1.EVAA_LP_TESTNET_VERSION,
|
|
37
|
-
masterConstants: general_1.MASTER_CONSTANTS,
|
|
38
|
-
nftId: general_1.LP_POOL_NFT_ID,
|
|
39
|
-
poolAssetsConfig: [
|
|
40
|
-
assets_1.TON_MAINNET,
|
|
41
|
-
assets_1.JUSDT_TESTNET,
|
|
42
|
-
assets_1.JUSDC_TESTNET,
|
|
43
|
-
assets_1.STTON_TESTNET
|
|
44
|
-
],
|
|
45
|
-
lendingCode: general_1.LENDING_CODE
|
|
46
|
-
};
|
|
47
34
|
exports.MAINNET_LP_POOL_CONFIG = {
|
|
48
35
|
masterAddress: general_1.EVAA_LP_MAINNET,
|
|
49
36
|
masterVersion: general_1.EVAA_LP_MAINNET_VERSION,
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Address, Cell } from '@ton/core';
|
|
2
|
+
import { OracleNFT, PoolConfig } from './types/Master';
|
|
2
3
|
export declare const EVAA_MASTER_MAINNET: Address;
|
|
3
4
|
export declare const MAINNET_VERSION = 5;
|
|
4
5
|
export declare const EVAA_MASTER_TESTNET: Address;
|
|
5
|
-
export declare const TESTNET_VERSION =
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const TESTNET_VERSION = 0;
|
|
7
|
+
export declare const ORACLE_NFTS: OracleNFT[];
|
|
7
8
|
export declare const MAINNET_ASSETS_ID: {
|
|
8
9
|
TON: bigint;
|
|
9
10
|
jUSDT: bigint;
|
|
@@ -18,39 +19,9 @@ export declare const TESTNET_ASSETS_ID: {
|
|
|
18
19
|
jUSDC: bigint;
|
|
19
20
|
stTON: bigint;
|
|
20
21
|
};
|
|
21
|
-
export declare const JETTON_MASTER_ADDRESSES: {
|
|
22
|
-
jUSDT_MAINNET: Address;
|
|
23
|
-
jUSDT_TESTNET: Address;
|
|
24
|
-
jUSDC_MAINNET: Address;
|
|
25
|
-
jUSDC_TESTNET: Address;
|
|
26
|
-
stTON_MAINNET: Address;
|
|
27
|
-
stTON_TESTNET: Address;
|
|
28
|
-
tsTON_MAINNET: Address;
|
|
29
|
-
tsTON_TESTNET: null;
|
|
30
|
-
USDT_MAINNET: Address;
|
|
31
|
-
USDT_TESTNET: null;
|
|
32
|
-
};
|
|
33
|
-
export declare const MASTER_CONSTANTS: {
|
|
34
|
-
FACTOR_SCALE: bigint;
|
|
35
|
-
ASSET_COEFFICIENT_SCALE: bigint;
|
|
36
|
-
ASSET_PRICE_SCALE: bigint;
|
|
37
|
-
ASSET_RESERVE_FACTOR_SCALE: bigint;
|
|
38
|
-
ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: bigint;
|
|
39
|
-
ASSET_ORIGINATION_FEE_SCALE: bigint;
|
|
40
|
-
};
|
|
41
22
|
export declare const LENDING_CODE: Cell;
|
|
42
|
-
export declare const
|
|
43
|
-
|
|
44
|
-
jUSDT_TESTNET: Cell;
|
|
45
|
-
jUSDC_MAINNET: Cell;
|
|
46
|
-
jUSDC_TESTNET: Cell;
|
|
47
|
-
stTON_MAINNET: Cell;
|
|
48
|
-
stTON_TESTNET: Cell;
|
|
49
|
-
tsTON_MAINNET: Cell;
|
|
50
|
-
tsTON_TESTNET: null;
|
|
51
|
-
USDT_MAINNET: Cell;
|
|
52
|
-
USDT_TESTNET: null;
|
|
53
|
-
};
|
|
23
|
+
export declare const MAINNET_POOL_CONFIG: PoolConfig;
|
|
24
|
+
export declare const TESTNET_POOL_CONFIG: PoolConfig;
|
|
54
25
|
export declare const OPCODES: {
|
|
55
26
|
SUPPLY: number;
|
|
56
27
|
WITHDRAW: number;
|
package/dist/constants.js
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FEES = exports.OPCODES = exports.
|
|
3
|
+
exports.FEES = exports.OPCODES = exports.TESTNET_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = exports.LENDING_CODE = exports.TESTNET_ASSETS_ID = exports.MAINNET_ASSETS_ID = exports.ORACLE_NFTS = 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
|
+
const MASTER_CONSTANTS = {
|
|
7
|
+
FACTOR_SCALE: BigInt(1e12),
|
|
8
|
+
ASSET_COEFFICIENT_SCALE: 10000n,
|
|
9
|
+
ASSET_PRICE_SCALE: BigInt(1e8),
|
|
10
|
+
ASSET_RESERVE_FACTOR_SCALE: 10000n,
|
|
11
|
+
ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: 10000n,
|
|
12
|
+
ASSET_ORIGINATION_FEE_SCALE: BigInt(1e9)
|
|
13
|
+
};
|
|
6
14
|
exports.EVAA_MASTER_MAINNET = core_1.Address.parse('EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr');
|
|
7
15
|
exports.MAINNET_VERSION = 5;
|
|
8
|
-
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('
|
|
9
|
-
exports.TESTNET_VERSION =
|
|
10
|
-
exports.
|
|
16
|
+
exports.EVAA_MASTER_TESTNET = core_1.Address.parse('EQDLsg3w-iBj26Gww7neYoJAxiT2t77Zo8ro56b0yuHsPp3C');
|
|
17
|
+
exports.TESTNET_VERSION = 0;
|
|
18
|
+
exports.ORACLE_NFTS = [{ id: 0, address: '0x3bb147a37b7a7f874c39320440f352bddd2c9337e31a778731910f0266391650' },
|
|
19
|
+
{ id: 1, address: '0x676767e93b05a21aec9023a65f73cffe1c725709c3c964a7c3f0fd4229089bfe' },
|
|
20
|
+
{ id: 2, address: '0x9c9e65951b0c5920c286bdb3410babcaf21f85bc9c90c13172988630f1244e0f' },
|
|
21
|
+
{ id: 3, address: '0x9dcf880229bfb68d7344fd294624b64f1e0b43b9d858f0fdb1bc6434616c08f5' },
|
|
22
|
+
{ id: 4, address: '0x4d1afcf7c0426ca61c405c8cfaef0053a0f0d143740ffed04c8716beb99cd614' },
|
|
23
|
+
{ id: 5, address: '0x11c6baa608ed10733051fd74134441d384e471722fbc496b43ea4e3c6652485f' },
|
|
24
|
+
{ id: 6, address: '0x2b685672f38dc2fce59013bb740bf24c6037049a1c267bb3b5f6f55d5b195f5f' },
|
|
25
|
+
];
|
|
11
26
|
exports.MAINNET_ASSETS_ID = {
|
|
12
27
|
TON: (0, sha256BigInt_1.sha256Hash)('TON'),
|
|
13
28
|
jUSDT: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
|
|
@@ -21,41 +36,79 @@ exports.TESTNET_ASSETS_ID = {
|
|
|
21
36
|
jUSDT: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
|
|
22
37
|
jUSDC: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
|
|
23
38
|
stTON: (0, sha256BigInt_1.sha256Hash)('stTON'),
|
|
24
|
-
// tsTON: sha256Hash('tsTON'),
|
|
25
|
-
// USDT: sha256Hash('USDT'),
|
|
26
|
-
};
|
|
27
|
-
exports.JETTON_MASTER_ADDRESSES = {
|
|
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'),
|
|
35
|
-
tsTON_TESTNET: null,
|
|
36
|
-
USDT_MAINNET: core_1.Address.parse('EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'),
|
|
37
|
-
USDT_TESTNET: null,
|
|
38
|
-
};
|
|
39
|
-
exports.MASTER_CONSTANTS = {
|
|
40
|
-
FACTOR_SCALE: BigInt(1e12),
|
|
41
|
-
ASSET_COEFFICIENT_SCALE: 10000n,
|
|
42
|
-
ASSET_PRICE_SCALE: BigInt(1e8),
|
|
43
|
-
ASSET_RESERVE_FACTOR_SCALE: 10000n,
|
|
44
|
-
ASSET_LIQUIDATION_RESERVE_FACTOR_SCALE: 10000n,
|
|
45
|
-
ASSET_ORIGINATION_FEE_SCALE: BigInt(1e9)
|
|
46
39
|
};
|
|
47
40
|
exports.LENDING_CODE = core_1.Cell.fromBoc(Buffer.from('b5ee9c72c1010e0100fd000d12182a555a6065717691969efd0114ff00f4a413f4bcf2c80b010202c8050202039f740403001ff2f8276a2687d2018fd201800f883b840051d38642c678b64e4400780e58fc10802faf07f80e59fa801e78b096664c02078067c07c100627a7978402014807060007a0ddb0c60201c709080013a0fd007a026900aa90400201200b0a0031b8e1002191960aa00b9e2ca007f4042796d225e8019203f6010201200d0c000bf7c147d2218400b9d10e86981fd201840b07f8138d809797976a2687d2029116382f970fd9178089910374daf81b619fd20182c7883b8701981684100627910eba56001797a6a6ba610fd8200e8768f76a9f6aa00cc2a32a8292878809bef2f1889f883bbcdeb86f01', 'hex'))[0];
|
|
48
|
-
exports.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
exports.MAINNET_POOL_CONFIG = {
|
|
42
|
+
masterAddress: exports.EVAA_MASTER_MAINNET,
|
|
43
|
+
masterVersion: exports.MAINNET_VERSION,
|
|
44
|
+
masterConstants: MASTER_CONSTANTS,
|
|
45
|
+
poolAssetsConfig: {
|
|
46
|
+
TON: {
|
|
47
|
+
name: 'TON',
|
|
48
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('TON')
|
|
49
|
+
},
|
|
50
|
+
jUSDT: {
|
|
51
|
+
name: 'jUSDT',
|
|
52
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
|
|
53
|
+
jettonMasterAddress: core_1.Address.parse('EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA'),
|
|
54
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000385000114ff00f4a413f4bcf2c80b0102016202030202cb0405001ba0f605da89a1f401f481f481a9a30201ce06070201580a0b02f70831c02497c138007434c0c05c6c2544d7c0fc07783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c076cf16cc8d0d0d09208403e29fa96ea68c1b088d978c4408fc06b809208405e351466ea6cc1b08978c840910c03c06f80dd6cda0841657c1ef2ea7c09c6c3cb4b01408eebcb8b1807c073817c160080900113e910c30003cb85360005c804ff833206e953080b1f833de206ef2d29ad0d30731d3ffd3fff404d307d430d0fa00fa00fa00fa00fa00fa00300008840ff2f00201580c0d020148111201f70174cfc0407e803e90087c007b51343e803e903e903534544da8548b31c17cb8b04ab0bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032481c007e401d3232c084b281f2fff274013e903d010c7e800835d270803cb8b13220060072c15401f3c59c3e809dc072dae00e02f33b51343e803e903e90353442b4cfc0407e80145468017e903e9014d771c1551cdbdc150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0325c007e401d3232c084b281f2fff2741403f1c147ac7cb8b0c33e801472a84a6d8206685401e8062849a49b1578c34975c2c070c00870802c200f1000aa13ccc88210178d4519580a02cb1fcb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25007a813a008aa005004a017a014bcf2e2c501c98040fb004300c85004fa0258cf1601cf16ccc9ed5400725269a018a1c882107362d09c2902cb1fcb3f5007fa025004cf165007cf16c9c8801001cb0527cf165004fa027101cb6a13ccc971fb0050421300748e23c8801001cb055006cf165005fa027001cb6a8210d53276db580502cb1fcb3fc972fb00925b33e24003c85004fa0258cf1601cf16ccc9ed5400eb3b51343e803e903e9035344174cfc0407e800870803cb8b0be903d01007434e7f440745458a8549631c17cb8b049b0bffcb8b0b220841ef765f7960100b2c7f2cfc07e8088f3c58073c584f2e7f27220060072c148f3c59c3e809c4072dab33260103ec01004f214013e809633c58073c5b3327b55200087200835c87b51343e803e903e9035344134c7c06103c8608405e351466e80a0841ef765f7ae84ac7cbd34cfc04c3e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
55
|
+
},
|
|
56
|
+
jUSDC: {
|
|
57
|
+
name: 'jUSDC',
|
|
58
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
|
|
59
|
+
jettonMasterAddress: core_1.Address.parse('EQB-MPwrd1G6WKNkLz_VnV6WqBDd142KMQv-g1O-8QUA3728'),
|
|
60
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021301000385000114ff00f4a413f4bcf2c80b0102016202030202cb0405001ba0f605da89a1f401f481f481a9a30201ce06070201580a0b02f70831c02497c138007434c0c05c6c2544d7c0fc07783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c076cf16cc8d0d0d09208403e29fa96ea68c1b088d978c4408fc06b809208405e351466ea6cc1b08978c840910c03c06f80dd6cda0841657c1ef2ea7c09c6c3cb4b01408eebcb8b1807c073817c160080900113e910c30003cb85360005c804ff833206e953080b1f833de206ef2d29ad0d30731d3ffd3fff404d307d430d0fa00fa00fa00fa00fa00fa00300008840ff2f00201580c0d020148111201f70174cfc0407e803e90087c007b51343e803e903e903534544da8548b31c17cb8b04ab0bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032481c007e401d3232c084b281f2fff274013e903d010c7e800835d270803cb8b13220060072c15401f3c59c3e809dc072dae00e02f33b51343e803e903e90353442b4cfc0407e80145468017e903e9014d771c1551cdbdc150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0325c007e401d3232c084b281f2fff2741403f1c147ac7cb8b0c33e801472a84a6d8206685401e8062849a49b1578c34975c2c070c00870802c200f1000aa13ccc88210178d4519580a02cb1fcb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25007a813a008aa005004a017a014bcf2e2c501c98040fb004300c85004fa0258cf1601cf16ccc9ed5400725269a018a1c882107362d09c2902cb1fcb3f5007fa025004cf165007cf16c9c8801001cb0527cf165004fa027101cb6a13ccc971fb0050421300748e23c8801001cb055006cf165005fa027001cb6a8210d53276db580502cb1fcb3fc972fb00925b33e24003c85004fa0258cf1601cf16ccc9ed5400eb3b51343e803e903e9035344174cfc0407e800870803cb8b0be903d01007434e7f440745458a8549631c17cb8b049b0bffcb8b0b220841ef765f7960100b2c7f2cfc07e8088f3c58073c584f2e7f27220060072c148f3c59c3e809c4072dab33260103ec01004f214013e809633c58073c5b3327b55200087200835c87b51343e803e903e9035344134c7c06103c8608405e351466e80a0841ef765f7ae84ac7cbd34cfc04c3e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
61
|
+
},
|
|
62
|
+
stTON: {
|
|
63
|
+
name: 'stTON',
|
|
64
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('stTON'),
|
|
65
|
+
jettonMasterAddress: core_1.Address.parse('EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k'),
|
|
66
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000362000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120090a01cf0831c02497c138007434c0c05c6c2544d7c0fc03783e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c8608403e29fa96ea54c4d167c02b808608405e351466ea58c511100fc02f80860841657c1ef2ea54c4d167c03380517c1300138c08c2103fcbc200800113e910c30003cb85360007ced44d0fa00fa40fa40d43010235f03018208989680a16d801072226eb32091719170e203c8cb055006cf165004fa02cb6a039358cc019130e201c901fb000201580b0c020148101101f100f4cffe803e90087c007b51343e803e903e90350c144da8548ab1c17cb8b04a30bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032483e401c1d3232c0b281f2fff274013e903d010c7e800835d270803cb8b11de0063232c1540233c59c3e8085f2dac4f3200d02f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad8228608239387028062849e5c412440e0dd7c138c34975c2c0600e0f009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a0820a625a00a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5400705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5400c90c3b51343e803e903e90350c01b4cffe800c145128548df1c17cb8b04970bffcb8b0812082e4e1c02fbcb8b160841ef765f7b232c7c532cfd63e808873c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b55200081200835c87b51343e803e903e90350c0134c7c8608405e351466e80a0841ef765f7ae84ac7cb83234cfcc7e800c04e81408f214013e809633c58073c5b3327b5520', 'hex'))[0],
|
|
67
|
+
},
|
|
68
|
+
tsTON: {
|
|
69
|
+
name: 'tsTON',
|
|
70
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('tsTON'),
|
|
71
|
+
jettonMasterAddress: core_1.Address.parse('EQC98_qAmNEptUtPc7W6xdHh_ZHrBUFpw5Ft_IzNU20QAJav'),
|
|
72
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c720101010100230000420212bebb0dc8e202b7e26f721e2547e16bb9ebaec934f657d19f22e76d62bec878', 'hex'))[0],
|
|
73
|
+
},
|
|
74
|
+
USDT: {
|
|
75
|
+
name: 'USDT',
|
|
76
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('USDT'),
|
|
77
|
+
jettonMasterAddress: core_1.Address.parse('EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'),
|
|
78
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c72010101010023000042028f452d7a4dfd74066b682365177259ed05734435be76b5fd4bd5d8af2b7c3d68', 'hex'))[0],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
lendingCode: exports.LENDING_CODE
|
|
82
|
+
};
|
|
83
|
+
exports.TESTNET_POOL_CONFIG = {
|
|
84
|
+
masterAddress: exports.EVAA_MASTER_TESTNET,
|
|
85
|
+
masterVersion: exports.TESTNET_VERSION,
|
|
86
|
+
masterConstants: MASTER_CONSTANTS,
|
|
87
|
+
poolAssetsConfig: {
|
|
88
|
+
TON: {
|
|
89
|
+
name: 'TON',
|
|
90
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('TON'),
|
|
91
|
+
},
|
|
92
|
+
jUSDT: {
|
|
93
|
+
name: 'jUSDT',
|
|
94
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('jUSDT'),
|
|
95
|
+
jettonMasterAddress: core_1.Address.parse('kQBe4gtSQMxM5RpMYLr4ydNY72F8JkY-icZXG1NJcsju8XM7'),
|
|
96
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
97
|
+
},
|
|
98
|
+
jUSDC: {
|
|
99
|
+
name: 'jUSDC',
|
|
100
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('jUSDC'),
|
|
101
|
+
jettonMasterAddress: core_1.Address.parse('kQDaY5yUatYnHei73HBqRX_Ox9LK2XnR7XuCY9MFC2INbfYI'),
|
|
102
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021101000323000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120080900c30831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7e08403e29fa954882ea54c4d167c0278208405e3514654882ea58c511100fc02b80d60841657c1ef2ea4d67c02f817c12103fcbc2000113e910c1c2ebcb853600201200a0b0083d40106b90f6a2687d007d207d206a1802698fc1080bc6a28ca9105d41083deecbef09dd0958f97162e99f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80c0201200d0e009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08209c9c380a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad822860822625a028062849e5c412440e0dd7c138c34975c2c0600f1000d73b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b08160824c4b402805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
103
|
+
},
|
|
104
|
+
stTON: {
|
|
105
|
+
name: 'stTON',
|
|
106
|
+
assetId: (0, sha256BigInt_1.sha256Hash)('stTON'),
|
|
107
|
+
jettonMasterAddress: core_1.Address.parse('kQC3Duw3dg8k98xf5S7Bm7YOWVJ5QW8hm3iLqFfJfa_g9h07'),
|
|
108
|
+
jettonWalletCode: core_1.Cell.fromBoc(Buffer.from('b5ee9c7201021201000362000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020120090a01cf0831c02497c138007434c0c05c6c2544d7c0fc03383e903e900c7e800c5c75c87e800c7e800c1cea6d0000b4c7c8608403e29fa96ea54c4d167c027808608405e351466ea58c511100fc02b80860841657c1ef2ea54c4d167c02f80517c1300138c08c2103fcbc200800113e910c30003cb85360007ced44d0fa00fa40fa40d43010235f03018208989680a16d801072226eb32091719170e203c8cb055006cf165004fa02cb6a039358cc019130e201c901fb000201200b0c0081d40106b90f6a2687d007d207d206a1802698f90c1080bc6a28cdd0141083deecbef5d0958f97064699f98fd001809d02811e428027d012c678b00e78b6664f6aa401f1503d33ffa00fa4021f001ed44d0fa00fa40fa40d4305136a1522ac705f2e2c128c2fff2e2c254344270542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c920f9007074c8cb02ca07cbffc9d004fa40f40431fa0020d749c200f2e2c4778018c8cb055008cf1670fa0217cb6b13cc80d0201200e0f009e8210178d4519c8cb1f19cb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a0820a625a00a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5402f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a019ad8228608239387028062849e5c412440e0dd7c138c34975c2c060101100c90c3b51343e803e903e90350c01b4cffe800c145128548df1c17cb8b04970bffcb8b0812082e4e1c02fbcb8b160841ef765f7b232c7c532cfd63e808873c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b552000705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718010c8cb0524cf165006fa0215cb6a14ccc971fb0010241023007cc30023c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed54', 'hex'))[0],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
lendingCode: exports.LENDING_CODE
|
|
59
112
|
};
|
|
60
113
|
exports.OPCODES = {
|
|
61
114
|
SUPPLY: 0x1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Address, Cell, Contract, ContractProvider, OpenedContract, Sender } from '@ton/core';
|
|
2
2
|
import { Maybe } from '@ton/core/dist/utils/maybe';
|
|
3
3
|
import { EvaaUser } from './UserContract';
|
|
4
|
-
import { MasterData, PoolAssetConfig, PoolConfig
|
|
4
|
+
import { MasterData, PoolAssetConfig, PoolConfig } from '../types/Master';
|
|
5
5
|
/**
|
|
6
6
|
* Parameters for the Evaa contract
|
|
7
7
|
* @property testnet - true for testnet, false for mainnet
|
|
@@ -11,44 +11,23 @@ export type EvaaParameters = {
|
|
|
11
11
|
poolConfig: PoolConfig;
|
|
12
12
|
debug?: boolean;
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Parameters for the Jetton message
|
|
16
|
-
* @property responseAddress - address to send excesses
|
|
17
|
-
* @property forwardAmount - amount to forward to the destination address
|
|
18
|
-
*/
|
|
19
|
-
export type JettonMessageParameters = {
|
|
20
|
-
responseAddress?: Address;
|
|
21
|
-
forwardAmount?: bigint;
|
|
22
|
-
};
|
|
23
14
|
/**
|
|
24
15
|
* Base parameters for supply
|
|
25
16
|
* @property queryID - unique query ID
|
|
26
17
|
* @property includeUserCode - true to include user code for update (needed when user contract code version is outdated)
|
|
27
18
|
* @property amount - amount to supply
|
|
28
19
|
* @property userAddress - user address
|
|
29
|
-
* @property
|
|
20
|
+
* @property asset
|
|
30
21
|
*/
|
|
31
|
-
export type
|
|
22
|
+
export type SupplyParameters = {
|
|
23
|
+
asset: PoolAssetConfig;
|
|
32
24
|
queryID: bigint;
|
|
33
25
|
includeUserCode: boolean;
|
|
34
26
|
amount: bigint;
|
|
35
27
|
userAddress: Address;
|
|
28
|
+
responseAddress?: Address;
|
|
29
|
+
forwardAmount?: bigint;
|
|
36
30
|
};
|
|
37
|
-
/**
|
|
38
|
-
* Parameters for the TON supply message
|
|
39
|
-
* @property type - 'ton'
|
|
40
|
-
*/
|
|
41
|
-
export type TonSupplyParameters = SupplyBaseParameters & {
|
|
42
|
-
asset: PoolAssetConfig;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Parameters for the jetton supply message
|
|
46
|
-
* @property type - 'jetton'
|
|
47
|
-
*/
|
|
48
|
-
export type JettonSupplyParameters = SupplyBaseParameters & JettonMessageParameters & {
|
|
49
|
-
asset: PoolJettonAssetConfig & PoolAssetConfig;
|
|
50
|
-
};
|
|
51
|
-
export type SupplyParameters = TonSupplyParameters | JettonSupplyParameters;
|
|
52
31
|
/**
|
|
53
32
|
* Parameters for the withdraw message
|
|
54
33
|
* @property queryID - unique query ID
|
|
@@ -91,25 +70,14 @@ export type LiquidationBaseData = {
|
|
|
91
70
|
* @property includeUserCode - true to include user code for update (needed when user contract code version is outdated)
|
|
92
71
|
* @property priceData - price data cell. Can be obtained from the getPrices function
|
|
93
72
|
*/
|
|
94
|
-
export type
|
|
73
|
+
export type LiquidationParameters = LiquidationBaseData & {
|
|
74
|
+
asset: PoolAssetConfig;
|
|
95
75
|
queryID: bigint;
|
|
96
76
|
liquidatorAddress: Address;
|
|
97
77
|
includeUserCode: boolean;
|
|
98
78
|
priceData: Cell;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* Parameters for the TON liquidation message
|
|
102
|
-
* @property type - 'ton'
|
|
103
|
-
*/
|
|
104
|
-
export type TonLiquidationParameters = LiquidationBaseParameters & {
|
|
105
|
-
asset: PoolAssetConfig;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Parameters for the jetton liquidation message
|
|
109
|
-
* @property type - 'jetton'
|
|
110
|
-
*/
|
|
111
|
-
export type JettonLiquidationParameters = LiquidationBaseParameters & JettonMessageParameters & {
|
|
112
|
-
asset: PoolAssetConfig & PoolJettonAssetConfig;
|
|
79
|
+
responseAddress?: Address;
|
|
80
|
+
forwardAmount?: bigint;
|
|
113
81
|
};
|
|
114
82
|
/**
|
|
115
83
|
* Evaa master contract wrapper
|
|
@@ -139,7 +107,7 @@ export declare class Evaa implements Contract {
|
|
|
139
107
|
* Create liquidation message
|
|
140
108
|
* @returns liquidation message as a cell
|
|
141
109
|
*/
|
|
142
|
-
createLiquidationMessage(parameters:
|
|
110
|
+
createLiquidationMessage(parameters: LiquidationParameters): Cell;
|
|
143
111
|
/**
|
|
144
112
|
* Calculate user contract address
|
|
145
113
|
* @param userAddress
|
|
@@ -157,9 +125,9 @@ export declare class Evaa implements Contract {
|
|
|
157
125
|
* Get master contract data
|
|
158
126
|
*/
|
|
159
127
|
get data(): Maybe<MasterData>;
|
|
160
|
-
sendSupply(provider: ContractProvider, via: Sender, value: bigint, parameters:
|
|
128
|
+
sendSupply(provider: ContractProvider, via: Sender, value: bigint, parameters: SupplyParameters): Promise<void>;
|
|
161
129
|
sendWithdraw(provider: ContractProvider, via: Sender, value: bigint, parameters: WithdrawParameters): Promise<void>;
|
|
162
|
-
sendLiquidation(provider: ContractProvider, via: Sender, value: bigint, parameters:
|
|
130
|
+
sendLiquidation(provider: ContractProvider, via: Sender, value: bigint, parameters: LiquidationParameters): Promise<void>;
|
|
163
131
|
/**
|
|
164
132
|
* Open user contract wrapper
|
|
165
133
|
* @param forwardPayload - payload that will be forwarded to the address which requested the data
|
|
@@ -27,16 +27,15 @@ class Evaa {
|
|
|
27
27
|
* @returns supply message as a cell
|
|
28
28
|
*/
|
|
29
29
|
createSupplyMessage(parameters) {
|
|
30
|
-
if (
|
|
31
|
-
const jettonParams = parameters;
|
|
30
|
+
if (!(0, __1.isTonAsset)(parameters.asset)) {
|
|
32
31
|
return (0, core_1.beginCell)()
|
|
33
32
|
.storeUint(general_1.OPCODES.JETTON_TRANSFER, 32)
|
|
34
33
|
.storeUint(parameters.queryID, 64)
|
|
35
34
|
.storeCoins(parameters.amount)
|
|
36
35
|
.storeAddress(this.address)
|
|
37
|
-
.storeAddress(
|
|
36
|
+
.storeAddress(parameters.responseAddress ?? parameters.userAddress)
|
|
38
37
|
.storeBit(0)
|
|
39
|
-
.storeCoins(
|
|
38
|
+
.storeCoins(parameters.forwardAmount ?? general_1.FEES.SUPPLY_JETTON_FWD)
|
|
40
39
|
.storeBit(1)
|
|
41
40
|
.storeRef((0, core_1.beginCell)()
|
|
42
41
|
.storeUint(general_1.OPCODES.SUPPLY, 32)
|
|
@@ -84,16 +83,15 @@ class Evaa {
|
|
|
84
83
|
* @returns liquidation message as a cell
|
|
85
84
|
*/
|
|
86
85
|
createLiquidationMessage(parameters) {
|
|
87
|
-
if (
|
|
88
|
-
const jettonParams = parameters;
|
|
86
|
+
if (!(0, __1.isTonAsset)(parameters.asset)) {
|
|
89
87
|
return (0, core_1.beginCell)()
|
|
90
88
|
.storeUint(general_1.OPCODES.JETTON_TRANSFER, 32)
|
|
91
89
|
.storeUint(parameters.queryID, 64)
|
|
92
90
|
.storeCoins(parameters.liquidationAmount)
|
|
93
91
|
.storeAddress(this.address)
|
|
94
|
-
.storeAddress(
|
|
92
|
+
.storeAddress(parameters.responseAddress ?? parameters.liquidatorAddress)
|
|
95
93
|
.storeBit(0)
|
|
96
|
-
.storeCoins(
|
|
94
|
+
.storeCoins(parameters.forwardAmount ?? general_1.FEES.LIQUIDATION_JETTON_FWD)
|
|
97
95
|
.storeBit(1)
|
|
98
96
|
.storeRef((0, core_1.beginCell)()
|
|
99
97
|
.storeUint(general_1.OPCODES.LIQUIDATE, 32)
|
|
@@ -162,7 +160,7 @@ class Evaa {
|
|
|
162
160
|
}
|
|
163
161
|
async sendSupply(provider, via, value, parameters) {
|
|
164
162
|
const message = this.createSupplyMessage(parameters);
|
|
165
|
-
if (
|
|
163
|
+
if (!(0, __1.isTonAsset)(parameters.asset)) {
|
|
166
164
|
if (!via.address) {
|
|
167
165
|
throw Error('Via address is required for jetton supply');
|
|
168
166
|
}
|
|
@@ -187,7 +185,7 @@ class Evaa {
|
|
|
187
185
|
}
|
|
188
186
|
async sendLiquidation(provider, via, value, parameters) {
|
|
189
187
|
const message = this.createLiquidationMessage(parameters);
|
|
190
|
-
if (
|
|
188
|
+
if (!(0, __1.isTonAsset)(parameters.asset)) {
|
|
191
189
|
if (!via.address) {
|
|
192
190
|
throw Error('Via address is required for jetton liquidation');
|
|
193
191
|
}
|
|
@@ -235,10 +233,10 @@ class Evaa {
|
|
|
235
233
|
}
|
|
236
234
|
async getPrices(provider, endpoints) {
|
|
237
235
|
if ((endpoints?.length ?? 0) > 0) {
|
|
238
|
-
return await (0, __1.
|
|
236
|
+
return await (0, __1.getPrices)(endpoints, this.poolConfig.nftId);
|
|
239
237
|
}
|
|
240
238
|
else {
|
|
241
|
-
return await (0, __1.
|
|
239
|
+
return await (0, __1.getPrices)(undefined, this.poolConfig.nftId);
|
|
242
240
|
}
|
|
243
241
|
}
|
|
244
242
|
}
|
|
@@ -25,7 +25,7 @@ class EvaaUser {
|
|
|
25
25
|
async getSyncLite(provider, assetsData, assetsConfig) {
|
|
26
26
|
const state = (await provider.getState()).state;
|
|
27
27
|
if (state.type === 'active') {
|
|
28
|
-
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64'), assetsData, assetsConfig, this.poolConfig
|
|
28
|
+
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64'), assetsData, assetsConfig, this.poolConfig);
|
|
29
29
|
this.lastSync = Math.floor(Date.now() / 1000);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
@@ -42,7 +42,7 @@ class EvaaUser {
|
|
|
42
42
|
*/
|
|
43
43
|
calculateUserData(assetsData, assetsConfig, prices) {
|
|
44
44
|
if (this._liteData) {
|
|
45
|
-
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices, this.poolConfig
|
|
45
|
+
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices, this.poolConfig);
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
48
|
return false;
|
|
@@ -65,8 +65,8 @@ class EvaaUser {
|
|
|
65
65
|
async getSync(provider, assetsData, assetsConfig, prices) {
|
|
66
66
|
const state = (await provider.getState()).state;
|
|
67
67
|
if (state.type === 'active') {
|
|
68
|
-
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64'), assetsData, assetsConfig, this.poolConfig
|
|
69
|
-
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices, this.poolConfig
|
|
68
|
+
this._liteData = (0, parser_1.parseUserLiteData)(state.data.toString('base64'), assetsData, assetsConfig, this.poolConfig);
|
|
69
|
+
this._data = (0, parser_1.parseUserData)(this._liteData, assetsData, assetsConfig, prices, this.poolConfig);
|
|
70
70
|
this.lastSync = Math.floor(Date.now() / 1000);
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
@@ -107,11 +107,11 @@ class EvaaUser {
|
|
|
107
107
|
}
|
|
108
108
|
return {
|
|
109
109
|
borrowerAddress: this._data.ownerAddress,
|
|
110
|
-
loanAsset: this._data.liquidationData.greatestLoanAsset,
|
|
111
|
-
collateralAsset: this._data.liquidationData.greatestCollateralAsset,
|
|
110
|
+
loanAsset: this._data.liquidationData.greatestLoanAsset.assetId,
|
|
111
|
+
collateralAsset: this._data.liquidationData.greatestCollateralAsset.assetId,
|
|
112
112
|
minCollateralAmount: this._data.liquidationData.minCollateralAmount,
|
|
113
113
|
liquidationAmount: this._data.liquidationData.liquidationAmount,
|
|
114
|
-
tonLiquidation: this._data.liquidationData.greatestLoanAsset === assets_1.TON_MAINNET.assetId,
|
|
114
|
+
tonLiquidation: this._data.liquidationData.greatestLoanAsset.assetId === assets_1.TON_MAINNET.assetId,
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
export { mulFactor, mulDiv, bigIntMin, bigIntMax, calculatePresentValue, calculateCurrentRates, calculateAssetData, calculateAssetInterest, getAvailableToBorrow, presentValue, calculateLiquidationData, } from './api/math';
|
|
1
|
+
export { mulFactor, mulDiv, bigIntMin, bigIntMax, calculatePresentValue, calculateCurrentRates, calculateAssetData, calculateAssetInterest, getAvailableToBorrow, calculateMaximumWithdrawAmount, presentValue, calculateLiquidationData, } from './api/math';
|
|
2
2
|
export { createAssetData, createAssetConfig, parseMasterData, parseUserData, parseUserLiteData } from './api/parser';
|
|
3
|
-
export {
|
|
3
|
+
export { getPrices } from './api/prices';
|
|
4
4
|
export { JettonWallet } from './contracts/JettonWallet';
|
|
5
|
-
export { EvaaParameters,
|
|
5
|
+
export { EvaaParameters, WithdrawParameters, LiquidationBaseData, Evaa, } from './contracts/MasterContract';
|
|
6
6
|
export { EvaaUser } from './contracts/UserContract';
|
|
7
7
|
export { PriceData } from './types/Common';
|
|
8
8
|
export { UpgradeConfig, AssetConfig, MasterConfig, AssetData, AssetInterest, AssetApy, ExtendedAssetData, MasterData, PoolConfig, ExtendedAssetsData, ExtendedAssetsConfig, PoolAssetConfig, PoolAssetsConfig, } from './types/Master';
|
|
9
9
|
export { BalanceType, UserBalance, UserLiqudationData, LiquidableData, NonLiquidableData, LiquidationData, UserDataInactive, UserDataActive, UserData, BalanceChangeType } from './types/User';
|
|
10
10
|
export { EVAA_MASTER_MAINNET, MAINNET_VERSION, EVAA_MASTER_TESTNET, TESTNET_VERSION, LENDING_CODE, OPCODES, FEES, MASTER_CONSTANTS } from './constants/general';
|
|
11
|
-
export { MAINNET_POOL_CONFIG, TESTNET_POOL_CONFIG, MAINNET_LP_POOL_CONFIG,
|
|
12
|
-
export { TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET, JUSDT_MAINNET, JUSDC_MAINNET, STTON_MAINNET, TSTON_MAINNET, JUSDT_TESTNET, JUSDC_TESTNET, STTON_TESTNET, } from './constants/assets';
|
|
11
|
+
export { MAINNET_POOL_CONFIG, TESTNET_POOL_CONFIG, MAINNET_LP_POOL_CONFIG, } from './constants/pools';
|
|
12
|
+
export { UNDEFINED_ASSET, TON_MAINNET, USDT_MAINNET, TONUSDT_DEDUST_MAINNET, TON_STORM_MAINNET, USDT_STORM_MAINNET, JUSDT_MAINNET, JUSDC_MAINNET, STTON_MAINNET, TSTON_MAINNET, JUSDT_TESTNET, JUSDC_TESTNET, STTON_TESTNET, } from './constants/assets';
|
|
13
13
|
export * from './constants/assets';
|
|
14
|
+
export * from './utils/utils';
|
|
14
15
|
export { getLastSentBoc, getTonConnectSender } from './utils/tonConnectSender';
|
|
15
16
|
export { getUserJettonWallet } from './utils/userJettonWallet';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getUserJettonWallet = exports.getTonConnectSender = exports.getLastSentBoc = exports.STTON_TESTNET = exports.JUSDC_TESTNET = exports.JUSDT_TESTNET = exports.TSTON_MAINNET = exports.STTON_MAINNET = exports.JUSDC_MAINNET = exports.JUSDT_MAINNET = exports.USDT_STORM_MAINNET = exports.TON_STORM_MAINNET = exports.TONUSDT_DEDUST_MAINNET = exports.USDT_MAINNET = exports.TON_MAINNET = exports.
|
|
17
|
+
exports.getUserJettonWallet = exports.getTonConnectSender = exports.getLastSentBoc = exports.STTON_TESTNET = exports.JUSDC_TESTNET = exports.JUSDT_TESTNET = exports.TSTON_MAINNET = exports.STTON_MAINNET = exports.JUSDC_MAINNET = exports.JUSDT_MAINNET = exports.USDT_STORM_MAINNET = exports.TON_STORM_MAINNET = exports.TONUSDT_DEDUST_MAINNET = exports.USDT_MAINNET = exports.TON_MAINNET = exports.UNDEFINED_ASSET = exports.MAINNET_LP_POOL_CONFIG = exports.TESTNET_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = exports.MASTER_CONSTANTS = exports.FEES = exports.OPCODES = exports.LENDING_CODE = exports.TESTNET_VERSION = exports.EVAA_MASTER_TESTNET = exports.MAINNET_VERSION = exports.EVAA_MASTER_MAINNET = exports.BalanceChangeType = 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.calculateMaximumWithdrawAmount = exports.getAvailableToBorrow = exports.calculateAssetInterest = exports.calculateAssetData = exports.calculateCurrentRates = exports.calculatePresentValue = exports.bigIntMax = exports.bigIntMin = exports.mulDiv = exports.mulFactor = void 0;
|
|
18
18
|
// Math
|
|
19
19
|
var math_1 = require("./api/math");
|
|
20
20
|
Object.defineProperty(exports, "mulFactor", { enumerable: true, get: function () { return math_1.mulFactor; } });
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "calculateCurrentRates", { enumerable: true, get:
|
|
|
26
26
|
Object.defineProperty(exports, "calculateAssetData", { enumerable: true, get: function () { return math_1.calculateAssetData; } });
|
|
27
27
|
Object.defineProperty(exports, "calculateAssetInterest", { enumerable: true, get: function () { return math_1.calculateAssetInterest; } });
|
|
28
28
|
Object.defineProperty(exports, "getAvailableToBorrow", { enumerable: true, get: function () { return math_1.getAvailableToBorrow; } });
|
|
29
|
+
Object.defineProperty(exports, "calculateMaximumWithdrawAmount", { enumerable: true, get: function () { return math_1.calculateMaximumWithdrawAmount; } });
|
|
29
30
|
Object.defineProperty(exports, "presentValue", { enumerable: true, get: function () { return math_1.presentValue; } });
|
|
30
31
|
Object.defineProperty(exports, "calculateLiquidationData", { enumerable: true, get: function () { return math_1.calculateLiquidationData; } });
|
|
31
32
|
// Parser
|
|
@@ -37,7 +38,7 @@ Object.defineProperty(exports, "parseUserData", { enumerable: true, get: functio
|
|
|
37
38
|
Object.defineProperty(exports, "parseUserLiteData", { enumerable: true, get: function () { return parser_1.parseUserLiteData; } });
|
|
38
39
|
// Prices
|
|
39
40
|
var prices_1 = require("./api/prices");
|
|
40
|
-
Object.defineProperty(exports, "
|
|
41
|
+
Object.defineProperty(exports, "getPrices", { enumerable: true, get: function () { return prices_1.getPrices; } });
|
|
41
42
|
// Contracts' wrappers
|
|
42
43
|
var JettonWallet_1 = require("./contracts/JettonWallet");
|
|
43
44
|
Object.defineProperty(exports, "JettonWallet", { enumerable: true, get: function () { return JettonWallet_1.JettonWallet; } });
|
|
@@ -62,8 +63,8 @@ var pools_1 = require("./constants/pools");
|
|
|
62
63
|
Object.defineProperty(exports, "MAINNET_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_POOL_CONFIG; } });
|
|
63
64
|
Object.defineProperty(exports, "TESTNET_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.TESTNET_POOL_CONFIG; } });
|
|
64
65
|
Object.defineProperty(exports, "MAINNET_LP_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.MAINNET_LP_POOL_CONFIG; } });
|
|
65
|
-
Object.defineProperty(exports, "TESTNET_LP_POOL_CONFIG", { enumerable: true, get: function () { return pools_1.TESTNET_LP_POOL_CONFIG; } });
|
|
66
66
|
var assets_1 = require("./constants/assets");
|
|
67
|
+
Object.defineProperty(exports, "UNDEFINED_ASSET", { enumerable: true, get: function () { return assets_1.UNDEFINED_ASSET; } });
|
|
67
68
|
Object.defineProperty(exports, "TON_MAINNET", { enumerable: true, get: function () { return assets_1.TON_MAINNET; } });
|
|
68
69
|
Object.defineProperty(exports, "USDT_MAINNET", { enumerable: true, get: function () { return assets_1.USDT_MAINNET; } });
|
|
69
70
|
Object.defineProperty(exports, "TONUSDT_DEDUST_MAINNET", { enumerable: true, get: function () { return assets_1.TONUSDT_DEDUST_MAINNET; } });
|
|
@@ -77,6 +78,7 @@ Object.defineProperty(exports, "JUSDT_TESTNET", { enumerable: true, get: functio
|
|
|
77
78
|
Object.defineProperty(exports, "JUSDC_TESTNET", { enumerable: true, get: function () { return assets_1.JUSDC_TESTNET; } });
|
|
78
79
|
Object.defineProperty(exports, "STTON_TESTNET", { enumerable: true, get: function () { return assets_1.STTON_TESTNET; } });
|
|
79
80
|
__exportStar(require("./constants/assets"), exports);
|
|
81
|
+
__exportStar(require("./utils/utils"), exports);
|
|
80
82
|
// Utils
|
|
81
83
|
var tonConnectSender_1 = require("./utils/tonConnectSender");
|
|
82
84
|
Object.defineProperty(exports, "getLastSentBoc", { enumerable: true, get: function () { return tonConnectSender_1.getLastSentBoc; } });
|