-
Notifications
You must be signed in to change notification settings - Fork 2
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
Deposit to ERC4626 Vaults #71
Conversation
dimpar
commented
Dec 8, 2023
•
edited
Loading
edited
- Added allocation functionality that deposits a single asset (tBTC) to an authorized vault
- Added and adjusted deployment scripts
- Changed unit tests and added an integration test that validates the flow of assets from Acre contract through Dispatcher that deposits assets to an authorized ERC4626 Vault
Renamed AcreRouter to Dispatcher and introduced an abstract contract called Router that will handle moving funds between Acre and Vaults. In order to deposit / redeem assets, Acre contract should approve assets for Dispatcher to spend and call depositToVault or redeemFromVault functions. These Acre's functions can be also called by a bot for rebalancing purposes.
f1f439d
to
54a1562
Compare
c0485d9
to
1166e5e
Compare
Takes tBTC that was staked in Acre Core and routes assets to the authorized Yield Modules (ERC4626 Vaults). For now handling only 1 asset (tBTC).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed contracts and deployment scripts. Will get back to tests in the next review round.
When a new dispatcher is set, the tBTC allowance for the old one should be set to zero. Added tests.
Making Slither happy to avoid reentrancy warning.
const assetsToAllocate = to1e18(100) | ||
const minSharesOut = to1e18(100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use different value for minSharesOut
to be able to test if the Router
actually enforces the check.
const assetsToAllocate = to1e18(100) | |
const minSharesOut = to1e18(100) | |
const assetsToAllocate = to1e18(100) | |
const expectedSharesOut = assetsToAllocate | |
const minSharesOut = expectedSharesOut - 1n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is checked in when allocation is not successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rename the test name then, to be clear, what scenario we are covering, "when allocation is not successful" feels too general.
- Renamings - Extracted isVaultAuthorized - error change CallerUnauthorized > NotMaintainer
core/test/Acre.test.ts
Outdated
describe("updateDispatcher", () => { | ||
context("when caller is not an owner", () => { | ||
it("should revert", async () => { | ||
await expect(acre.connect(staker1).updateDispatcher(ZeroAddress)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could get one more signer named thirdParty
from getUnnamedSigner()
function call in the fixture setup and use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test to Deployment.test.ts checking the initial state right after the deployment scripts execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM I left a non-blocking comment.
core/test/Dispatcher.test.ts
Outdated
let governance: HardhatEthersSigner | ||
let thirdParty: HardhatEthersSigner | ||
let maintainer: HardhatEthersSigner | ||
let vault: TestERC4626 | ||
let acre: Acre | ||
let tbtc: TestERC20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move contract vars definition above signers for consistency?
let acre: Acre
let tbtc: TestERC20
let vault: TestERC4626
let governance: HardhatEthersSigner
let thirdParty: HardhatEthersSigner
let maintainer: HardhatEthersSigner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.