@evaafi/sdk 0.9.0 → 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.
Files changed (117) hide show
  1. package/dist/api/feeds.d.ts +16 -24
  2. package/dist/api/feeds.js +22 -49
  3. package/dist/api/math.d.ts +1 -1
  4. package/dist/api/math.js +55 -38
  5. package/dist/api/parser.d.ts +2 -2
  6. package/dist/api/parser.js +3 -3
  7. package/dist/api/parsers/PythOracleParser.d.ts +3 -2
  8. package/dist/api/parsers/PythOracleParser.js +2 -1
  9. package/dist/api/prices.d.ts +1 -0
  10. package/dist/api/prices.js +2 -1
  11. package/dist/constants/general/index.d.ts +25 -11
  12. package/dist/constants/general/index.js +15 -1
  13. package/dist/constants/pools/mainnet.js +20 -18
  14. package/dist/constants/pools/testnet.js +14 -6
  15. package/dist/contracts/AbstractMaster.d.ts +239 -127
  16. package/dist/contracts/AbstractMaster.js +101 -16
  17. package/dist/contracts/ClassicMaster.d.ts +12 -12
  18. package/dist/contracts/PythMaster.d.ts +41 -24
  19. package/dist/contracts/PythMaster.js +61 -76
  20. package/dist/contracts/PythOracle.d.ts +16 -0
  21. package/dist/contracts/PythOracle.js +19 -0
  22. package/dist/contracts/index.d.ts +1 -0
  23. package/dist/contracts/index.js +1 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/{prices → oracles}/Types.d.ts +1 -4
  27. package/dist/oracles/collectors/AbstractCollector.d.ts +10 -0
  28. package/dist/oracles/collectors/AbstractCollector.js +6 -0
  29. package/dist/oracles/collectors/ClassicCollector.d.ts +22 -0
  30. package/dist/oracles/collectors/ClassicCollector.js +192 -0
  31. package/dist/oracles/collectors/PythCollector.d.ts +27 -0
  32. package/dist/oracles/collectors/PythCollector.js +252 -0
  33. package/dist/oracles/collectors/index.d.ts +3 -0
  34. package/dist/oracles/collectors/index.js +19 -0
  35. package/dist/{prices → oracles}/index.d.ts +2 -3
  36. package/dist/{prices → oracles}/index.js +2 -3
  37. package/dist/oracles/prices/AbstractPrices.d.ts +33 -0
  38. package/dist/oracles/prices/AbstractPrices.js +40 -0
  39. package/dist/oracles/prices/ClassicPrices.d.ts +19 -0
  40. package/dist/oracles/prices/ClassicPrices.js +48 -0
  41. package/dist/oracles/prices/PythPrices.d.ts +18 -0
  42. package/dist/oracles/prices/PythPrices.js +32 -0
  43. package/dist/oracles/prices/index.d.ts +3 -0
  44. package/dist/oracles/prices/index.js +19 -0
  45. package/dist/{prices → oracles}/utils.d.ts +7 -1
  46. package/dist/{prices → oracles}/utils.js +10 -1
  47. package/dist/rewards/RewardMaster.d.ts +1 -0
  48. package/dist/rewards/RewardUser.d.ts +1 -0
  49. package/dist/types/Master.d.ts +5 -5
  50. package/dist/types/MasterRewards.d.ts +1 -0
  51. package/dist/types/UserRewards.d.ts +1 -0
  52. package/dist/utils/sha256BigInt.d.ts +1 -0
  53. package/package.json +2 -3
  54. package/src/api/feeds.ts +24 -60
  55. package/src/api/math.ts +118 -90
  56. package/src/api/parser.ts +5 -5
  57. package/src/api/parsers/PythOracleParser.ts +6 -2
  58. package/src/api/prices.ts +2 -1
  59. package/src/constants/general/index.ts +16 -1
  60. package/src/constants/pools/mainnet.ts +20 -35
  61. package/src/constants/pools/testnet.ts +17 -8
  62. package/src/contracts/AbstractMaster.ts +272 -144
  63. package/src/contracts/ClassicMaster.ts +12 -12
  64. package/src/contracts/PythMaster.ts +130 -123
  65. package/src/contracts/PythOracle.ts +20 -0
  66. package/src/contracts/index.ts +2 -0
  67. package/src/index.ts +1 -1
  68. package/src/{prices → oracles}/Types.ts +0 -5
  69. package/src/oracles/collectors/AbstractCollector.ts +22 -0
  70. package/src/oracles/collectors/ClassicCollector.ts +263 -0
  71. package/src/oracles/collectors/PythCollector.ts +358 -0
  72. package/src/oracles/collectors/index.ts +3 -0
  73. package/src/{prices → oracles}/index.ts +2 -3
  74. package/src/oracles/prices/AbstractPrices.ts +59 -0
  75. package/src/oracles/prices/ClassicPrices.ts +52 -0
  76. package/src/oracles/prices/PythPrices.ts +40 -0
  77. package/src/oracles/prices/index.ts +3 -0
  78. package/src/{prices → oracles}/utils.ts +12 -1
  79. package/src/types/Master.ts +4 -6
  80. package/dist/api/pyth.d.ts +0 -16
  81. package/dist/api/pyth.js +0 -35
  82. package/dist/constants/assets.d.ts +0 -48
  83. package/dist/constants/assets.js +0 -176
  84. package/dist/constants/general.d.ts +0 -67
  85. package/dist/constants/general.js +0 -75
  86. package/dist/constants/pools.d.ts +0 -13
  87. package/dist/constants/pools.js +0 -120
  88. package/dist/contracts/MasterContract.d.ts +0 -156
  89. package/dist/contracts/MasterContract.js +0 -260
  90. package/dist/prices/Oracle.interface.d.ts +0 -9
  91. package/dist/prices/Oracle.interface.js +0 -2
  92. package/dist/prices/Prices.d.ts +0 -11
  93. package/dist/prices/Prices.js +0 -53
  94. package/dist/prices/PricesCollector.d.ts +0 -22
  95. package/dist/prices/PricesCollector.js +0 -146
  96. package/dist/prices/PythCollector.d.ts +0 -22
  97. package/dist/prices/PythCollector.js +0 -217
  98. package/src/prices/Oracle.interface.ts +0 -18
  99. package/src/prices/Prices.ts +0 -45
  100. package/src/prices/PricesCollector.ts +0 -169
  101. package/src/prices/PythCollector.ts +0 -294
  102. /package/dist/{prices → oracles}/Types.js +0 -0
  103. /package/dist/{prices → oracles}/constants.d.ts +0 -0
  104. /package/dist/{prices → oracles}/constants.js +0 -0
  105. /package/dist/{prices → oracles}/sources/Backend.d.ts +0 -0
  106. /package/dist/{prices → oracles}/sources/Backend.js +0 -0
  107. /package/dist/{prices → oracles}/sources/Icp.d.ts +0 -0
  108. /package/dist/{prices → oracles}/sources/Icp.js +0 -0
  109. /package/dist/{prices → oracles}/sources/PriceSource.d.ts +0 -0
  110. /package/dist/{prices → oracles}/sources/PriceSource.js +0 -0
  111. /package/dist/{prices → oracles}/sources/index.d.ts +0 -0
  112. /package/dist/{prices → oracles}/sources/index.js +0 -0
  113. /package/src/{prices → oracles}/constants.ts +0 -0
  114. /package/src/{prices → oracles}/sources/Backend.ts +0 -0
  115. /package/src/{prices → oracles}/sources/Icp.ts +0 -0
  116. /package/src/{prices → oracles}/sources/PriceSource.ts +0 -0
  117. /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 prices_1 = require("../../prices");
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
- oracles: new prices_1.PythCollector({
35
- pythConfig: prices_1.DefaultPythPriceSourcesConfig,
34
+ collector: new oracles_1.PythCollector({
35
+ pythConfig: oracles_1.DefaultPythPriceSourcesConfig,
36
36
  poolAssetsConfig: exports.MAINNET_POOL_ASSETS_CONFIG,
37
37
  pythOracle: {
38
- feedsMap: core_1.Dictionary.empty()
39
- .set(BigInt(feeds_1.PYTH_TON_PRICE_FEED_ID), (0, feeds_1.packConnectedFeeds)(assets_1.ASSET_ID.TON, 0n))
40
- .set(BigInt(feeds_1.PYTH_USDT_PRICE_FEED_ID), (0, feeds_1.packConnectedFeeds)(assets_1.ASSET_ID.USDT, 0n))
41
- .set(BigInt(feeds_1.PYTH_TSTON_PRICE_FEED_ID), (0, feeds_1.packConnectedFeeds)(feeds_1.EVAA_TSTON_PRICE_FEED_ID, BigInt(feeds_1.PYTH_TON_PRICE_FEED_ID)))
42
- .set(BigInt(feeds_1.PYTH_TSUSDE_PRICE_FEED_ID), (0, feeds_1.packConnectedFeeds)(feeds_1.EVAA_TSUSDE_PRICE_FEED_ID, BigInt(feeds_1.PYTH_USDT_PRICE_FEED_ID))),
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
- oracles: new prices_1.PricesCollector({
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
- oracles: new prices_1.PricesCollector({
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
- oracles: new prices_1.PricesCollector({
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
- oracles: new prices_1.PythCollector({
96
- pythConfig: prices_1.DefaultPythPriceSourcesConfig,
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: core_1.Dictionary.empty()
100
- .set(BigInt(feeds_1.PYTH_TON_PRICE_FEED_ID), (0, feeds_1.packConnectedFeeds)(assets_1.ASSET_ID.TON, 0n))
101
- .set(BigInt(feeds_1.PYTH_USDT_PRICE_FEED_ID), (0, feeds_1.packConnectedFeeds)(assets_1.ASSET_ID.USDT, 0n)),
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(BigInt(feeds_1.EVAA_JUSDT_PRICE_FEED_ID), BigInt(assets_1.ASSET_ID.USDT)),
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
- oracles: new prices_1.PricesCollector({
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 prices_1 = require("../../prices");
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
- oracles: new prices_1.PythCollector({
15
+ collector: new oracles_1.PythCollector({
16
16
  poolAssetsConfig: exports.TESTNET_POOL_ASSETS_CONFIG_TOB_AUDITED,
17
17
  pythOracle: {
18
- feedsMap: feeds_1.TESTNET_FEEDS_MAP,
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: feeds_1.TESTNET_ALLOWED_REF_TOKENS,
28
+ allowedRefTokens: core_1.Dictionary.empty().set(assets_1.ASSET_ID.jUSDT, assets_1.ASSET_ID.USDT),
21
29
  },
22
- pythConfig: prices_1.DefaultPythPriceSourcesConfig,
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
- oracles: new prices_1.PricesCollector({
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
- type JettonParams = {
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 the Evaa contract
22
- * @property testnet - true for testnet, false for mainnet
23
- * @property debug - true to enable debug mode (optional)
25
+ * Parameters for initializing an Evaa contract instance
26
+ * @interface EvaaParameters
24
27
  */
25
- export type EvaaParameters = {
26
- poolConfig: PoolConfig;
27
- debug?: boolean;
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
- * Base parameters for supply
31
- * @property queryID - unique query ID
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 type SupplyParameters = {
38
- asset: PoolAssetConfig;
39
- queryID: bigint;
40
- includeUserCode: boolean;
41
- amount: bigint;
42
- userAddress: Address;
43
- responseAddress?: Address;
44
- forwardAmount?: bigint;
45
- payload: Cell;
46
- subaccountId?: number;
47
- returnRepayRemainingsFlag?: boolean;
48
- customPayloadRecipient?: Address;
49
- customPayloadSaturationFlag?: boolean;
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 the withdraw message
53
- * @property queryID - unique query ID
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 type WithdrawParameters = {
60
- queryID: bigint;
61
- amount: bigint;
62
- userAddress: Address;
63
- includeUserCode: boolean;
64
- asset: PoolAssetConfig;
65
- payload: Cell;
66
- subaccountId?: number;
67
- forwardAmount?: bigint;
68
- amountToTransfer: bigint;
69
- customPayloadSaturationFlag: boolean;
70
- returnRepayRemainingsFlag: boolean;
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 type LiquidationInnerParameters = {
96
+ export interface LiquidationInnerParameters {
77
97
  /** Liquidation operation payload cell */
78
- payload: Cell;
79
- subaccountId: number;
80
- customPayloadRecipient: Address;
81
- customPayloadSaturationFlag: boolean;
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 data for liquidation. Can be obtained from the user contract liquidationParameters getter
85
- * @property loanAsset - loan asset ID
86
- * @property queryID - unique query ID
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 type LiquidationParameters = {
90
- loanAsset: bigint;
91
- queryID: bigint;
92
- liquidatorAddress: Address;
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
- * @property asset - asset config
96
- * @property borrowerAddress - borrower address (user address that is being liquidated)
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 type LiquidationOperationBuilderParameters = {
103
- asset: PoolAssetConfig;
104
- borrowerAddress: Address;
105
- collateralAsset: bigint;
106
- minCollateralAmount: bigint;
107
- liquidationAmount: bigint;
108
- includeUserCode: boolean;
109
- };
110
- export type SupplyWithdrawParameters = {
111
- queryID: bigint;
112
- supplyAmount: bigint;
113
- supplyAsset: PoolAssetConfig;
114
- withdrawAmount: bigint;
115
- withdrawAsset: PoolAssetConfig;
116
- withdrawRecipient: Address;
117
- includeUserCode: boolean;
118
- tonForRepayRemainings?: bigint;
119
- payload: Cell;
120
- subaccountId?: number;
121
- returnRepayRemainingsFlag?: boolean;
122
- customPayloadSaturationFlag?: boolean;
123
- forwardAmount?: bigint;
124
- responseAddress?: Address;
125
- };
126
- export type BaseMasterConfig = {
127
- ifActive: number;
128
- admin: Address;
129
- tokenKeys: Cell | null;
130
- supervisor: Address | null;
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 type MasterConfig<T extends OracleInfo> = BaseMasterConfig & {
134
- oraclesInfo: T;
135
- };
136
- export type BaseMasterData = {
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 type MasterData<T extends MasterConfig<OracleInfo>> = BaseMasterData & {
148
- masterConfig: T;
149
- };
173
+ }
174
+ export interface MasterData<T extends MasterConfig<OracleInfo>> extends BaseMasterData {
175
+ readonly masterConfig: T;
176
+ }
150
177
  /**
151
- * Abstract EVAA Master base that encapsulates shared logic and structure.
152
- * Concrete implementations (Classic/Pyth) should override message creation for
153
- * withdraw/liquidation and supply-withdraw wrapping.
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>;