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

Handling ERC4626 vaults in AcreRouter #62

Merged
merged 20 commits into from
Dec 13, 2023
Merged

Conversation

dimpar
Copy link
Member

@dimpar dimpar commented Dec 4, 2023

AcreRouter contract should manage ERC4626 vaults within the Acre ecosystem. Owner of the contract should be able to add or remove vaults.

There's a Vault struct inside of the AcreRouter that holds only one boolean approved. This struct will grow in the next PR(s) adding things like "distribution percent" for each vault.

AcreRouter contract should manage ERC4626 vaults within the Acre system.
Owner of the contract should be able to add or remove vaults.
@dimpar dimpar self-assigned this Dec 4, 2023
@dimpar dimpar requested review from nkuba and r-czajkowski December 4, 2023 15:12
@dimpar dimpar added the 🔗 Solidity Solidity contracts label Dec 4, 2023
@dimpar dimpar added this to the MVP milestone Dec 4, 2023
core/contracts/AcreRouter.sol Outdated Show resolved Hide resolved
core/package.json Outdated Show resolved Hide resolved
core/contracts/AcreRouter.sol Outdated Show resolved Hide resolved
@dimpar dimpar changed the base branch from main to test-fixtures December 7, 2023 14:42
@dimpar dimpar marked this pull request as ready for review December 7, 2023 15:30
core/.solhint.json Outdated Show resolved Hide resolved
core/contracts/AcreRouter.sol Outdated Show resolved Hide resolved
core/contracts/AcreRouter.sol Outdated Show resolved Hide resolved
core/contracts/AcreRouter.sol Outdated Show resolved Hide resolved
core/contracts/AcreRouter.sol Outdated Show resolved Hide resolved
core/test/AcreRouter.test.ts Outdated Show resolved Hide resolved
core/test/AcreRouter.test.ts Outdated Show resolved Hide resolved
core/test/AcreRouter.test.ts Outdated Show resolved Hide resolved
core/test/AcreRouter.test.ts Outdated Show resolved Hide resolved
core/test/AcreRouter.test.ts Outdated Show resolved Hide resolved
await acreRouter.connect(governance).addVault(vault3)

expect(await acreRouter.vaults(0)).to.equal(vault1)
const isVault1Approved = await acreRouter.vaultsInfo(vault1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting - it returns boolean when the vaultsInfo is a map of Vaultstruct. I would expect the struct even if there is one field in the structure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, looks like Solidity compiler optimizes the use of Struct with 1 var and we can reference our boolean as if it was just a boolean with no Struct.

/// implemented externally. As long as it complies with ERC4626
/// standard and is authorized by the owner it can be plugged into
/// Acre.
address[] public vaults;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wonder if we need this array. From the dapp/subgprah perspective, we can get the vault address from an event. Not sure about the contracts perspective, maybe other contracts will need this?

Copy link
Member Author

@dimpar dimpar Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array will track all the vaults within Acre ecosystem. vaultsInfo map won't iterate through all the vaults in Acre, you need to know and provide a concrete address. From the dApp perspective maybe it's easy tracking all the authorize/deauthorize events and produce the final result what's in the system, but if a user just want to go to etherscan and see the vaults addresses that won't make it. Besides, it's way easier just to call vaults() and get all the vaults rather than fetching events and then combine them to get the final answer.

@nkuba nkuba merged commit 5cdfff9 into test-fixtures Dec 13, 2023
9 checks passed
@nkuba nkuba deleted the vaults-acre-router branch December 13, 2023 07:41
@nkuba nkuba restored the vaults-acre-router branch December 13, 2023 08:18
@nkuba nkuba mentioned this pull request Dec 13, 2023
dimpar added a commit that referenced this pull request Dec 13, 2023
Depends on: #58

Improve test fixtures used in Acre contract tests:
- use Acre and TBTC contracts deployed with hardhat development scripts
(#58)
- use unnamed signers as stakers, to not overlap with named signers
defined in `hardhat.config.ts`. `ethers.getSigners()` returns all
signers, regardless of whether it is a Hardhat named or unnamed account

---
This PR contains changes from #62
which were unintentionally merged to this branch.
Comment on lines +11 to +12
error VaultAlreadyAuthorized();
error VaultUnauthorized();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a warning here. We should define errors below the events declaration.

obraz

Copy link
Member Author

@dimpar dimpar Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll change that in the following PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔗 Solidity Solidity contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants