Verified contractExactUNLICENSED
AuraCompounderStrategy
Address0x7fcb9de1b62b15bb192e1fb3c09deb08511f76d8
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.10
- Same code
Only this contract
Details
- Compiler
- solc 0.8.10+commit.fc410830
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- london
- License
- UNLICENSED
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 18,384,276
- Creation transaction
- 0xa72d538531…3a12908724
20 files
- src/compounder/strategies/AuraCompounderStrategy.solmain27.05 KB
- lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol3.15 KB
- lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC20Upgradeable.sol162 B
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol6.63 KB
- lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol3.38 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol2.78 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol2.26 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol4.59 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol8.28 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol1.35 KB
- lib/solmate/src/utils/FixedPointMathLib.sol16.63 KB
- src/errors/Errors.sol1.19 KB
- src/interfaces/IAuraBribe.sol382 B
- src/interfaces/IAuraLocker.sol2.32 KB
- src/interfaces/IAuraRouter.sol843 B
- src/interfaces/IDelegateRegistry.sol281 B
- src/interfaces/IRewardDistributor.sol1.8 KB
- src/interfaces/IStrategy.sol684 B
- src/interfaces/ITokenSwapper.sol304 B
- src/interfaces/IWeth.sol119 B
src/compounder/strategies/AuraCompounderStrategy.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2023 JonesDAO - All rights reserved
// Jones DAO: https://www.jonesdao.io/
// Check https://docs.jonesdao.io/jones-dao/other/bounty for details on our bounty program.
pragma solidity ^0.8.10;
import "openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol";
import "openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "src/interfaces/IAuraRouter.sol";
import "src/interfaces/IStrategy.sol";
import "src/interfaces/IAuraLocker.sol";
import "src/interfaces/IDelegateRegistry.sol";
import "src/interfaces/ITokenSwapper.sol";
import "src/interfaces/IRewardDistributor.sol";
import "src/interfaces/IWeth.sol";
import "src/errors/Errors.sol";
import "solmate/utils/FixedPointMathLib.sol";
import "src/interfaces/IAuraBribe.sol";
contract AuraCompounderStrategy is IStrategy, OwnableUpgradeable, ReentrancyGuardUpgradeable {
using SafeERC20Upgradeable for IERC20Upgradeable;
using FixedPointMathLib for uint256;
event OnBribeNotify(address[] rewardTokens, uint256[] rewardAmounts);
event Relock(uint256 amount);
struct IncentiveSettings {
address jAURAVoter;
address jonesTreasury;
address auraTreasury;
address withdrawRecipient;
address jAuraLPAddress;
uint64 jonesTreasuryPercent; // denominator 10000
uint64 auraTreasuryPercent; // denominator 10000
uint64 withdrawPercent; // denominator 10000
uint64 bribesPercent; // denominator 10000
}
IAuraRouter public router;
IAuraBribe public constant auraBribe = IAuraBribe(0x642c59937A62cf7dc92F70Fd78A13cEe0aa2Bd9c);
address private constant gov = 0x2a88a454A7b0C29d36D5A121b7Cf582db01bfCEC;
address public vault;
address public keeper;
IncentiveSettings public incentiveSettings;
uint256 private lsdBalance;
bool private isClaimingBribes;
bool private shouldRelock;
mapping(address => mapping(address => ITokenSwapper)) public swappers; // tokenIn => tokenOut => swapper
// constant variables
IERC20Upgradeable public constant WETH = IERC20Upgradeable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IERC20Upgradeable public constant AURA = IERC20Upgradeable(0xC0c293ce456fF0ED870ADd98a0828Dd4d2903DBF);
IERC20Upgradeable public constant AURABAL = IERC20Upgradeable(0x616e8BfA43F920657B3497DBf40D6b1A02D4608d);
IAuraLocker public constant LOCKER = IAuraLocker(0x3Fa73f1E5d8A792C80F426fc8F84FBF7Ce9bBCAC);
IDelegateRegistry public constant SNAPSHOT = IDelegateRegistry(0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446);
uint256 public constant DENOMINATOR = 10000;
ITokenSwapper public constant inchSwapper = ITokenSwapper(0x1111111254fb6c44bAC0beD2854e76F90643097d);
ITokenSwapper public defaultSwapper;
IAuraBribe public newAuraBribe;
// Fallback function to receive ETH and wrap it into WETH.
receive() external payable {
address WETH_ADDRESS = address(WETH);
assembly {
// ---------------------------------------------------
// 0. The value of the call
// ---------------------------------------------------
// callvalue = msg.value
let _amount := callvalue()
// ---------------------------------------------------
// 1. The Function Selector
// ---------------------------------------------------
// 0x2e1a7d4d (first 4 bytes of the keccak-256 hash of the string "deposit()")
let functionSelector := 0x2e1a7d4d
// ---------------------------------------------------
// 2. The Memory Layout
// ---------------------------------------------------
// Memory is divided into slots, and each slot is 32 bytes (256 bits).
// The free memory pointer always points to the next available slot in memory.
// mload(0x40) retrieves the current free memory pointer.
let ptr := mload(0x40)
// ptr now points here (let's call this position A):
// A: [ ??? ]
// As you can see, it's uninitialized memory, indicated by ???.
// ---------------------------------------------------
// 3. Creating Calldata
// ---------------------------------------------------
// Calldata for our call needs to be the function selector.
// We store it at the position ptr (position A).
mstore(ptr, functionSelector)
// Memory now looks like this:
// A: [ functionSelector ]
// But, Ethereum is big-endian, which means the most significant byte is stored at the smallest address.
// So, our memory looks like this in a more detailed view:
// A: [ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
// 00 00 00 00 00 00 00 00 00 00 00 00 2e 1a 7d 4d ]
// ---------------------------------------------------
// 4. Making the External Call
// ---------------------------------------------------
// We are now ready to make the external call to the WETH contract.
// call(gas, to, value, inOffset, inSize, outOffset, outSize) is the structure.
// gas() - Remaining gas for the transaction.
// WETH_ADDRESS - The address of the WETH contract.
// _amount - The ether value we're sending with the call.
// add(functionSelector, 0x20) - Where our calldata starts in memory.
// 0x04 - Size of our calldata (4 bytes for the function selector).
// 0 - We don't expect any return data, so outOffset is 0.
// 0 - We don't expect any return data, so outSize is 0.
let result := call(gas(), WETH_ADDRESS, _amount, add(ptr, 0x20), 0x04, 0, 0)
// Check if the call was successful, if not revert.
switch iszero(result)
case 1 {
// Store the error message in memory.
let err := "WETH: FAIL"
mstore(ptr, err)
// Revert with our custom error message.
revert(ptr, 10) // "WETH: FAIL" has 10 characters.
}
}
}
function initialize(address _router, address _vault, address _keeper, IncentiveSettings memory _incentiveSettings)
external
initializer
{
if (msg.sender != gov) {
revert Errors.notOwner();
}
__Ownable_init();
__ReentrancyGuard_init();
router = IAuraRouter(_router);
vault = _vault;
keeper = _keeper;
incentiveSettings = _incentiveSettings;
AURA.safeApprove(address(LOCKER), type(uint256).max);
shouldRelock = true;
}
/**
* @notice Gets the total amount of locked and unlocked AURA assets.
* @return The total amount of locked and unlocked AURA assets.
*/
function totalAssets() external view override returns (uint256) {
IAuraLocker.Balances memory balances = LOCKER.balances(address(this));
unchecked {
return balances.locked + AURA.balanceOf(address(this));
}
}
/**
* @notice Returns the total assets of LSD Vault`.
*/
function totalAssetsLSD() external view returns (uint256) {
return lsdBalance;
}
/**
* @notice Returns the total assets of no tokenized Vault`.
*/
function totalNoTokenizedAssets() external view returns (uint256) {
(uint256 noTokenzedBalance,) = vaultsPosition();
return noTokenzedBalance;
}
/**
* @notice Returns the recipient and percent values from `incentiveSettings`.
* @return recipient Address of the incentive receiver
* @return percent Retention percentage
*/
function withdrawRetention() external view returns (address recipient, uint64 percent) {
return (incentiveSettings.withdrawRecipient, incentiveSettings.withdrawPercent);
}
/**
* @notice Return Vaults balances
* @return No tokenized Vault Balance
* @return LSD Vault balance
*/
function vaultsPosition() public view returns (uint256, uint256) {
IAuraLocker.Balances memory balances = LOCKER.balances(address(this));
unchecked {
uint256 auraBalance = balances.locked + AURA.balanceOf(address(this));
return (auraBalance - lsdBalance, lsdBalance);
}
}
/**
* @notice Return Current Vaults portion in Strategy
* @return No tokenized Vault Portion
* @return LSD Vault Portion
*/
function vaultsCurrentPosition() public view returns (uint256, uint256) {
uint256 strategyBalance = AURA.balanceOf(address(this));
(uint256 ntBalance, uint256 tBalance) = vaultsPosition();
uint256 noTokenizedPortion = (ntBalance * strategyBalance) / (ntBalance + tBalance);
unchecked {
uint256 tokenizedPortion = strategyBalance > 0 ? strategyBalance - noTokenizedPortion : 0;
return (noTokenizedPortion, tokenizedPortion);
}
}
/**
* @notice Allows the vaults to relock AURA in the contract.
*/
function deposit(uint256 auraAmount, bool tokenized) external nonReentrant {
_onlyRouter();
if (tokenized) {
lsdBalance = lsdBalance + auraAmount;
}
}
function withdraw(address user, uint256 amount, bool tokenized) external nonReentrant returns (uint256) {
_onlyRouter();
// Get current AURA balance
uint256 balNow = AURA.balanceOf(address(this));
// If we dont have enough AURA
if (balNow < amount) {
// Check how much we can get by process unlocks
(, uint256 unlockable,,) = LOCKER.lockedBalances(address(this));
// If still not enough, revert
if (unlockable + balNow < amount) revert Errors.InsufficientWithdraw();
LOCKER.processExpiredLocks(false);
}
if (tokenized) {
unchecked {
lsdBalance = lsdBalance > amount ? lsdBalance - amount : 0;
}
}
if (incentiveSettings.withdrawPercent > 0 && incentiveSettings.withdrawRecipient != address(0)) {
uint256 withdrawalRetention = (amount * incentiveSettings.withdrawPercent) / DENOMINATOR;
uint256 jonesRetention = (withdrawalRetention * 2) / 3;
AURA.safeTransfer(incentiveSettings.withdrawRecipient, jonesRetention);
unchecked {
//`withdrawalRetention` is always less than `amount` so it should never overflow
amount -= withdrawalRetention;
}
}
AURA.safeTransfer(user, amount);
return amount;
}
function afterRehyphotecate(uint256 _auraAmount, bool _tokenized) external {
_onlyRouter();
if (!_tokenized) {
lsdBalance = lsdBalance + _auraAmount;
}
}
/**
* @notice Allows the keeper address to harvest auraBAL reward from AuraLocker.
* @param autoCompoundAll If true, the rewards will be automatically compounded into AURA.
* @param minAmountOut keeper calculates both assets price and amounts and inputs the desired value.
*/
function harvest(bool autoCompoundAll, uint256 minAmountOut) external {
_onlyKeeper();
uint256 balanceBefore = AURABAL.balanceOf(address(this));
// Claim auraBAL from AuraLocker
LOCKER.getReward(address(this));
// Calculate how much was harvested in rewards, revert if no new rewards
unchecked {
uint256 amountEarned = AURABAL.balanceOf(address(this)) - balanceBefore;
if (amountEarned == 0) {
revert Errors.NoReward();
}
if (autoCompoundAll) {
// Swap auraBAL to AURA
processEarned(address(AURABAL), amountEarned, address(AURA), minAmountOut, "");
}
}
}
function relockExpiredLocks(bool _shouldRelock) external {
_onlyKeeper();
LOCKER.processExpiredLocks(_shouldRelock);
}
/**
* @notice Allows the keeper address to claim rewards from the hiddenHandDistributor contract and process them accordingly. OnBribeNotify is emitted with the claimed reward tokens and amounts.
* @param hiddenHandDistributor The contract that will be used to claim rewards.
* @param _claims An array of claims to be made with the hiddenHandDistributor contract.
*/
function claimHiddenHand(IRewardDistributor hiddenHandDistributor, IRewardDistributor.Claim[] calldata _claims)
external
nonReentrant
{
_onlyKeeper();
uint256 numClaims = _claims.length;
// Track token balances before bribes claim
uint256[] memory beforeBalance = new uint256[](numClaims);
address[] memory rewardTokens = new address[](numClaims);
uint256 i;
for (; i < numClaims;) {
(rewardTokens[i],,,) = hiddenHandDistributor.rewards(_claims[i].identifier);
beforeBalance[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(this));
//++i should never overflow since it will always be less than the length of the _claims array
unchecked {
++i;
}
}
(uint256 ntBalance, uint256 tBalance) = vaultsPosition();
// Claim bribes
isClaimingBribes = true;
hiddenHandDistributor.claim(_claims);
// Update bribe field for token receive lock
delete isClaimingBribes;
i = 0;
uint256[] memory rewardAmounts = new uint256[](numClaims);
for (; i < numClaims;) {
rewardAmounts[i] = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(this)) - beforeBalance[i];
// Check if AURA earned
if (rewardTokens[i] == address(AURA) && rewardAmounts[i] > 0) {
_processAuraEarned(rewardAmounts[i], ntBalance, tBalance);
}
unchecked {
//++j should never overflow since it will always be less than the length of the _claims array
++i;
}
}
emit OnBribeNotify(rewardTokens, rewardAmounts);
}
/**
* @notice Processes an earned token amount and swaps it for `tokenOut` token.
* @param tokenIn The address of the input token contract.
* @param amountIn The amount of the input token to be transferred.
* @param tokenOut The address of the output token contract.
* @param minAmountOut The minimum amount of the output token to be received.
* @param externalData External data that can be used by token swapper contracts.
*/
function processEarned(
address tokenIn,
uint256 amountIn,
address tokenOut,
uint256 minAmountOut,
bytes memory externalData // this external data can be used in token swappers to get some off-chain data (e.g. 1Inch)
) public nonReentrant {
_onlyKeeper();
if (tokenIn == address(AURA)) {
revert Errors.InvalidTokenIn(tokenIn, address(AURA));
}
if (amountIn == 0 || amountIn > IERC20Upgradeable(tokenIn).balanceOf(address(this))) {
revert Errors.InvalidAmountIn(amountIn, IERC20Upgradeable(tokenIn).balanceOf(address(this)));
}
ITokenSwapper tokenSwapper = getSwapper(tokenIn, tokenOut);
if (address(tokenSwapper) == address(0)) {
revert Errors.NoSwapper();
}
(uint256 ntBalance, uint256 tBalance) = vaultsPosition();
if (tokenIn != address(AURABAL)) {
IERC20Upgradeable(tokenIn).safeTransfer(address(tokenSwapper), amountIn);
}
uint256 amountOut = tokenSwapper.swap(tokenIn, amountIn, tokenOut, minAmountOut, externalData);
if (tokenOut == address(AURA)) {
_processAuraEarned(amountOut, ntBalance, tBalance);
}
}
/**
* @notice Processes AURA "bribes" to various recipients based on the amount of AURA earned.
* @param auraEarned The amount of AURA earned.
*/
function _processAuraEarned(uint256 auraEarned, uint256 ntBalance, uint256 tBalance) private {
unchecked {
uint256 remaining = auraEarned;
// transfer bribe incentive to jones treasury
if (incentiveSettings.jonesTreasury != address(0)) {
uint256 amount = (auraEarned * incentiveSettings.jonesTreasuryPercent) / DENOMINATOR;
if (amount > 0) {
AURA.safeTransfer(incentiveSettings.jonesTreasury, amount);
remaining -= amount;
}
}
// transfer bribe to aura treasury
if (incentiveSettings.auraTreasury != address(0)) {
uint256 amount = (auraEarned * incentiveSettings.auraTreasuryPercent) / DENOMINATOR;
if (amount > 0) {
AURA.safeTransfer(incentiveSettings.auraTreasury, amount);
remaining -= amount;
}
}
// Update Vault Balances
uint256 lsdEarned = (tBalance * remaining) / (tBalance + ntBalance);
lsdBalance = lsdBalance + lsdEarned;
// transfer bribe to jAURA/AURA pool voter
if (incentiveSettings.jAURAVoter != address(0) && incentiveSettings.jAuraLPAddress != address(0)) {
uint256 amount = (
(
lsdEarned * IERC20Upgradeable(vault).balanceOf(incentiveSettings.jAuraLPAddress)
* incentiveSettings.bribesPercent
) / IERC20Upgradeable(vault).totalSupply()
) / DENOMINATOR;
if (amount > 0) {
AURA.safeTransfer(incentiveSettings.jAURAVoter, amount);
lsdBalance = lsdBalance - amount;
}
}
}
}
/**
* @notice Allows the keeper address to claim rewards from the hiddenHandDistributor contract on L2s and not go through the usual flow.
* @param hiddenHandDistributor The contract that will be used to claim rewards.
* @param _claims An array of claims to be made with the hiddenHandDistributor contract.
*/
function L2sClaimHiddenHand(
IRewardDistributor hiddenHandDistributor,
IRewardDistributor.Claim[] calldata _claims,
address rewardBridge
) external nonReentrant {
_onlyKeeper();
uint256 numClaims = _claims.length;
// Hidden hand uses BRIBE_VAULT address as a substitute for ETH
address hhBribeVault = hiddenHandDistributor.BRIBE_VAULT();
// Track token balances before bribes claim
address[] memory rewardTokens = new address[](numClaims);
uint256 i;
for (; i < numClaims;) {
(rewardTokens[i],,,) = hiddenHandDistributor.rewards(_claims[i].identifier);
//++i should never overflow since it will always be less than the length of the _claims array
unchecked {
++i;
}
}
// Claim bribes
hiddenHandDistributor.claim(_claims);
i = 0;
// send rewards to bridge contract
for (; i < numClaims;) {
if (rewardTokens[i] == hhBribeVault) {
uint256 rewards = address(this).balance;
if (rewards > 0) {
IWeth(address(WETH)).deposit{value: rewards}();
WETH.transfer(rewardBridge, rewards);
}
} else {
uint256 rewards = IERC20Upgradeable(rewardTokens[i]).balanceOf(address(this));
if (rewards > 0) {
IERC20Upgradeable(rewardTokens[i]).transfer(rewardBridge, rewards);
}
}
unchecked {
//++j should never overflow since it will always be less than the length of the _claims array
++i;
}
}
}
/**
* @notice Allows the strategy to relock AURA in the contract.
*/
function relock() external nonReentrant {
_onlyKeeper();
_relock();
}
/**
* @notice Internal processer of AURA relock.
*/
function _relock() internal {
if (shouldRelock) {
uint256 currentBalance = AURA.balanceOf(address(this));
uint256 withdrawRequests = router.totalWithdrawRequests();
unchecked {
if (currentBalance > withdrawRequests) {
uint256 relockAmount = currentBalance - withdrawRequests;
// relock
LOCKER.lock(address(this), relockAmount);
emit Relock(relockAmount);
}
}
}
}
/// ----- Ownable Functions ------
/**
* @notice Sets the `router` contract.
* @param _router The new `router` address.
* @dev This function can only be called by the contract owner.
*/
function setRouter(address _router) external onlyOwner {
router = IAuraRouter(_router);
}
/**
* @notice Sets the `vault` address.
* @param _vault The new `_vault` address.
* @dev This function can only be called by the contract owner.
*/
function setVault(address _vault) external onlyOwner {
vault = _vault;
}
/**
* @notice Sets the `keeper` address.
* @param _keeper The new `keeper` address.
* @dev This function can only be called by the contract owner.
*/
function setKeeper(address _keeper) external onlyOwner {
keeper = _keeper;
}
/**
* @notice Sets the `IncentiveSettings` values.
* @param _incentiveSettings The new `incentiveSettings` values.
* @dev This function can only be called by the contract owner.
*/
function setFeeSettings(IncentiveSettings memory _incentiveSettings) external onlyOwner {
incentiveSettings = _incentiveSettings;
}
/**
* @notice Sets the token swapper contract for the given token pair.
* @param tokenIn The address of the input token contract.
* @param tokenOut The address of the output token contract.
* @param tokenSwapper The address of the token swapper contract.
* @param allowance The allowance for the token swapper contract to transfer the input token.
* @dev This function can only be called by the contract owner.
*/
function setTokenSwapper(address tokenIn, address tokenOut, address tokenSwapper, uint256 allowance)
external
onlyOwner
{
swappers[tokenIn][tokenOut] = ITokenSwapper(tokenSwapper);
IERC20Upgradeable(tokenIn).safeApprove(tokenSwapper, allowance);
}
/**
* @notice Sets the custom allowance for the given token and token swapper contract.
* @param token The address of the token contract.
* @param tokenSwapper The address of the token swapper contract.
* @param allowance The new allowance for the token swapper contract to transfer the token.
* @dev This function can only be called by the contract owner.
*/
function setCustomAllowance(address token, address tokenSwapper, uint256 allowance) external onlyOwner {
IERC20Upgradeable(token).safeApprove(tokenSwapper, 0);
if (allowance > 0) {
IERC20Upgradeable(token).safeApprove(tokenSwapper, allowance);
}
}
/// ------ Delegation ------
/**
* @notice Sets the delegate for the Aura Locker contract.
* @param delegate The new delegate address.
* @dev This function can only be called by the contract owner.
*/
function setAuraLockerDelegate(address delegate) external onlyOwner {
// Set delegate is enough as it will clear previous delegate automatically
LOCKER.delegate(delegate);
}
/**
* @notice Sets the delegate for the Snapshot contract with the given ID.
* @param id The ID of the Snapshot contract.
* @param delegate The new delegate address.
* @dev This function can only be called by the contract owner. This cannot be used to remove delegation.
*/
function setSnapshotDelegate(bytes32 id, address delegate) external onlyOwner {
// Set delegate is enough as it will clear previous delegate automatically
SNAPSHOT.setDelegate(id, delegate);
}
/**
* @notice Set the address able to claim Hidden Hand rewards.
* @param delegate The new delegate address.
* @dev This function can only be called by the contract owner.
*/
function forwardHiddenHandRewards(address delegate) external onlyOwner {
// Set delegate is enough as it will clear previous delegate automatically
auraBribe.setRewardForwarding(delegate);
}
/**
* @notice Clears the snapshot delegate associated with the given snapshot ID.
* @param id The ID of the snapshot to clear the delegate for.
* @dev This function can only be called by the contract owner.
*/
function clearSnapshotDelegate(bytes32 id) external onlyOwner {
SNAPSHOT.clearDelegate(id);
}
function updateShouldRelock(bool _status) external onlyOwner {
shouldRelock = _status;
}
function updateDefaultSwapper(ITokenSwapper _defaultSwapper) external onlyOwner {
defaultSwapper = _defaultSwapper;
}
function updateNewAuraBribe(IAuraBribe _newAuraBribe) external onlyOwner {
newAuraBribe = _newAuraBribe;
}
function rescueStuckEther() external onlyOwner {
payable(owner()).transfer(address(this).balance);
}
//// ------ Access ------
/// @notice Checks if msg.sender is router.
/// @dev Reverts if sender != router.
function _onlyRouter() private view {
if (msg.sender != address(router)) {
revert Errors.Unauthorized();
}
}
/// @notice Checks if msg.sender is keeper.
/// @dev Reverts if sender != keeper.
function _onlyKeeper() private view {
if (msg.sender != keeper) {
revert Errors.Unauthorized();
}
}
function _isWhitelisted(address _token) private view returns (bool) {
return newAuraBribe.isWhitelistedToken(_token);
}
function getSwapper(address _tokenIn, address _tokenOut) public view returns (ITokenSwapper) {
ITokenSwapper swapper = swappers[_tokenIn][_tokenOut];
if (address(swapper) != address(0)) {
return swapper;
} else if (_isWhitelisted(_tokenIn) && address(swapper) == address(0)) {
return defaultSwapper;
} else {
revert Errors.InvalidToken();
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/IERC20Upgradeable.sol";
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
function safeTransfer(
IERC20Upgradeable token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20Upgradeable token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/solmate/src/utils/FixedPointMathLib.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)
library FixedPointMathLib {
/*//////////////////////////////////////////////////////////////
SIMPLIFIED FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
}
function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
}
function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
}
function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
}
function powWad(int256 x, int256 y) internal pure returns (int256) {
// Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)
return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.
}
function expWad(int256 x) internal pure returns (int256 r) {
unchecked {
// When the result is < 0.5 we return zero. This happens when
// x <= floor(log(0.5e18) * 1e18) ~ -42e18
if (x <= -42139678854452767551) return 0;
// When the result is > (2**255 - 1) / 1e18 we can not represent it as an
// int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
if (x >= 135305999368893231589) revert("EXP_OVERFLOW");
// x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
// for more intermediate precision and a binary basis. This base conversion
// is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
x = (x << 78) / 5**18;
// Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
// of two such that exp(x) = exp(x') * 2**k, where k is an integer.
// Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;
x = x - k * 54916777467707473351141471128;
// k is in the range [-61, 195].
// Evaluate using a (6, 7)-term rational approximation.
// p is made monic, we'll multiply by a scale factor later.
int256 y = x + 1346386616545796478920950773328;
y = ((y * x) >> 96) + 57155421227552351082224309758442;
int256 p = y + x - 94201549194550492254356042504812;
p = ((p * y) >> 96) + 28719021644029726153956944680412240;
p = p * x + (4385272521454847904659076985693276 << 96);
// We leave p in 2**192 basis so we don't need to scale it back up for the division.
int256 q = x - 2855989394907223263936484059900;
q = ((q * x) >> 96) + 50020603652535783019961831881945;
q = ((q * x) >> 96) - 533845033583426703283633433725380;
q = ((q * x) >> 96) + 3604857256930695427073651918091429;
q = ((q * x) >> 96) - 14423608567350463180887372962807573;
q = ((q * x) >> 96) + 26449188498355588339934803723976023;
assembly {
// Div in assembly because solidity adds a zero check despite the unchecked.
// The q polynomial won't have zeros in the domain as all its roots are complex.
// No scaling is necessary because p is already 2**96 too large.
r := sdiv(p, q)
}
// r should be in the range (0.09, 0.25) * 2**96.
// We now need to multiply r by:
// * the scale factor s = ~6.031367120.
// * the 2**k factor from the range reduction.
// * the 1e18 / 2**96 factor for base conversion.
// We do this all at once, with an intermediate result in 2**213
// basis, so the final right shift is always by a positive amount.
r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
}
}
function lnWad(int256 x) internal pure returns (int256 r) {
unchecked {
require(x > 0, "UNDEFINED");
// We want to convert x from 10**18 fixed point to 2**96 fixed point.
// We do this by multiplying by 2**96 / 10**18. But since
// ln(x * C) = ln(x) + ln(C), we can simply do nothing here
// and add ln(2**96 / 10**18) at the end.
// Reduce range of x to (1, 2) * 2**96
// ln(2^k * x) = k * ln(2) + ln(x)
int256 k = int256(log2(uint256(x))) - 96;
x <<= uint256(159 - k);
x = int256(uint256(x) >> 159);
// Evaluate using a (8, 8)-term rational approximation.
// p is made monic, we will multiply by a scale factor later.
int256 p = x + 3273285459638523848632254066296;
p = ((p * x) >> 96) + 24828157081833163892658089445524;
p = ((p * x) >> 96) + 43456485725739037958740375743393;
p = ((p * x) >> 96) - 11111509109440967052023855526967;
p = ((p * x) >> 96) - 45023709667254063763336534515857;
p = ((p * x) >> 96) - 14706773417378608786704636184526;
p = p * x - (795164235651350426258249787498 << 96);
// We leave p in 2**192 basis so we don't need to scale it back up for the division.
// q is monic by convention.
int256 q = x + 5573035233440673466300451813936;
q = ((q * x) >> 96) + 71694874799317883764090561454958;
q = ((q * x) >> 96) + 283447036172924575727196451306956;
q = ((q * x) >> 96) + 401686690394027663651624208769553;
q = ((q * x) >> 96) + 204048457590392012362485061816622;
q = ((q * x) >> 96) + 31853899698501571402653359427138;
q = ((q * x) >> 96) + 909429971244387300277376558375;
assembly {
// Div in assembly because solidity adds a zero check despite the unchecked.
// The q polynomial is known not to have zeros in the domain.
// No scaling required because p is already 2**96 too large.
r := sdiv(p, q)
}
// r is in the range (0, 0.125) * 2**96
// Finalization, we need to:
// * multiply by the scale factor s = 5.549…
// * add ln(2**96 / 10**18)
// * add k * ln(2)
// * multiply by 10**18 / 2**96 = 5**18 >> 78
// mul s * 5e18 * 2**96, base is now 5**18 * 2**192
r *= 1677202110996718588342820967067443963516166;
// add ln(2) * k * 5e18 * 2**192
r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;
// add ln(2**96 / 10**18) * 5e18 * 2**192
r += 600920179829731861736702779321621459595472258049074101567377883020018308;
// base conversion: mul 2**18 / 2**192
r >>= 174;
}
}
/*//////////////////////////////////////////////////////////////
LOW LEVEL FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
function mulDivDown(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
assembly {
// Store x * y in z for now.
z := mul(x, y)
// Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
revert(0, 0)
}
// Divide z by the denominator.
z := div(z, denominator)
}
}
function mulDivUp(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
assembly {
// Store x * y in z for now.
z := mul(x, y)
// Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
revert(0, 0)
}
// First, divide z - 1 by the denominator and add 1.
// We allow z - 1 to underflow if z is 0, because we multiply the
// end result by 0 if z is zero, ensuring we return 0 if z is zero.
z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))
}
}
function rpow(
uint256 x,
uint256 n,
uint256 scalar
) internal pure returns (uint256 z) {
assembly {
switch x
case 0 {
switch n
case 0 {
// 0 ** 0 = 1
z := scalar
}
default {
// 0 ** n = 0
z := 0
}
}
default {
switch mod(n, 2)
case 0 {
// If n is even, store scalar in z for now.
z := scalar
}
default {
// If n is odd, store x in z for now.
z := x
}
// Shifting right by 1 is like dividing by 2.
let half := shr(1, scalar)
for {
// Shift n right by 1 before looping to halve it.
n := shr(1, n)
} n {
// Shift n right by 1 each iteration to halve it.
n := shr(1, n)
} {
// Revert immediately if x ** 2 would overflow.
// Equivalent to iszero(eq(div(xx, x), x)) here.
if shr(128, x) {
revert(0, 0)
}
// Store x squared.
let xx := mul(x, x)
// Round to the nearest number.
let xxRound := add(xx, half)
// Revert if xx + half overflowed.
if lt(xxRound, xx) {
revert(0, 0)
}
// Set x to scaled xxRound.
x := div(xxRound, scalar)
// If n is even:
if mod(n, 2) {
// Compute z * x.
let zx := mul(z, x)
// If z * x overflowed:
if iszero(eq(div(zx, x), z)) {
// Revert if x is non-zero.
if iszero(iszero(x)) {
revert(0, 0)
}
}
// Round to the nearest number.
let zxRound := add(zx, half)
// Revert if zx + half overflowed.
if lt(zxRound, zx) {
revert(0, 0)
}
// Return properly scaled zxRound.
z := div(zxRound, scalar)
}
}
}
}
}
/*//////////////////////////////////////////////////////////////
GENERAL NUMBER UTILITIES
//////////////////////////////////////////////////////////////*/
function sqrt(uint256 x) internal pure returns (uint256 z) {
assembly {
let y := x // We start y at x, which will help us make our initial estimate.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// We check y >= 2^(k + 8) but shift right by k bits
// each branch to ensure that if x >= 256, then y >= 256.
if iszero(lt(y, 0x10000000000000000000000000000000000)) {
y := shr(128, y)
z := shl(64, z)
}
if iszero(lt(y, 0x1000000000000000000)) {
y := shr(64, y)
z := shl(32, z)
}
if iszero(lt(y, 0x10000000000)) {
y := shr(32, y)
z := shl(16, z)
}
if iszero(lt(y, 0x1000000)) {
y := shr(16, y)
z := shl(8, z)
}
// Goal was to get z*z*y within a small factor of x. More iterations could
// get y in a tighter range. Currently, we will have y in [256, 256*2^16).
// We ensured y >= 256 so that the relative difference between y and y+1 is small.
// That's not possible if x < 256 but we can just verify those cases exhaustively.
// Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
// Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
// Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.
// For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
// (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.
// Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
// sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.
// There is no overflow risk here since y < 2^136 after the first branch above.
z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If x+1 is a perfect square, the Babylonian method cycles between
// floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
z := sub(z, lt(div(x, z), z))
}
}
function log2(uint256 x) internal pure returns (uint256 r) {
require(x > 0, "UNDEFINED");
assembly {
r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffff, shr(r, x))))
r := or(r, shl(3, lt(0xff, shr(r, x))))
r := or(r, shl(2, lt(0xf, shr(r, x))))
r := or(r, shl(1, lt(0x3, shr(r, x))))
r := or(r, lt(0x1, shr(r, x)))
}
}
function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
assembly {
// z will equal 0 if y is 0, unlike in Solidity where it will revert.
z := mod(x, y)
}
}
function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
assembly {
// z will equal 0 if y is 0, unlike in Solidity where it will revert.
z := div(x, y)
}
}
/// @dev Will return 0 instead of reverting if y is zero.
function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
assembly {
// Add 1 to x * y if x % y > 0.
z := add(gt(mod(x, y), 0), div(x, y))
}
}
}
src/errors/Errors.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2023 JonesDAO - All rights reserved
// Jones DAO: https://www.jonesdao.io/
// Check https://docs.jonesdao.io/jones-dao/other/bounty for details on our bounty program.
pragma solidity ^0.8.10;
interface Errors {
// Vault
error ZeroAddress();
error ZeroAmount();
error WithdrawCooldown();
error InsufficientShares();
error InsufficientAssets();
error InsufficientRequest();
error notOwner();
// Strategy
error OnlyFromHiddenHand();
error Unauthorized();
error InsufficientWithdraw();
error NoReward();
error NoSwapper();
// Swapper
error Slippage(uint256 amountOut, uint256 minAmountOut);
error InvalidToken();
// Misc.
error InvalidTokenIn(address have, address want);
error InvalidTokenOut(address have, address want);
error InvalidAmountIn(uint256 have, uint256 want);
error InvalidMinAmountOut(uint256 have, uint256 want);
error InvalidReceiver(address have, address want);
error InvalidPathSegment(address from, address to);
error EmptyPath();
error EmptyTokenIn();
error EmptyTokenOut();
error EmptyRouter();
}
src/interfaces/IAuraBribe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IAuraBribe {
function depositBribeERC20(bytes32 proposal, address token, uint256 amount) external;
function isWhitelistedToken(address token) external view returns (bool);
function setRewardForwarding(address to) external;
function rewardForwarding(address from) external view returns (address);
}
src/interfaces/IAuraLocker.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IAuraLocker {
struct EarnedData {
address token;
uint256 amount;
}
struct Balances {
uint112 locked;
uint32 nextUnlockIndex;
}
struct LockedBalance {
uint112 amount;
uint32 unlockTime;
}
struct Epoch {
uint224 supply;
uint32 date; //epoch start date
}
function lock(address _account, uint256 _amount) external;
function getReward(address _account) external;
function getReward(address _account, bool _stake) external;
function claimableRewards(address _account) external view returns (EarnedData[] memory userRewards);
function rewardTokens(uint256 _index) external view returns (address token);
function rewardPerToken(address _rewardsToken) external view returns (uint256);
function lastTimeRewardApplicable(address _rewardsToken) external view returns (uint256);
//BOOSTED balance of an account which only includes properly locked tokens as of the most recent eligible epoch
function balanceOf(address _user) external view returns (uint256 amount);
function balanceAtEpochOf(uint256 _epoch, address _user) external view returns (uint256 amount);
function balances(address _user) external view returns (Balances memory bals);
function userLocks(address _user, uint256 _index) external view returns (LockedBalance memory lockedBals);
function lockedBalances(address _user)
external
view
returns (uint256 total, uint256 unlockable, uint256 locked, LockedBalance[] memory lockData);
function findEpochId(uint256 _time) external view returns (uint256 epoch);
function epochs(uint256 _index) external view returns (Epoch memory epoch);
function lockedSupply() external view returns (uint256);
// Withdraw/relock all currently locked tokens where the unlock time has passed
function processExpiredLocks(bool _relock, uint256 _spendRatio, address _withdrawTo) external;
// Withdraw/relock all currently locked tokens where the unlock time has passed
function processExpiredLocks(bool _relock) external;
function delegate(address newDelegatee) external;
function delegates(address account) external view returns (address);
}
src/interfaces/IAuraRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IAuraRouter {
function deposit(uint256 _assets, bool _tokenized) external returns (uint256);
function withdrawRequest(uint256 _shares, bool _tokenized, address _receiver) external;
function withdraw(uint256 _assets, bool _tokenized) external returns (uint256);
function rehypothecate(uint256 assets, bool _tokenized) external returns (uint256);
function noTokenizedUserInfo(address _user) external view returns (uint128, uint64, uint64);
function lsdUserInfo(address _user) external view returns (uint128, uint64, uint64);
function totalWithdrawRequests() external view returns (uint256);
function totalWithdrawRequestsLSD() external view returns (uint256);
function totalWithdrawRequestsNoTokenized() external view returns (uint256);
}
src/interfaces/IDelegateRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IDelegateRegistry {
function setDelegate(bytes32 id, address delegate) external;
function clearDelegate(bytes32 id) external;
function delegation(address, bytes32) external view returns (address);
}
src/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IRewardDistributor {
struct Claim {
bytes32 identifier;
address account;
uint256 amount;
bytes32[] merkleProof;
}
event RewardClaimed(
bytes32 indexed identifier, address indexed token, address indexed account, uint256 amount, uint256 updateCount
);
event RewardMetadataUpdated(
bytes32 indexed identifier,
address indexed token,
bytes32 merkleRoot,
bytes32 proof,
uint256 indexed updateCount
);
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function BRIBE_VAULT() external view returns (address);
function DEFAULT_ADMIN_ROLE() external view returns (bytes32);
function claim(Claim[] calldata _claims) external;
function claimed(bytes32, address) external view returns (uint256);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function hasRole(bytes32 role, address account) external view returns (bool);
function renounceRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function rewards(bytes32)
external
view
returns (address token, bytes32 merkleRoot, bytes32 proof, uint256 updateCount);
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function updateRewardsMetadata(Claim[] calldata _distributions) external;
}
src/interfaces/IStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IStrategy {
function totalAssets() external view returns (uint256);
function totalAssetsLSD() external view returns (uint256);
function totalNoTokenizedAssets() external view returns (uint256);
function deposit(uint256 auraAmount, bool tokenized) external;
function withdrawRetention() external view returns (address recipient, uint64 percent);
function withdraw(address user, uint256 amount, bool tokenized) external returns (uint256);
function afterRehyphotecate(uint256 auraAmount, bool tokenized) external;
function vaultsPosition() external view returns (uint256, uint256);
}
src/interfaces/ITokenSwapper.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
// token swapper for AURA (tokenin => AURA)
interface ITokenSwapper {
function swap(address tokenIn, uint256 amountIn, address tokenOut, uint256 minAmountOut, bytes memory externalData)
external
returns (uint256 amountOut);
}
src/interfaces/IWeth.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface IWeth {
function deposit() external payable;
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "london",
"remappings": [
":@openzeppelin/=lib/openzeppelin-contracts/",
":@uniswap/v3-core/=lib/v3-core/",
":@uniswap/v3-periphery/=lib/v3-periphery/",
":ds-test/=lib/ds-test/src/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":solmate/=lib/solmate/src/",
":v3-core/=lib/v3-core/",
":v3-periphery/=lib/v3-periphery/contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.