Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate eth+ prop #1211

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading