@defisaver/positions-sdk 0.0.149 → 0.0.151
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/.vscode/launch.json +17 -0
- package/.vscode/settings.json +22 -0
- package/README.md +69 -69
- package/cjs/{markets → src/markets}/compound/marketsAssets.js +3 -3
- package/cjs/tests/aaveV2.d.ts +1 -0
- package/cjs/tests/aaveV2.js +109 -0
- package/cjs/tests/aaveV3.d.ts +1 -0
- package/cjs/tests/aaveV3.js +241 -0
- package/cjs/tests/chickenBonds.d.ts +1 -0
- package/cjs/tests/chickenBonds.js +90 -0
- package/cjs/tests/compoundV2.d.ts +1 -0
- package/cjs/tests/compoundV2.js +109 -0
- package/cjs/tests/compoundV3.d.ts +1 -0
- package/cjs/tests/compoundV3.js +247 -0
- package/cjs/tests/curveUsd.d.ts +1 -0
- package/cjs/tests/curveUsd.js +239 -0
- package/cjs/tests/index.js +20 -0
- package/cjs/tests/liquity.d.ts +1 -0
- package/cjs/tests/liquity.js +78 -0
- package/cjs/tests/llamaLend.d.ts +1 -0
- package/cjs/tests/llamaLend.js +119 -0
- package/cjs/tests/maker.d.ts +1 -0
- package/cjs/tests/maker.js +108 -0
- package/cjs/tests/morphoAaveV2.d.ts +1 -0
- package/cjs/tests/morphoAaveV2.js +109 -0
- package/cjs/tests/morphoAaveV3.d.ts +1 -0
- package/cjs/tests/morphoAaveV3.js +109 -0
- package/cjs/tests/morphoBlue.d.ts +1 -0
- package/cjs/tests/morphoBlue.js +470 -0
- package/cjs/tests/spark.d.ts +1 -0
- package/cjs/tests/spark.js +109 -0
- package/cjs/tests/utils/getWeb3Instance.d.ts +2 -0
- package/cjs/tests/utils/getWeb3Instance.js +15 -0
- package/esm/{markets → src/markets}/compound/marketsAssets.js +3 -3
- package/esm/src/types/maker.js +1 -0
- package/esm/tests/aaveV2.d.ts +1 -0
- package/esm/tests/aaveV2.js +84 -0
- package/esm/tests/aaveV3.d.ts +1 -0
- package/esm/tests/aaveV3.js +216 -0
- package/esm/tests/chickenBonds.d.ts +1 -0
- package/esm/tests/chickenBonds.js +65 -0
- package/esm/tests/compoundV2.d.ts +1 -0
- package/esm/tests/compoundV2.js +84 -0
- package/esm/tests/compoundV3.d.ts +1 -0
- package/esm/tests/compoundV3.js +222 -0
- package/esm/tests/curveUsd.d.ts +1 -0
- package/esm/tests/curveUsd.js +214 -0
- package/esm/tests/index.d.ts +2 -0
- package/esm/tests/index.js +19 -0
- package/esm/tests/liquity.d.ts +1 -0
- package/esm/tests/liquity.js +53 -0
- package/esm/tests/llamaLend.d.ts +1 -0
- package/esm/tests/llamaLend.js +94 -0
- package/esm/tests/maker.d.ts +1 -0
- package/esm/tests/maker.js +83 -0
- package/esm/tests/morphoAaveV2.d.ts +1 -0
- package/esm/tests/morphoAaveV2.js +84 -0
- package/esm/tests/morphoAaveV3.d.ts +1 -0
- package/esm/tests/morphoAaveV3.js +84 -0
- package/esm/tests/morphoBlue.d.ts +1 -0
- package/esm/tests/morphoBlue.js +445 -0
- package/esm/tests/spark.d.ts +1 -0
- package/esm/tests/spark.js +84 -0
- package/esm/tests/utils/getWeb3Instance.d.ts +2 -0
- package/esm/tests/utils/getWeb3Instance.js +8 -0
- package/package.json +47 -44
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +590 -590
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +219 -219
- package/src/compoundV3/index.ts +281 -281
- package/src/config/contracts.js +1034 -1034
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +128 -128
- package/src/curveUsd/index.ts +229 -229
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +194 -194
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +246 -246
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/index.ts +7 -7
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +115 -115
- package/src/helpers/sparkHelpers/index.ts +150 -150
- package/src/index.ts +46 -46
- package/src/liquity/index.ts +116 -116
- package/src/llamaLend/index.ts +275 -275
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +152 -152
- package/src/markets/aave/marketAssets.ts +46 -46
- package/src/markets/compound/index.ts +173 -173
- package/src/markets/compound/marketsAssets.ts +64 -64
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +21 -21
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +691 -691
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +630 -630
- package/src/morphoBlue/index.ts +171 -171
- package/src/multicall/index.ts +22 -22
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +21 -21
- package/src/services/utils.ts +54 -54
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +424 -424
- package/src/staking/staking.ts +189 -189
- package/src/types/aave.ts +262 -262
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +129 -129
- package/src/types/curveUsd.ts +118 -118
- package/src/types/index.ts +8 -8
- package/src/types/liquity.ts +30 -30
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +144 -144
- package/src/types/spark.ts +127 -127
- /package/cjs/{aaveV2 → src/aaveV2}/index.d.ts +0 -0
- /package/cjs/{aaveV2 → src/aaveV2}/index.js +0 -0
- /package/cjs/{aaveV3 → src/aaveV3}/index.d.ts +0 -0
- /package/cjs/{aaveV3 → src/aaveV3}/index.js +0 -0
- /package/cjs/{assets → src/assets}/index.d.ts +0 -0
- /package/cjs/{assets → src/assets}/index.js +0 -0
- /package/cjs/{chickenBonds → src/chickenBonds}/index.d.ts +0 -0
- /package/cjs/{chickenBonds → src/chickenBonds}/index.js +0 -0
- /package/cjs/{compoundV2 → src/compoundV2}/index.d.ts +0 -0
- /package/cjs/{compoundV2 → src/compoundV2}/index.js +0 -0
- /package/cjs/{compoundV3 → src/compoundV3}/index.d.ts +0 -0
- /package/cjs/{compoundV3 → src/compoundV3}/index.js +0 -0
- /package/cjs/{config → src/config}/contracts.d.ts +0 -0
- /package/cjs/{config → src/config}/contracts.js +0 -0
- /package/cjs/{constants → src/constants}/index.d.ts +0 -0
- /package/cjs/{constants → src/constants}/index.js +0 -0
- /package/cjs/{contracts.d.ts → src/contracts.d.ts} +0 -0
- /package/cjs/{contracts.js → src/contracts.js} +0 -0
- /package/cjs/{curveUsd → src/curveUsd}/index.d.ts +0 -0
- /package/cjs/{curveUsd → src/curveUsd}/index.js +0 -0
- /package/cjs/{exchange → src/exchange}/index.d.ts +0 -0
- /package/cjs/{exchange → src/exchange}/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/aaveHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/aaveHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/chickenBondsHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/chickenBondsHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/compoundHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/compoundHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/curveUsdHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/curveUsdHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/llamaLendHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/llamaLendHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/makerHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/makerHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/morphoBlueHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/morphoBlueHelpers/index.js +0 -0
- /package/cjs/{helpers → src/helpers}/sparkHelpers/index.d.ts +0 -0
- /package/cjs/{helpers → src/helpers}/sparkHelpers/index.js +0 -0
- /package/cjs/{index.d.ts → src/index.d.ts} +0 -0
- /package/cjs/{index.js → src/index.js} +0 -0
- /package/cjs/{liquity → src/liquity}/index.d.ts +0 -0
- /package/cjs/{liquity → src/liquity}/index.js +0 -0
- /package/cjs/{llamaLend → src/llamaLend}/index.d.ts +0 -0
- /package/cjs/{llamaLend → src/llamaLend}/index.js +0 -0
- /package/cjs/{maker → src/maker}/index.d.ts +0 -0
- /package/cjs/{maker → src/maker}/index.js +0 -0
- /package/cjs/{markets → src/markets}/aave/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/aave/index.js +0 -0
- /package/cjs/{markets → src/markets}/aave/marketAssets.d.ts +0 -0
- /package/cjs/{markets → src/markets}/aave/marketAssets.js +0 -0
- /package/cjs/{markets → src/markets}/compound/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/compound/index.js +0 -0
- /package/cjs/{markets → src/markets}/compound/marketsAssets.d.ts +0 -0
- /package/cjs/{markets → src/markets}/curveUsd/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/curveUsd/index.js +0 -0
- /package/cjs/{markets → src/markets}/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/index.js +0 -0
- /package/cjs/{markets → src/markets}/llamaLend/contractAddresses.d.ts +0 -0
- /package/cjs/{markets → src/markets}/llamaLend/contractAddresses.js +0 -0
- /package/cjs/{markets → src/markets}/llamaLend/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/llamaLend/index.js +0 -0
- /package/cjs/{markets → src/markets}/morphoBlue/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/morphoBlue/index.js +0 -0
- /package/cjs/{markets → src/markets}/spark/index.d.ts +0 -0
- /package/cjs/{markets → src/markets}/spark/index.js +0 -0
- /package/cjs/{markets → src/markets}/spark/marketAssets.d.ts +0 -0
- /package/cjs/{markets → src/markets}/spark/marketAssets.js +0 -0
- /package/cjs/{moneymarket → src/moneymarket}/index.d.ts +0 -0
- /package/cjs/{moneymarket → src/moneymarket}/index.js +0 -0
- /package/cjs/{moneymarket → src/moneymarket}/moneymarketCommonService.d.ts +0 -0
- /package/cjs/{moneymarket → src/moneymarket}/moneymarketCommonService.js +0 -0
- /package/cjs/{morphoAaveV2 → src/morphoAaveV2}/index.d.ts +0 -0
- /package/cjs/{morphoAaveV2 → src/morphoAaveV2}/index.js +0 -0
- /package/cjs/{morphoAaveV3 → src/morphoAaveV3}/index.d.ts +0 -0
- /package/cjs/{morphoAaveV3 → src/morphoAaveV3}/index.js +0 -0
- /package/cjs/{morphoBlue → src/morphoBlue}/index.d.ts +0 -0
- /package/cjs/{morphoBlue → src/morphoBlue}/index.js +0 -0
- /package/cjs/{multicall → src/multicall}/index.d.ts +0 -0
- /package/cjs/{multicall → src/multicall}/index.js +0 -0
- /package/cjs/{services → src/services}/dsrService.d.ts +0 -0
- /package/cjs/{services → src/services}/dsrService.js +0 -0
- /package/cjs/{services → src/services}/priceService.d.ts +0 -0
- /package/cjs/{services → src/services}/priceService.js +0 -0
- /package/cjs/{services → src/services}/utils.d.ts +0 -0
- /package/cjs/{services → src/services}/utils.js +0 -0
- /package/cjs/{setup.d.ts → src/setup.d.ts} +0 -0
- /package/cjs/{setup.js → src/setup.js} +0 -0
- /package/cjs/{spark → src/spark}/index.d.ts +0 -0
- /package/cjs/{spark → src/spark}/index.js +0 -0
- /package/cjs/{staking → src/staking}/index.d.ts +0 -0
- /package/cjs/{staking → src/staking}/index.js +0 -0
- /package/cjs/{staking → src/staking}/staking.d.ts +0 -0
- /package/cjs/{staking → src/staking}/staking.js +0 -0
- /package/cjs/{types → src/types}/aave.d.ts +0 -0
- /package/cjs/{types → src/types}/aave.js +0 -0
- /package/cjs/{types → src/types}/chickenBonds.d.ts +0 -0
- /package/cjs/{types → src/types}/chickenBonds.js +0 -0
- /package/cjs/{types → src/types}/common.d.ts +0 -0
- /package/cjs/{types → src/types}/common.js +0 -0
- /package/cjs/{types → src/types}/compound.d.ts +0 -0
- /package/cjs/{types → src/types}/compound.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveLendingPoolV2.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveLendingPoolV2.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveLoanInfoV2.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveLoanInfoV2.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveProtocolDataProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveProtocolDataProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveUiIncentiveDataProviderV3.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveUiIncentiveDataProviderV3.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3EtherfiLendingPool.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3EtherfiLendingPool.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3EtherfiPoolAddressesProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3EtherfiPoolAddressesProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3EtherfiProtocolDataProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3EtherfiProtocolDataProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LendingPool.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LendingPool.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LidoLendingPool.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LidoLendingPool.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LidoPoolAddressesProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LidoPoolAddressesProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LidoProtocolDataProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3LidoProtocolDataProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3PoolAddressesProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3PoolAddressesProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3ProtocolDataProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3ProtocolDataProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3View.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/AaveV3View.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/BalanceScanner.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/BalanceScanner.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CETHv3.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CETHv3.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/COMPPriceFeed.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/COMPPriceFeed.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDCev3.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDCev3.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDCv3.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDCv3.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDTv3.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDTv3.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDbCv3.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CUSDbCv3.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CbEth.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CbEth.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/ChickenBondsManager.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/ChickenBondsManager.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/ChickenBondsView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/ChickenBondsView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CollSurplusPool.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CollSurplusPool.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3BulkerL2.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3BulkerL2.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3BulkerMainnetETH.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3BulkerMainnetETH.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3BulkerMainnetUSDC.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3BulkerMainnetUSDC.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3View.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompV3View.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompoundLoanInfo.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CompoundLoanInfo.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Comptroller.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Comptroller.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDETHAmm.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDETHAmm.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDETHController.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDETHController.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDFactory.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDFactory.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDWBTCAmm.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDWBTCAmm.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDWBTCController.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDWBTCController.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDsfrxETHAmm.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDsfrxETHAmm.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDsfrxETHController.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDsfrxETHController.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDtBTCAmm.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDtBTCAmm.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDtBTCController.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDtBTCController.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDwstETHAmm.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDwstETHAmm.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDwstETHController.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/CrvUSDwstETHController.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/ETHPriceFeed.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/ETHPriceFeed.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Erc20.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Erc20.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/FeedRegistry.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/FeedRegistry.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/GHO.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/GHO.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/GhoDiscountRateStrategy.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/GhoDiscountRateStrategy.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/IAToken.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/IAToken.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/IVariableDebtToken.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/IVariableDebtToken.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LendingPoolAddressesProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LendingPoolAddressesProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Lido.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Lido.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LiquityActivePool.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LiquityActivePool.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LiquityView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LiquityView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LlamaLendControllerAbi.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LlamaLendControllerAbi.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LlamaLendView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/LlamaLendView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdDog.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdDog.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdJug.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdJug.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdSpotter.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdSpotter.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdVat.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdVat.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/McdView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoAaveV2Proxy.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoAaveV2Proxy.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoAaveV2View.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoAaveV2View.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoAaveV3ProxyEthMarket.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoAaveV3ProxyEthMarket.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoBlueView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/MorphoBlueView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Pot.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/Pot.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/PriceFeed.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/PriceFeed.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/REth.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/REth.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkIncentiveDataProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkIncentiveDataProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkLendingPool.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkLendingPool.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkPoolAddressesProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkPoolAddressesProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkProtocolDataProvider.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkProtocolDataProvider.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkView.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/SparkView.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/TroveManager.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/TroveManager.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/USDCPriceFeed.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/USDCPriceFeed.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/UniMulticall.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/UniMulticall.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/WstETH.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/WstETH.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/index.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/index.js +0 -0
- /package/cjs/{types → src/types}/contracts/generated/types.d.ts +0 -0
- /package/cjs/{types → src/types}/contracts/generated/types.js +0 -0
- /package/cjs/{types → src/types}/curveUsd.d.ts +0 -0
- /package/cjs/{types → src/types}/curveUsd.js +0 -0
- /package/cjs/{types → src/types}/index.d.ts +0 -0
- /package/cjs/{types → src/types}/index.js +0 -0
- /package/cjs/{types → src/types}/liquity.d.ts +0 -0
- /package/cjs/{types → src/types}/liquity.js +0 -0
- /package/cjs/{types → src/types}/llamaLend.d.ts +0 -0
- /package/cjs/{types → src/types}/llamaLend.js +0 -0
- /package/cjs/{types → src/types}/maker.d.ts +0 -0
- /package/cjs/{types → src/types}/maker.js +0 -0
- /package/cjs/{types → src/types}/morphoBlue.d.ts +0 -0
- /package/cjs/{types → src/types}/morphoBlue.js +0 -0
- /package/cjs/{types → src/types}/spark.d.ts +0 -0
- /package/cjs/{types → src/types}/spark.js +0 -0
- /package/{esm/setup.d.ts → cjs/tests/index.d.ts} +0 -0
- /package/esm/{aaveV2 → src/aaveV2}/index.d.ts +0 -0
- /package/esm/{aaveV2 → src/aaveV2}/index.js +0 -0
- /package/esm/{aaveV3 → src/aaveV3}/index.d.ts +0 -0
- /package/esm/{aaveV3 → src/aaveV3}/index.js +0 -0
- /package/esm/{assets → src/assets}/index.d.ts +0 -0
- /package/esm/{assets → src/assets}/index.js +0 -0
- /package/esm/{chickenBonds → src/chickenBonds}/index.d.ts +0 -0
- /package/esm/{chickenBonds → src/chickenBonds}/index.js +0 -0
- /package/esm/{compoundV2 → src/compoundV2}/index.d.ts +0 -0
- /package/esm/{compoundV2 → src/compoundV2}/index.js +0 -0
- /package/esm/{compoundV3 → src/compoundV3}/index.d.ts +0 -0
- /package/esm/{compoundV3 → src/compoundV3}/index.js +0 -0
- /package/esm/{config → src/config}/contracts.d.ts +0 -0
- /package/esm/{config → src/config}/contracts.js +0 -0
- /package/esm/{constants → src/constants}/index.d.ts +0 -0
- /package/esm/{constants → src/constants}/index.js +0 -0
- /package/esm/{contracts.d.ts → src/contracts.d.ts} +0 -0
- /package/esm/{contracts.js → src/contracts.js} +0 -0
- /package/esm/{curveUsd → src/curveUsd}/index.d.ts +0 -0
- /package/esm/{curveUsd → src/curveUsd}/index.js +0 -0
- /package/esm/{exchange → src/exchange}/index.d.ts +0 -0
- /package/esm/{exchange → src/exchange}/index.js +0 -0
- /package/esm/{helpers → src/helpers}/aaveHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/aaveHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/chickenBondsHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/chickenBondsHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/compoundHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/compoundHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/curveUsdHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/curveUsdHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/index.js +0 -0
- /package/esm/{helpers → src/helpers}/llamaLendHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/llamaLendHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/makerHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/makerHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/morphoBlueHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/morphoBlueHelpers/index.js +0 -0
- /package/esm/{helpers → src/helpers}/sparkHelpers/index.d.ts +0 -0
- /package/esm/{helpers → src/helpers}/sparkHelpers/index.js +0 -0
- /package/esm/{index.d.ts → src/index.d.ts} +0 -0
- /package/esm/{index.js → src/index.js} +0 -0
- /package/esm/{liquity → src/liquity}/index.d.ts +0 -0
- /package/esm/{liquity → src/liquity}/index.js +0 -0
- /package/esm/{llamaLend → src/llamaLend}/index.d.ts +0 -0
- /package/esm/{llamaLend → src/llamaLend}/index.js +0 -0
- /package/esm/{maker → src/maker}/index.d.ts +0 -0
- /package/esm/{maker → src/maker}/index.js +0 -0
- /package/esm/{markets → src/markets}/aave/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/aave/index.js +0 -0
- /package/esm/{markets → src/markets}/aave/marketAssets.d.ts +0 -0
- /package/esm/{markets → src/markets}/aave/marketAssets.js +0 -0
- /package/esm/{markets → src/markets}/compound/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/compound/index.js +0 -0
- /package/esm/{markets → src/markets}/compound/marketsAssets.d.ts +0 -0
- /package/esm/{markets → src/markets}/curveUsd/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/curveUsd/index.js +0 -0
- /package/esm/{markets → src/markets}/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/index.js +0 -0
- /package/esm/{markets → src/markets}/llamaLend/contractAddresses.d.ts +0 -0
- /package/esm/{markets → src/markets}/llamaLend/contractAddresses.js +0 -0
- /package/esm/{markets → src/markets}/llamaLend/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/llamaLend/index.js +0 -0
- /package/esm/{markets → src/markets}/morphoBlue/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/morphoBlue/index.js +0 -0
- /package/esm/{markets → src/markets}/spark/index.d.ts +0 -0
- /package/esm/{markets → src/markets}/spark/index.js +0 -0
- /package/esm/{markets → src/markets}/spark/marketAssets.d.ts +0 -0
- /package/esm/{markets → src/markets}/spark/marketAssets.js +0 -0
- /package/esm/{moneymarket → src/moneymarket}/index.d.ts +0 -0
- /package/esm/{moneymarket → src/moneymarket}/index.js +0 -0
- /package/esm/{moneymarket → src/moneymarket}/moneymarketCommonService.d.ts +0 -0
- /package/esm/{moneymarket → src/moneymarket}/moneymarketCommonService.js +0 -0
- /package/esm/{morphoAaveV2 → src/morphoAaveV2}/index.d.ts +0 -0
- /package/esm/{morphoAaveV2 → src/morphoAaveV2}/index.js +0 -0
- /package/esm/{morphoAaveV3 → src/morphoAaveV3}/index.d.ts +0 -0
- /package/esm/{morphoAaveV3 → src/morphoAaveV3}/index.js +0 -0
- /package/esm/{morphoBlue → src/morphoBlue}/index.d.ts +0 -0
- /package/esm/{morphoBlue → src/morphoBlue}/index.js +0 -0
- /package/esm/{multicall → src/multicall}/index.d.ts +0 -0
- /package/esm/{multicall → src/multicall}/index.js +0 -0
- /package/esm/{services → src/services}/dsrService.d.ts +0 -0
- /package/esm/{services → src/services}/dsrService.js +0 -0
- /package/esm/{services → src/services}/priceService.d.ts +0 -0
- /package/esm/{services → src/services}/priceService.js +0 -0
- /package/esm/{services → src/services}/utils.d.ts +0 -0
- /package/esm/{services → src/services}/utils.js +0 -0
- /package/esm/{types/contracts/generated/index.js → src/setup.d.ts} +0 -0
- /package/esm/{setup.js → src/setup.js} +0 -0
- /package/esm/{spark → src/spark}/index.d.ts +0 -0
- /package/esm/{spark → src/spark}/index.js +0 -0
- /package/esm/{staking → src/staking}/index.d.ts +0 -0
- /package/esm/{staking → src/staking}/index.js +0 -0
- /package/esm/{staking → src/staking}/staking.d.ts +0 -0
- /package/esm/{staking → src/staking}/staking.js +0 -0
- /package/esm/{types → src/types}/aave.d.ts +0 -0
- /package/esm/{types → src/types}/aave.js +0 -0
- /package/esm/{types → src/types}/chickenBonds.d.ts +0 -0
- /package/esm/{types → src/types}/chickenBonds.js +0 -0
- /package/esm/{types → src/types}/common.d.ts +0 -0
- /package/esm/{types → src/types}/common.js +0 -0
- /package/esm/{types → src/types}/compound.d.ts +0 -0
- /package/esm/{types → src/types}/compound.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveLendingPoolV2.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveLendingPoolV2.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveLoanInfoV2.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveLoanInfoV2.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveProtocolDataProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveProtocolDataProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveUiIncentiveDataProviderV3.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveUiIncentiveDataProviderV3.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3EtherfiLendingPool.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3EtherfiLendingPool.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3EtherfiPoolAddressesProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3EtherfiPoolAddressesProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3EtherfiProtocolDataProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3EtherfiProtocolDataProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LendingPool.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LendingPool.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LidoLendingPool.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LidoLendingPool.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LidoPoolAddressesProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LidoPoolAddressesProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LidoProtocolDataProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3LidoProtocolDataProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3PoolAddressesProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3PoolAddressesProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3ProtocolDataProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3ProtocolDataProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3View.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/AaveV3View.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/BalanceScanner.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/BalanceScanner.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CETHv3.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CETHv3.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/COMPPriceFeed.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/COMPPriceFeed.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDCev3.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDCev3.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDCv3.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDCv3.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDTv3.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDTv3.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDbCv3.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CUSDbCv3.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CbEth.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CbEth.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/ChickenBondsManager.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/ChickenBondsManager.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/ChickenBondsView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/ChickenBondsView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CollSurplusPool.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CollSurplusPool.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3BulkerL2.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3BulkerL2.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3BulkerMainnetETH.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3BulkerMainnetETH.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3BulkerMainnetUSDC.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3BulkerMainnetUSDC.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3View.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompV3View.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompoundLoanInfo.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CompoundLoanInfo.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/Comptroller.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/Comptroller.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDETHAmm.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDETHAmm.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDETHController.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDETHController.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDFactory.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDFactory.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDWBTCAmm.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDWBTCAmm.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDWBTCController.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDWBTCController.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDsfrxETHAmm.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDsfrxETHAmm.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDsfrxETHController.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDsfrxETHController.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDtBTCAmm.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDtBTCAmm.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDtBTCController.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDtBTCController.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDwstETHAmm.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDwstETHAmm.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDwstETHController.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/CrvUSDwstETHController.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/ETHPriceFeed.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/ETHPriceFeed.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/Erc20.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/Erc20.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/FeedRegistry.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/FeedRegistry.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/GHO.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/GHO.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/GhoDiscountRateStrategy.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/GhoDiscountRateStrategy.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/IAToken.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/IAToken.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/IVariableDebtToken.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/IVariableDebtToken.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/LendingPoolAddressesProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/LendingPoolAddressesProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/Lido.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/Lido.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/LiquityActivePool.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/LiquityActivePool.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/LiquityView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/LiquityView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/LlamaLendControllerAbi.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/LlamaLendControllerAbi.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/LlamaLendView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/LlamaLendView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdDog.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdDog.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdJug.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdJug.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdSpotter.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdSpotter.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdVat.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdVat.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/McdView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoAaveV2Proxy.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoAaveV2Proxy.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoAaveV2View.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoAaveV2View.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoAaveV3ProxyEthMarket.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoAaveV3ProxyEthMarket.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoBlueView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/MorphoBlueView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/Pot.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/Pot.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/PriceFeed.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/PriceFeed.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/REth.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/REth.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkIncentiveDataProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkIncentiveDataProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkLendingPool.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkLendingPool.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkPoolAddressesProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkPoolAddressesProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkProtocolDataProvider.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkProtocolDataProvider.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkView.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/SparkView.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/TroveManager.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/TroveManager.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/USDCPriceFeed.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/USDCPriceFeed.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/UniMulticall.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/UniMulticall.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/WstETH.d.ts +0 -0
- /package/esm/{types → src/types}/contracts/generated/WstETH.js +0 -0
- /package/esm/{types → src/types}/contracts/generated/index.d.ts +0 -0
- /package/esm/{types/contracts/generated/types.js → src/types/contracts/generated/index.js} +0 -0
- /package/esm/{types → src/types}/contracts/generated/types.d.ts +0 -0
- /package/esm/{types/maker.js → src/types/contracts/generated/types.js} +0 -0
- /package/esm/{types → src/types}/curveUsd.d.ts +0 -0
- /package/esm/{types → src/types}/curveUsd.js +0 -0
- /package/esm/{types → src/types}/index.d.ts +0 -0
- /package/esm/{types → src/types}/index.js +0 -0
- /package/esm/{types → src/types}/liquity.d.ts +0 -0
- /package/esm/{types → src/types}/liquity.js +0 -0
- /package/esm/{types → src/types}/llamaLend.d.ts +0 -0
- /package/esm/{types → src/types}/llamaLend.js +0 -0
- /package/esm/{types → src/types}/maker.d.ts +0 -0
- /package/esm/{types → src/types}/morphoBlue.d.ts +0 -0
- /package/esm/{types → src/types}/morphoBlue.js +0 -0
- /package/esm/{types → src/types}/spark.d.ts +0 -0
- /package/esm/{types → src/types}/spark.js +0 -0
package/src/spark/index.ts
CHANGED
|
@@ -1,424 +1,424 @@
|
|
|
1
|
-
import Web3 from 'web3';
|
|
2
|
-
import Dec from 'decimal.js';
|
|
3
|
-
import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
|
|
4
|
-
import {
|
|
5
|
-
Blockish, EthAddress, NetworkNumber, PositionBalances,
|
|
6
|
-
} from '../types/common';
|
|
7
|
-
import {
|
|
8
|
-
ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress,
|
|
9
|
-
} from '../services/utils';
|
|
10
|
-
import {
|
|
11
|
-
calculateNetApy, getStakingApy, STAKING_ASSETS,
|
|
12
|
-
} from '../staking';
|
|
13
|
-
import { getDsrApy } from '../services/dsrService';
|
|
14
|
-
import {
|
|
15
|
-
SparkIncentiveDataProviderContract,
|
|
16
|
-
SparkViewContract,
|
|
17
|
-
getConfigContractAbi,
|
|
18
|
-
createContractWrapper,
|
|
19
|
-
} from '../contracts';
|
|
20
|
-
import {
|
|
21
|
-
SparkEModeCategoryDataMapping,
|
|
22
|
-
SparkAssetData,
|
|
23
|
-
SparkAssetsData,
|
|
24
|
-
SparkMarketData,
|
|
25
|
-
SparkMarketsData,
|
|
26
|
-
SparkPositionData,
|
|
27
|
-
SparkUsedAsset,
|
|
28
|
-
SparkUsedAssets,
|
|
29
|
-
} from '../types';
|
|
30
|
-
import { multicall } from '../multicall';
|
|
31
|
-
import { sparkGetAggregatedPositionData, sparkIsInIsolationMode } from '../helpers/sparkHelpers';
|
|
32
|
-
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
33
|
-
import { SPARK_V1 } from '../markets/spark';
|
|
34
|
-
|
|
35
|
-
export const sparkEmodeCategoriesMapping = (extractedState: { assetsData: SparkAssetsData }, usedAssets: SparkUsedAssets) => {
|
|
36
|
-
const { assetsData } = extractedState;
|
|
37
|
-
const usedAssetsValues = Object.values(usedAssets);
|
|
38
|
-
|
|
39
|
-
const categoriesMapping: { [key: number]: SparkEModeCategoryDataMapping } = {};
|
|
40
|
-
Object.values(assetsData).forEach((a) => {
|
|
41
|
-
const borrowingOnlyFromCategory = a.eModeCategory === 0
|
|
42
|
-
? true
|
|
43
|
-
: !usedAssetsValues.filter(u => u.isBorrowed && u.eModeCategory !== a.eModeCategory).length;
|
|
44
|
-
const afterEnteringCategory = sparkGetAggregatedPositionData({
|
|
45
|
-
...extractedState, usedAssets, eModeCategory: a.eModeCategory,
|
|
46
|
-
});
|
|
47
|
-
const willStayOverCollateralized = new Dec(afterEnteringCategory.ratio).eq(0) || new Dec(afterEnteringCategory.ratio).gt(afterEnteringCategory.liqPercent);
|
|
48
|
-
const enteringTerms = [borrowingOnlyFromCategory, willStayOverCollateralized];
|
|
49
|
-
|
|
50
|
-
categoriesMapping[a.eModeCategory] = {
|
|
51
|
-
enteringTerms,
|
|
52
|
-
canEnterCategory: !enteringTerms.includes(false),
|
|
53
|
-
id: a.eModeCategory,
|
|
54
|
-
data: a.eModeCategoryData,
|
|
55
|
-
assets: a.eModeCategory === 0 ? [] : [...(categoriesMapping[a.eModeCategory]?.assets || []), a.symbol],
|
|
56
|
-
enabledData: {
|
|
57
|
-
ratio: afterEnteringCategory.ratio,
|
|
58
|
-
liqRatio: afterEnteringCategory.liqRatio,
|
|
59
|
-
liqPercent: afterEnteringCategory.liqPercent,
|
|
60
|
-
collRatio: afterEnteringCategory.collRatio,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
return categoriesMapping;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const getSparkMarketsData = async (web3: Web3, network: NetworkNumber, selectedMarket: SparkMarketData, mainnetWeb3: Web3): Promise<SparkMarketsData> => {
|
|
68
|
-
const marketAddress = selectedMarket.providerAddress;
|
|
69
|
-
|
|
70
|
-
let rewardInfo: any[] = [];
|
|
71
|
-
if (network === 10) {
|
|
72
|
-
const sparkIncentivesContract = SparkIncentiveDataProviderContract(web3, network);
|
|
73
|
-
rewardInfo = await sparkIncentivesContract.methods.getReservesIncentivesData(marketAddress).call();
|
|
74
|
-
rewardInfo = rewardInfo.reduce((all, market) => {
|
|
75
|
-
// eslint-disable-next-line no-param-reassign
|
|
76
|
-
all[market.underlyingAsset] = market;
|
|
77
|
-
return all;
|
|
78
|
-
}, {});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const loanInfoContract = SparkViewContract(web3, network);
|
|
82
|
-
|
|
83
|
-
const loanInfo = await loanInfoContract.methods.getFullTokensInfo(
|
|
84
|
-
marketAddress,
|
|
85
|
-
selectedMarket.assets.map(a => getAssetInfo(ethToWeth(a)).address),
|
|
86
|
-
).call();
|
|
87
|
-
|
|
88
|
-
const assetsData: SparkAssetData[] = await Promise.all(loanInfo
|
|
89
|
-
.map(async (market, i) => {
|
|
90
|
-
const symbol = selectedMarket.assets[i];
|
|
91
|
-
|
|
92
|
-
const borrowCapInWei = new Dec(assetAmountInWei(market.borrowCap.toString(), symbol));
|
|
93
|
-
let marketLiquidity = borrowCapInWei.lt(new Dec(market.totalSupply))
|
|
94
|
-
? assetAmountInEth(borrowCapInWei
|
|
95
|
-
.sub(market.totalBorrow.toString())
|
|
96
|
-
.toString(), symbol)
|
|
97
|
-
: assetAmountInEth(new Dec(market.totalSupply.toString())
|
|
98
|
-
.sub(market.totalBorrow.toString())
|
|
99
|
-
.toString(), symbol);
|
|
100
|
-
|
|
101
|
-
if (new Dec(marketLiquidity).lt(0)) {
|
|
102
|
-
marketLiquidity = '0';
|
|
103
|
-
}
|
|
104
|
-
return ({
|
|
105
|
-
symbol: selectedMarket.assets[i],
|
|
106
|
-
isIsolated: new Dec(market.debtCeilingForIsolationMode).gt(0),
|
|
107
|
-
debtCeilingForIsolationMode: new Dec(market.debtCeilingForIsolationMode).div(100).toString(),
|
|
108
|
-
isSiloed: market.isSiloedForBorrowing,
|
|
109
|
-
eModeCategory: +market.emodeCategory,
|
|
110
|
-
isolationModeTotalDebt: new Dec(market.isolationModeTotalDebt).div(100).toString(),
|
|
111
|
-
assetId: Number(market.assetId),
|
|
112
|
-
underlyingTokenAddress: market.underlyingTokenAddress,
|
|
113
|
-
supplyRate: aprToApy(new Dec(market.supplyRate.toString()).div(1e25).toString()),
|
|
114
|
-
borrowRate: aprToApy(new Dec(market.borrowRateVariable.toString()).div(1e25).toString()),
|
|
115
|
-
borrowRateStable: aprToApy(new Dec(market.borrowRateStable.toString()).div(1e25).toString()),
|
|
116
|
-
collateralFactor: new Dec(market.collateralFactor.toString()).div(10000).toString(),
|
|
117
|
-
liquidationRatio: new Dec(market.liquidationRatio.toString()).div(10000).toString(),
|
|
118
|
-
marketLiquidity,
|
|
119
|
-
utilization: new Dec(market.totalBorrow.toString()).times(100).div(new Dec(market.totalSupply.toString())).toString(),
|
|
120
|
-
usageAsCollateralEnabled: market.usageAsCollateralEnabled,
|
|
121
|
-
supplyCap: market.supplyCap,
|
|
122
|
-
borrowCap: market.borrowCap,
|
|
123
|
-
totalSupply: assetAmountInEth(market.totalSupply.toString(), selectedMarket.assets[i]),
|
|
124
|
-
isInactive: !market.isActive,
|
|
125
|
-
isFrozen: market.isFrozen,
|
|
126
|
-
isPaused: market.isPaused,
|
|
127
|
-
canBeBorrowed: market.isActive && !market.isPaused && !market.isFrozen && market.borrowingEnabled,
|
|
128
|
-
canBeSupplied: market.isActive && !market.isPaused && !market.isFrozen,
|
|
129
|
-
canBeWithdrawn: market.isActive && !market.isPaused,
|
|
130
|
-
canBePayBacked: market.isActive && !market.isPaused,
|
|
131
|
-
disabledStableBorrowing: !market.stableBorrowRateEnabled,
|
|
132
|
-
totalBorrow: assetAmountInEth(market.totalBorrow.toString(), selectedMarket.assets[i]),
|
|
133
|
-
totalBorrowVar: assetAmountInEth(market.totalBorrowVar.toString(), selectedMarket.assets[i]),
|
|
134
|
-
price: new Dec(market.price.toString()).div(1e8).toString(), // is actually price in USD
|
|
135
|
-
isolationModeBorrowingEnabled: market.isolationModeBorrowingEnabled,
|
|
136
|
-
isFlashLoanEnabled: market.isFlashLoanEnabled,
|
|
137
|
-
aTokenAddress: market.aTokenAddress,
|
|
138
|
-
eModeCategoryData: {
|
|
139
|
-
label: market.label,
|
|
140
|
-
liquidationBonus: new Dec(market.liquidationBonus).div(10000).toString(),
|
|
141
|
-
liquidationRatio: new Dec(market.liquidationThreshold).div(10000).toString(),
|
|
142
|
-
collateralFactor: new Dec(market.ltv).div(10000).toString(),
|
|
143
|
-
priceSource: market.priceSource,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
}));
|
|
147
|
-
|
|
148
|
-
await Promise.all(assetsData.map(async (market) => {
|
|
149
|
-
/* eslint-disable no-param-reassign */
|
|
150
|
-
const rewardForMarket = (rewardInfo as any)[market.underlyingTokenAddress];
|
|
151
|
-
if (STAKING_ASSETS.includes(market.symbol)) {
|
|
152
|
-
market.incentiveSupplyApy = await getStakingApy(market.symbol, mainnetWeb3);
|
|
153
|
-
market.incentiveSupplyToken = market.symbol;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (market.symbol === 'sDAI') {
|
|
157
|
-
market.incentiveSupplyApy = await getDsrApy(web3, network);
|
|
158
|
-
market.incentiveSupplyToken = 'sDAI';
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (market.canBeBorrowed && market.incentiveSupplyApy) {
|
|
162
|
-
market.incentiveBorrowApy = `-${market.incentiveSupplyApy}`;
|
|
163
|
-
market.incentiveBorrowToken = market.incentiveSupplyToken;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (!rewardForMarket) return;
|
|
167
|
-
const supplyRewardData = rewardForMarket.aIncentiveData.rewardsTokenInformation[0];
|
|
168
|
-
if (supplyRewardData) {
|
|
169
|
-
if (supplyRewardData.emissionEndTimestamp * 1000 < Date.now()) return;
|
|
170
|
-
market.incentiveSupplyToken = supplyRewardData.rewardTokenSymbol;
|
|
171
|
-
const supplyEmissionPerSecond = supplyRewardData.emissionPerSecond;
|
|
172
|
-
const supplyRewardPrice = new Dec(supplyRewardData.rewardPriceFeed).div(10 ** supplyRewardData.priceFeedDecimals).toString();
|
|
173
|
-
market.incentiveSupplyApy = new Dec(supplyEmissionPerSecond).div((10 ** supplyRewardData.rewardTokenDecimals) / 100)
|
|
174
|
-
.mul(365 * 24 * 3600)
|
|
175
|
-
.mul(supplyRewardPrice)
|
|
176
|
-
.div(market.price)
|
|
177
|
-
.div(market.totalSupply)
|
|
178
|
-
.toString();
|
|
179
|
-
}
|
|
180
|
-
const borrowRewardData = rewardForMarket.vIncentiveData.rewardsTokenInformation[0];
|
|
181
|
-
if (borrowRewardData) {
|
|
182
|
-
if (borrowRewardData.emissionEndTimestamp * 1000 < Date.now()) return;
|
|
183
|
-
market.incentiveBorrowToken = borrowRewardData.rewardTokenSymbol;
|
|
184
|
-
const supplyEmissionPerSecond = borrowRewardData.emissionPerSecond;
|
|
185
|
-
const supplyRewardPrice = new Dec(borrowRewardData.rewardPriceFeed).div(10 ** borrowRewardData.priceFeedDecimals).toString();
|
|
186
|
-
market.incentiveBorrowApy = new Dec(supplyEmissionPerSecond).div((10 ** borrowRewardData.rewardTokenDecimals) / 100)
|
|
187
|
-
.mul(365 * 24 * 3600)
|
|
188
|
-
.mul(supplyRewardPrice)
|
|
189
|
-
.div(market.price)
|
|
190
|
-
.div(market.totalBorrowVar)
|
|
191
|
-
.toString();
|
|
192
|
-
}
|
|
193
|
-
/* eslint-enable no-param-reassign */
|
|
194
|
-
}));
|
|
195
|
-
|
|
196
|
-
const payload: SparkAssetsData = {};
|
|
197
|
-
// Sort by market size
|
|
198
|
-
assetsData
|
|
199
|
-
.sort((a, b) => {
|
|
200
|
-
const aMarket = new Dec(a.price).times(a.totalSupply).toString();
|
|
201
|
-
const bMarket = new Dec(b.price).times(b.totalSupply).toString();
|
|
202
|
-
|
|
203
|
-
return new Dec(bMarket).minus(aMarket).toNumber();
|
|
204
|
-
})
|
|
205
|
-
.forEach((assetData: SparkAssetData, i) => {
|
|
206
|
-
payload[assetData.symbol] = { ...assetData, sortIndex: i };
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
return { assetsData: payload };
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
export const EMPTY_SPARK_DATA = {
|
|
213
|
-
usedAssets: {},
|
|
214
|
-
suppliedUsd: '0',
|
|
215
|
-
borrowedUsd: '0',
|
|
216
|
-
borrowLimitUsd: '0',
|
|
217
|
-
leftToBorrowUsd: '0',
|
|
218
|
-
ratio: '0',
|
|
219
|
-
minRatio: '0',
|
|
220
|
-
netApy: '0',
|
|
221
|
-
incentiveUsd: '0',
|
|
222
|
-
totalInterestUsd: '0',
|
|
223
|
-
eModeCategory: 0,
|
|
224
|
-
isInIsolationMode: false,
|
|
225
|
-
isInSiloedMode: false,
|
|
226
|
-
collRatio: '0',
|
|
227
|
-
suppliedCollateralUsd: '0',
|
|
228
|
-
totalSupplied: '0',
|
|
229
|
-
eModeCategories: [],
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export const getSparkAccountBalances = async (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress): Promise<PositionBalances> => {
|
|
233
|
-
let balances: PositionBalances = {
|
|
234
|
-
collateral: {},
|
|
235
|
-
debt: {},
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
if (!address) {
|
|
239
|
-
return balances;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const loanInfoContract = SparkViewContract(web3, network, block);
|
|
243
|
-
|
|
244
|
-
const market = SPARK_V1(network);
|
|
245
|
-
const marketAddress = market.providerAddress;
|
|
246
|
-
// @ts-ignore
|
|
247
|
-
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
248
|
-
|
|
249
|
-
const reserveTokens = await protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
250
|
-
const symbols = reserveTokens.map(({ symbol }: { symbol: string }) => symbol);
|
|
251
|
-
const _addresses = reserveTokens.map(({ tokenAddress }: { tokenAddress: EthAddress }) => tokenAddress);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// split addresses in half to avoid gas limit by multicall
|
|
255
|
-
const middleAddressIndex = Math.floor(_addresses.length / 2);
|
|
256
|
-
|
|
257
|
-
const multicallData = [
|
|
258
|
-
{
|
|
259
|
-
target: loanInfoContract.options.address,
|
|
260
|
-
abiItem: loanInfoContract.options.jsonInterface.find(({ name }) => name === 'getTokenBalances'),
|
|
261
|
-
params: [marketAddress, address, _addresses.slice(0, middleAddressIndex)],
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
target: loanInfoContract.options.address,
|
|
265
|
-
abiItem: loanInfoContract.options.jsonInterface.find(({ name }) => name === 'getTokenBalances'),
|
|
266
|
-
params: [marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length)],
|
|
267
|
-
},
|
|
268
|
-
];
|
|
269
|
-
|
|
270
|
-
const multicallRes = await multicall(multicallData, web3, network, block);
|
|
271
|
-
|
|
272
|
-
const loanInfo = [...multicallRes[0][0], ...multicallRes[1][0]];
|
|
273
|
-
|
|
274
|
-
loanInfo.forEach((tokenInfo: any, i: number) => {
|
|
275
|
-
const asset = wethToEth(symbols[i]);
|
|
276
|
-
const assetAddr = wethToEthByAddress(_addresses[i], network).toLowerCase();
|
|
277
|
-
|
|
278
|
-
balances = {
|
|
279
|
-
collateral: {
|
|
280
|
-
...balances.collateral,
|
|
281
|
-
[addressMapping ? assetAddr : asset]: tokenInfo.balance.toString(),
|
|
282
|
-
},
|
|
283
|
-
debt: {
|
|
284
|
-
...balances.debt,
|
|
285
|
-
[addressMapping ? assetAddr : asset]: new Dec(tokenInfo.borrowsStable.toString()).add(tokenInfo.borrowsVariable.toString()).toString(),
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
return balances;
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export const getSparkAccountData = async (web3: Web3, network: NetworkNumber, address: string, extractedState: { selectedMarket: SparkMarketData, assetsData: SparkAssetsData }) => {
|
|
294
|
-
const {
|
|
295
|
-
selectedMarket: market, assetsData,
|
|
296
|
-
} = extractedState;
|
|
297
|
-
let payload: SparkPositionData = {
|
|
298
|
-
...EMPTY_SPARK_DATA,
|
|
299
|
-
lastUpdated: Date.now(),
|
|
300
|
-
};
|
|
301
|
-
if (!address) {
|
|
302
|
-
// structure that this function returns is complex and dynamic so i didnt want to hardcode it in EMPTY_SPARK_DATA
|
|
303
|
-
// This case only triggers if user doesnt have proxy and data is refetched once proxy is created
|
|
304
|
-
// TODO when refactoring spark figure out if this is the best solution.
|
|
305
|
-
payload.eModeCategories = sparkEmodeCategoriesMapping(extractedState, {});
|
|
306
|
-
|
|
307
|
-
return payload;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const loanInfoContract = SparkViewContract(web3, network);
|
|
311
|
-
const marketAddress = market.providerAddress;
|
|
312
|
-
const _addresses = market.assets.map((a) => getAssetInfo(ethToWeth(a)).address);
|
|
313
|
-
|
|
314
|
-
const middleAddressIndex = Math.floor(_addresses.length / 2); // split addresses in half to avoid gas limit by multicall
|
|
315
|
-
|
|
316
|
-
const LendingPoolAbi = getConfigContractAbi(market.lendingPool);
|
|
317
|
-
|
|
318
|
-
const multicallData = [
|
|
319
|
-
{
|
|
320
|
-
target: market.lendingPoolAddress,
|
|
321
|
-
abiItem: LendingPoolAbi.find(({ name }) => name === 'getUserEMode'),
|
|
322
|
-
params: [address],
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
target: loanInfoContract.options.address,
|
|
326
|
-
abiItem: getAbiItem(loanInfoContract.options.jsonInterface, 'getTokenBalances'),
|
|
327
|
-
params: [marketAddress, address, _addresses.slice(0, middleAddressIndex)],
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
target: loanInfoContract.options.address,
|
|
331
|
-
abiItem: getAbiItem(loanInfoContract.options.jsonInterface, 'getTokenBalances'),
|
|
332
|
-
params: [marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length)],
|
|
333
|
-
},
|
|
334
|
-
];
|
|
335
|
-
|
|
336
|
-
const multicallRes = await multicall(multicallData, web3, network);
|
|
337
|
-
|
|
338
|
-
const loanInfo = [...multicallRes[1][0], ...multicallRes[2][0]];
|
|
339
|
-
|
|
340
|
-
const usedAssets = {} as SparkUsedAssets;
|
|
341
|
-
loanInfo.forEach((tokenInfo, i) => {
|
|
342
|
-
const asset = market.assets[i];
|
|
343
|
-
const isSupplied = tokenInfo.balance.toString() !== '0';
|
|
344
|
-
const isBorrowed = tokenInfo.borrowsStable.toString() !== '0' || tokenInfo.borrowsVariable.toString() !== '0';
|
|
345
|
-
if (!isSupplied && !isBorrowed) return;
|
|
346
|
-
|
|
347
|
-
const supplied = assetAmountInEth(tokenInfo.balance.toString(), asset);
|
|
348
|
-
const borrowedStable = assetAmountInEth(tokenInfo.borrowsStable.toString(), asset);
|
|
349
|
-
const borrowedVariable = assetAmountInEth(tokenInfo.borrowsVariable.toString(), asset);
|
|
350
|
-
const enabledAsCollateral = assetsData[asset].usageAsCollateralEnabled ? tokenInfo.enabledAsCollateral : false;
|
|
351
|
-
let interestMode;
|
|
352
|
-
if (borrowedVariable === '0' && borrowedStable !== '0') {
|
|
353
|
-
interestMode = '1';
|
|
354
|
-
} else if (borrowedVariable !== '0' && borrowedStable === '0') {
|
|
355
|
-
interestMode = '2';
|
|
356
|
-
} else {
|
|
357
|
-
interestMode = 'both';
|
|
358
|
-
}
|
|
359
|
-
if (!usedAssets[asset]) usedAssets[asset] = {} as SparkUsedAsset;
|
|
360
|
-
usedAssets[asset] = {
|
|
361
|
-
...usedAssets[asset],
|
|
362
|
-
symbol: asset,
|
|
363
|
-
supplied,
|
|
364
|
-
suppliedUsd: new Dec(supplied).mul(assetsData[asset].price).toString(),
|
|
365
|
-
isSupplied,
|
|
366
|
-
collateral: enabledAsCollateral,
|
|
367
|
-
stableBorrowRate: aprToApy(new Dec(tokenInfo.stableBorrowRate).div(1e25).toString()),
|
|
368
|
-
borrowedStable,
|
|
369
|
-
borrowedVariable,
|
|
370
|
-
borrowedUsdStable: new Dec(borrowedStable).mul(assetsData[asset].price).toString(),
|
|
371
|
-
borrowedUsdVariable: new Dec(borrowedVariable).mul(assetsData[asset].price).toString(),
|
|
372
|
-
borrowed: new Dec(borrowedStable).add(borrowedVariable).toString(),
|
|
373
|
-
borrowedUsd: new Dec(new Dec(borrowedVariable).add(borrowedStable)).mul(assetsData[asset].price).toString(),
|
|
374
|
-
isBorrowed,
|
|
375
|
-
eModeCategory: assetsData[asset].eModeCategory,
|
|
376
|
-
interestMode,
|
|
377
|
-
};
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
payload.eModeCategory = +multicallRes[0][0];
|
|
381
|
-
payload = {
|
|
382
|
-
...payload,
|
|
383
|
-
usedAssets,
|
|
384
|
-
...sparkGetAggregatedPositionData({
|
|
385
|
-
...extractedState, usedAssets, eModeCategory: payload.eModeCategory,
|
|
386
|
-
}),
|
|
387
|
-
};
|
|
388
|
-
payload.eModeCategories = sparkEmodeCategoriesMapping(extractedState, usedAssets);
|
|
389
|
-
payload.isInIsolationMode = sparkIsInIsolationMode({ usedAssets, assetsData });
|
|
390
|
-
payload.isInSiloedMode = sparkIsInIsolationMode({ usedAssets, assetsData });
|
|
391
|
-
|
|
392
|
-
payload.ratio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
393
|
-
? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
394
|
-
: '0';
|
|
395
|
-
payload.minRatio = '100';
|
|
396
|
-
payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
397
|
-
? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
398
|
-
: '0';
|
|
399
|
-
|
|
400
|
-
// Calculate borrow limits per asset
|
|
401
|
-
Object.values(payload.usedAssets).forEach((item) => {
|
|
402
|
-
if (item.isBorrowed) {
|
|
403
|
-
// eslint-disable-next-line no-param-reassign
|
|
404
|
-
item.stableLimit = calculateBorrowingAssetLimit(item.borrowedUsdStable, payload.borrowLimitUsd);
|
|
405
|
-
// eslint-disable-next-line no-param-reassign
|
|
406
|
-
item.variableLimit = calculateBorrowingAssetLimit(item.borrowedUsdVariable, payload.borrowLimitUsd);
|
|
407
|
-
// eslint-disable-next-line no-param-reassign
|
|
408
|
-
item.limit = calculateBorrowingAssetLimit(item.borrowedUsd, payload.borrowLimitUsd);
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy(usedAssets, assetsData);
|
|
413
|
-
payload.netApy = netApy;
|
|
414
|
-
payload.incentiveUsd = incentiveUsd;
|
|
415
|
-
payload.totalInterestUsd = totalInterestUsd;
|
|
416
|
-
|
|
417
|
-
return payload;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
export const getSparkFullPositionData = async (web3: Web3, network: NetworkNumber, address: string, market: SparkMarketData, mainnetWeb3: Web3): Promise<SparkPositionData> => {
|
|
421
|
-
const marketData = await getSparkMarketsData(web3, network, market, mainnetWeb3);
|
|
422
|
-
const positionData = await getSparkAccountData(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market });
|
|
423
|
-
return positionData;
|
|
424
|
-
};
|
|
1
|
+
import Web3 from 'web3';
|
|
2
|
+
import Dec from 'decimal.js';
|
|
3
|
+
import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
|
|
4
|
+
import {
|
|
5
|
+
Blockish, EthAddress, NetworkNumber, PositionBalances,
|
|
6
|
+
} from '../types/common';
|
|
7
|
+
import {
|
|
8
|
+
ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress,
|
|
9
|
+
} from '../services/utils';
|
|
10
|
+
import {
|
|
11
|
+
calculateNetApy, getStakingApy, STAKING_ASSETS,
|
|
12
|
+
} from '../staking';
|
|
13
|
+
import { getDsrApy } from '../services/dsrService';
|
|
14
|
+
import {
|
|
15
|
+
SparkIncentiveDataProviderContract,
|
|
16
|
+
SparkViewContract,
|
|
17
|
+
getConfigContractAbi,
|
|
18
|
+
createContractWrapper,
|
|
19
|
+
} from '../contracts';
|
|
20
|
+
import {
|
|
21
|
+
SparkEModeCategoryDataMapping,
|
|
22
|
+
SparkAssetData,
|
|
23
|
+
SparkAssetsData,
|
|
24
|
+
SparkMarketData,
|
|
25
|
+
SparkMarketsData,
|
|
26
|
+
SparkPositionData,
|
|
27
|
+
SparkUsedAsset,
|
|
28
|
+
SparkUsedAssets,
|
|
29
|
+
} from '../types';
|
|
30
|
+
import { multicall } from '../multicall';
|
|
31
|
+
import { sparkGetAggregatedPositionData, sparkIsInIsolationMode } from '../helpers/sparkHelpers';
|
|
32
|
+
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
33
|
+
import { SPARK_V1 } from '../markets/spark';
|
|
34
|
+
|
|
35
|
+
export const sparkEmodeCategoriesMapping = (extractedState: { assetsData: SparkAssetsData }, usedAssets: SparkUsedAssets) => {
|
|
36
|
+
const { assetsData } = extractedState;
|
|
37
|
+
const usedAssetsValues = Object.values(usedAssets);
|
|
38
|
+
|
|
39
|
+
const categoriesMapping: { [key: number]: SparkEModeCategoryDataMapping } = {};
|
|
40
|
+
Object.values(assetsData).forEach((a) => {
|
|
41
|
+
const borrowingOnlyFromCategory = a.eModeCategory === 0
|
|
42
|
+
? true
|
|
43
|
+
: !usedAssetsValues.filter(u => u.isBorrowed && u.eModeCategory !== a.eModeCategory).length;
|
|
44
|
+
const afterEnteringCategory = sparkGetAggregatedPositionData({
|
|
45
|
+
...extractedState, usedAssets, eModeCategory: a.eModeCategory,
|
|
46
|
+
});
|
|
47
|
+
const willStayOverCollateralized = new Dec(afterEnteringCategory.ratio).eq(0) || new Dec(afterEnteringCategory.ratio).gt(afterEnteringCategory.liqPercent);
|
|
48
|
+
const enteringTerms = [borrowingOnlyFromCategory, willStayOverCollateralized];
|
|
49
|
+
|
|
50
|
+
categoriesMapping[a.eModeCategory] = {
|
|
51
|
+
enteringTerms,
|
|
52
|
+
canEnterCategory: !enteringTerms.includes(false),
|
|
53
|
+
id: a.eModeCategory,
|
|
54
|
+
data: a.eModeCategoryData,
|
|
55
|
+
assets: a.eModeCategory === 0 ? [] : [...(categoriesMapping[a.eModeCategory]?.assets || []), a.symbol],
|
|
56
|
+
enabledData: {
|
|
57
|
+
ratio: afterEnteringCategory.ratio,
|
|
58
|
+
liqRatio: afterEnteringCategory.liqRatio,
|
|
59
|
+
liqPercent: afterEnteringCategory.liqPercent,
|
|
60
|
+
collRatio: afterEnteringCategory.collRatio,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return categoriesMapping;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const getSparkMarketsData = async (web3: Web3, network: NetworkNumber, selectedMarket: SparkMarketData, mainnetWeb3: Web3): Promise<SparkMarketsData> => {
|
|
68
|
+
const marketAddress = selectedMarket.providerAddress;
|
|
69
|
+
|
|
70
|
+
let rewardInfo: any[] = [];
|
|
71
|
+
if (network === 10) {
|
|
72
|
+
const sparkIncentivesContract = SparkIncentiveDataProviderContract(web3, network);
|
|
73
|
+
rewardInfo = await sparkIncentivesContract.methods.getReservesIncentivesData(marketAddress).call();
|
|
74
|
+
rewardInfo = rewardInfo.reduce((all, market) => {
|
|
75
|
+
// eslint-disable-next-line no-param-reassign
|
|
76
|
+
all[market.underlyingAsset] = market;
|
|
77
|
+
return all;
|
|
78
|
+
}, {});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const loanInfoContract = SparkViewContract(web3, network);
|
|
82
|
+
|
|
83
|
+
const loanInfo = await loanInfoContract.methods.getFullTokensInfo(
|
|
84
|
+
marketAddress,
|
|
85
|
+
selectedMarket.assets.map(a => getAssetInfo(ethToWeth(a)).address),
|
|
86
|
+
).call();
|
|
87
|
+
|
|
88
|
+
const assetsData: SparkAssetData[] = await Promise.all(loanInfo
|
|
89
|
+
.map(async (market, i) => {
|
|
90
|
+
const symbol = selectedMarket.assets[i];
|
|
91
|
+
|
|
92
|
+
const borrowCapInWei = new Dec(assetAmountInWei(market.borrowCap.toString(), symbol));
|
|
93
|
+
let marketLiquidity = borrowCapInWei.lt(new Dec(market.totalSupply))
|
|
94
|
+
? assetAmountInEth(borrowCapInWei
|
|
95
|
+
.sub(market.totalBorrow.toString())
|
|
96
|
+
.toString(), symbol)
|
|
97
|
+
: assetAmountInEth(new Dec(market.totalSupply.toString())
|
|
98
|
+
.sub(market.totalBorrow.toString())
|
|
99
|
+
.toString(), symbol);
|
|
100
|
+
|
|
101
|
+
if (new Dec(marketLiquidity).lt(0)) {
|
|
102
|
+
marketLiquidity = '0';
|
|
103
|
+
}
|
|
104
|
+
return ({
|
|
105
|
+
symbol: selectedMarket.assets[i],
|
|
106
|
+
isIsolated: new Dec(market.debtCeilingForIsolationMode).gt(0),
|
|
107
|
+
debtCeilingForIsolationMode: new Dec(market.debtCeilingForIsolationMode).div(100).toString(),
|
|
108
|
+
isSiloed: market.isSiloedForBorrowing,
|
|
109
|
+
eModeCategory: +market.emodeCategory,
|
|
110
|
+
isolationModeTotalDebt: new Dec(market.isolationModeTotalDebt).div(100).toString(),
|
|
111
|
+
assetId: Number(market.assetId),
|
|
112
|
+
underlyingTokenAddress: market.underlyingTokenAddress,
|
|
113
|
+
supplyRate: aprToApy(new Dec(market.supplyRate.toString()).div(1e25).toString()),
|
|
114
|
+
borrowRate: aprToApy(new Dec(market.borrowRateVariable.toString()).div(1e25).toString()),
|
|
115
|
+
borrowRateStable: aprToApy(new Dec(market.borrowRateStable.toString()).div(1e25).toString()),
|
|
116
|
+
collateralFactor: new Dec(market.collateralFactor.toString()).div(10000).toString(),
|
|
117
|
+
liquidationRatio: new Dec(market.liquidationRatio.toString()).div(10000).toString(),
|
|
118
|
+
marketLiquidity,
|
|
119
|
+
utilization: new Dec(market.totalBorrow.toString()).times(100).div(new Dec(market.totalSupply.toString())).toString(),
|
|
120
|
+
usageAsCollateralEnabled: market.usageAsCollateralEnabled,
|
|
121
|
+
supplyCap: market.supplyCap,
|
|
122
|
+
borrowCap: market.borrowCap,
|
|
123
|
+
totalSupply: assetAmountInEth(market.totalSupply.toString(), selectedMarket.assets[i]),
|
|
124
|
+
isInactive: !market.isActive,
|
|
125
|
+
isFrozen: market.isFrozen,
|
|
126
|
+
isPaused: market.isPaused,
|
|
127
|
+
canBeBorrowed: market.isActive && !market.isPaused && !market.isFrozen && market.borrowingEnabled,
|
|
128
|
+
canBeSupplied: market.isActive && !market.isPaused && !market.isFrozen,
|
|
129
|
+
canBeWithdrawn: market.isActive && !market.isPaused,
|
|
130
|
+
canBePayBacked: market.isActive && !market.isPaused,
|
|
131
|
+
disabledStableBorrowing: !market.stableBorrowRateEnabled,
|
|
132
|
+
totalBorrow: assetAmountInEth(market.totalBorrow.toString(), selectedMarket.assets[i]),
|
|
133
|
+
totalBorrowVar: assetAmountInEth(market.totalBorrowVar.toString(), selectedMarket.assets[i]),
|
|
134
|
+
price: new Dec(market.price.toString()).div(1e8).toString(), // is actually price in USD
|
|
135
|
+
isolationModeBorrowingEnabled: market.isolationModeBorrowingEnabled,
|
|
136
|
+
isFlashLoanEnabled: market.isFlashLoanEnabled,
|
|
137
|
+
aTokenAddress: market.aTokenAddress,
|
|
138
|
+
eModeCategoryData: {
|
|
139
|
+
label: market.label,
|
|
140
|
+
liquidationBonus: new Dec(market.liquidationBonus).div(10000).toString(),
|
|
141
|
+
liquidationRatio: new Dec(market.liquidationThreshold).div(10000).toString(),
|
|
142
|
+
collateralFactor: new Dec(market.ltv).div(10000).toString(),
|
|
143
|
+
priceSource: market.priceSource,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
await Promise.all(assetsData.map(async (market) => {
|
|
149
|
+
/* eslint-disable no-param-reassign */
|
|
150
|
+
const rewardForMarket = (rewardInfo as any)[market.underlyingTokenAddress];
|
|
151
|
+
if (STAKING_ASSETS.includes(market.symbol)) {
|
|
152
|
+
market.incentiveSupplyApy = await getStakingApy(market.symbol, mainnetWeb3);
|
|
153
|
+
market.incentiveSupplyToken = market.symbol;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (market.symbol === 'sDAI') {
|
|
157
|
+
market.incentiveSupplyApy = await getDsrApy(web3, network);
|
|
158
|
+
market.incentiveSupplyToken = 'sDAI';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (market.canBeBorrowed && market.incentiveSupplyApy) {
|
|
162
|
+
market.incentiveBorrowApy = `-${market.incentiveSupplyApy}`;
|
|
163
|
+
market.incentiveBorrowToken = market.incentiveSupplyToken;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!rewardForMarket) return;
|
|
167
|
+
const supplyRewardData = rewardForMarket.aIncentiveData.rewardsTokenInformation[0];
|
|
168
|
+
if (supplyRewardData) {
|
|
169
|
+
if (supplyRewardData.emissionEndTimestamp * 1000 < Date.now()) return;
|
|
170
|
+
market.incentiveSupplyToken = supplyRewardData.rewardTokenSymbol;
|
|
171
|
+
const supplyEmissionPerSecond = supplyRewardData.emissionPerSecond;
|
|
172
|
+
const supplyRewardPrice = new Dec(supplyRewardData.rewardPriceFeed).div(10 ** supplyRewardData.priceFeedDecimals).toString();
|
|
173
|
+
market.incentiveSupplyApy = new Dec(supplyEmissionPerSecond).div((10 ** supplyRewardData.rewardTokenDecimals) / 100)
|
|
174
|
+
.mul(365 * 24 * 3600)
|
|
175
|
+
.mul(supplyRewardPrice)
|
|
176
|
+
.div(market.price)
|
|
177
|
+
.div(market.totalSupply)
|
|
178
|
+
.toString();
|
|
179
|
+
}
|
|
180
|
+
const borrowRewardData = rewardForMarket.vIncentiveData.rewardsTokenInformation[0];
|
|
181
|
+
if (borrowRewardData) {
|
|
182
|
+
if (borrowRewardData.emissionEndTimestamp * 1000 < Date.now()) return;
|
|
183
|
+
market.incentiveBorrowToken = borrowRewardData.rewardTokenSymbol;
|
|
184
|
+
const supplyEmissionPerSecond = borrowRewardData.emissionPerSecond;
|
|
185
|
+
const supplyRewardPrice = new Dec(borrowRewardData.rewardPriceFeed).div(10 ** borrowRewardData.priceFeedDecimals).toString();
|
|
186
|
+
market.incentiveBorrowApy = new Dec(supplyEmissionPerSecond).div((10 ** borrowRewardData.rewardTokenDecimals) / 100)
|
|
187
|
+
.mul(365 * 24 * 3600)
|
|
188
|
+
.mul(supplyRewardPrice)
|
|
189
|
+
.div(market.price)
|
|
190
|
+
.div(market.totalBorrowVar)
|
|
191
|
+
.toString();
|
|
192
|
+
}
|
|
193
|
+
/* eslint-enable no-param-reassign */
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
const payload: SparkAssetsData = {};
|
|
197
|
+
// Sort by market size
|
|
198
|
+
assetsData
|
|
199
|
+
.sort((a, b) => {
|
|
200
|
+
const aMarket = new Dec(a.price).times(a.totalSupply).toString();
|
|
201
|
+
const bMarket = new Dec(b.price).times(b.totalSupply).toString();
|
|
202
|
+
|
|
203
|
+
return new Dec(bMarket).minus(aMarket).toNumber();
|
|
204
|
+
})
|
|
205
|
+
.forEach((assetData: SparkAssetData, i) => {
|
|
206
|
+
payload[assetData.symbol] = { ...assetData, sortIndex: i };
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return { assetsData: payload };
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export const EMPTY_SPARK_DATA = {
|
|
213
|
+
usedAssets: {},
|
|
214
|
+
suppliedUsd: '0',
|
|
215
|
+
borrowedUsd: '0',
|
|
216
|
+
borrowLimitUsd: '0',
|
|
217
|
+
leftToBorrowUsd: '0',
|
|
218
|
+
ratio: '0',
|
|
219
|
+
minRatio: '0',
|
|
220
|
+
netApy: '0',
|
|
221
|
+
incentiveUsd: '0',
|
|
222
|
+
totalInterestUsd: '0',
|
|
223
|
+
eModeCategory: 0,
|
|
224
|
+
isInIsolationMode: false,
|
|
225
|
+
isInSiloedMode: false,
|
|
226
|
+
collRatio: '0',
|
|
227
|
+
suppliedCollateralUsd: '0',
|
|
228
|
+
totalSupplied: '0',
|
|
229
|
+
eModeCategories: [],
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const getSparkAccountBalances = async (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress): Promise<PositionBalances> => {
|
|
233
|
+
let balances: PositionBalances = {
|
|
234
|
+
collateral: {},
|
|
235
|
+
debt: {},
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
if (!address) {
|
|
239
|
+
return balances;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const loanInfoContract = SparkViewContract(web3, network, block);
|
|
243
|
+
|
|
244
|
+
const market = SPARK_V1(network);
|
|
245
|
+
const marketAddress = market.providerAddress;
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
const protocolDataProviderContract = createContractWrapper(web3, network, market.protocolData, market.protocolDataAddress);
|
|
248
|
+
|
|
249
|
+
const reserveTokens = await protocolDataProviderContract.methods.getAllReservesTokens().call({}, block);
|
|
250
|
+
const symbols = reserveTokens.map(({ symbol }: { symbol: string }) => symbol);
|
|
251
|
+
const _addresses = reserveTokens.map(({ tokenAddress }: { tokenAddress: EthAddress }) => tokenAddress);
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
// split addresses in half to avoid gas limit by multicall
|
|
255
|
+
const middleAddressIndex = Math.floor(_addresses.length / 2);
|
|
256
|
+
|
|
257
|
+
const multicallData = [
|
|
258
|
+
{
|
|
259
|
+
target: loanInfoContract.options.address,
|
|
260
|
+
abiItem: loanInfoContract.options.jsonInterface.find(({ name }) => name === 'getTokenBalances'),
|
|
261
|
+
params: [marketAddress, address, _addresses.slice(0, middleAddressIndex)],
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
target: loanInfoContract.options.address,
|
|
265
|
+
abiItem: loanInfoContract.options.jsonInterface.find(({ name }) => name === 'getTokenBalances'),
|
|
266
|
+
params: [marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length)],
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
const multicallRes = await multicall(multicallData, web3, network, block);
|
|
271
|
+
|
|
272
|
+
const loanInfo = [...multicallRes[0][0], ...multicallRes[1][0]];
|
|
273
|
+
|
|
274
|
+
loanInfo.forEach((tokenInfo: any, i: number) => {
|
|
275
|
+
const asset = wethToEth(symbols[i]);
|
|
276
|
+
const assetAddr = wethToEthByAddress(_addresses[i], network).toLowerCase();
|
|
277
|
+
|
|
278
|
+
balances = {
|
|
279
|
+
collateral: {
|
|
280
|
+
...balances.collateral,
|
|
281
|
+
[addressMapping ? assetAddr : asset]: tokenInfo.balance.toString(),
|
|
282
|
+
},
|
|
283
|
+
debt: {
|
|
284
|
+
...balances.debt,
|
|
285
|
+
[addressMapping ? assetAddr : asset]: new Dec(tokenInfo.borrowsStable.toString()).add(tokenInfo.borrowsVariable.toString()).toString(),
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return balances;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export const getSparkAccountData = async (web3: Web3, network: NetworkNumber, address: string, extractedState: { selectedMarket: SparkMarketData, assetsData: SparkAssetsData }) => {
|
|
294
|
+
const {
|
|
295
|
+
selectedMarket: market, assetsData,
|
|
296
|
+
} = extractedState;
|
|
297
|
+
let payload: SparkPositionData = {
|
|
298
|
+
...EMPTY_SPARK_DATA,
|
|
299
|
+
lastUpdated: Date.now(),
|
|
300
|
+
};
|
|
301
|
+
if (!address) {
|
|
302
|
+
// structure that this function returns is complex and dynamic so i didnt want to hardcode it in EMPTY_SPARK_DATA
|
|
303
|
+
// This case only triggers if user doesnt have proxy and data is refetched once proxy is created
|
|
304
|
+
// TODO when refactoring spark figure out if this is the best solution.
|
|
305
|
+
payload.eModeCategories = sparkEmodeCategoriesMapping(extractedState, {});
|
|
306
|
+
|
|
307
|
+
return payload;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const loanInfoContract = SparkViewContract(web3, network);
|
|
311
|
+
const marketAddress = market.providerAddress;
|
|
312
|
+
const _addresses = market.assets.map((a) => getAssetInfo(ethToWeth(a)).address);
|
|
313
|
+
|
|
314
|
+
const middleAddressIndex = Math.floor(_addresses.length / 2); // split addresses in half to avoid gas limit by multicall
|
|
315
|
+
|
|
316
|
+
const LendingPoolAbi = getConfigContractAbi(market.lendingPool);
|
|
317
|
+
|
|
318
|
+
const multicallData = [
|
|
319
|
+
{
|
|
320
|
+
target: market.lendingPoolAddress,
|
|
321
|
+
abiItem: LendingPoolAbi.find(({ name }) => name === 'getUserEMode'),
|
|
322
|
+
params: [address],
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
target: loanInfoContract.options.address,
|
|
326
|
+
abiItem: getAbiItem(loanInfoContract.options.jsonInterface, 'getTokenBalances'),
|
|
327
|
+
params: [marketAddress, address, _addresses.slice(0, middleAddressIndex)],
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
target: loanInfoContract.options.address,
|
|
331
|
+
abiItem: getAbiItem(loanInfoContract.options.jsonInterface, 'getTokenBalances'),
|
|
332
|
+
params: [marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length)],
|
|
333
|
+
},
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
const multicallRes = await multicall(multicallData, web3, network);
|
|
337
|
+
|
|
338
|
+
const loanInfo = [...multicallRes[1][0], ...multicallRes[2][0]];
|
|
339
|
+
|
|
340
|
+
const usedAssets = {} as SparkUsedAssets;
|
|
341
|
+
loanInfo.forEach((tokenInfo, i) => {
|
|
342
|
+
const asset = market.assets[i];
|
|
343
|
+
const isSupplied = tokenInfo.balance.toString() !== '0';
|
|
344
|
+
const isBorrowed = tokenInfo.borrowsStable.toString() !== '0' || tokenInfo.borrowsVariable.toString() !== '0';
|
|
345
|
+
if (!isSupplied && !isBorrowed) return;
|
|
346
|
+
|
|
347
|
+
const supplied = assetAmountInEth(tokenInfo.balance.toString(), asset);
|
|
348
|
+
const borrowedStable = assetAmountInEth(tokenInfo.borrowsStable.toString(), asset);
|
|
349
|
+
const borrowedVariable = assetAmountInEth(tokenInfo.borrowsVariable.toString(), asset);
|
|
350
|
+
const enabledAsCollateral = assetsData[asset].usageAsCollateralEnabled ? tokenInfo.enabledAsCollateral : false;
|
|
351
|
+
let interestMode;
|
|
352
|
+
if (borrowedVariable === '0' && borrowedStable !== '0') {
|
|
353
|
+
interestMode = '1';
|
|
354
|
+
} else if (borrowedVariable !== '0' && borrowedStable === '0') {
|
|
355
|
+
interestMode = '2';
|
|
356
|
+
} else {
|
|
357
|
+
interestMode = 'both';
|
|
358
|
+
}
|
|
359
|
+
if (!usedAssets[asset]) usedAssets[asset] = {} as SparkUsedAsset;
|
|
360
|
+
usedAssets[asset] = {
|
|
361
|
+
...usedAssets[asset],
|
|
362
|
+
symbol: asset,
|
|
363
|
+
supplied,
|
|
364
|
+
suppliedUsd: new Dec(supplied).mul(assetsData[asset].price).toString(),
|
|
365
|
+
isSupplied,
|
|
366
|
+
collateral: enabledAsCollateral,
|
|
367
|
+
stableBorrowRate: aprToApy(new Dec(tokenInfo.stableBorrowRate).div(1e25).toString()),
|
|
368
|
+
borrowedStable,
|
|
369
|
+
borrowedVariable,
|
|
370
|
+
borrowedUsdStable: new Dec(borrowedStable).mul(assetsData[asset].price).toString(),
|
|
371
|
+
borrowedUsdVariable: new Dec(borrowedVariable).mul(assetsData[asset].price).toString(),
|
|
372
|
+
borrowed: new Dec(borrowedStable).add(borrowedVariable).toString(),
|
|
373
|
+
borrowedUsd: new Dec(new Dec(borrowedVariable).add(borrowedStable)).mul(assetsData[asset].price).toString(),
|
|
374
|
+
isBorrowed,
|
|
375
|
+
eModeCategory: assetsData[asset].eModeCategory,
|
|
376
|
+
interestMode,
|
|
377
|
+
};
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
payload.eModeCategory = +multicallRes[0][0];
|
|
381
|
+
payload = {
|
|
382
|
+
...payload,
|
|
383
|
+
usedAssets,
|
|
384
|
+
...sparkGetAggregatedPositionData({
|
|
385
|
+
...extractedState, usedAssets, eModeCategory: payload.eModeCategory,
|
|
386
|
+
}),
|
|
387
|
+
};
|
|
388
|
+
payload.eModeCategories = sparkEmodeCategoriesMapping(extractedState, usedAssets);
|
|
389
|
+
payload.isInIsolationMode = sparkIsInIsolationMode({ usedAssets, assetsData });
|
|
390
|
+
payload.isInSiloedMode = sparkIsInIsolationMode({ usedAssets, assetsData });
|
|
391
|
+
|
|
392
|
+
payload.ratio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
393
|
+
? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
394
|
+
: '0';
|
|
395
|
+
payload.minRatio = '100';
|
|
396
|
+
payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
397
|
+
? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
398
|
+
: '0';
|
|
399
|
+
|
|
400
|
+
// Calculate borrow limits per asset
|
|
401
|
+
Object.values(payload.usedAssets).forEach((item) => {
|
|
402
|
+
if (item.isBorrowed) {
|
|
403
|
+
// eslint-disable-next-line no-param-reassign
|
|
404
|
+
item.stableLimit = calculateBorrowingAssetLimit(item.borrowedUsdStable, payload.borrowLimitUsd);
|
|
405
|
+
// eslint-disable-next-line no-param-reassign
|
|
406
|
+
item.variableLimit = calculateBorrowingAssetLimit(item.borrowedUsdVariable, payload.borrowLimitUsd);
|
|
407
|
+
// eslint-disable-next-line no-param-reassign
|
|
408
|
+
item.limit = calculateBorrowingAssetLimit(item.borrowedUsd, payload.borrowLimitUsd);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy(usedAssets, assetsData);
|
|
413
|
+
payload.netApy = netApy;
|
|
414
|
+
payload.incentiveUsd = incentiveUsd;
|
|
415
|
+
payload.totalInterestUsd = totalInterestUsd;
|
|
416
|
+
|
|
417
|
+
return payload;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export const getSparkFullPositionData = async (web3: Web3, network: NetworkNumber, address: string, market: SparkMarketData, mainnetWeb3: Web3): Promise<SparkPositionData> => {
|
|
421
|
+
const marketData = await getSparkMarketsData(web3, network, market, mainnetWeb3);
|
|
422
|
+
const positionData = await getSparkAccountData(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market });
|
|
423
|
+
return positionData;
|
|
424
|
+
};
|