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

MainnetSwapSteward #3

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

efecarranza
Copy link

Changelog

Add mainnet steward to perform swaps.
Add interface.
Add tests.

Copy link
Contributor

@sakulstra sakulstra left a comment

Choose a reason for hiding this comment

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

these two errors mean the same thing as i get it.

@efecarranza
Copy link
Author

@sakulstra after discussing internally, we've added the budget limitation to the contract. for deployment, we'll prepare an ARFC with the right parameters for the initial budgets based on historical swaps the DAO has conducted.

Copy link
Contributor

@sakulstra sakulstra left a comment

Choose a reason for hiding this comment

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

After looking into Swapper honestly to me the design of this is not so optimal.

The permissioned steward calls a permissioned, upgreadable contract(that in fact does not use upgreadable variants of the contracts).

My suggestion would be the following:

  1. merge this steward & aave swapper together.
  • use a permissionless rescuable as on ClinicSteward, because the contract should never hold funds, right?
  • this will simplify the contract a bit as e.g. recipient can be hardcoded (i think there's probably more that can be simplified)
  1. inline the CollectorUtils swap.
  • swapper will always be the contract itself
  • oracle decimals are already checked when registering the oracle
  • the uint.max path should probably be moved to tokenSwap and take into account available budget

import {ICollector} from "aave-v3-origin/contracts/treasury/ICollector.sol";
import {CollectorUtils as CU} from "aave-helpers/src/CollectorUtils.sol";
import {MiscEthereum} from "aave-address-book/MiscEthereum.sol";
import {IAggregatorInterface} from "src/finance/interfaces/IAggregatorInterface.sol";
Copy link
Contributor

Choose a reason for hiding this comment

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

better to do relative imports, otherwise remappings are hell to work with.

import {CollectorUtils as CU} from "aave-helpers/src/CollectorUtils.sol";
import {MiscEthereum} from "aave-address-book/MiscEthereum.sol";
import {IAggregatorInterface} from "src/finance/interfaces/IAggregatorInterface.sol";

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

tokenBudget[fromToken] -= amount;

COLLECTOR.swap(
address(SWAPPER), CU.SwapInput(milkman, priceChecker, fromToken, toToken, fromOracle, toOracle, amount, slippage)
Copy link
Contributor

Choose a reason for hiding this comment

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

when using so many params, better to use {} object format to ensure they are passed in correct order.

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

Successfully merging this pull request may close these issues.

2 participants