generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: rebalancer review * fixes * fix: tests in the PR * fix: setOrder function * feat: deployment script * adjust check on decimals --------- Co-authored-by: Pablo Veyrat <[email protected]>
- Loading branch information
Showing
6 changed files
with
171 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity >=0.5.0; | ||
|
||
struct Order { | ||
// Total agToken budget allocated to subsidize the swaps between the tokens associated to the order | ||
uint112 subsidyBudget; | ||
// Decimals of the `tokenIn` associated to the order | ||
uint8 decimalsIn; | ||
// Decimals of the `tokenOut` associated to the order | ||
uint8 decimalsOut; | ||
// Guaranteed exchange rate in `BASE_18` for the swaps between the `tokenIn` and `tokenOut` associated to | ||
// the order. This rate is a minimum rate guaranteed up to when the `subsidyBudget` is fully consumed | ||
uint128 guaranteedRate; | ||
} | ||
|
||
/// @title IRebalancer | ||
/// @author Angle Labs, Inc. | ||
interface IRebalancer { | ||
/// @notice Swaps `tokenIn` for `tokenOut` through an intermediary agToken mint from `tokenIn` and | ||
/// burn to `tokenOut`. Eventually, this transaction may be sponsored and yield an amount of `tokenOut` | ||
/// higher than what would be obtained through a mint and burn directly on the `transmuter` | ||
/// @param amountIn Amount of `tokenIn` to bring for the rebalancing | ||
/// @param amountOutMin Minimum amount of `tokenOut` that must be obtained from the swap | ||
/// @param to Address to which `tokenOut` must be sent | ||
/// @param deadline Timestamp before which this transaction must be included | ||
/// @return amountOut Amount of outToken obtained | ||
function swapExactInput( | ||
uint256 amountIn, | ||
uint256 amountOutMin, | ||
address tokenIn, | ||
address tokenOut, | ||
address to, | ||
uint256 deadline | ||
) external returns (uint256 amountOut); | ||
|
||
/// @notice Approximates how much a call to `swapExactInput` with the same parameters would yield in terms | ||
/// of `amountOut` | ||
function quoteIn(uint256 amountIn, address tokenIn, address tokenOut) external view returns (uint256 amountOut); | ||
|
||
/// @notice Helper to compute the minimum guaranteed amount out that would be obtained from a swap of `amountIn` | ||
/// of `tokenIn` to `tokenOut` | ||
function getGuaranteedAmountOut( | ||
address tokenIn, | ||
address tokenOut, | ||
uint256 amountIn | ||
) external view returns (uint256); | ||
|
||
/// @notice Lets governance set an order to subsidize rebalances between `tokenIn` and `tokenOut` | ||
function setOrder(address tokenIn, address tokenOut, uint256 subsidyBudget, uint256 guaranteedRate) external; | ||
|
||
/// @notice Recovers `amount` of `token` to the `to` address | ||
/// @dev This function checks if too much is not being recovered with respect to currently available budgets | ||
function recover(address token, uint256 amount, address to) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.19; | ||
|
||
import { Utils } from "./utils/Utils.s.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import { Rebalancer } from "contracts/helpers/Rebalancer.sol"; | ||
import { IAccessControlManager } from "contracts/utils/AccessControl.sol"; | ||
import { ITransmuter } from "contracts/interfaces/ITransmuter.sol"; | ||
import "./Constants.s.sol"; | ||
import "oz/interfaces/IERC20.sol"; | ||
import "oz-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; | ||
|
||
contract DeployRebalancer is Utils { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.deriveKey(vm.envString("MNEMONIC_FORK"), "m/44'/60'/0'/0/", 0); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
address deployer = vm.addr(deployerPrivateKey); | ||
console.log("Deployer address: ", deployer); | ||
Rebalancer rebalancer = new Rebalancer(IAccessControlManager(ACCESS_CONTROL_MANAGER), ITransmuter(TRANSMUTER)); | ||
console.log("Rebalancer deployed at: ", address(rebalancer)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Oops, something went wrong.