impermax-sdk 1.2.112 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/lib/abis/ImpermaxABI.d.ts +2 -2
  2. package/lib/abis/ImpermaxABI.js +3 -3
  3. package/lib/abis/contracts/ClaimAggregator.json +2015 -2015
  4. package/lib/abis/contracts/IAllowanceTransfer.json +3772 -0
  5. package/lib/abis/contracts/IBorrowable.json +13207 -13207
  6. package/lib/abis/contracts/IClaimable.json +406 -406
  7. package/lib/abis/contracts/ICollateral.json +9052 -9052
  8. package/lib/abis/contracts/IERC20.json +2376 -2376
  9. package/lib/abis/contracts/IERC721.json +3515 -0
  10. package/lib/abis/contracts/IFactory.json +3660 -3660
  11. package/lib/abis/contracts/IFarmingPool.json +3584 -3584
  12. package/lib/abis/contracts/ILendingVaultV1.json +8358 -8358
  13. package/lib/abis/contracts/IMerkleDistributor.json +1134 -1134
  14. package/lib/abis/contracts/IRouter02.json +7283 -7283
  15. package/lib/abis/contracts/ISimpleUniswapOracle.json +1469 -1469
  16. package/lib/abis/contracts/IStakedLPToken.json +7309 -7309
  17. package/lib/abis/contracts/IStakingRewards.json +1036 -1036
  18. package/lib/abis/contracts/ITokenizedUniswapV2Position.json +4167 -0
  19. package/lib/abis/contracts/ITokenizedUniswapV3Position.json +5539 -0
  20. package/lib/abis/contracts/IUniswapV2Factory.json +1690 -1690
  21. package/lib/abis/contracts/IUniswapV2Pair.json +6761 -6761
  22. package/lib/abis/contracts/IUniswapV3Pool.json +6606 -0
  23. package/lib/abis/contracts/ImpermaxChef.json +20945 -20945
  24. package/lib/abis/contracts/ImpermaxConfigManager.json +31595 -31595
  25. package/lib/abis/contracts/ImpermaxV3Borrowable.json +22131 -0
  26. package/lib/abis/contracts/ImpermaxV3Collateral.json +22988 -0
  27. package/lib/abis/contracts/ImpermaxV3Factory.json +17645 -0
  28. package/lib/abis/contracts/ImpermaxV3UniV2Router01.json +32488 -0
  29. package/lib/abis/contracts/ImpermaxV3UniV3Router01.json +37742 -0
  30. package/lib/abis/contracts/LendingVaultWatcher01.json +4076 -4076
  31. package/lib/abis/contracts/PoolTokenRouter01.json +9058 -0
  32. package/lib/config/amms.d.ts +102 -104
  33. package/lib/config/amms.js +433 -436
  34. package/lib/config/chainId.d.ts +2 -0
  35. package/lib/config/chainId.js +26 -0
  36. package/lib/config/contracts/claim-aggregators.d.ts +2 -2
  37. package/lib/config/contracts/claim-aggregators.js +26 -26
  38. package/lib/config/contracts/impermax-chef.d.ts +2 -2
  39. package/lib/config/contracts/impermax-chef.js +27 -27
  40. package/lib/config/contracts/impermax-config-manager.d.ts +2 -2
  41. package/lib/config/contracts/impermax-config-manager.js +26 -26
  42. package/lib/config/contracts/impermax-factories.d.ts +4 -4
  43. package/lib/config/contracts/impermax-factories.js +87 -87
  44. package/lib/config/contracts/imxes.d.ts +2 -2
  45. package/lib/config/contracts/imxes.js +26 -26
  46. package/lib/config/contracts/lending-vault-watcher.d.ts +2 -2
  47. package/lib/config/contracts/lending-vault-watcher.js +26 -26
  48. package/lib/config/contracts/merkle-distributors.d.ts +4 -4
  49. package/lib/config/contracts/merkle-distributors.js +70 -70
  50. package/lib/config/contracts/routers.d.ts +4 -3
  51. package/lib/config/contracts/routers.js +118 -94
  52. package/lib/config/contracts/simple-uniswap-oracles.d.ts +2 -2
  53. package/lib/config/contracts/simple-uniswap-oracles.js +49 -49
  54. package/lib/config/contracts/weths.d.ts +2 -2
  55. package/lib/config/contracts/weths.js +27 -27
  56. package/lib/config/debank-ids.d.ts +2 -2
  57. package/lib/config/debank-ids.js +26 -26
  58. package/lib/config/endpoints/merkle-distributors.d.ts +4 -4
  59. package/lib/config/endpoints/merkle-distributors.js +70 -70
  60. package/lib/config/eth.d.ts +3 -3
  61. package/lib/config/eth.js +48 -48
  62. package/lib/config/factories.d.ts +7 -7
  63. package/lib/config/factories.js +31 -30
  64. package/lib/config/farms.d.ts +109 -111
  65. package/lib/config/farms.js +207 -210
  66. package/lib/config/general.d.ts +5 -5
  67. package/lib/config/general.js +8 -8
  68. package/lib/config/subgraphs.d.ts +45 -45
  69. package/lib/config/subgraphs.js +187 -187
  70. package/lib/config/types.d.ts +85 -72
  71. package/lib/config/types.js +72 -58
  72. package/lib/index.d.ts +36 -35
  73. package/lib/index.js +159 -152
  74. package/lib/offchain/account/index.d.ts +9 -7
  75. package/lib/offchain/account/index.js +43 -39
  76. package/lib/offchain/account/lendingPool/borrowable.d.ts +14 -0
  77. package/lib/offchain/account/lendingPool/borrowable.js +73 -0
  78. package/lib/offchain/account/lendingPool/collateral.d.ts +12 -0
  79. package/lib/offchain/account/lendingPool/collateral.js +42 -0
  80. package/lib/offchain/account/lendingPool/index.d.ts +6 -5
  81. package/lib/offchain/account/lendingPool/index.js +14 -12
  82. package/lib/offchain/account/lendingPool/offchainAccountBorrowable.d.ts +14 -17
  83. package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +45 -71
  84. package/lib/offchain/account/lendingPool/offchainAccountCollateral.d.ts +11 -13
  85. package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +31 -43
  86. package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +28 -21
  87. package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +69 -68
  88. package/lib/offchain/account/lendingPool/offchainLeveragedPosition.d.ts +25 -0
  89. package/lib/offchain/account/lendingPool/offchainLeveragedPosition.js +116 -0
  90. package/lib/offchain/account/lendingVault.d.ts +11 -0
  91. package/lib/offchain/account/lendingVault.js +38 -0
  92. package/lib/offchain/account/offchainAccount.d.ts +25 -25
  93. package/lib/offchain/account/offchainAccount.js +129 -129
  94. package/lib/offchain/account/offchainAccountLendingVault.d.ts +16 -16
  95. package/lib/offchain/account/offchainAccountLendingVault.js +64 -64
  96. package/lib/offchain/account/offchainAccountPoolToken.d.ts +7 -7
  97. package/lib/offchain/account/offchainAccountPoolToken.js +24 -24
  98. package/lib/offchain/account/offchainMultichainAccount.d.ts +34 -0
  99. package/lib/offchain/account/offchainMultichainAccount.js +66 -0
  100. package/lib/offchain/account/poolToken.d.ts +6 -0
  101. package/lib/offchain/account/poolToken.js +21 -0
  102. package/lib/offchain/account/vault/index.d.ts +3 -0
  103. package/lib/offchain/account/vault/index.js +7 -0
  104. package/lib/offchain/account/vault/offchainAccountVault.d.ts +16 -0
  105. package/lib/offchain/account/vault/offchainAccountVault.js +64 -0
  106. package/lib/offchain/configManager/index.d.ts +5 -5
  107. package/lib/offchain/configManager/index.js +12 -12
  108. package/lib/offchain/configManager/offchainConfigManager.d.ts +25 -25
  109. package/lib/offchain/configManager/offchainConfigManager.js +76 -76
  110. package/lib/offchain/configManager/offchainConfigManagerInitializer.d.ts +6 -6
  111. package/lib/offchain/configManager/offchainConfigManagerInitializer.js +53 -53
  112. package/lib/offchain/configManager/offchainPairConfig.d.ts +40 -40
  113. package/lib/offchain/configManager/offchainPairConfig.js +86 -86
  114. package/lib/offchain/configManager/offchainProposal.d.ts +17 -17
  115. package/lib/offchain/configManager/offchainProposal.js +53 -53
  116. package/lib/offchain/index.d.ts +15 -14
  117. package/lib/offchain/index.js +55 -53
  118. package/lib/offchain/initializer.d.ts +32 -0
  119. package/lib/offchain/initializer.js +627 -0
  120. package/lib/offchain/lendingPool/borrowable.d.ts +55 -0
  121. package/lib/offchain/lendingPool/borrowable.js +351 -0
  122. package/lib/offchain/lendingPool/collateral.d.ts +17 -0
  123. package/lib/offchain/lendingPool/collateral.js +72 -0
  124. package/lib/offchain/lendingPool/index.d.ts +5 -5
  125. package/lib/offchain/lendingPool/index.js +12 -12
  126. package/lib/offchain/lendingPool/offchainBorrowable.d.ts +59 -59
  127. package/lib/offchain/lendingPool/offchainBorrowable.js +366 -366
  128. package/lib/offchain/lendingPool/offchainCollateral.d.ts +20 -19
  129. package/lib/offchain/lendingPool/offchainCollateral.js +81 -75
  130. package/lib/offchain/lendingPool/offchainLendingPool.d.ts +60 -47
  131. package/lib/offchain/lendingPool/offchainLendingPool.js +277 -230
  132. package/lib/offchain/lendingVault.d.ts +22 -0
  133. package/lib/offchain/lendingVault.js +115 -0
  134. package/lib/offchain/offchain.d.ts +106 -113
  135. package/lib/offchain/offchain.js +248 -251
  136. package/lib/offchain/offchainAPRHelper.d.ts +45 -45
  137. package/lib/offchain/offchainAPRHelper.js +239 -239
  138. package/lib/offchain/offchainEndpointManager.d.ts +25 -25
  139. package/lib/offchain/offchainEndpointManager.js +126 -126
  140. package/lib/offchain/offchainInitializer.d.ts +52 -52
  141. package/lib/offchain/offchainInitializer.js +792 -792
  142. package/lib/offchain/offchainLendingVault.d.ts +25 -25
  143. package/lib/offchain/offchainLendingVault.js +114 -114
  144. package/lib/offchain/offchainMultichain.d.ts +50 -0
  145. package/lib/offchain/offchainMultichain.js +75 -0
  146. package/lib/offchain/offchainPoolToken.d.ts +21 -21
  147. package/lib/offchain/offchainPoolToken.js +128 -128
  148. package/lib/offchain/offchainPriceHelper.d.ts +22 -22
  149. package/lib/offchain/offchainPriceHelper.js +364 -364
  150. package/lib/offchain/offchainSolidexHelper.d.ts +16 -16
  151. package/lib/offchain/offchainSolidexHelper.js +58 -58
  152. package/lib/offchain/offchainTypes.d.ts +212 -212
  153. package/lib/offchain/offchainTypes.js +3 -3
  154. package/lib/offchain/poolToken.d.ts +20 -0
  155. package/lib/offchain/poolToken.js +120 -0
  156. package/lib/offchain/priceHelper.d.ts +21 -0
  157. package/lib/offchain/priceHelper.js +195 -0
  158. package/lib/offchain/queries/apis/ponder/index.d.ts +14 -14
  159. package/lib/offchain/queries/apis/ponder/index.js +281 -281
  160. package/lib/offchain/queries/apis/thegraph/index.d.ts +19 -19
  161. package/lib/offchain/queries/apis/thegraph/index.js +355 -355
  162. package/lib/offchain/queries/index.d.ts +20 -20
  163. package/lib/offchain/queries/index.js +51 -51
  164. package/lib/offchain/queries/interfaces/query-builder.d.ts +19 -19
  165. package/lib/offchain/queries/interfaces/query-builder.js +2 -2
  166. package/lib/offchain/queries/interfaces/transformers.js +9 -9
  167. package/lib/offchain/query.d.ts +15 -0
  168. package/lib/offchain/query.js +323 -0
  169. package/lib/offchain/solidexHelper.d.ts +16 -0
  170. package/lib/offchain/solidexHelper.js +58 -0
  171. package/lib/offchain/types.d.ts +150 -0
  172. package/lib/offchain/types.js +3 -0
  173. package/lib/offchain/vault/index.d.ts +6 -0
  174. package/lib/offchain/vault/index.js +14 -0
  175. package/lib/offchain/vault/offchainHedgedVault.d.ts +9 -0
  176. package/lib/offchain/vault/offchainHedgedVault.js +57 -0
  177. package/lib/offchain/vault/offchainLendingVault.d.ts +16 -0
  178. package/lib/offchain/vault/offchainLendingVault.js +73 -0
  179. package/lib/offchain/vault/offchainLeveragedVault.d.ts +9 -0
  180. package/lib/offchain/vault/offchainLeveragedVault.js +57 -0
  181. package/lib/offchain/vault/offchainVault.d.ts +34 -0
  182. package/lib/offchain/vault/offchainVault.js +130 -0
  183. package/lib/onchain/account/index.d.ts +6 -6
  184. package/lib/onchain/account/index.js +38 -38
  185. package/lib/onchain/account/interactions/index.d.ts +28 -0
  186. package/lib/onchain/account/interactions/index.js +158 -0
  187. package/lib/onchain/account/interactions/lendingPool/borrowable.d.ts +16 -0
  188. package/lib/onchain/account/interactions/lendingPool/borrowable.js +49 -0
  189. package/lib/onchain/account/interactions/lendingPool/collateral.d.ts +15 -0
  190. package/lib/onchain/account/interactions/lendingPool/collateral.js +33 -0
  191. package/lib/onchain/account/interactions/lendingPool/index.d.ts +41 -0
  192. package/lib/onchain/account/interactions/lendingPool/index.js +120 -0
  193. package/lib/onchain/account/interactions/lendingVault.d.ts +10 -0
  194. package/lib/onchain/account/interactions/lendingVault.js +12 -0
  195. package/lib/onchain/account/interactions/poolToken.d.ts +33 -0
  196. package/lib/onchain/account/interactions/poolToken.js +180 -0
  197. package/lib/onchain/account/lendingPool/borrowable.d.ts +29 -0
  198. package/lib/onchain/account/lendingPool/borrowable.js +135 -0
  199. package/lib/onchain/account/lendingPool/collateral.d.ts +15 -0
  200. package/lib/onchain/account/lendingPool/collateral.js +66 -0
  201. package/lib/onchain/account/lendingPool/index.d.ts +12 -5
  202. package/lib/onchain/account/lendingPool/index.js +49 -12
  203. package/lib/onchain/account/lendingPool/nftlp/index.d.ts +4 -0
  204. package/lib/onchain/account/lendingPool/nftlp/index.js +11 -0
  205. package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.d.ts +7 -0
  206. package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.js +12 -0
  207. package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.d.ts +4 -0
  208. package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.js +13 -0
  209. package/lib/onchain/account/lendingPool/onchainAccountBorrowable.d.ts +39 -34
  210. package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +131 -176
  211. package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.d.ts +10 -0
  212. package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.js +55 -0
  213. package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.d.ts +10 -0
  214. package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.js +28 -0
  215. package/lib/onchain/account/lendingPool/onchainAccountCollateral.d.ts +10 -23
  216. package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +26 -109
  217. package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +25 -0
  218. package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.js +99 -0
  219. package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.d.ts +18 -0
  220. package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.js +44 -0
  221. package/lib/onchain/account/lendingPool/onchainAccountLendingPool.d.ts +42 -57
  222. package/lib/onchain/account/lendingPool/onchainAccountLendingPool.js +142 -352
  223. package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.d.ts +44 -0
  224. package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.js +285 -0
  225. package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.d.ts +27 -0
  226. package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.js +32 -0
  227. package/lib/onchain/account/lendingVault.d.ts +10 -0
  228. package/lib/onchain/account/lendingVault.js +35 -0
  229. package/lib/onchain/account/onchainAccount.d.ts +32 -32
  230. package/lib/onchain/account/onchainAccount.js +166 -167
  231. package/lib/onchain/account/onchainAccountLendingVault.d.ts +19 -19
  232. package/lib/onchain/account/onchainAccountLendingVault.js +48 -48
  233. package/lib/onchain/account/onchainAccountPoolToken.d.ts +30 -30
  234. package/lib/onchain/account/onchainAccountPoolToken.js +86 -86
  235. package/lib/onchain/account/poolToken.d.ts +24 -0
  236. package/lib/onchain/account/poolToken.js +84 -0
  237. package/lib/onchain/configManager/index.d.ts +5 -5
  238. package/lib/onchain/configManager/index.js +12 -12
  239. package/lib/onchain/configManager/onchainConfigManager.d.ts +12 -12
  240. package/lib/onchain/configManager/onchainConfigManager.js +38 -38
  241. package/lib/onchain/configManager/onchainPairConfig.d.ts +38 -38
  242. package/lib/onchain/configManager/onchainPairConfig.js +85 -85
  243. package/lib/onchain/configManager/onchainProposal.d.ts +17 -17
  244. package/lib/onchain/configManager/onchainProposal.js +55 -55
  245. package/lib/onchain/contractsHelper.d.ts +29 -0
  246. package/lib/onchain/contractsHelper.js +52 -0
  247. package/lib/onchain/impermaxFactory/index.d.ts +7 -5
  248. package/lib/onchain/impermaxFactory/index.js +39 -35
  249. package/lib/onchain/impermaxFactory/lendingPool/borrowable.d.ts +36 -0
  250. package/lib/onchain/impermaxFactory/lendingPool/borrowable.js +153 -0
  251. package/lib/onchain/impermaxFactory/lendingPool/collateral.d.ts +17 -0
  252. package/lib/onchain/impermaxFactory/lendingPool/collateral.js +59 -0
  253. package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +12 -5
  254. package/lib/onchain/impermaxFactory/lendingPool/index.js +50 -12
  255. package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.d.ts +4 -0
  256. package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.js +11 -0
  257. package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.d.ts +22 -0
  258. package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.js +19 -0
  259. package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.d.ts +24 -0
  260. package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.js +90 -0
  261. package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.d.ts +38 -34
  262. package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +137 -156
  263. package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.d.ts +9 -0
  264. package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.js +36 -0
  265. package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.d.ts +7 -0
  266. package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.js +23 -0
  267. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.d.ts +8 -19
  268. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.js +24 -61
  269. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.d.ts +20 -0
  270. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.js +58 -0
  271. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.d.ts +13 -0
  272. package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.js +36 -0
  273. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.d.ts +43 -58
  274. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +81 -367
  275. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.d.ts +76 -0
  276. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.js +338 -0
  277. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.d.ts +42 -0
  278. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.js +39 -0
  279. package/lib/onchain/impermaxFactory/onchainImpermaxFactory.d.ts +26 -16
  280. package/lib/onchain/impermaxFactory/onchainImpermaxFactory.js +42 -52
  281. package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.d.ts +16 -0
  282. package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.js +81 -0
  283. package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.d.ts +16 -0
  284. package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.js +88 -0
  285. package/lib/onchain/index.d.ts +10 -10
  286. package/lib/onchain/index.js +49 -49
  287. package/lib/onchain/interactions/index.d.ts +8 -8
  288. package/lib/onchain/interactions/index.js +41 -41
  289. package/lib/onchain/interactions/lendingPool/borrowable.d.ts +14 -0
  290. package/lib/onchain/interactions/lendingPool/borrowable.js +47 -0
  291. package/lib/onchain/interactions/lendingPool/collateral.d.ts +13 -0
  292. package/lib/onchain/interactions/lendingPool/collateral.js +31 -0
  293. package/lib/onchain/interactions/lendingPool/index.d.ts +12 -5
  294. package/lib/onchain/interactions/lendingPool/index.js +49 -12
  295. package/lib/onchain/interactions/lendingPool/nftlp/index.d.ts +4 -0
  296. package/lib/onchain/interactions/lendingPool/nftlp/index.js +11 -0
  297. package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +7 -0
  298. package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +12 -0
  299. package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +4 -0
  300. package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +13 -0
  301. package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.d.ts +17 -21
  302. package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +24 -56
  303. package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.d.ts +15 -0
  304. package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.js +63 -0
  305. package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.d.ts +9 -0
  306. package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.js +14 -0
  307. package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.d.ts +7 -19
  308. package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.js +11 -43
  309. package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.d.ts +20 -0
  310. package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.js +48 -0
  311. package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.d.ts +13 -0
  312. package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.js +20 -0
  313. package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.d.ts +31 -46
  314. package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +53 -135
  315. package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.d.ts +42 -0
  316. package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.js +114 -0
  317. package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.d.ts +27 -0
  318. package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.js +32 -0
  319. package/lib/onchain/interactions/lendingVault.d.ts +8 -0
  320. package/lib/onchain/interactions/lendingVault.js +15 -0
  321. package/lib/onchain/interactions/onchainInteractions.d.ts +31 -31
  322. package/lib/onchain/interactions/onchainInteractions.js +136 -137
  323. package/lib/onchain/interactions/onchainInteractionsConfigManager.d.ts +17 -17
  324. package/lib/onchain/interactions/onchainInteractionsConfigManager.js +44 -44
  325. package/lib/onchain/interactions/onchainInteractionsLendingVault.d.ts +14 -14
  326. package/lib/onchain/interactions/onchainInteractionsLendingVault.js +21 -21
  327. package/lib/onchain/interactions/onchainInteractionsPoolToken.d.ts +35 -35
  328. package/lib/onchain/interactions/onchainInteractionsPoolToken.js +134 -186
  329. package/lib/onchain/interactions/poolToken.d.ts +31 -0
  330. package/lib/onchain/interactions/poolToken.js +181 -0
  331. package/lib/onchain/lendingVault.d.ts +17 -0
  332. package/lib/onchain/lendingVault.js +56 -0
  333. package/lib/onchain/onchain.d.ts +38 -35
  334. package/lib/onchain/onchain.js +78 -70
  335. package/lib/onchain/onchainContractsHelper.d.ts +42 -31
  336. package/lib/onchain/onchainContractsHelper.js +90 -56
  337. package/lib/onchain/onchainLendingVault.d.ts +22 -22
  338. package/lib/onchain/onchainLendingVault.js +69 -69
  339. package/lib/onchain/onchainPermitHelper.d.ts +21 -0
  340. package/lib/onchain/onchainPermitHelper.js +198 -0
  341. package/lib/onchain/onchainPoolToken.d.ts +35 -35
  342. package/lib/onchain/onchainPoolToken.js +129 -129
  343. package/lib/onchain/onchainTypes.d.ts +70 -64
  344. package/lib/onchain/onchainTypes.js +14 -14
  345. package/lib/onchain/poolToken.d.ts +32 -0
  346. package/lib/onchain/poolToken.js +121 -0
  347. package/lib/onchain/types.d.ts +45 -0
  348. package/lib/onchain/types.js +14 -0
  349. package/lib/utils/ether-utils.d.ts +5 -5
  350. package/lib/utils/ether-utils.js +26 -26
  351. package/lib/utils/index.d.ts +3 -3
  352. package/lib/utils/index.js +16 -16
  353. package/lib/utils/lliquidity-math.d.ts +30 -30
  354. package/lib/utils/lliquidity-math.js +139 -139
  355. package/lib/utils/price-from-reserves.d.ts +2 -0
  356. package/lib/utils/price-from-reserves.js +19 -0
  357. package/package.json +36 -36
