diff --git a/README.md b/README.md index 3ab38e66b..b813c78c0 100644 --- a/README.md +++ b/README.md @@ -1548,14 +1548,16 @@ This will start a hardhat mainnet forked RPC node at the block number configured You'll need an Alchemy API key to create the fork. ``` -ALCHEMY_API_KEY=enter_your_key_here yarn start-fork:rpc-node +ALCHEMY_API_KEY=enter_your_key_here yarn start-fork ``` ``` yarn start-demo:dev-frontend ``` -This spawns a modified version of dev-frontend that ignores MetaMask, and directly uses the local blockchain node. Every time the page is reloaded (at http://localhost:3000). Additionally, transactions are automatically signed, so you no longer need to accept wallet confirmations. This lets you play around with Liquity more freely. +This spawns a modified version of dev-frontend that automatically signs transactions so you don't need to interact with a browser wallet. It directly uses the local blockchain node. This lets you play around with Liquity more freely. + +Make sure you configure your browser wallet to use the local fork RPC node: `http://localhost:8045` When you no longer need the forked frontend mode, press Ctrl+C. diff --git a/hardhat.config.mainnet-fork.ts b/hardhat.config.mainnet-fork.ts index 39728c41b..37852fa92 100644 --- a/hardhat.config.mainnet-fork.ts +++ b/hardhat.config.mainnet-fork.ts @@ -8,8 +8,8 @@ const config: HardhatUserConfig = { hardhat: { chainId: 1, forking: { - url: `https://eth-mainnet.alchemyapi.io/v2/${alchemyApiKey}`, - blockNumber: 15767479 + url: `https://eth-mainnet.g.alchemy.com/v2/${alchemyApiKey}`, + blockNumber: 16233419 }, accounts: [ { diff --git a/packages/dev-frontend/src/components/Bonds/context/api.ts b/packages/dev-frontend/src/components/Bonds/context/api.ts index 27f899114..19aeff556 100644 --- a/packages/dev-frontend/src/components/Bonds/context/api.ts +++ b/packages/dev-frontend/src/components/Bonds/context/api.ts @@ -232,23 +232,6 @@ const cacheYearnVaultApys = async (): Promise => { } }; -const getClaimedBonds = async ( - account: string, - chickenBondManager: ChickenBondManager -): Promise => { - const claimedBondsFilter = await chickenBondManager.filters.BondClaimed(account); - const events = await chickenBondManager.queryFilter(claimedBondsFilter); - const claimedBonds = events.reduce((accumulator, current) => { - const { bondId, bLusdAmount } = current.args; - return { - ...accumulator, - [bondId.toNumber().toString()]: decimalify(bLusdAmount) - }; - }, {}); - - return claimedBonds; -}; - const getAccountBonds = async ( account: string, bondNft: BondNFT, @@ -280,7 +263,8 @@ const getAccountBonds = async ( startTimes: bondIds.map(bondId => bondNft.getBondStartTime(bondId)), endTimes: bondIds.map(bondId => bondNft.getBondEndTime(bondId)), statuses: bondIds.map(bondId => bondNft.getBondStatus(bondId)), - tokenUris: bondIds.map(bondId => bondNft.tokenURI(bondId)) + tokenUris: bondIds.map(bondId => bondNft.tokenURI(bondId)), + claimedAmounts: bondIds.map(bondId => bondNft.getBondClaimedBLUSD(bondId)) }; const bondDeposits = await Promise.all(bondRequests.deposits); @@ -289,7 +273,7 @@ const getAccountBonds = async ( const bondEndTimes = await Promise.all(bondRequests.endTimes); const bondStatuses = await Promise.all(bondRequests.statuses); const bondTokenUris = await Promise.all(bondRequests.tokenUris); - const claimedBonds = await getClaimedBonds(account, chickenBondManager); + const bondClaimedAmounts = await Promise.all(bondRequests.claimedAmounts); const bonds = bondIds .reduce((accumulator, _, idx) => { @@ -368,7 +352,7 @@ const getAccountBonds = async ( const rebondReturn = accrued.isZero ? 0 : getReturn(rebondAccrual, deposit, marketPrice); const rebondRoi = rebondReturn / toFloat(deposit); const rebondApr = rebondRoi * (365 / (bondAgeInDays + remainingRebondDays)); - const claimedAmount = claimedBonds[id]; + const claimedAmount = Decimal.from(numberify(bondClaimedAmounts[idx])); return [ ...accumulator,