@raac/rpc 1.0.1 → 1.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RPCLibrary.js +61 -8
- package/dist/artifacts/core/collectors/FeeCollector.sol/FeeCollector.json +1743 -0
- package/dist/artifacts/core/minters/RAACMinter/RAACMinter.sol/RAACMinter.json +175 -67
- package/dist/artifacts/core/oracles/BaseVRFv2Consumer.sol/BaseVRFv2Consumer.json +279 -0
- package/dist/artifacts/core/pools/LendingPool/LendingPool.sol/LendingPool.json +1231 -195
- package/dist/artifacts/core/pools/StabilityPool/StabilityPool.sol/StabilityPool.json +153 -199
- package/dist/artifacts/core/primitives/RAACHousePrices.sol/RAACHousePrices.json +72 -2
- package/dist/artifacts/core/tokens/DEToken.sol/DEToken.json +2 -2
- package/dist/artifacts/core/tokens/IndexToken.sol/IndexToken.json +770 -0
- package/dist/artifacts/core/tokens/RAACNFT.sol/RAACNFT.json +707 -49
- package/dist/artifacts/core/tokens/RAACToken.sol/RAACToken.json +23 -84
- package/dist/artifacts/core/tokens/RToken.sol/RToken.json +62 -62
- package/dist/artifacts/core/tokens/veRAACToken.sol/veRAACToken.json +2 -2
- package/dist/artifacts/mocks/core/oracles/MockVRFCoordinatorV2.sol/MockVRFCoordinatorV2.json +774 -0
- package/dist/artifacts/zeno/Auction.sol/Auction.json +34 -114
- package/dist/artifacts/zeno/AuctionFactory.sol/AuctionFactory.json +3 -3
- package/dist/artifacts/zeno/Zeno.sol/Zeno.json +3 -3
- package/dist/artifacts/zeno/ZenoFactory.sol/ZenoFactory.json +3 -3
- package/dist/configs/chains/17000.json +127 -0
- package/dist/configs/chains/8453.json +26 -14
- package/dist/configs/chains/index.js +2 -0
- package/dist/configs/createConfig.js +6 -0
- package/dist/contracts/feeCollector/claimRewardFromPool.js +24 -0
- package/dist/contracts/housePrices/getLatestPrice.js +1 -1
- package/dist/contracts/indexToken/getNextRandomNFT.js +30 -0
- package/dist/contracts/indexToken/redeemNFT.js +39 -0
- package/dist/nfts/getAllTokens.js +34 -0
- package/dist/nfts/{addNewBatch.js → getBaseUri.js} +7 -8
- package/dist/nfts/getMintFeePercentage.js +23 -0
- package/dist/nfts/getMintPrice.js +28 -0
- package/dist/nfts/getTokenURI.js +23 -0
- package/dist/nfts/getTokensByOwner.js +35 -0
- package/dist/nfts/getTotalPropertiesCount.js +23 -0
- package/dist/nfts/{getCurrentBatchSize.js → totalNFTSupply.js} +3 -3
- package/dist/pools/lendingPool/borrowFromLendingPool.js +4 -3
- package/dist/pools/lendingPool/borrowFromLendingPoolWithInsurance.js +40 -0
- package/dist/pools/lendingPool/calculateInsuranceFee.js +20 -0
- package/dist/pools/lendingPool/claimReward.js +22 -0
- package/dist/pools/lendingPool/closeLiquidation.js +28 -0
- package/dist/pools/lendingPool/depositNFTToLendingPool.js +0 -1
- package/dist/pools/lendingPool/depositToLendingPool.js +2 -2
- package/dist/pools/lendingPool/getAllUserData.js +28 -0
- package/dist/pools/lendingPool/getEligibleUserDeposits.js +27 -0
- package/dist/pools/lendingPool/getHealthFactor.js +27 -0
- package/dist/pools/lendingPool/getLendingPoolInfo.js +8 -5
- package/dist/pools/lendingPool/getPendingReward.js +20 -0
- package/dist/pools/lendingPool/getPositionDebt.js +27 -0
- package/dist/pools/lendingPool/getPositionScaledDebt.js +27 -0
- package/dist/pools/lendingPool/getPositionView.js +38 -0
- package/dist/pools/lendingPool/getPositionsScaledDebt.js +27 -0
- package/dist/pools/lendingPool/getRawUserDepositsInLendingPool.js +21 -0
- package/dist/pools/lendingPool/getUserCollateralValue.js +27 -0
- package/dist/pools/lendingPool/initializeLiquidation.js +28 -0
- package/dist/pools/lendingPool/repayToLendingPool.js +4 -8
- package/dist/pools/lendingPool/withdrawFromLendingPool.js +2 -2
- package/dist/pools/stabilityPool/depositNFTToStabilityPool.js +40 -0
- package/dist/pools/stabilityPool/getRawUserDepositsInStabilityPool.js +21 -0
- package/dist/pools/stabilityPool/getStabilityPoolInfo.js +2 -12
- package/dist/scripts/index.js +90 -35
- package/dist/types/RPCLibrary.d.ts +61 -8
- package/dist/types/configs/chains/index.d.ts +2 -0
- package/dist/types/configs/createConfig.d.ts +6 -0
- package/dist/types/configs/index.d.ts +1 -0
- package/dist/types/contracts/feeCollector/claimRewardFromPool.d.ts +4 -0
- package/dist/types/contracts/housePrices/getLatestPrice.d.ts +1 -1
- package/dist/types/contracts/indexToken/getNextRandomNFT.d.ts +7 -0
- package/dist/types/contracts/indexToken/redeemNFT.d.ts +4 -0
- package/dist/types/nfts/getAllTokens.d.ts +7 -0
- package/dist/types/nfts/getBaseUri.d.ts +4 -0
- package/dist/types/nfts/getMintFeePercentage.d.ts +4 -0
- package/dist/types/nfts/getMintPrice.d.ts +7 -0
- package/dist/types/nfts/getTokenURI.d.ts +4 -0
- package/dist/types/nfts/getTokensByOwner.d.ts +10 -0
- package/dist/types/nfts/getTotalPropertiesCount.d.ts +4 -0
- package/dist/types/nfts/totalNFTSupply.d.ts +4 -0
- package/dist/types/pools/lendingPool/borrowFromLendingPool.d.ts +1 -1
- package/dist/types/pools/lendingPool/borrowFromLendingPoolWithInsurance.d.ts +4 -0
- package/dist/types/pools/lendingPool/calculateInsuranceFee.d.ts +4 -0
- package/dist/types/pools/lendingPool/claimReward.d.ts +4 -0
- package/dist/types/pools/lendingPool/closeLiquidation.d.ts +11 -0
- package/dist/types/pools/lendingPool/getAllUserData.d.ts +16 -0
- package/dist/types/pools/lendingPool/getEligibleUserDeposits.d.ts +11 -0
- package/dist/types/pools/lendingPool/getHealthFactor.d.ts +11 -0
- package/dist/types/pools/lendingPool/getLendingPoolInfo.d.ts +2 -1
- package/dist/types/pools/lendingPool/getPendingReward.d.ts +4 -0
- package/dist/types/pools/lendingPool/getPositionDebt.d.ts +11 -0
- package/dist/types/pools/lendingPool/getPositionScaledDebt.d.ts +11 -0
- package/dist/types/pools/lendingPool/getPositionView.d.ts +27 -0
- package/dist/types/pools/lendingPool/getPositionsScaledDebt.d.ts +11 -0
- package/dist/types/pools/lendingPool/getRawUserDepositsInLendingPool.d.ts +4 -0
- package/dist/types/pools/lendingPool/getUserCollateralValue.d.ts +11 -0
- package/dist/types/pools/lendingPool/initializeLiquidation.d.ts +11 -0
- package/dist/types/pools/lendingPool/repayToLendingPool.d.ts +2 -2
- package/dist/types/pools/lendingPool/withdrawNFTFromLendingPool.d.ts +1 -1
- package/dist/types/pools/stabilityPool/depositNFTToStabilityPool.d.ts +4 -0
- package/dist/types/pools/stabilityPool/getRawUserDepositsInStabilityPool.d.ts +4 -0
- package/dist/types/pools/stabilityPool/getStabilityPoolInfo.d.ts +1 -3
- package/dist/types/typechain-types/@chainlink/contracts/src/v0.8/index.d.ts +2 -0
- package/dist/types/typechain-types/@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.d.ts +35 -0
- package/dist/types/typechain-types/@chainlink/contracts/src/v0.8/vrf/index.d.ts +3 -0
- package/dist/types/typechain-types/@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.d.ts +156 -0
- package/dist/types/typechain-types/@chainlink/contracts/src/v0.8/vrf/interfaces/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/core/collectors/FeeCollector.d.ts +446 -221
- package/dist/types/typechain-types/contracts/core/minters/RAACMinter/RAACMinter.d.ts +108 -20
- package/dist/types/typechain-types/contracts/core/minters/RAACReleaseOrchestrator/RAACReleaseOrchestrator.d.ts +6 -16
- package/dist/types/typechain-types/contracts/core/oracles/BaseVRFv2Consumer.d.ts +166 -0
- package/dist/types/typechain-types/contracts/core/oracles/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/core/pools/LendingPool/LendingPool.d.ts +811 -99
- package/dist/types/typechain-types/contracts/core/pools/StabilityPool/StabilityPool.d.ts +152 -148
- package/dist/types/typechain-types/contracts/core/pools/StabilityPool/index.d.ts +0 -1
- package/dist/types/typechain-types/contracts/core/primitives/RAACHousePrices.d.ts +29 -2
- package/dist/types/typechain-types/contracts/core/tokens/DebtToken.d.ts +65 -51
- package/dist/types/typechain-types/contracts/core/tokens/IndexToken.d.ts +187 -2
- package/dist/types/typechain-types/contracts/core/tokens/RAACNFT.d.ts +413 -19
- package/dist/types/typechain-types/contracts/core/tokens/RToken.d.ts +40 -40
- package/dist/types/typechain-types/contracts/interfaces/core/collectors/IBaseCollector.d.ts +39 -0
- package/dist/types/typechain-types/contracts/interfaces/core/collectors/IFeeCollector.d.ts +317 -130
- package/dist/types/typechain-types/contracts/interfaces/core/collectors/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/interfaces/core/index.d.ts +2 -0
- package/dist/types/typechain-types/contracts/interfaces/core/minters/RAACMinter/IRAACMinter.d.ts +58 -22
- package/dist/types/typechain-types/contracts/interfaces/core/minters/RAACReleaseOrchestrator/IReleaseOrchestrator.d.ts +5 -3
- package/dist/types/typechain-types/contracts/interfaces/core/oracles/IBaseVRFv2Consumer.d.ts +86 -0
- package/dist/types/typechain-types/contracts/interfaces/core/oracles/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/interfaces/core/pools/ILiquidityPool.d.ts +83 -45
- package/dist/types/typechain-types/contracts/interfaces/core/pools/LendingPool/ILendingPool.d.ts +539 -54
- package/dist/types/typechain-types/contracts/interfaces/core/pools/StabilityPool/IStabilityPool.d.ts +92 -71
- package/dist/types/typechain-types/contracts/interfaces/core/tokens/IDebtToken.d.ts +123 -27
- package/dist/types/typechain-types/contracts/interfaces/core/tokens/IIndexToken.d.ts +187 -0
- package/dist/types/typechain-types/contracts/interfaces/core/tokens/IRAACNFT.d.ts +243 -17
- package/dist/types/typechain-types/contracts/interfaces/core/tokens/IRToken.d.ts +37 -37
- package/dist/types/typechain-types/contracts/interfaces/core/tokens/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/interfaces/core/vaults/IBaseVault.d.ts +83 -0
- package/dist/types/typechain-types/contracts/interfaces/core/vaults/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/interfaces/index.d.ts +0 -1
- package/dist/types/typechain-types/contracts/mocks/core/collectors/index.d.ts +0 -1
- package/dist/types/typechain-types/contracts/mocks/core/governance/proposals/TimelockTestTarget.d.ts +5 -1
- package/dist/types/typechain-types/contracts/mocks/core/index.d.ts +2 -0
- package/dist/types/typechain-types/contracts/mocks/core/oracles/MockVRFCoordinatorV2.d.ts +530 -0
- package/dist/types/typechain-types/contracts/mocks/core/oracles/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/mocks/core/pools/MockLendingPoolCollector.d.ts +156 -0
- package/dist/types/typechain-types/contracts/mocks/core/pools/MockLendingPoolDebtToken.d.ts +557 -102
- package/dist/types/typechain-types/contracts/mocks/core/pools/MockLiquidityPool.d.ts +486 -0
- package/dist/types/typechain-types/contracts/mocks/core/pools/index.d.ts +2 -0
- package/dist/types/typechain-types/contracts/mocks/core/primitives/MockDistributableContract.d.ts +35 -0
- package/dist/types/typechain-types/contracts/mocks/core/primitives/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/mocks/core/tokens/MockCollectableUnderlying.d.ts +292 -0
- package/dist/types/typechain-types/contracts/mocks/core/tokens/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/mocks/core/vaults/MockVault.d.ts +290 -0
- package/dist/types/typechain-types/contracts/mocks/core/vaults/index.d.ts +1 -0
- package/dist/types/typechain-types/contracts/mocks/libraries/MockStringUtils.d.ts +25 -0
- package/dist/types/typechain-types/contracts/mocks/libraries/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/@chainlink/contracts/src/v0.8/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2__factory.d.ts +33 -0
- package/dist/types/typechain-types/factories/@chainlink/contracts/src/v0.8/vrf/index.d.ts +2 -0
- package/dist/types/typechain-types/factories/@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface__factory.d.ts +171 -0
- package/dist/types/typechain-types/factories/@chainlink/contracts/src/v0.8/vrf/interfaces/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/core/collectors/FeeCollector__factory.d.ts +571 -194
- package/dist/types/typechain-types/factories/contracts/core/minters/RAACMinter/RAACMinter__factory.d.ts +138 -54
- package/dist/types/typechain-types/factories/contracts/core/minters/RAACReleaseOrchestrator/RAACReleaseOrchestrator__factory.d.ts +5 -31
- package/dist/types/typechain-types/factories/contracts/core/oracles/BaseVRFv2Consumer__factory.d.ts +231 -0
- package/dist/types/typechain-types/factories/contracts/core/oracles/RAACHousePriceOracle__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/core/oracles/RAACPrimeRateOracle__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/core/oracles/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/core/pools/LendingPool/LendingPool__factory.d.ts +897 -64
- package/dist/types/typechain-types/factories/contracts/core/pools/StabilityPool/NFTLiquidator__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/core/pools/StabilityPool/StabilityPool__factory.d.ts +128 -161
- package/dist/types/typechain-types/factories/contracts/core/pools/StabilityPool/index.d.ts +0 -1
- package/dist/types/typechain-types/factories/contracts/core/primitives/RAACHousePrices__factory.d.ts +54 -1
- package/dist/types/typechain-types/factories/contracts/core/tokens/DebtToken__factory.d.ts +47 -29
- package/dist/types/typechain-types/factories/contracts/core/tokens/IndexToken__factory.d.ts +317 -1
- package/dist/types/typechain-types/factories/contracts/core/tokens/RAACNFT__factory.d.ts +525 -17
- package/dist/types/typechain-types/factories/contracts/core/tokens/RAACToken__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/core/tokens/RToken__factory.d.ts +52 -52
- package/dist/types/typechain-types/factories/contracts/core/tokens/VeRAACToken__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/interfaces/core/collectors/IBaseCollector__factory.d.ts +33 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/core/collectors/IFeeCollector__factory.d.ts +409 -90
- package/dist/types/typechain-types/factories/contracts/interfaces/core/collectors/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/core/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/core/minters/RAACMinter/IRAACMinter__factory.d.ts +59 -15
- package/dist/types/typechain-types/factories/contracts/interfaces/core/minters/RAACReleaseOrchestrator/IReleaseOrchestrator__factory.d.ts +4 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/core/oracles/IBaseVRFv2Consumer__factory.d.ts +78 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/core/oracles/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/core/pools/ILiquidityPool__factory.d.ts +119 -39
- package/dist/types/typechain-types/factories/contracts/interfaces/core/pools/LendingPool/ILendingPool__factory.d.ts +547 -19
- package/dist/types/typechain-types/factories/contracts/interfaces/core/pools/StabilityPool/IStabilityPool__factory.d.ts +68 -67
- package/dist/types/typechain-types/factories/contracts/interfaces/core/tokens/IDebtToken__factory.d.ts +119 -6
- package/dist/types/typechain-types/factories/{erc721a/contracts/IERC721A__factory.d.ts → contracts/interfaces/core/tokens/IIndexToken__factory.d.ts} +74 -215
- package/dist/types/typechain-types/factories/contracts/interfaces/core/tokens/IRAACNFT__factory.d.ts +274 -10
- package/dist/types/typechain-types/factories/contracts/interfaces/core/tokens/IRToken__factory.d.ts +26 -26
- package/dist/types/typechain-types/factories/contracts/interfaces/core/tokens/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/{IMarketCreator__factory.d.ts → core/vaults/IBaseVault__factory.d.ts} +78 -42
- package/dist/types/typechain-types/factories/contracts/interfaces/core/vaults/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/interfaces/index.d.ts +0 -1
- package/dist/types/typechain-types/factories/contracts/libraries/pools/ReserveLibrary__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/collectors/index.d.ts +0 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/governance/gauges/MockBaseGauge__factory.d.ts +16 -4
- package/dist/types/typechain-types/factories/contracts/mocks/core/governance/proposals/TimelockTestTarget__factory.d.ts +10 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/oracles/MockOracle__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/oracles/MockVRFCoordinatorV2__factory.d.ts +620 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/oracles/TestRAACHousePriceOracle__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/oracles/TestRAACPrimeRateOracle__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/oracles/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/pools/MockLendingPoolCollector__factory.d.ts +234 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/pools/MockLendingPoolDebtToken__factory.d.ts +539 -77
- package/dist/types/typechain-types/factories/contracts/mocks/core/pools/MockLendingPool__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/pools/MockLiquidityPool__factory.d.ts +795 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/pools/MockStabilityPool__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/core/pools/index.d.ts +2 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/primitives/MockDistributableContract__factory.d.ts +68 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/primitives/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/tokens/MockCollectableUnderlying__factory.d.ts +451 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/tokens/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/vaults/MockVault__factory.d.ts +525 -0
- package/dist/types/typechain-types/factories/contracts/mocks/core/vaults/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/mocks/libraries/MockStringUtils__factory.d.ts +40 -0
- package/dist/types/typechain-types/factories/contracts/mocks/libraries/index.d.ts +1 -0
- package/dist/types/typechain-types/factories/contracts/mocks/libraries/pools/ReserveLibraryMock__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/contracts/mocks/tests/VeRAACFuzzHelper__factory.d.ts +1 -1
- package/dist/types/typechain-types/factories/index.d.ts +0 -1
- package/dist/types/typechain-types/index.d.ts +28 -10
- package/dist/types/utils/artifacts.d.ts +677 -39
- package/dist/types/utils/contracts.d.ts +2 -0
- package/dist/utils/artifacts.js +9 -0
- package/package.json +1 -1
- package/dist/nfts/getDepositedNFTs.js +0 -19
- package/dist/nfts/getOwnedNFTs.js +0 -34
- package/dist/types/nfts/addNewBatch.d.ts +0 -4
- package/dist/types/nfts/getCurrentBatchSize.d.ts +0 -4
- package/dist/types/nfts/getDepositedNFTs.d.ts +0 -7
- package/dist/types/nfts/getOwnedNFTs.d.ts +0 -7
- package/dist/types/typechain-types/contracts/core/pools/StabilityPool/MarketCreator.d.ts +0 -274
- package/dist/types/typechain-types/contracts/interfaces/IMarketCreator.d.ts +0 -85
- package/dist/types/typechain-types/contracts/mocks/core/collectors/MockFeeCollector.d.ts +0 -708
- package/dist/types/typechain-types/erc721a/contracts/IERC721A.d.ts +0 -242
- package/dist/types/typechain-types/erc721a/contracts/index.d.ts +0 -1
- package/dist/types/typechain-types/erc721a/index.d.ts +0 -2
- package/dist/types/typechain-types/factories/contracts/core/pools/StabilityPool/MarketCreator__factory.d.ts +0 -405
- package/dist/types/typechain-types/factories/contracts/mocks/core/collectors/MockFeeCollector__factory.d.ts +0 -985
- package/dist/types/typechain-types/factories/erc721a/contracts/index.d.ts +0 -1
- package/dist/types/typechain-types/factories/erc721a/index.d.ts +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
+
// This is the total price: includes the mint price and the mint fee
|
|
7
|
+
async function getMintPrice(chainId, tokenId, provider) {
|
|
8
|
+
if (!provider) {
|
|
9
|
+
throw new Error("Wallet not connected");
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
|
|
13
|
+
const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
|
|
14
|
+
const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, provider);
|
|
15
|
+
const price = await raacNFTContract.getMintPrice(tokenId);
|
|
16
|
+
const token = await raacNFTContract.token();
|
|
17
|
+
const tokenContract = new ethers_1.Contract(token, ["function decimals() view returns (uint8)"], provider);
|
|
18
|
+
const decimals = await tokenContract.decimals();
|
|
19
|
+
const formattedValue = ethers_1.ethers.formatUnits(price, await decimals.decimals());
|
|
20
|
+
console.log(`Retrieved house price for ${tokenId}: ${formattedValue}`);
|
|
21
|
+
return { price, decimals };
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error("Error retrieving mint price for " + tokenId, error);
|
|
25
|
+
throw new Error(`Failed retrieve mint price: ${error.message}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = getMintPrice;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
+
async function getTokenURI(chainId, tokenId, provider) {
|
|
7
|
+
if (!provider) {
|
|
8
|
+
throw new Error("Wallet not connected");
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
|
|
12
|
+
const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
|
|
13
|
+
const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, provider);
|
|
14
|
+
const uri = await raacNFTContract.tokenURI(tokenId);
|
|
15
|
+
console.log(`Retrieved token URI: ${uri}`);
|
|
16
|
+
return uri;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error("Error getting token URI:", error);
|
|
20
|
+
throw new Error(`Failed to get token URI: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = getTokenURI;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
+
async function getTokensByOwner(chainId, address, provider, pagination) {
|
|
7
|
+
try {
|
|
8
|
+
const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
|
|
9
|
+
const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
|
|
10
|
+
const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, provider);
|
|
11
|
+
const balance = await raacNFTContract.balanceOf(address);
|
|
12
|
+
if (balance === 0n) {
|
|
13
|
+
return { address, tokens: [] };
|
|
14
|
+
}
|
|
15
|
+
let tokens = [];
|
|
16
|
+
if (pagination) {
|
|
17
|
+
const offset = pagination?.offset || 0;
|
|
18
|
+
const limit = pagination?.limit || 10;
|
|
19
|
+
const start = offset;
|
|
20
|
+
const end = Math.min(offset + limit, Number(balance)) || balance;
|
|
21
|
+
tokens = await raacNFTContract["getTokensByOwner(address,uint256,uint256)"](address, start, end);
|
|
22
|
+
console.log(offset, limit, start, end);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
tokens = await raacNFTContract["getTokensByOwner(address)"](address);
|
|
26
|
+
}
|
|
27
|
+
// toString()
|
|
28
|
+
return { address, tokens: tokens.map((token) => token.toString()) };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error("Error getting owned NFTs:", error);
|
|
32
|
+
throw new Error(`Failed to get owned NFTs: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = getTokensByOwner;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
+
async function getTotalPropertiesCount(chainId, provider) {
|
|
7
|
+
if (!provider) {
|
|
8
|
+
throw new Error("Wallet not connected");
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const raacHousePrices = (0, contracts_1.getContractAddress)(chainId, "raachouseprices");
|
|
12
|
+
const raacHousePricesABI = (0, artifacts_1.getABI)("raachouseprices");
|
|
13
|
+
const raacHousePricesContract = new ethers_1.ethers.Contract(raacHousePrices, raacHousePricesABI, provider);
|
|
14
|
+
const count = await raacHousePricesContract.count();
|
|
15
|
+
console.log(`Retrieved total properties count: ${count}`);
|
|
16
|
+
return count;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error("Error retrieving total houses count:", error);
|
|
20
|
+
throw new Error(`Failed to retrieve the number of houses: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = getTotalPropertiesCount;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const contracts_1 = require("../utils/contracts");
|
|
5
5
|
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
-
async function
|
|
6
|
+
async function totalNFTSupply(chainId, provider) {
|
|
7
7
|
try {
|
|
8
8
|
const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
|
|
9
9
|
const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
|
|
10
10
|
const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, provider);
|
|
11
|
-
const batchSize = await raacNFTContract.
|
|
11
|
+
const batchSize = await raacNFTContract.totalSupply();
|
|
12
12
|
return batchSize.toString();
|
|
13
13
|
}
|
|
14
14
|
catch (error) {
|
|
@@ -16,4 +16,4 @@ async function getCurrentBatchSize(chainId, provider) {
|
|
|
16
16
|
throw new Error(`Failed to get current batch size: ${error.message}`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
exports.default =
|
|
19
|
+
exports.default = totalNFTSupply;
|
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
5
|
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
-
// checked
|
|
7
6
|
async function borrowFromLendingPool(chainId, tokenId, amount, signer) {
|
|
8
7
|
try {
|
|
9
8
|
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
10
9
|
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
11
10
|
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, signer);
|
|
12
|
-
const
|
|
11
|
+
const amountInWei = ethers_1.ethers.parseEther(amount);
|
|
12
|
+
console.log("Borrowing amount in wei:", amountInWei.toString());
|
|
13
|
+
const tx = await lendingPoolContract.borrow(tokenId, amountInWei.toString());
|
|
13
14
|
const receipt = await tx.wait();
|
|
14
|
-
console.log(`Borrowed ${ethers_1.ethers.formatEther(amount)}
|
|
15
|
+
console.log(`Borrowed ${ethers_1.ethers.formatEther(amount)} from lending pool`);
|
|
15
16
|
console.log(`Transaction hash: ${receipt?.hash}`);
|
|
16
17
|
return receipt;
|
|
17
18
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ethers_1 = require("ethers");
|
|
7
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
8
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
9
|
+
const checkAllowance_1 = __importDefault(require("../../methods/commons/checkAllowance"));
|
|
10
|
+
const approveAsset_1 = __importDefault(require("../../wallet/assets/approveAsset"));
|
|
11
|
+
async function borrowFromLendingPoolWithInsurance(chainId, tokenId, amount, signer) {
|
|
12
|
+
try {
|
|
13
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
14
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
15
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, signer);
|
|
16
|
+
const feeCollectorAddress = (0, getContractAddress_1.getContractAddress)(chainId, "feecollector");
|
|
17
|
+
const userAddress = await signer.getAddress();
|
|
18
|
+
const amountInWei = ethers_1.ethers.parseEther(amount);
|
|
19
|
+
console.log("Borrowing amount in wei:", amountInWei.toString());
|
|
20
|
+
// get the total insurance they need to pay
|
|
21
|
+
const insurance = await lendingPoolContract.calculateInsuranceFee(userAddress, tokenId, amountInWei.toString());
|
|
22
|
+
// Approve the crvUSD balance to the fee collector
|
|
23
|
+
const allowance = await (0, checkAllowance_1.default)(chainId, "crvusd", userAddress, feeCollectorAddress, signer.provider);
|
|
24
|
+
// If the allowance is less than the insurance, approve the difference
|
|
25
|
+
if (allowance < insurance) {
|
|
26
|
+
await (0, approveAsset_1.default)(chainId, "crvusd", feeCollectorAddress, insurance.toString(), signer);
|
|
27
|
+
console.log(`Approved ${ethers_1.ethers.formatEther(insurance)} crvUSD to fee collector`);
|
|
28
|
+
}
|
|
29
|
+
const tx = await lendingPoolContract.borrowWithInsurance(tokenId, amountInWei.toString());
|
|
30
|
+
const receipt = await tx.wait();
|
|
31
|
+
console.log(`Borrowed ${ethers_1.ethers.formatEther(amount)} from lending pool by paying insurance: ${ethers_1.ethers.formatEther(insurance)}`);
|
|
32
|
+
console.log(`Transaction hash: ${receipt?.hash}`);
|
|
33
|
+
return receipt;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error("Error in borrowFromLendingPoolWithInsurance:", error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = borrowFromLendingPoolWithInsurance;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
async function calculateInsuranceFee(chainId, address, tokenId, amount, provider) {
|
|
7
|
+
try {
|
|
8
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
9
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
10
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
11
|
+
const amountInWei = ethers_1.ethers.parseEther(amount);
|
|
12
|
+
const insuranceFee = await lendingPoolContract.calculateInsuranceFee(address, tokenId, amountInWei.toString());
|
|
13
|
+
return ethers_1.ethers.formatEther(insuranceFee);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error("Error in calculateInsuranceFee:", error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = calculateInsuranceFee;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
async function claimReward(chainId, signer) {
|
|
7
|
+
try {
|
|
8
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
9
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
10
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, signer);
|
|
11
|
+
const tx = await lendingPoolContract.claimReward();
|
|
12
|
+
const receipt = await tx.wait();
|
|
13
|
+
console.log(`Claimed reward from lending pool`);
|
|
14
|
+
console.log(`Transaction hash: ${receipt?.hash}`);
|
|
15
|
+
return receipt;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error("Error in claimReward:", error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = claimReward;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Close the liqudation after the debt has been paid
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
async function closeLiquidation(chainId, tokenId, signer) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, signer);
|
|
18
|
+
const tx = await lendingPoolContract.closeLiquidation(tokenId);
|
|
19
|
+
await tx.wait();
|
|
20
|
+
console.log(`closeLiquidation result: ${tx.hash}`);
|
|
21
|
+
return tx;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error("Error in closeLiquidation:", error);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = closeLiquidation;
|
|
@@ -32,7 +32,6 @@ async function depositNFTToLendingPool(chainId, tokenId, signer) {
|
|
|
32
32
|
});
|
|
33
33
|
await approveTx.wait();
|
|
34
34
|
console.log(`Approved lending pool to transfer NFT #${tokenId}`);
|
|
35
|
-
console.log(lendingPoolContract);
|
|
36
35
|
// Deposit (stake) the NFT
|
|
37
36
|
const depositTx = await lendingPoolContract.depositNFT(tokenId, {
|
|
38
37
|
maxFeePerGas,
|
|
@@ -22,9 +22,9 @@ async function depositToLendingPool(chainId, amount, signer) {
|
|
|
22
22
|
maxFeePerGas,
|
|
23
23
|
nonce: await signer.getNonce(),
|
|
24
24
|
});
|
|
25
|
-
console.log(`Deposit transaction sent for
|
|
25
|
+
console.log(`Deposit transaction sent for rToken:`, depositTx.hash);
|
|
26
26
|
const receipt = await depositTx.wait();
|
|
27
|
-
console.log(`Deposited ${amount}
|
|
27
|
+
console.log(`Deposited ${amount} rToken to lending pool successfully:`, receipt?.hash);
|
|
28
28
|
return receipt;
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
const getPositionView_1 = require("./getPositionView");
|
|
7
|
+
// checked
|
|
8
|
+
async function getAllUserData(chainId, address, provider) {
|
|
9
|
+
try {
|
|
10
|
+
const lendingPoolAddress = (0, contracts_1.getContractAddress)(chainId, "lendingpool");
|
|
11
|
+
const abi = (0, artifacts_1.getABI)("lendingpool");
|
|
12
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, abi, provider);
|
|
13
|
+
const data = await lendingPoolContract.getAllUserData(address);
|
|
14
|
+
// ILendingPool.UserDataView
|
|
15
|
+
const formattedData = {
|
|
16
|
+
nftTokenIds: (data[0] || []).map((id) => id.toString()),
|
|
17
|
+
scaledDebtBalance: ethers_1.ethers.formatEther(data[1] || 0n),
|
|
18
|
+
userCollateralValue: ethers_1.ethers.formatEther(data[2] || 0n),
|
|
19
|
+
positions: (data[3] || []).map((e) => (0, getPositionView_1.transformPositionView)(e)),
|
|
20
|
+
};
|
|
21
|
+
return formattedData;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error("Error fetching lending pool info:", error);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = getAllUserData;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Total amount of RToken + DEToken = total crvUSD they put in the system so far. How much they have contributed to the system.
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
async function getEligibleUserDeposits(chainId, address, provider) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
18
|
+
const value = await lendingPoolContract.getEligibleUserDeposits(address);
|
|
19
|
+
console.log(`Eligible user deposits: ${ethers_1.ethers.formatEther(value)}`);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error("Error in getEligibleUserDeposits:", error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = getEligibleUserDeposits;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Get the health factor of a NFT position -> factor < 1 : undercollateralized.
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns The health factor of a position (0, inf)
|
|
12
|
+
*/
|
|
13
|
+
async function getHealthFactor(chainId, address, tokenId, provider) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
18
|
+
const value = await lendingPoolContract.calculateHealthFactor(address, tokenId);
|
|
19
|
+
console.log(`getHealthFactor result: ${value}`);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error("Error in getHealthFactor:", error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = getHealthFactor;
|
|
@@ -16,7 +16,7 @@ async function getLendingPoolInfo(chainId, address, provider) {
|
|
|
16
16
|
}
|
|
17
17
|
throw error;
|
|
18
18
|
};
|
|
19
|
-
const [reserve, rateData, normalizedIncome, normalizedDebt,
|
|
19
|
+
const [reserve, rateData, normalizedIncome, normalizedDebt, liquidationThreshold, healthFactorLiquidationThreshold,] = await Promise.all([
|
|
20
20
|
lendingPoolContract.reserve().catch(handleError("reserve")),
|
|
21
21
|
lendingPoolContract.rateData().catch(handleError("rateData")),
|
|
22
22
|
lendingPoolContract
|
|
@@ -26,8 +26,11 @@ async function getLendingPoolInfo(chainId, address, provider) {
|
|
|
26
26
|
.getNormalizedDebt()
|
|
27
27
|
.catch(handleError("getNormalizedDebt", 0n)),
|
|
28
28
|
lendingPoolContract
|
|
29
|
-
.
|
|
30
|
-
.catch(handleError("
|
|
29
|
+
.liquidationThreshold()
|
|
30
|
+
.catch(handleError("liquidationThreshold", 0n)),
|
|
31
|
+
lendingPoolContract
|
|
32
|
+
.healthFactorLiquidationThreshold()
|
|
33
|
+
.catch(handleError("healthFactorLiquidationThreshold", 0n)),
|
|
31
34
|
]);
|
|
32
35
|
console.log(reserve);
|
|
33
36
|
// Extract data from reserve
|
|
@@ -93,9 +96,9 @@ async function getLendingPoolInfo(chainId, address, provider) {
|
|
|
93
96
|
normalizedDebt: (Number(normalizedDebt.toString()) / 1e27).toFixed(6),
|
|
94
97
|
apy: (Number(apy.toString()) / 1e25).toFixed(2) + "%",
|
|
95
98
|
userRedeemable: ethers_1.ethers.formatEther(userRedeemable ?? 0n),
|
|
96
|
-
|
|
99
|
+
liquidationThreshold: Number(liquidationThreshold.toString()) / 10e3,
|
|
100
|
+
healthFactorLiquidationThreshold: healthFactorLiquidationThreshold.toString(),
|
|
97
101
|
};
|
|
98
|
-
console.log(result);
|
|
99
102
|
return result;
|
|
100
103
|
}
|
|
101
104
|
catch (error) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
async function getPendingReward(chainId, address, provider) {
|
|
7
|
+
try {
|
|
8
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
9
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
10
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
11
|
+
const reward = await lendingPoolContract.getPendingReward(address);
|
|
12
|
+
console.log(`Pending reward: ${ethers_1.ethers.formatEther(reward)}`);
|
|
13
|
+
return reward;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error("Error in getPendingReward:", error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = getPendingReward;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Get the raw debt of the user on a NFT. Equivant to the original amount borrowed on NFT.
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns The raw debt of the user on a NFT
|
|
12
|
+
*/
|
|
13
|
+
async function getPositionDebt(chainId, address, tokenId, provider) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
18
|
+
const reward = await lendingPoolContract.getPositionDebt(address, tokenId);
|
|
19
|
+
console.log(`getPositionDebt result: ${ethers_1.ethers.formatEther(reward)}`);
|
|
20
|
+
return reward;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error("Error in getPositionDebt:", error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = getPositionDebt;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Get the scaled debt of the user on a NFT (contains the accured interest)
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns The debt of the user on a NFT with the accured interest
|
|
12
|
+
*/
|
|
13
|
+
async function getPositionScaledDebt(chainId, address, tokenId, provider) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
18
|
+
const reward = await lendingPoolContract.getPositionScaledDebt(address, tokenId);
|
|
19
|
+
console.log(`getPositionScaledDebt result: ${ethers_1.ethers.formatEther(reward)}`);
|
|
20
|
+
return reward;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error("Error in getPositionScaledDebt:", error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = getPositionScaledDebt;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformPositionView = transformPositionView;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
6
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
7
|
+
function transformPositionView(positionView) {
|
|
8
|
+
return {
|
|
9
|
+
rawDebtBalance: ethers_1.ethers.formatEther(positionView?.[0] || 0n),
|
|
10
|
+
scaledDebtBalance: ethers_1.ethers.formatEther(positionView?.[1] || 0n),
|
|
11
|
+
healthFactor: (positionView?.[2] || 0n).toString(),
|
|
12
|
+
isUnderLiquidation: positionView?.[3] || false,
|
|
13
|
+
liquidationStartTime: (positionView?.[4] || 0n).toString(),
|
|
14
|
+
positionIndex: (positionView?.[5] || 0n).toString(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description Return all the information about a NFT position
|
|
19
|
+
* @param chainId
|
|
20
|
+
* @param address
|
|
21
|
+
* @param provider
|
|
22
|
+
* @returns All information about a NFT position
|
|
23
|
+
*/
|
|
24
|
+
async function getPositionView(chainId, address, tokenId, provider) {
|
|
25
|
+
try {
|
|
26
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
27
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
28
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
29
|
+
const res = await lendingPoolContract.getPositionView(address, tokenId);
|
|
30
|
+
console.log(`getPositionView result: ${res}`);
|
|
31
|
+
return transformPositionView(res);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Error in getPositionView:", error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = getPositionView;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Get the sum of all the scaled debts of a user over all NFTs
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns The debt of the user
|
|
12
|
+
*/
|
|
13
|
+
async function getPositionsScaledDebt(chainId, address, provider) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
18
|
+
const reward = await lendingPoolContract.getPositionsScaledDebt(address);
|
|
19
|
+
console.log(`getPositionsScaledDebt result: ${ethers_1.ethers.formatEther(reward)}`);
|
|
20
|
+
return reward;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error("Error in getPositionsScaledDebt:", error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = getPositionsScaledDebt;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
// Get the amount of RToken RAW deposit in the lending pool, without the accured interest
|
|
7
|
+
async function getRawUserDepositsInLendingPool(chainId, address, provider) {
|
|
8
|
+
try {
|
|
9
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
10
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
11
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
12
|
+
const value = await lendingPoolContract.getUserDeposits(address);
|
|
13
|
+
console.log(`User deposits in lending pool: ${ethers_1.ethers.formatEther(value)}`);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error("Error in getRawUserDepositsInLendingPool:", error);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = getRawUserDepositsInLendingPool;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Sum of the prices of all the NFTS
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns The total value of the collateral
|
|
12
|
+
*/
|
|
13
|
+
async function getUserCollateralValue(chainId, address, provider) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, provider);
|
|
18
|
+
const reward = await lendingPoolContract.getUserCollateralValue(address);
|
|
19
|
+
console.log(`getUserCollateralValue result: ${ethers_1.ethers.formatEther(reward)}`);
|
|
20
|
+
return reward;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error("Error in getUserCollateralValue:", error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = getUserCollateralValue;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const getContractAddress_1 = require("../../contracts/getContractAddress");
|
|
5
|
+
const artifacts_1 = require("../../utils/artifacts");
|
|
6
|
+
/**
|
|
7
|
+
* @description Get the sum of all the scaled debts of a user over all NFTs
|
|
8
|
+
* @param chainId
|
|
9
|
+
* @param address
|
|
10
|
+
* @param provider
|
|
11
|
+
* @returns The debt of the user
|
|
12
|
+
*/
|
|
13
|
+
async function initializeLiquidation(chainId, address, tokenId, signer) {
|
|
14
|
+
try {
|
|
15
|
+
const lendingPoolAddress = (0, getContractAddress_1.getContractAddress)(chainId, "lendingpool");
|
|
16
|
+
const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
|
|
17
|
+
const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, signer);
|
|
18
|
+
const tx = await lendingPoolContract.initiateLiquidation(address, tokenId);
|
|
19
|
+
await tx.wait();
|
|
20
|
+
console.log(`initializeLiquidation result: ${tx.hash}`);
|
|
21
|
+
return tx;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error("Error in initializeLiquidation:", error);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = initializeLiquidation;
|