@@ -1,129 +1,129 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const utils_1 = require("../utils");
13
- const ether_utils_1 = require("../utils/ether-utils");
14
- class OnchainPoolToken {
15
- constructor() {
16
- this.cache = {};
17
- // Cache that can't be erased
18
- this.lockedCache = {};
19
- }
20
- cleanCache() {
21
- this.cache = {};
22
- }
23
- getPoolToken() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- if (!this.cache.poolToken)
26
- this.cache.poolToken = this.initializePoolToken();
27
- return this.cache.poolToken;
28
- });
29
- }
30
- getToken() {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- if (!this.cache.token)
33
- this.cache.token = this.initializeToken();
34
- return this.cache.token;
35
- });
36
- }
37
- getTokenAddress() {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return (yield this.getToken())._address;
40
- });
41
- }
42
- getDecimals() {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const offchainPoolToken = yield this.getOffchainPoolToken();
45
- return yield offchainPoolToken.getDecimals();
46
- });
47
- }
48
- // Utilities
49
- normalize(amount) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- return amount / Math.pow(10, yield this.getDecimals());
52
- });
53
- }
54
- toBigNumber(amount) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- if (!(0, utils_1.isValidNumber)(amount))
57
- return null;
58
- return (0, ether_utils_1.decimalToBalance)(amount, yield this.getDecimals());
59
- });
60
- }
61
- toNumber(amount) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- if (!amount)
64
- return null;
65
- return parseFloat(amount.toString()) / Math.pow(10, yield this.getDecimals());
66
- });
67
- }
68
- toTokens(amount) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- if (!(0, utils_1.isValidNumber)(amount))
71
- return null;
72
- const exchangeRate = yield this.getLockedExchangeRate();
73
- return (0, ether_utils_1.decimalToBalance)(amount / exchangeRate, yield this.getDecimals());
74
- });
75
- }
76
- fromTokens(amount) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- if (!amount)
79
- return null;
80
- const exchangeRate = yield this.getLockedExchangeRate();
81
- return parseFloat(amount.toString()) * exchangeRate / Math.pow(10, yield this.getDecimals());
82
- });
83
- }
84
- // Total balance
85
- initializeTotalBalance() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const poolToken = yield this.getPoolToken();
88
- const amount = yield poolToken.methods.totalBalance().call();
89
- return this.normalize(amount);
90
- });
91
- }
92
- getTotalBalance() {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- if (!this.cache.totalBalance)
95
- this.cache.totalBalance = this.initializeTotalBalance();
96
- return this.cache.totalBalance;
97
- });
98
- }
99
- getTotalBalanceUSD() {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const totalBalance = yield this.getTotalBalance();
102
- const offchainPoolToken = yield this.getOffchainPoolToken();
103
- const tokenPrice = yield offchainPoolToken.getTokenPriceFast();
104
- return totalBalance * tokenPrice;
105
- });
106
- }
107
- // Exchange rate
108
- initializeExchangeRate() {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- const poolToken = yield this.getPoolToken();
111
- return (yield poolToken.methods.exchangeRate().call()) / 1e18;
112
- });
113
- }
114
- getExchangeRate() {
115
- return __awaiter(this, void 0, void 0, function* () {
116
- if (!this.cache.exchangeRate)
117
- this.cache.exchangeRate = this.initializeExchangeRate();
118
- return this.cache.exchangeRate;
119
- });
120
- }
121
- getLockedExchangeRate() {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- if (!this.lockedCache.exchangeRate)
124
- this.lockedCache.exchangeRate = this.getExchangeRate();
125
- return this.lockedCache.exchangeRate;
126
- });
127
- }
128
- }
129
- exports.default = OnchainPoolToken;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const utils_1 = require("../utils");
13
+ const ether_utils_1 = require("../utils/ether-utils");
14
+ class OnchainPoolToken {
15
+ constructor() {
16
+ this.cache = {};
17
+ // Cache that can't be erased
18
+ this.lockedCache = {};
19
+ }
20
+ cleanCache() {
21
+ this.cache = {};
22
+ }
23
+ getPoolToken() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if (!this.cache.poolToken)
26
+ this.cache.poolToken = this.initializePoolToken();
27
+ return this.cache.poolToken;
28
+ });
29
+ }
30
+ getToken() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ if (!this.cache.token)
33
+ this.cache.token = this.initializeToken();
34
+ return this.cache.token;
35
+ });
36
+ }
37
+ getTokenAddress() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ return (yield this.getToken())._address;
40
+ });
41
+ }
42
+ getDecimals() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const offchainPoolToken = yield this.getOffchainPoolToken();
45
+ return yield offchainPoolToken.getDecimals();
46
+ });
47
+ }
48
+ // Utilities
49
+ normalize(amount) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ return amount / Math.pow(10, yield this.getDecimals());
52
+ });
53
+ }
54
+ toBigNumber(amount) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (!(0, utils_1.isValidNumber)(amount))
57
+ return null;
58
+ return (0, ether_utils_1.decimalToBalance)(amount, yield this.getDecimals());
59
+ });
60
+ }
61
+ toNumber(amount) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ if (!amount)
64
+ return null;
65
+ return parseFloat(amount.toString()) / Math.pow(10, yield this.getDecimals());
66
+ });
67
+ }
68
+ toTokens(amount) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ if (!(0, utils_1.isValidNumber)(amount))
71
+ return null;
72
+ const exchangeRate = yield this.getLockedExchangeRate();
73
+ return (0, ether_utils_1.decimalToBalance)(amount / exchangeRate, yield this.getDecimals());
74
+ });
75
+ }
76
+ fromTokens(amount) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ if (!amount)
79
+ return null;
80
+ const exchangeRate = yield this.getLockedExchangeRate();
81
+ return parseFloat(amount.toString()) * exchangeRate / Math.pow(10, yield this.getDecimals());
82
+ });
83
+ }
84
+ // Total balance
85
+ initializeTotalBalance() {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const poolToken = yield this.getPoolToken();
88
+ const amount = yield poolToken.methods.totalBalance().call();
89
+ return this.normalize(amount);
90
+ });
91
+ }
92
+ getTotalBalance() {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ if (!this.cache.totalBalance)
95
+ this.cache.totalBalance = this.initializeTotalBalance();
96
+ return this.cache.totalBalance;
97
+ });
98
+ }
99
+ getTotalBalanceUSD() {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ const totalBalance = yield this.getTotalBalance();
102
+ const offchainPoolToken = yield this.getOffchainPoolToken();
103
+ const tokenPrice = yield offchainPoolToken.getTokenPriceFast();
104
+ return totalBalance * tokenPrice;
105
+ });
106
+ }
107
+ // Exchange rate
108
+ initializeExchangeRate() {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const poolToken = yield this.getPoolToken();
111
+ return (yield poolToken.methods.exchangeRate().call()) / 1e18;
112
+ });
113
+ }
114
+ getExchangeRate() {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ if (!this.cache.exchangeRate)
117
+ this.cache.exchangeRate = this.initializeExchangeRate();
118
+ return this.cache.exchangeRate;
119
+ });
120
+ }
121
+ getLockedExchangeRate() {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ if (!this.lockedCache.exchangeRate)
124
+ this.lockedCache.exchangeRate = this.getExchangeRate();
125
+ return this.lockedCache.exchangeRate;
126
+ });
127
+ }
128
+ }
129
+ exports.default = OnchainPoolToken;
@@ -1,64 +1,70 @@
1
- import { BigNumber } from "ethers";
2
- import Offchain from "../offchain";
3
- import { Networks } from '../config/types';
4
- export type Contract = any;
5
- export declare enum ApprovalType {
6
- POOL_TOKEN = 0,
7
- UNDERLYING = 1,
8
- BORROW = 2
9
- }
10
- export interface PermitData {
11
- permitData: string;
12
- amount: BigNumber;
13
- deadline: BigNumber;
14
- }
15
- export interface OnchainConfig {
16
- network: Networks;
17
- offchain: Offchain;
18
- web3: any;
19
- chainId: number;
20
- priceInverted?: boolean;
21
- }
22
- export interface Changes {
23
- changeBorrowedA: number;
24
- changeBorrowedB: number;
25
- changeCollateral: number;
26
- }
27
- export declare const NO_CHANGES: {
28
- changeBorrowedA: number;
29
- changeBorrowedB: number;
30
- changeCollateral: number;
31
- };
32
- export interface Values {
33
- valueCollateral: number;
34
- valueA: number;
35
- valueB: number;
36
- }
37
- export interface AirdropData {
38
- index: number;
39
- amount: BigNumber | null;
40
- proof: Array<string>;
41
- }
42
- export interface PendingRewardUI {
43
- symbol: string;
44
- amount: number;
45
- }
46
- export interface CollateralConfig {
47
- safetyMarginSqrt: string;
48
- liquidationIncentive: string;
49
- liquidationFee: string;
50
- }
51
- export interface BorrowableConfig {
52
- reserveFactor: string;
53
- kinkUtilizationRate: string;
54
- adjustSpeed: string;
55
- borrowTracker: string;
56
- }
57
- export interface PairConfig {
58
- factory: string;
59
- pair: string;
60
- whitelistState: string;
61
- collateralConfig: CollateralConfig;
62
- borrowable0Config: BorrowableConfig;
63
- borrowable1Config: BorrowableConfig;
64
- }
1
+ import { BigNumber } from "ethers";
2
+ import Offchain from "../offchain";
3
+ import { Networks } from '../config/types';
4
+ export type Contract = any;
5
+ export declare enum ApprovalType {
6
+ POOL_TOKEN = 0,
7
+ UNDERLYING = 1,
8
+ BORROW = 2
9
+ }
10
+ export interface PermitData {
11
+ permitData: string;
12
+ amount: BigNumber;
13
+ deadline: BigNumber;
14
+ }
15
+ export interface Permit {
16
+ permitType: string;
17
+ permitData: string;
18
+ signature: string;
19
+ }
20
+ export type Permits = Array<Permit>;
21
+ export interface OnchainConfig {
22
+ network: Networks;
23
+ offchain: Offchain;
24
+ web3: any;
25
+ chainId: number;
26
+ priceInverted?: boolean;
27
+ }
28
+ export interface Changes {
29
+ changeBorrowedA: number;
30
+ changeBorrowedB: number;
31
+ changeCollateral: number;
32
+ }
33
+ export declare const NO_CHANGES: {
34
+ changeBorrowedA: number;
35
+ changeBorrowedB: number;
36
+ changeCollateral: number;
37
+ };
38
+ export interface Values {
39
+ valueCollateral: number;
40
+ valueA: number;
41
+ valueB: number;
42
+ }
43
+ export interface AirdropData {
44
+ index: number;
45
+ amount: BigNumber | null;
46
+ proof: Array<string>;
47
+ }
48
+ export interface PendingRewardUI {
49
+ symbol: string;
50
+ amount: number;
51
+ }
52
+ export interface CollateralConfig {
53
+ safetyMarginSqrt: string;
54
+ liquidationIncentive: string;
55
+ liquidationFee: string;
56
+ }
57
+ export interface BorrowableConfig {
58
+ reserveFactor: string;
59
+ kinkUtilizationRate: string;
60
+ adjustSpeed: string;
61
+ borrowTracker: string;
62
+ }
63
+ export interface PairConfig {
64
+ factory: string;
65
+ pair: string;
66
+ whitelistState: string;
67
+ collateralConfig: CollateralConfig;
68
+ borrowable0Config: BorrowableConfig;
69
+ borrowable1Config: BorrowableConfig;
70
+ }
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NO_CHANGES = exports.ApprovalType = void 0;
4
- var ApprovalType;
5
- (function (ApprovalType) {
6
- ApprovalType[ApprovalType["POOL_TOKEN"] = 0] = "POOL_TOKEN";
7
- ApprovalType[ApprovalType["UNDERLYING"] = 1] = "UNDERLYING";
8
- ApprovalType[ApprovalType["BORROW"] = 2] = "BORROW";
9
- })(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
10
- exports.NO_CHANGES = {
11
- changeBorrowedA: 0,
12
- changeBorrowedB: 0,
13
- changeCollateral: 0,
14
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NO_CHANGES = exports.ApprovalType = void 0;
4
+ var ApprovalType;
5
+ (function (ApprovalType) {
6
+ ApprovalType[ApprovalType["POOL_TOKEN"] = 0] = "POOL_TOKEN";
7
+ ApprovalType[ApprovalType["UNDERLYING"] = 1] = "UNDERLYING";
8
+ ApprovalType[ApprovalType["BORROW"] = 2] = "BORROW";
9
+ })(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
10
+ exports.NO_CHANGES = {
11
+ changeBorrowedA: 0,
12
+ changeBorrowedB: 0,
13
+ changeCollateral: 0,
14
+ };
@@ -0,0 +1,32 @@
1
+ import { BigNumber } from "ethers";
2
+ import { Contract } from "./types";
3
+ import { Address, PoolTokenType } from '../config/types';
4
+ import * as offchain from '../offchain';
5
+ export default abstract class PoolToken {
6
+ poolTokenType: PoolTokenType;
7
+ cache: {
8
+ token?: Promise<Contract>;
9
+ poolToken?: Promise<Contract>;
10
+ exchangeRate?: Promise<number>;
11
+ totalBalance?: Promise<number>;
12
+ };
13
+ cleanCache(): void;
14
+ abstract getOffchainPoolToken(): Promise<offchain.OffchainPoolToken>;
15
+ abstract getPoolTokenAddress(): Promise<Address>;
16
+ abstract initializePoolToken(): Promise<Contract>;
17
+ getPoolToken(): Promise<any>;
18
+ abstract initializeToken(): Promise<Contract>;
19
+ getToken(): Promise<any>;
20
+ getTokenAddress(): Promise<any>;
21
+ getDecimals(): Promise<number>;
22
+ normalize(amount: number): Promise<number>;
23
+ toBigNumber(amount: number): Promise<BigNumber | null>;
24
+ toNumber(amount: BigNumber): Promise<number | null>;
25
+ toTokens(amount: number): Promise<BigNumber | null>;
26
+ fromTokens(amount: BigNumber): Promise<number | null>;
27
+ private initializeTotalBalance;
28
+ getTotalBalance(): Promise<number>;
29
+ getTotalBalanceUSD(): Promise<number>;
30
+ protected initializeExchangeRate(): Promise<number>;
31
+ getExchangeRate(): Promise<number>;
32
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const utils_1 = require("../utils");
13
+ const ether_utils_1 = require("../utils/ether-utils");
14
+ class PoolToken {
15
+ constructor() {
16
+ this.cache = {};
17
+ }
18
+ cleanCache() {
19
+ this.cache = {};
20
+ }
21
+ getPoolToken() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ if (!this.cache.onchainPoolToken)
24
+ this.cache.poolTokens = this.initializePoolToken();
25
+ return this.cache.onchainPoolToken;
26
+ });
27
+ }
28
+ getToken() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ if (!this.cache.token)
31
+ this.cache.token = this.initializeToken();
32
+ return this.cache.token;
33
+ });
34
+ }
35
+ getTokenAddress() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ return (yield this.getToken())._address;
38
+ });
39
+ }
40
+ getDecimals() {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const offchainPoolToken = yield this.getOffchainPoolToken();
43
+ return yield offchainPoolToken.getDecimals();
44
+ });
45
+ }
46
+ // Utilities
47
+ normalize(amount) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ return amount / Math.pow(10, yield this.getDecimals());
50
+ });
51
+ }
52
+ toBigNumber(amount) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ if (!(0, utils_1.isValidNumber)(amount))
55
+ return null;
56
+ return (0, ether_utils_1.decimalToBalance)(amount, yield this.getDecimals());
57
+ });
58
+ }
59
+ toNumber(amount) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ if (!amount)
62
+ return null;
63
+ return parseFloat(amount.toString()) / Math.pow(10, yield this.getDecimals());
64
+ });
65
+ }
66
+ toTokens(amount) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ if (!(0, utils_1.isValidNumber)(amount))
69
+ return null;
70
+ const exchangeRate = yield this.getExchangeRate();
71
+ return (0, ether_utils_1.decimalToBalance)(amount / exchangeRate, yield this.getDecimals());
72
+ });
73
+ }
74
+ fromTokens(amount) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ if (!amount)
77
+ return null;
78
+ const exchangeRate = yield this.getExchangeRate();
79
+ return parseFloat(amount.toString()) * exchangeRate / Math.pow(10, yield this.getDecimals());
80
+ });
81
+ }
82
+ // Total balance
83
+ initializeTotalBalance() {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const poolToken = yield this.getPoolToken();
86
+ const amount = yield poolToken.methods.totalBalance().call();
87
+ return this.normalize(amount);
88
+ });
89
+ }
90
+ getTotalBalance() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ if (!this.cache.totalBalance)
93
+ this.cache.totalBalance = this.initializeTotalBalance();
94
+ return this.cache.totalBalance;
95
+ });
96
+ }
97
+ getTotalBalanceUSD() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const totalBalance = yield this.getTotalBalance();
100
+ const offchainPoolToken = yield this.getOffchainPoolToken();
101
+ const tokenPrice = yield offchainPoolToken.getTokenPriceFast();
102
+ return totalBalance * tokenPrice;
103
+ });
104
+ }
105
+ // Exchange rate
106
+ initializeExchangeRate() {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const poolToken = yield this.getPoolToken();
109
+ let exchangeRate = (yield poolToken.methods.exchangeRate().call()) / 1e18;
110
+ return exchangeRate;
111
+ });
112
+ }
113
+ getExchangeRate() {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ if (!this.cache.exchangeRate)
116
+ this.cache.exchangeRate = this.initializeExchangeRate();
117
+ return this.cache.exchangeRate;
118
+ });
119
+ }
120
+ }
121
+ exports.default = PoolToken;
@@ -0,0 +1,45 @@
1
+ import { BigNumber } from "ethers";
2
+ import Offchain from "../offchain";
3
+ import { Networks } from '../config/types';
4
+ export type Contract = any;
5
+ export declare enum ApprovalType {
6
+ POOL_TOKEN = 0,
7
+ UNDERLYING = 1,
8
+ BORROW = 2
9
+ }
10
+ export interface PermitData {
11
+ permitData: string;
12
+ amount: BigNumber;
13
+ deadline: BigNumber;
14
+ }
15
+ export interface OnchainConfig {
16
+ network: Networks;
17
+ offchain: Offchain;
18
+ web3: any;
19
+ chainId: number;
20
+ priceInverted?: boolean;
21
+ }
22
+ export interface Changes {
23
+ changeBorrowedA: number;
24
+ changeBorrowedB: number;
25
+ changeCollateral: number;
26
+ }
27
+ export declare const NO_CHANGES: {
28
+ changeBorrowedA: number;
29
+ changeBorrowedB: number;
30
+ changeCollateral: number;
31
+ };
32
+ export interface Values {
33
+ valueCollateral: number;
34
+ valueA: number;
35
+ valueB: number;
36
+ }
37
+ export interface AirdropData {
38
+ index: number;
39
+ amount: BigNumber | null;
40
+ proof: Array<string>;
41
+ }
42
+ export interface PendingRewardUI {
43
+ symbol: string;
44
+ amount: number;
45
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NO_CHANGES = exports.ApprovalType = void 0;
4
+ var ApprovalType;
5
+ (function (ApprovalType) {
6
+ ApprovalType[ApprovalType["POOL_TOKEN"] = 0] = "POOL_TOKEN";
7
+ ApprovalType[ApprovalType["UNDERLYING"] = 1] = "UNDERLYING";
8
+ ApprovalType[ApprovalType["BORROW"] = 2] = "BORROW";
9
+ })(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
10
+ exports.NO_CHANGES = {
11
+ changeBorrowedA: 0,
12
+ changeBorrowedB: 0,
13
+ changeCollateral: 0,
14
+ };
@@ -1,5 +1,5 @@
1
- import { BigNumber } from 'ethers';
2
- export declare function balanceToDecimal(s: string): string;
3
- export declare function formatToDecimals(n: number, decimals?: number): string;
4
- export declare function decimalToBalance(d: string | number, decimals?: number): BigNumber;
5
- export declare function address(n: number): string;
1
+ import { BigNumber } from 'ethers';
2
+ export declare function balanceToDecimal(s: string): string;
3
+ export declare function formatToDecimals(n: number, decimals?: number): string;
4
+ export declare function decimalToBalance(d: string | number, decimals?: number): BigNumber;
5
+ export declare function address(n: number): string;