@evaafi/sdk 0.9.0-a → 0.9.1
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/feeds.d.ts +15 -24
- package/dist/api/feeds.js +22 -49
- package/dist/api/math.d.ts +1 -1
- package/dist/api/math.js +55 -38
- package/dist/api/parser.d.ts +2 -2
- package/dist/api/parser.js +3 -3
- package/dist/api/parsers/PythOracleParser.d.ts +3 -3
- package/dist/api/parsers/PythOracleParser.js +2 -1
- package/dist/api/prices.js +2 -1
- package/dist/constants/general/index.d.ts +25 -11
- package/dist/constants/general/index.js +15 -1
- package/dist/constants/pools/mainnet.js +20 -18
- package/dist/constants/pools/testnet.js +14 -6
- package/dist/contracts/AbstractMaster.d.ts +239 -127
- package/dist/contracts/AbstractMaster.js +101 -16
- package/dist/contracts/ClassicMaster.d.ts +12 -12
- package/dist/contracts/PythMaster.d.ts +40 -24
- package/dist/contracts/PythMaster.js +61 -76
- package/dist/contracts/PythOracle.d.ts +16 -0
- package/dist/contracts/PythOracle.js +19 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{prices → oracles}/Types.d.ts +0 -4
- package/dist/oracles/collectors/AbstractCollector.d.ts +10 -0
- package/dist/oracles/collectors/AbstractCollector.js +6 -0
- package/dist/oracles/collectors/ClassicCollector.d.ts +22 -0
- package/dist/oracles/collectors/ClassicCollector.js +192 -0
- package/dist/oracles/collectors/PythCollector.d.ts +27 -0
- package/dist/oracles/collectors/PythCollector.js +252 -0
- package/dist/oracles/collectors/index.d.ts +3 -0
- package/dist/oracles/collectors/index.js +19 -0
- package/dist/{prices → oracles}/index.d.ts +2 -3
- package/dist/{prices → oracles}/index.js +2 -3
- package/dist/oracles/prices/AbstractPrices.d.ts +33 -0
- package/dist/oracles/prices/AbstractPrices.js +40 -0
- package/dist/oracles/prices/ClassicPrices.d.ts +19 -0
- package/dist/oracles/prices/ClassicPrices.js +48 -0
- package/dist/oracles/prices/PythPrices.d.ts +18 -0
- package/dist/oracles/prices/PythPrices.js +32 -0
- package/dist/oracles/prices/index.d.ts +3 -0
- package/dist/oracles/prices/index.js +19 -0
- package/dist/{prices → oracles}/utils.d.ts +6 -1
- package/dist/{prices → oracles}/utils.js +10 -1
- package/dist/types/Master.d.ts +4 -5
- package/package.json +2 -3
- package/src/api/feeds.ts +24 -60
- package/src/api/math.ts +118 -90
- package/src/api/parser.ts +5 -5
- package/src/api/parsers/PythOracleParser.ts +6 -2
- package/src/api/prices.ts +2 -1
- package/src/constants/general/index.ts +16 -1
- package/src/constants/pools/mainnet.ts +20 -35
- package/src/constants/pools/testnet.ts +17 -8
- package/src/contracts/AbstractMaster.ts +272 -144
- package/src/contracts/ClassicMaster.ts +12 -12
- package/src/contracts/PythMaster.ts +130 -123
- package/src/contracts/PythOracle.ts +20 -0
- package/src/contracts/index.ts +2 -0
- package/src/index.ts +1 -1
- package/src/{prices → oracles}/Types.ts +0 -5
- package/src/oracles/collectors/AbstractCollector.ts +22 -0
- package/src/oracles/collectors/ClassicCollector.ts +263 -0
- package/src/oracles/collectors/PythCollector.ts +358 -0
- package/src/oracles/collectors/index.ts +3 -0
- package/src/{prices → oracles}/index.ts +2 -3
- package/src/oracles/prices/AbstractPrices.ts +59 -0
- package/src/oracles/prices/ClassicPrices.ts +52 -0
- package/src/oracles/prices/PythPrices.ts +40 -0
- package/src/oracles/prices/index.ts +3 -0
- package/src/{prices → oracles}/utils.ts +12 -1
- package/src/types/Master.ts +4 -6
- package/dist/prices/Oracle.interface.d.ts +0 -9
- package/dist/prices/Oracle.interface.js +0 -2
- package/dist/prices/Prices.d.ts +0 -11
- package/dist/prices/Prices.js +0 -53
- package/dist/prices/PricesCollector.d.ts +0 -22
- package/dist/prices/PricesCollector.js +0 -146
- package/dist/prices/PythCollector.d.ts +0 -22
- package/dist/prices/PythCollector.js +0 -217
- package/src/prices/Oracle.interface.ts +0 -18
- package/src/prices/Prices.ts +0 -45
- package/src/prices/PricesCollector.ts +0 -169
- package/src/prices/PythCollector.ts +0 -294
- /package/dist/{prices → oracles}/Types.js +0 -0
- /package/dist/{prices → oracles}/constants.d.ts +0 -0
- /package/dist/{prices → oracles}/constants.js +0 -0
- /package/dist/{prices → oracles}/sources/Backend.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/Backend.js +0 -0
- /package/dist/{prices → oracles}/sources/Icp.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/Icp.js +0 -0
- /package/dist/{prices → oracles}/sources/PriceSource.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/PriceSource.js +0 -0
- /package/dist/{prices → oracles}/sources/index.d.ts +0 -0
- /package/dist/{prices → oracles}/sources/index.js +0 -0
- /package/src/{prices → oracles}/constants.ts +0 -0
- /package/src/{prices → oracles}/sources/Backend.ts +0 -0
- /package/src/{prices → oracles}/sources/Icp.ts +0 -0
- /package/src/{prices → oracles}/sources/PriceSource.ts +0 -0
- /package/src/{prices → oracles}/sources/index.ts +0 -0
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ALL_MAINNET_POOLS = exports.MAINNET_MASTER_USDT_REWARD_CONFIG = exports.MAINNET_MASTER_TON_REWARD_CONFIG = exports.MAINNET_V8_TOB_POOL_CONFIG = exports.MAINNET_V8_TOB_POOL_ASSETS_CONFIG = exports.MAINNET_PYTH_V8_TOB_POOL_CONFIG = exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG = exports.MAINNET_ALTS_POOL_CONFIG = exports.MAINNET_LP_POOL_CONFIG = exports.MAINNET_STABLE_POOL_CONFIG = exports.MAINNET_POOL_CONFIG = exports.MAINNET_POOL_ASSETS_CONFIG = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const feeds_1 = require("../../api/feeds");
|
|
6
|
-
const
|
|
6
|
+
const oracles_1 = require("../../oracles");
|
|
7
7
|
const assets_1 = require("../assets");
|
|
8
8
|
const general_1 = require("../general");
|
|
9
9
|
// Pool assets configs
|
|
@@ -31,15 +31,16 @@ exports.MAINNET_POOL_CONFIG = {
|
|
|
31
31
|
masterAddress: general_1.EVAA_MASTER_MAINNET,
|
|
32
32
|
masterVersion: general_1.MAINNET_VERSION,
|
|
33
33
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
34
|
-
|
|
35
|
-
pythConfig:
|
|
34
|
+
collector: new oracles_1.PythCollector({
|
|
35
|
+
pythConfig: oracles_1.DefaultPythPriceSourcesConfig,
|
|
36
36
|
poolAssetsConfig: exports.MAINNET_POOL_ASSETS_CONFIG,
|
|
37
37
|
pythOracle: {
|
|
38
|
-
feedsMap:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
feedsMap: new Map([
|
|
39
|
+
[feeds_1.FEED_ID.TON, { assetId: assets_1.ASSET_ID.TON, feedId: '0x0' }],
|
|
40
|
+
[feeds_1.FEED_ID.USDT, { assetId: assets_1.ASSET_ID.USDT, feedId: '0x0' }],
|
|
41
|
+
[feeds_1.FEED_ID.tsTON, { assetId: assets_1.ASSET_ID.tsTON, feedId: feeds_1.FEED_ID.TON }],
|
|
42
|
+
[feeds_1.FEED_ID.tsUSDe, { assetId: assets_1.ASSET_ID.tsUSDe, feedId: feeds_1.FEED_ID.USDT }],
|
|
43
|
+
]),
|
|
43
44
|
pythAddress: general_1.PYTH_ORACLE_MAINNET,
|
|
44
45
|
allowedRefTokens: core_1.Dictionary.empty()
|
|
45
46
|
.set(assets_1.ASSET_ID.jUSDT, assets_1.ASSET_ID.USDT)
|
|
@@ -55,7 +56,7 @@ exports.MAINNET_STABLE_POOL_CONFIG = {
|
|
|
55
56
|
masterAddress: general_1.EVAA_STABLE_MAINNET,
|
|
56
57
|
masterVersion: general_1.STABLE_VERSION,
|
|
57
58
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
58
|
-
|
|
59
|
+
collector: new oracles_1.ClassicCollector({
|
|
59
60
|
poolAssetsConfig: MAINNET_STABLE_POOL_ASSETS_CONFIG,
|
|
60
61
|
minimalOracles: 3,
|
|
61
62
|
evaaOracles: general_1.ORACLES_MAINNET,
|
|
@@ -67,7 +68,7 @@ exports.MAINNET_LP_POOL_CONFIG = {
|
|
|
67
68
|
masterAddress: general_1.EVAA_LP_MAINNET,
|
|
68
69
|
masterVersion: general_1.EVAA_LP_MAINNET_VERSION,
|
|
69
70
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
70
|
-
|
|
71
|
+
collector: new oracles_1.ClassicCollector({
|
|
71
72
|
poolAssetsConfig: MAINNET_LP_POOL_ASSETS_CONFIG,
|
|
72
73
|
minimalOracles: 3,
|
|
73
74
|
evaaOracles: general_1.ORACLES_LP,
|
|
@@ -79,7 +80,7 @@ exports.MAINNET_ALTS_POOL_CONFIG = {
|
|
|
79
80
|
masterAddress: general_1.EVAA_ALTS_MAINNET,
|
|
80
81
|
masterVersion: general_1.EVAA_ALTS_MAINNET_VERSION,
|
|
81
82
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
82
|
-
|
|
83
|
+
collector: new oracles_1.ClassicCollector({
|
|
83
84
|
poolAssetsConfig: MAINNET_ALTS_POOL_ASSETS_CONFIG,
|
|
84
85
|
minimalOracles: 3,
|
|
85
86
|
evaaOracles: general_1.ORACLES_ALTS,
|
|
@@ -92,15 +93,16 @@ exports.MAINNET_PYTH_V8_TOB_POOL_CONFIG = {
|
|
|
92
93
|
masterAddress: general_1.EVAA_PYTH_TOB_MAINNET,
|
|
93
94
|
masterVersion: general_1.EVAA_PYTH_TOB_VERSION,
|
|
94
95
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
95
|
-
|
|
96
|
-
pythConfig:
|
|
96
|
+
collector: new oracles_1.PythCollector({
|
|
97
|
+
pythConfig: oracles_1.DefaultPythPriceSourcesConfig,
|
|
97
98
|
poolAssetsConfig: exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG,
|
|
98
99
|
pythOracle: {
|
|
99
|
-
feedsMap:
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
feedsMap: new Map([
|
|
101
|
+
[feeds_1.FEED_ID.TON, { assetId: assets_1.ASSET_ID.TON, feedId: '0x0' }],
|
|
102
|
+
[feeds_1.FEED_ID.USDT, { assetId: assets_1.ASSET_ID.USDT, feedId: '0x0' }],
|
|
103
|
+
]),
|
|
102
104
|
pythAddress: general_1.PYTH_ORACLE_MAINNET,
|
|
103
|
-
allowedRefTokens: core_1.Dictionary.empty().set(
|
|
105
|
+
allowedRefTokens: core_1.Dictionary.empty().set(assets_1.ASSET_ID.jUSDT, assets_1.ASSET_ID.USDT),
|
|
104
106
|
},
|
|
105
107
|
}),
|
|
106
108
|
poolAssetsConfig: exports.MAINNET_PYTH_V8_TOB_POOL_ASSETS_CONFIG,
|
|
@@ -111,7 +113,7 @@ exports.MAINNET_V8_TOB_POOL_CONFIG = {
|
|
|
111
113
|
masterAddress: general_1.EVAA_TOB_MAINNET,
|
|
112
114
|
masterVersion: general_1.EVAA_TOB_VERSION,
|
|
113
115
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
114
|
-
|
|
116
|
+
collector: new oracles_1.ClassicCollector({
|
|
115
117
|
poolAssetsConfig: exports.MAINNET_V8_TOB_POOL_ASSETS_CONFIG,
|
|
116
118
|
minimalOracles: 3,
|
|
117
119
|
evaaOracles: general_1.ORACLES_MAINNET,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ALL_TESTNET_POOLS = exports.TESTNET_MASTER_EUSDT_REWARD_CONFIG = exports.TESTNET_MASTER_REWARD_CONFIG = exports.TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED = exports.TESTNET_PYTH_POOL_CONFIG_TOB_AUDITED = exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED = exports.TESTNET_POOL_ASSETS_CONFIG = void 0;
|
|
4
4
|
const core_1 = require("@ton/core");
|
|
5
5
|
const feeds_1 = require("../../api/feeds");
|
|
6
|
-
const
|
|
6
|
+
const oracles_1 = require("../../oracles");
|
|
7
7
|
const assets_1 = require("../assets");
|
|
8
8
|
const general_1 = require("../general");
|
|
9
9
|
exports.TESTNET_POOL_ASSETS_CONFIG = [assets_1.TON_TESTNET, assets_1.JUSDC_TESTNET];
|
|
@@ -12,14 +12,22 @@ exports.TESTNET_PYTH_POOL_CONFIG_TOB_AUDITED = {
|
|
|
12
12
|
masterAddress: general_1.EVAA_MASTER_TESTNET_PYTH_TOB_AUDITED,
|
|
13
13
|
masterVersion: general_1.TESTNET_PYTH_VERSION_TOB_AUDITED,
|
|
14
14
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
15
|
-
|
|
15
|
+
collector: new oracles_1.PythCollector({
|
|
16
16
|
poolAssetsConfig: exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED,
|
|
17
17
|
pythOracle: {
|
|
18
|
-
feedsMap:
|
|
18
|
+
feedsMap: new Map([
|
|
19
|
+
[
|
|
20
|
+
feeds_1.FEED_ID.TON,
|
|
21
|
+
{
|
|
22
|
+
assetId: assets_1.ASSET_ID.TON,
|
|
23
|
+
feedId: '0x0',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
]),
|
|
19
27
|
pythAddress: general_1.PYTH_ORACLE_TESTNET,
|
|
20
|
-
allowedRefTokens:
|
|
28
|
+
allowedRefTokens: core_1.Dictionary.empty().set(assets_1.ASSET_ID.jUSDT, assets_1.ASSET_ID.USDT),
|
|
21
29
|
},
|
|
22
|
-
pythConfig:
|
|
30
|
+
pythConfig: oracles_1.DefaultPythPriceSourcesConfig,
|
|
23
31
|
}),
|
|
24
32
|
poolAssetsConfig: exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED,
|
|
25
33
|
lendingCode: general_1.LENDING_CODE,
|
|
@@ -28,7 +36,7 @@ exports.TESTNET_CLASSIC_POOL_CONFIG_TOB_AUDITED = {
|
|
|
28
36
|
masterAddress: general_1.EVAA_MASTER_TESTNET_CLASSIC_TOB_AUDITED,
|
|
29
37
|
masterVersion: general_1.TESTNET_CLASSIC_TOB_AUDITED,
|
|
30
38
|
masterConstants: general_1.MASTER_CONSTANTS,
|
|
31
|
-
|
|
39
|
+
collector: new oracles_1.ClassicCollector({
|
|
32
40
|
poolAssetsConfig: exports.TESTNET_POOL_ASSETS_CONFIG,
|
|
33
41
|
minimalOracles: 3,
|
|
34
42
|
evaaOracles: general_1.ORACLES_TESTNET,
|
|
@@ -6,151 +6,184 @@ import { ExtendedAssetsConfig, ExtendedAssetsData, PoolAssetConfig, PoolConfig,
|
|
|
6
6
|
import { ClassicLiquidationOperationParameters, ClassicLiquidationParameters, ClassicSupplyWithdrawParameters, ClassicWithdrawParameters } from './ClassicMaster';
|
|
7
7
|
import { PythLiquidationOperationParameters, PythLiquidationParameters, PythSupplyWithdrawParameters, PythWithdrawParameters } from './PythMaster';
|
|
8
8
|
import { EvaaUser } from './UserContract';
|
|
9
|
-
|
|
10
|
-
queryID: bigint;
|
|
11
|
-
amount?: bigint;
|
|
12
|
-
liquidationAmount?: bigint;
|
|
13
|
-
supplyAmount?: bigint;
|
|
14
|
-
responseAddress?: Address;
|
|
15
|
-
userAddress?: Address;
|
|
16
|
-
liquidatorAddress?: Address;
|
|
17
|
-
forwardAmount?: bigint;
|
|
18
|
-
destinationAddress?: Address;
|
|
19
|
-
}
|
|
9
|
+
export interface JettonParams {
|
|
10
|
+
readonly queryID: bigint;
|
|
11
|
+
readonly amount?: bigint;
|
|
12
|
+
readonly liquidationAmount?: bigint;
|
|
13
|
+
readonly supplyAmount?: bigint;
|
|
14
|
+
readonly responseAddress?: Address;
|
|
15
|
+
readonly userAddress?: Address;
|
|
16
|
+
readonly liquidatorAddress?: Address;
|
|
17
|
+
readonly forwardAmount?: bigint;
|
|
18
|
+
readonly destinationAddress?: Address;
|
|
19
|
+
}
|
|
20
|
+
type RequireAtLeastOne<T, K extends keyof T> = T & {
|
|
21
|
+
[P in K]: Required<T>[P];
|
|
22
|
+
}[K];
|
|
23
|
+
export type ValidJettonParams = RequireAtLeastOne<JettonParams, 'amount' | 'liquidationAmount' | 'supplyAmount'>;
|
|
20
24
|
/**
|
|
21
|
-
* Parameters for
|
|
22
|
-
* @
|
|
23
|
-
* @property debug - true to enable debug mode (optional)
|
|
25
|
+
* Parameters for initializing an Evaa contract instance
|
|
26
|
+
* @interface EvaaParameters
|
|
24
27
|
*/
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
export interface EvaaParameters {
|
|
29
|
+
/** Pool configuration containing contract addresses and settings */
|
|
30
|
+
readonly poolConfig: PoolConfig;
|
|
31
|
+
/** Optional debug mode flag for development purposes */
|
|
32
|
+
readonly debug?: boolean;
|
|
33
|
+
}
|
|
29
34
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
32
|
-
* @property includeUserCode - true to include user code for update (needed when user contract code version is outdated)
|
|
33
|
-
* @property amount - amount to supply
|
|
34
|
-
* @property userAddress - user address
|
|
35
|
-
* @property asset
|
|
35
|
+
* Parameters for supply operations
|
|
36
|
+
* @interface SupplyParameters
|
|
36
37
|
*/
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
export interface SupplyParameters {
|
|
39
|
+
/** Asset configuration for the supply operation */
|
|
40
|
+
readonly asset: PoolAssetConfig;
|
|
41
|
+
/** Unique identifier for this operation */
|
|
42
|
+
readonly queryID: bigint;
|
|
43
|
+
/** Whether to include user contract code update */
|
|
44
|
+
readonly includeUserCode: boolean;
|
|
45
|
+
/** Amount to supply (must be positive) */
|
|
46
|
+
readonly amount: bigint;
|
|
47
|
+
/** Address of the user performing the supply */
|
|
48
|
+
readonly userAddress: Address;
|
|
49
|
+
/** Optional address for operation response */
|
|
50
|
+
readonly responseAddress?: Address;
|
|
51
|
+
/** Optional forward amount for transaction fees */
|
|
52
|
+
readonly forwardAmount?: bigint;
|
|
53
|
+
/** Operation payload cell */
|
|
54
|
+
readonly payload: Cell;
|
|
55
|
+
/** Optional subaccount identifier (0-255) */
|
|
56
|
+
readonly subaccountId?: number;
|
|
57
|
+
/** Whether to return repay remainings */
|
|
58
|
+
readonly returnRepayRemainingsFlag?: boolean;
|
|
59
|
+
/** Optional custom payload recipient address */
|
|
60
|
+
readonly customPayloadRecipient?: Address;
|
|
61
|
+
/** Whether to saturate custom payload */
|
|
62
|
+
readonly customPayloadSaturationFlag?: boolean;
|
|
63
|
+
}
|
|
51
64
|
/**
|
|
52
|
-
* Parameters for
|
|
53
|
-
* @
|
|
54
|
-
* @property asset - asset config
|
|
55
|
-
* @property amount - amount to withdraw
|
|
56
|
-
* @property userAddress - user address
|
|
57
|
-
* @property includeUserCode - true to include user code for update (needed when user contract code version is outdated)
|
|
65
|
+
* Parameters for withdraw operations
|
|
66
|
+
* @interface WithdrawParameters
|
|
58
67
|
*/
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
export interface WithdrawParameters {
|
|
69
|
+
/** Unique identifier for this operation */
|
|
70
|
+
readonly queryID: bigint;
|
|
71
|
+
/** Amount to withdraw (must be positive) */
|
|
72
|
+
readonly amount: bigint;
|
|
73
|
+
/** Address of the user performing the withdrawal */
|
|
74
|
+
readonly userAddress: Address;
|
|
75
|
+
/** Whether to include user contract code update */
|
|
76
|
+
readonly includeUserCode: boolean;
|
|
77
|
+
/** Asset configuration for the withdrawal */
|
|
78
|
+
readonly asset: PoolAssetConfig;
|
|
79
|
+
/** Operation payload cell */
|
|
80
|
+
readonly payload: Cell;
|
|
81
|
+
/** Optional subaccount identifier (0-255) */
|
|
82
|
+
readonly subaccountId?: number;
|
|
83
|
+
/** Optional forward amount for transaction fees */
|
|
84
|
+
readonly forwardAmount?: bigint;
|
|
85
|
+
/** Actual amount to transfer after calculations */
|
|
86
|
+
readonly amountToTransfer: bigint;
|
|
87
|
+
/** Whether to saturate custom payload */
|
|
88
|
+
readonly customPayloadSaturationFlag: boolean;
|
|
89
|
+
/** Whether to return repay remainings */
|
|
90
|
+
readonly returnRepayRemainingsFlag: boolean;
|
|
91
|
+
}
|
|
72
92
|
/**
|
|
73
93
|
* Parameters for liquidation inner operations
|
|
74
94
|
* @interface LiquidationInnerParameters
|
|
75
95
|
*/
|
|
76
|
-
export
|
|
96
|
+
export interface LiquidationInnerParameters {
|
|
77
97
|
/** Liquidation operation payload cell */
|
|
78
|
-
payload: Cell;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
98
|
+
readonly payload: Cell;
|
|
99
|
+
/** Subaccount identifier for the operation */
|
|
100
|
+
readonly subaccountId: number;
|
|
101
|
+
/** Address to receive custom payload */
|
|
102
|
+
readonly customPayloadRecipient: Address;
|
|
103
|
+
/** Whether to saturate the custom payload */
|
|
104
|
+
readonly customPayloadSaturationFlag: boolean;
|
|
105
|
+
}
|
|
83
106
|
/**
|
|
84
|
-
* Base
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
87
|
-
* @property liquidatorAddress - liquidator address, where and collateral will be sent
|
|
107
|
+
* Base parameters for liquidation operations
|
|
108
|
+
* @interface LiquidationParameters
|
|
109
|
+
* @description Can be obtained from the user contract liquidationParameters getter
|
|
88
110
|
*/
|
|
89
|
-
export
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
export interface LiquidationParameters {
|
|
112
|
+
/** Asset ID of the loan being liquidated */
|
|
113
|
+
readonly loanAsset: bigint;
|
|
114
|
+
/** Unique identifier for this operation */
|
|
115
|
+
readonly queryID: bigint;
|
|
116
|
+
/** Address where collateral will be sent upon liquidation */
|
|
117
|
+
readonly liquidatorAddress: Address;
|
|
118
|
+
}
|
|
94
119
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
97
|
-
* @property collateralAsset - collateral asset ID
|
|
98
|
-
* @property minCollateralAmount - minimal amount to receive from the liquidation
|
|
99
|
-
* @property liquidationAmount - amount to liquidate
|
|
100
|
-
* @property includeUserCode - true to include user code for update (needed when user contract code version is outdated)
|
|
120
|
+
* Parameters for building liquidation operations
|
|
121
|
+
* @interface LiquidationOperationBuilderParameters
|
|
101
122
|
*/
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
123
|
+
export interface LiquidationOperationBuilderParameters {
|
|
124
|
+
/** Asset configuration for the liquidation */
|
|
125
|
+
readonly asset: PoolAssetConfig;
|
|
126
|
+
/** Address of the borrower being liquidated */
|
|
127
|
+
readonly borrowerAddress: Address;
|
|
128
|
+
/** Asset ID of the collateral to be seized */
|
|
129
|
+
readonly collateralAsset: bigint;
|
|
130
|
+
/** Minimum collateral amount expected from liquidation */
|
|
131
|
+
readonly minCollateralAmount: bigint;
|
|
132
|
+
/** Amount of debt to liquidate */
|
|
133
|
+
readonly liquidationAmount: bigint;
|
|
134
|
+
/** Whether to include user contract code update */
|
|
135
|
+
readonly includeUserCode: boolean;
|
|
136
|
+
}
|
|
137
|
+
export interface SupplyWithdrawParameters {
|
|
138
|
+
readonly queryID: bigint;
|
|
139
|
+
readonly supplyAmount: bigint;
|
|
140
|
+
readonly supplyAsset: PoolAssetConfig;
|
|
141
|
+
readonly withdrawAmount: bigint;
|
|
142
|
+
readonly withdrawAsset: PoolAssetConfig;
|
|
143
|
+
readonly withdrawRecipient: Address;
|
|
144
|
+
readonly includeUserCode: boolean;
|
|
145
|
+
readonly tonForRepayRemainings?: bigint;
|
|
146
|
+
readonly payload: Cell;
|
|
147
|
+
readonly subaccountId?: number;
|
|
148
|
+
readonly returnRepayRemainingsFlag?: boolean;
|
|
149
|
+
readonly customPayloadSaturationFlag?: boolean;
|
|
150
|
+
readonly forwardAmount?: bigint;
|
|
151
|
+
readonly responseAddress?: Address;
|
|
152
|
+
}
|
|
153
|
+
export interface BaseMasterConfig {
|
|
154
|
+
readonly ifActive: number;
|
|
155
|
+
readonly admin: Address;
|
|
156
|
+
readonly tokenKeys: Cell | null;
|
|
157
|
+
readonly supervisor: Address | null;
|
|
158
|
+
}
|
|
132
159
|
export type OracleInfo = PythOracleInfo | ClassicOracleInfo;
|
|
133
|
-
export
|
|
134
|
-
oraclesInfo: T;
|
|
135
|
-
}
|
|
136
|
-
export
|
|
137
|
-
meta: string;
|
|
138
|
-
upgradeConfig: UpgradeConfig;
|
|
139
|
-
assetsConfig: ExtendedAssetsConfig;
|
|
140
|
-
assetsData: ExtendedAssetsData;
|
|
141
|
-
assetsReserves: Dictionary<bigint, bigint>;
|
|
142
|
-
apy: {
|
|
143
|
-
supply: Dictionary<bigint, number>;
|
|
144
|
-
borrow: Dictionary<bigint, number>;
|
|
160
|
+
export interface MasterConfig<T extends OracleInfo> extends BaseMasterConfig {
|
|
161
|
+
readonly oraclesInfo: T;
|
|
162
|
+
}
|
|
163
|
+
export interface BaseMasterData {
|
|
164
|
+
readonly meta: string;
|
|
165
|
+
readonly upgradeConfig: UpgradeConfig;
|
|
166
|
+
readonly assetsConfig: ExtendedAssetsConfig;
|
|
167
|
+
readonly assetsData: ExtendedAssetsData;
|
|
168
|
+
readonly assetsReserves: Dictionary<bigint, bigint>;
|
|
169
|
+
readonly apy: {
|
|
170
|
+
readonly supply: Dictionary<bigint, number>;
|
|
171
|
+
readonly borrow: Dictionary<bigint, number>;
|
|
145
172
|
};
|
|
146
|
-
}
|
|
147
|
-
export
|
|
148
|
-
masterConfig: T;
|
|
149
|
-
}
|
|
173
|
+
}
|
|
174
|
+
export interface MasterData<T extends MasterConfig<OracleInfo>> extends BaseMasterData {
|
|
175
|
+
readonly masterConfig: T;
|
|
176
|
+
}
|
|
150
177
|
/**
|
|
151
|
-
* Abstract
|
|
152
|
-
*
|
|
153
|
-
*
|
|
178
|
+
* Abstract base class for EVAA Master contracts
|
|
179
|
+
*
|
|
180
|
+
* This class provides shared functionality for both Classic and Pyth master implementations,
|
|
181
|
+
* including message creation, validation, and transaction handling. Concrete implementations
|
|
182
|
+
* must override oracle-specific methods for withdraw/liquidation operations.
|
|
183
|
+
*
|
|
184
|
+
* @template T - Master data type extending MasterData with specific oracle configuration
|
|
185
|
+
* @abstract
|
|
186
|
+
* @implements {Contract}
|
|
154
187
|
*/
|
|
155
188
|
export declare abstract class AbstractEvaaMaster<T extends MasterData<MasterConfig<OracleInfo>>> implements Contract {
|
|
156
189
|
readonly address: Address;
|
|
@@ -158,14 +191,79 @@ export declare abstract class AbstractEvaaMaster<T extends MasterData<MasterConf
|
|
|
158
191
|
protected readonly debug?: boolean;
|
|
159
192
|
protected _data?: T;
|
|
160
193
|
protected lastSync: number;
|
|
194
|
+
/**
|
|
195
|
+
* Initialize the abstract master contract
|
|
196
|
+
* @param parameters - Configuration parameters for the Evaa master
|
|
197
|
+
*/
|
|
161
198
|
constructor(parameters: EvaaParameters);
|
|
199
|
+
/**
|
|
200
|
+
* Get the current pool configuration
|
|
201
|
+
* @returns {PoolConfig} The pool configuration object
|
|
202
|
+
*/
|
|
162
203
|
get poolConfig(): PoolConfig;
|
|
204
|
+
/**
|
|
205
|
+
* Get the synchronized master data
|
|
206
|
+
* @returns {T | undefined} Master data if available, undefined otherwise
|
|
207
|
+
*/
|
|
163
208
|
get data(): T | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Validates jetton parameters ensuring at least one amount field is provided
|
|
211
|
+
* @private
|
|
212
|
+
* @static
|
|
213
|
+
* @param parameters - Jetton parameters to validate
|
|
214
|
+
* @returns {ValidJettonParams} Validated parameters
|
|
215
|
+
* @throws {Error} When no amount fields are provided
|
|
216
|
+
*/
|
|
217
|
+
private static validateJettonParams;
|
|
218
|
+
/**
|
|
219
|
+
* Creates a jetton transfer message with the provided parameters
|
|
220
|
+
* @protected
|
|
221
|
+
* @param parameters - Jetton transfer parameters
|
|
222
|
+
* @param defaultFees - Default fee amount for the operation
|
|
223
|
+
* @param message - Operation message cell to include
|
|
224
|
+
* @returns {Cell} Complete jetton transfer message cell
|
|
225
|
+
* @throws {Error} When validation fails or required addresses are missing
|
|
226
|
+
*/
|
|
164
227
|
protected createJettonTransferMessage(parameters: JettonParams, defaultFees: bigint, message: Cell): Cell;
|
|
228
|
+
/**
|
|
229
|
+
* Builds general data payload for supply-withdraw operations
|
|
230
|
+
* @abstract
|
|
231
|
+
* @param parameters - Supply-withdraw parameters (oracle-specific)
|
|
232
|
+
* @returns {Cell} General data payload cell
|
|
233
|
+
*/
|
|
165
234
|
abstract buildGeneralDataPayload(parameters: PythSupplyWithdrawParameters | ClassicSupplyWithdrawParameters): Cell;
|
|
166
235
|
protected buildSupplyWithdrawOperationPayload(parameters: PythSupplyWithdrawParameters | ClassicSupplyWithdrawParameters): Cell;
|
|
236
|
+
/**
|
|
237
|
+
* Validates supply operation parameters
|
|
238
|
+
* @private
|
|
239
|
+
* @static
|
|
240
|
+
* @param parameters - Supply parameters to validate
|
|
241
|
+
* @throws {Error} When amount is invalid or subaccount ID is out of range
|
|
242
|
+
*/
|
|
243
|
+
private static validateSupplyParameters;
|
|
244
|
+
/**
|
|
245
|
+
* Creates a supply operation message
|
|
246
|
+
* @param parameters - Supply operation parameters
|
|
247
|
+
* @returns {Cell} Complete supply message cell
|
|
248
|
+
* @throws {Error} When validation fails
|
|
249
|
+
*/
|
|
167
250
|
createSupplyMessage(parameters: SupplyParameters): Cell;
|
|
251
|
+
/**
|
|
252
|
+
* Creates a supply-withdraw operation message
|
|
253
|
+
* @abstract
|
|
254
|
+
* @param parameters - Oracle-specific supply-withdraw parameters
|
|
255
|
+
* @returns {Cell} Complete supply-withdraw message cell
|
|
256
|
+
* @remarks Concrete classes must wrap the operation payload correctly for their oracle
|
|
257
|
+
*/
|
|
168
258
|
abstract createSupplyWithdrawMessage(parameters: ClassicSupplyWithdrawParameters | PythSupplyWithdrawParameters): Cell;
|
|
259
|
+
/**
|
|
260
|
+
* Sends a supply operation to the master contract
|
|
261
|
+
* @param provider - Contract provider instance
|
|
262
|
+
* @param via - Sender instance
|
|
263
|
+
* @param value - Transaction value in nanoTON
|
|
264
|
+
* @param parameters - Supply operation parameters
|
|
265
|
+
* @throws {Error} When validation fails or transaction fails
|
|
266
|
+
*/
|
|
169
267
|
sendSupply(provider: ContractProvider, via: Sender, value: bigint, parameters: SupplyParameters): Promise<void>;
|
|
170
268
|
sendSupplyWithdraw(provider: ContractProvider, via: Sender, value: bigint, parameters: ClassicSupplyWithdrawParameters | PythSupplyWithdrawParameters): Promise<void>;
|
|
171
269
|
abstract sendWithdraw(provider: ContractProvider, via: Sender, value: bigint, parameters: ClassicWithdrawParameters | PythWithdrawParameters): Promise<void>;
|
|
@@ -174,7 +272,21 @@ export declare abstract class AbstractEvaaMaster<T extends MasterData<MasterConf
|
|
|
174
272
|
protected abstract buildLiquidationOperationPayload(parameters: PythLiquidationOperationParameters | ClassicLiquidationOperationParameters): Cell | Builder;
|
|
175
273
|
protected buildLiquidationOperationPayloadBuilder(parameters: LiquidationOperationBuilderParameters): Builder;
|
|
176
274
|
abstract sendLiquidation(provider: ContractProvider, via: Sender, value: bigint, parameters: ClassicLiquidationParameters | PythLiquidationParameters): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Calculates the user smart contract address for a given user and subaccount
|
|
277
|
+
* @param userAddress - The user's wallet address
|
|
278
|
+
* @param lendingCode - The user contract code cell
|
|
279
|
+
* @param subaccountId - Optional subaccount identifier (default: 0)
|
|
280
|
+
* @returns {Address} The calculated user contract address
|
|
281
|
+
* @throws {Error} When subaccount ID is invalid
|
|
282
|
+
*/
|
|
177
283
|
calculateUserSCAddr(userAddress: Address, lendingCode: Cell, subaccountId?: number): Address;
|
|
284
|
+
/**
|
|
285
|
+
* Creates a user contract instance for the given address and subaccount
|
|
286
|
+
* @param userAddress - The user's wallet address
|
|
287
|
+
* @param subaccountId - Optional subaccount identifier (default: 0)
|
|
288
|
+
* @returns {EvaaUser} User contract instance
|
|
289
|
+
*/
|
|
178
290
|
openUserContract(userAddress: Address, subaccountId?: number): EvaaUser;
|
|
179
291
|
getOpenedUserContract(provider: ContractProvider, userAddress: Address, subaccountId?: number): OpenedContract<EvaaUser>;
|
|
180
292
|
sendOnchainGetter(provider: ContractProvider, via: Sender, value: bigint, queryID: bigint, forwardPayload: Cell): Promise<void>;
|