Skip to content

Commit

Permalink
Validate eth+ prop (#1211)
Browse files Browse the repository at this point in the history
Co-authored-by: Akshat Mittal <[email protected]>
  • Loading branch information
pmckelvy1 and akshatmittal authored Nov 5, 2024
1 parent 288ba07 commit 39d5d68
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 108 deletions.
6 changes: 3 additions & 3 deletions tasks/validation/proposal-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ task('proposal-validator', 'Runs a proposal and confirms can fully rebalance + r
await main.assetRegistry()
)
const basketHandler = await hre.ethers.getContractAt(
'TestIBasketHandler',
'BasketHandlerP1',
await main.basketHandler()
)
const backingManager = await hre.ethers.getContractAt(
Expand All @@ -103,7 +103,7 @@ task('proposal-validator', 'Runs a proposal and confirms can fully rebalance + r
console.log('💪 Basket is SOUND and fully collateralized!')
console.log('\n', 'Basket:')
const [primeBasketERC20s] = await basketHandler.getPrimeBasket()
const [refBasketERC20s] = await basketHandler.quote(fp('1e18'), 0)
const [refBasketERC20s] = await basketHandler['quote(uint192,uint8)'](fp('1e18'), 0)
if (primeBasketERC20s.length != refBasketERC20s.length) {
throw new Error('Reference basket length != prime basket length')
}
Expand Down Expand Up @@ -337,7 +337,7 @@ const runCheck_mint = async (
rToken: RTokenP1
) => {
console.log(`\nIssuing ${formatEther(issueAmt)} RTokens...`)
const [erc20s] = await basketHandler.quote(fp('1'), 2)
const [erc20s] = await basketHandler['quote(uint192,uint8)'](fp('1'), 2)
for (let i = 0; i < erc20s.length; i++) {
const erc20 = await hre.ethers.getContractAt(
'@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20',
Expand Down
11 changes: 10 additions & 1 deletion tasks/validation/utils/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,16 @@ export const executeProposal = async (
** Make sure to specify any extra assets that may have been registered.
*/

await pushOraclesForward(hre, rtokenAddress, [])
// gather any unregistered assets from the proposal, push them forward as well
const extraOracles: Array<string> = []
proposal.calldatas.forEach((data: string) => {
const funcSig = data.slice(0, 10)
if (funcSig === '0x4420e486' || funcSig === '0x3ba3712a') {
extraOracles.push('0x' + data.slice(34))
}
})

await pushOraclesForward(hre, rtokenAddress, extraOracles)

console.log('Executing now...')

Expand Down
1 change: 1 addition & 0 deletions tasks/validation/utils/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const tokens: { [key: string]: string } = {
['0x53f1df4e5591ae35bf738742981669c3767241fa'.toLowerCase()]: 'wcUSDCv3 (base)',
['0x6f6f81e5e66f503184f2202d83a79650c3285759'.toLowerCase()]: 'saBasUSDC (base)',
['0x184460704886f9f2a7f3a0c2887680867954dc6e'.toLowerCase()]: 'saBasUSDC (base)',
['0xA35b1B31Ce002FBF2058D22F30f95D405200A15b'.toLowerCase()]: 'ETHx',
}

export const logToken = (tokenAddress: string) => {
Expand Down
19 changes: 14 additions & 5 deletions tasks/validation/utils/rtokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,20 @@ export const redeemRTokens = async (
await assetRegistry.refresh()
const basketsNeeded = await rToken.basketsNeeded()
const totalSupply = await rToken.totalSupply()
const redeemQuote = await basketHandler.quote(
redeemAmount.mul(basketsNeeded).div(totalSupply),
false,
0
)
const bhVersion = await basketHandler.version()
let redeemQuote
if (bhVersion == '4.0.0') {
redeemQuote = await basketHandler['quote(uint192,bool,uint8)'](
redeemAmount.mul(basketsNeeded).div(totalSupply),
false,
0
)
} else {
redeemQuote = await basketHandler['quote(uint192,uint8)'](
redeemAmount.mul(basketsNeeded).div(totalSupply),
0
)
}
const expectedTokens = redeemQuote.erc20s
const expectedBalances: Balances = {}
let log = ''
Expand Down
Loading

0 comments on commit 39d5d68

Please sign in to comment.