Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/main/strategies/aave/StrategyAAVEV3Core.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.25;
import "../swap/ParaSwapCaller.sol";
import "../../libraries/Errors.sol";
import "../../../interfaces/aave/v3/IPoolV3.sol";
import "../../../interfaces/aave/v3/IRewardsController.sol";
import "../../../interfaces/mantleStandardBridge/IL1StandardBridge.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
/**
* @title StrategyAave contract
* @author Naturelab
*/
contract StrategyAAVEV3Core is OwnableUpgradeable, ParaSwapCaller {
using SafeERC20 for IERC20;
// The version of the contract
string public constant VERSION = "1.0";
// The address of USDT token
address public constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
// The address of USDC token
address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
// The address of the AAVE Core Market Pool contract
IPoolV3 internal constant POOL_AAVEV3 = IPoolV3(0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2);
// The address of the AAVE v3 RewardsController contract
IRewardsController internal constant REWARDS_CONTROLLER =
IRewardsController(0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb);
// The address of the AAVE aToken of USDT
address internal constant aUSDT = 0x23878914EFE38d27C4D67Ab83ed1b93A74D4086a; // decimals: 6
// The address of the AAVE aToken of USDC
address internal constant aUSDC = 0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c; // decimals: 6
// The address of the mantle bridge contract on L1
IL1StandardBridge internal constant L1_STANDARD_BRIDGE =
IL1StandardBridge(0x95fC37A27a2f68e3A647CDc081F0A89bb47c3012);
// The address of receiver on L2
address public L2Receiver;
address public rebalancer;
/**
* @dev Ensure that this method is only called by authorized portfolio managers.
*/
modifier onlyRebalancer() {
if (msg.sender != rebalancer) revert Errors.CallerNotRebalancer();
_;
}
event UpdateRebalancer(address oldRebalancer, address newRebalancer);
event TokenSwapped(address srcToken, address dstToken, uint256 amountIn, uint256 amountGet);
/**
* @dev Initialize the strategy with given parameters.
* @param _initBytes Initialization data
*/
function initialize(bytes calldata _initBytes) external initializer {
(address admin_, address rebalancer_, address L2Receiver_)
= abi.decode(_initBytes, (address, address, address));
if (admin_ == address(0)) revert Errors.InvalidAdmin();
if (rebalancer_ == address(0)) revert Errors.InvalidRebalancer();
if (L2Receiver_ == address(0)) revert Errors.InvalidL2Receiver();
__Ownable_init(admin_);
rebalancer = rebalancer_;
L2Receiver = L2Receiver_;
_enterProtocol();
}
/**
* @dev Add a new address to the position adjustment whitelist.
* @param _newRebalancer The new address to be added.
*/
function updateRebalancer(address _newRebalancer) external onlyOwner {
if (_newRebalancer == address(0)) revert Errors.InvalidRebalancer();
emit UpdateRebalancer(rebalancer, _newRebalancer);
rebalancer = _newRebalancer;
}
/**
* @dev Update the L2 receiver address.
* @param _newL2Receiver The new L2 receiver address.
*/
function updateL2Receiver(address _newL2Receiver) external onlyOwner {
if (_newL2Receiver == address(0)) revert Errors.InvalidL2Receiver();
L2Receiver = _newL2Receiver;
}
/**
* @dev send the token to L2.
* @param _token The address of the token to send.
* @param _amount The amount to send. type(uint256).max to send all balance.
*/
function sendToken(address _token, uint256 _amount) external onlyRebalancer {
if (L2Receiver == address(0)) revert Errors.InvalidL1Receiver();
address L2Token_;
if (_token == USDT) {
L2Token_ = 0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE;
} else if (_token == USDC) {
L2Token_ = 0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9;
} else {
revert Errors.InvalidToken();
}
if (_amount == type(uint256).max) {
_amount = IERC20(_token).balanceOf(address(this));
}
L1_STANDARD_BRIDGE.depositERC20To(_token, L2Token_, L2Receiver, _amount, 200000, "");
}
/**
* @dev swap token.
* @param _srcToken The address of the source token.
* @param _dstToken The address of the destination token.
* @param _amountIn The amount of source token to swap.
* @param _swapData The swap data.
* @param _swapGetMin The minimum amount of destination token to get.
* @return returnAmount_ The amount of destination token to get.
*/
function swap(address _srcToken, address _dstToken, uint256 _amountIn, bytes memory _swapData, uint256 _swapGetMin)
external
onlyRebalancer
returns (uint256 returnAmount_)
{
if ((_srcToken != USDT && _srcToken != USDC) || (_dstToken != USDT && _dstToken != USDC)) {
revert Errors.InvalidToken();
}
(returnAmount_,) = _executeSwap(_amountIn, _srcToken, _dstToken, _swapData, _swapGetMin);
emit TokenSwapped(_srcToken, _dstToken, _amountIn, returnAmount_);
}
/**
* @dev Execute a deposit operation in the AAVE protocol.
* @param _token The address of the asset to deposit.
* @param _amount The amount of the asset to deposit.
*/
function deposit(address _token, uint256 _amount) external onlyRebalancer {
POOL_AAVEV3.supply(_token, _amount, address(this), 0);
}
/**
* @dev Execute a withdrawal operation in the AAVE protocol.
* @param _token The address of the asset to withdraw.
* @param _amount The amount of the asset to withdraw.
*/
function withdraw(address _token, uint256 _amount) external onlyRebalancer {
POOL_AAVEV3.withdraw(_token, _amount, address(this));
}
/**
* @dev claim rewards from the AAVE protocol.
*/
function claimAllRewards(address _receiver) external onlyRebalancer {
address[] memory assets_ = new address[](2);
assets_[0] = aUSDT;
assets_[1] = aUSDC;
REWARDS_CONTROLLER.claimAllRewards(assets_, _receiver);
}
function _enterProtocol() internal {
// for supply
IERC20(USDT).safeIncreaseAllowance(address(POOL_AAVEV3), type(uint256).max);
IERC20(USDC).safeIncreaseAllowance(address(POOL_AAVEV3), type(uint256).max);
// for crossing chain
IERC20(USDT).safeIncreaseAllowance(address(L1_STANDARD_BRIDGE), type(uint256).max);
IERC20(USDC).safeIncreaseAllowance(address(L1_STANDARD_BRIDGE), type(uint256).max);
}
function getNetAssets() external view returns (uint256 netAssets) {
uint256 USDTBalance_ = IERC20(USDT).balanceOf(address(this));
uint256 USDCBalance_ = IERC20(USDC).balanceOf(address(this));
uint256 totalColUSDT_ = IERC20(aUSDT).balanceOf(address(this));
uint256 totalColUSDC_ = IERC20(aUSDC).balanceOf(address(this));
netAssets = USDTBalance_ + USDCBalance_ + totalColUSDT_ + totalColUSDC_;
}
}
"
},
"src/main/strategies/swap/ParaSwapCaller.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.25;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../../../interfaces/paraswap/IParaSwapV62.sol";
contract ParaSwapCaller {
using Address for address;
using SafeERC20 for IERC20;
address internal constant PARASWAP_AUGUSTUS_PROXY_V6 = 0x6A000F20005980200259B80c5102003040001068;
function _decodeBalancerV2Tokens(
bytes memory balancerData
) internal pure returns (address srcToken, address destToken) {
// solhint-disable-next-line no-inline-assembly
assembly ("memory-safe") {
// For a memory bytes array, the first 32 bytes store the length.
// The actual data starts at an offset of 32 bytes from the start of the array pointer.
let dataPtr := add(balancerData, 32)
// The encoded function arguments start after the 4-byte function selector.
let dataWithoutSelector := add(dataPtr, 4)
// Check the function selector by loading the first 32 bytes of the data.
switch mload(dataPtr)
// If the selector is for swap(tuple singleSwap,tuple funds,uint256 limit,uint256 deadline)
case 0x52bbbe2900000000000000000000000000000000000000000000000000000000 {
// According to the ABI encoding for this function signature, assetIn and assetOut
// are at fixed offsets from the start of the arguments data.
// Load srcToken from singleSwap.assetIn.
srcToken := mload(add(dataWithoutSelector, 288))
// Load destToken from singleSwap.assetOut.
destToken := mload(add(dataWithoutSelector, 320))
}
// If the selector is for batchSwap(uint8 kind,tuple[] swaps,address[] assets,tuple funds,int256[] limits,uint256 deadline)
case 0x945bcec900000000000000000000000000000000000000000000000000000000 {
// Load the offset to the 'assets' array. It's the 3rd argument, at offset 64 from the start of arguments.
let assetsOffset := mload(add(dataWithoutSelector, 64))
// Get the pointer to the 'assets' array data (which starts with the length).
let assetsPtr := add(dataWithoutSelector, assetsOffset)
// Load the length of the 'assets' array.
let assetsCount := mload(assetsPtr)
// Get the swap type ('kind') from the first argument.
let swapType := mload(dataWithoutSelector)
// Set srcToken and destToken based on the swapType.
switch eq(swapType, 1) // 1 is GIVEN_OUT
case 1 {
// For GIVEN_OUT, srcToken is the last asset, and destToken is the first.
// Load srcToken as the last asset in balancerData.assets.
// The address of the last element is assetsPtr + assetsCount * 32.
srcToken := mload(add(assetsPtr, mul(assetsCount, 32)))
// Load destToken as the first asset in balancerData.assets.
// The address of the first element is assetsPtr + 32.
destToken := mload(add(assetsPtr, 32))
}
default { // 0 is GIVEN_IN
// For GIVEN_IN, srcToken is the first asset, and destToken is the last.
// Load srcToken as the first asset.
srcToken := mload(add(assetsPtr, 32))
// Load destToken as the last asset.
destToken := mload(add(assetsPtr, mul(assetsCount, 32)))
}
}
default {
// If the selector is invalid, revert with a custom error.
mstore(0, 0x7352d91c00000000000000000000000000000000000000000000000000000000) // selector for InvalidSelector()
revert(0, 4)
}
// Balancer uses address(0) for ETH, so we convert it to a standard wrapped ETH representation.
if eq(srcToken, 0) { srcToken := 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE }
if eq(destToken, 0) { destToken := 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE }
}
return (srcToken, destToken);
}
function analysisPayload(
bytes calldata _swapData
) external pure returns (uint256 amountIn_, address tokenIn_, address tokenOut_) {
// Match the selector
require(
_swapData.length >= 4,
"ParaSwapCaller: Invalid calldata length"
);
bytes4 selector = bytes4(_swapData[:4]);
if (selector == IParaSwapV62.swapExactAmountIn.selector) {
// Decode the swapData
(, GenericData memory d_, , , ) = abi.decode(
_swapData[4:],
(address, GenericData, uint256, bytes, bytes)
);
tokenIn_ = address(d_.srcToken);
tokenOut_ = address(d_.destToken);
amountIn_ = d_.fromAmount;
} else if (selector == IParaSwapV62.swapOnAugustusRFQTryBatchFill.selector) {
// todo: test this function
// Decode the swapData
(AugustusRFQData memory data_, OrderInfo[] memory order_, ) = abi.decode(
_swapData[4:],
(AugustusRFQData, OrderInfo[], bytes)
);
uint8 wrapApproveDirection_ = data_.wrapApproveDirection;
bool direction_;
assembly {
direction_ := and(shr(3, wrapApproveDirection_), 1)
}
amountIn_ = data_.fromAmount;
if (direction_) {
// If direction is true, we are filling taker amount
tokenIn_ = address(order_[0].order.makerAsset);
tokenOut_ = address(order_[0].order.takerAsset);
} else {
// If direction is false, we are filling maker amount
tokenIn_ = address(order_[0].order.takerAsset);
tokenOut_ = address(order_[0].order.makerAsset);
}
} else if (selector == IParaSwapV62.swapExactAmountInOnBalancerV2.selector) {
// Decode the swapData
(BalancerV2Data memory d_, , , bytes memory data_) = abi.decode(
_swapData[4:],
(BalancerV2Data, uint256, bytes, bytes)
);
// The first 20 bytes are the beneficiary address and the left most bit is the approve flag
(tokenIn_, tokenOut_) = _decodeBalancerV2Tokens(data_);
amountIn_ = d_.fromAmount;
} else if (selector == IParaSwapV62.swapExactAmountInOnCurveV1.selector) {
(CurveV1Data memory curveV1Data_, , ) = abi.decode(
_swapData[4:],
(CurveV1Data, uint256, bytes)
);
tokenIn_ = address(curveV1Data_.srcToken);
tokenOut_ = address(curveV1Data_.destToken);
amountIn_ = curveV1Data_.fromAmount;
} else if (selector == IParaSwapV62.swapExactAmountInOnCurveV2.selector) {
(CurveV2Data memory curveV2Data_, , ) = abi.decode(
_swapData[4:],
(CurveV2Data, uint256, bytes)
);
tokenIn_ = address(curveV2Data_.srcToken);
tokenOut_ = address(curveV2Data_.destToken);
amountIn_ = curveV2Data_.fromAmount;
} else if (selector == IParaSwapV62.swapExactAmountInOnUniswapV2.selector) {
(UniswapV2Data memory uniswapV2Data_, , ) = abi.decode(
_swapData[4:],
(UniswapV2Data, uint256, bytes)
);
tokenIn_ = address(uniswapV2Data_.srcToken);
tokenOut_ = address(uniswapV2Data_.destToken);
amountIn_ = uniswapV2Data_.fromAmount;
} else if (selector == IParaSwapV62.swapExactAmountInOnUniswapV3.selector) {
(UniswapV3Data memory uniswapV3Data_, , ) = abi.decode(
_swapData[4:],
(UniswapV3Data, uint256, bytes)
);
tokenIn_ = address(uniswapV3Data_.srcToken);
tokenOut_ = address(uniswapV3Data_.destToken);
amountIn_ = uniswapV3Data_.fromAmount;
} else if (selector == IParaSwapV62.swapExactAmountInOutOnMakerPSM.selector) {
(MakerPSMData memory makerPSMData_, ) = abi.decode(
_swapData[4:],
(MakerPSMData, bytes)
);
tokenIn_ = address(makerPSMData_.srcToken);
tokenOut_ = address(makerPSMData_.destToken);
amountIn_ = makerPSMData_.fromAmount;
} else {
revert("ParaSwapCaller: Unsupported selector");
}
}
/**
* @dev Executes the swap operation and verify the validity of the parameters and results.
* @param _amount The maximum amount of currency spent.
* @param _srcToken The token to be spent.
* @param _dstToken The token to be received.
* @param _swapData Calldata of 1inch.
* @param _swapGetMin Minimum amount of the token to be received.
* @return returnAmount_ Actual amount of the token spent.
* @return spentAmount_ Actual amount of the token received.
*/
function _executeSwap(
uint256 _amount,
address _srcToken,
address _dstToken,
bytes memory _swapData,
uint256 _swapGetMin
) internal returns (uint256 returnAmount_, uint256 spentAmount_) {
(bool success_, bytes memory resp_) = address(this).staticcall(
abi.encodeWithSelector(
this.analysisPayload.selector,
_swapData
)
);
uint256 amountBefore_ = IERC20(_dstToken).balanceOf(address(this));
require(success_, "ParaSwapCaller: Analysis payload failed");
(uint256 amountIn_, address tokenIn_, address tokenOut_) = abi.decode(
resp_,
(uint256, address, address)
);
require(
amountIn_ <= _amount,
"ParaSwapCaller: Amount in exceeds maximum"
);
if (_srcToken != tokenIn_) {
revert("ParaSwapCaller: Source token mismatch");
}
if (_dstToken != tokenOut_) {
revert("ParaSwapCaller: Destination token mismatch");
}
// If srcToken is not ETH, call approve.
if (_srcToken != address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) {
IERC20(_srcToken).safeIncreaseAllowance(PARASWAP_AUGUSTUS_PROXY_V6, _amount);
}
// Call the ParaSwap Augustus proxy contract with the swap data.
(success_, resp_) = PARASWAP_AUGUSTUS_PROXY_V6.call{value: _srcToken == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) ? _amount : 0}(_swapData);
require(success_, "ParaSwapCaller: Swap execution failed");
uint256 amountAfter_ = IERC20(_dstToken).balanceOf(address(this));
require(
amountAfter_ - amountBefore_ >= _swapGetMin,
"ParaSwapCaller: Insufficient output amount"
);
return (
amountAfter_ - amountBefore_,
amountIn_
);
}
}"
},
"src/main/libraries/Errors.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.25;
library Errors {
// Revert Errors:
error CallerNotOperator(); // 0xa5523ee5
error CallerNotRebalancer(); // 0xbd72e291
error CallerNotVault(); // 0xedd7338f
error CallerNotMinter(); // 0x5eee367a
error CallerNotWhiteList(); // 0xf37be7b6
error ExitFeeRateTooHigh(); // 0xf4d1caab
error ExceededMaxDeposit(); // 0x3bc9ae09
error FlashloanInProgress(); // 0x772ac4e8
error IncorrectState(); // 0x508c9390
error InfoExpired(); // 0x4ddf4a65
error InvalidAccount(); // 0x6d187b28
error InvalidAdapter(); // 0xfbf66df1
error InvalidAdmin(); // 0xb5eba9f0
error InvalidAsset(); // 0xc891add2
error InvalidCaller(); // 0x48f5c3ed
error InvalidClaimTime(); // 0x1221b97b
error InvalidFeeReceiver(); // 0xd200485c
error InvalidFlashloanCall(); // 0xd2208d52
error InvalidFlashloanHelper(); // 0x8690f016
error InvalidFlashloanProvider(); // 0xb6b48551
error InvalidGasLimit(); // 0x98bdb2e0
error InvalidInitiator(); // 0xbfda1f28
error InvalidL1Receiver(); // 0xc17a1851
error InvalidL2Receiver(); // 0x6305ce43
error InvalidLength(); // 0x947d5a84
error InvalidLimit(); // 0xe55fb509
error InvalidManagementFeeClaimPeriod(); // 0x4022e4f6
error InvalidManagementFeeRate(); // 0x09aa66eb
error InvalidMarketCapacity(); // 0xc9034604
error InvalidNetAssets(); // 0x6da79d69
error InvalidNewOperator(); // 0xba0cdec5
error InvalidOperator(); // 0xccea9e6f
error InvalidOracle(); // 0x9589a27d
error InvalidRebalancer(); // 0xff288a8e
error InvalidRedeemOperator(); // 0xd214a597
error InvalidSafeProtocolRatio(); // 0x7c6b23d6
error InvalidShares(); // 0x6edcc523
error InvalidTarget(); // 0x82d5d76a
error InvalidToken(); // 0xc1ab6dc1
error InvalidTokenId(); // 0x3f6cc768
error InvalidUnderlyingToken(); // 0x2fb86f96
error InvalidVault(); // 0xd03a6320
error InvalidWithdrawalUser(); // 0x36c17319
error ManagementFeeRateTooHigh(); // 0x09aa66eb
error ManagementFeeClaimPeriodTooShort(); // 0x4022e4f6
error MarketCapacityTooLow(); // 0xc9034604
error InterestNotUpdated(); // 0xd76ec0c2
error NotSupportedYet(); // 0xfb89ba2a
error PriceNotUpdated(); // 0x1f4bcb2b
error PriceUpdatePeriodTooLong(); // 0xe88d3ecb
error RatioOutOfRange(); // 0x9179cbfa
error RevenueFeeRateTooHigh(); // 0x0674143f
error UnSupportedOperation(); // 0xe9ec8129
error UnsupportedToken(); // 0x6a172882
error WithdrawZero(); // 0x7ea773a9
error DepositHalted(); // 0x3ddeeb34
// for 1inch swap
error OneInchInvalidReceiver(); // 0xd540519e
error OneInchInvalidToken(); // 0x8e7ad912
error OneInchInvalidInputAmount(); // 0x672b500f
error OneInchInvalidFunctionSignature(); // 0x247f51aa
error OneInchUnexpectedSpentAmount(); // 0x295ada05
error OneInchUnexpectedReturnAmount(); // 0x05e64ca8
error OneInchNotSupported(); // 0x04b2de78
}
"
},
"src/interfaces/aave/v3/IPoolV3.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;
import "./libraries/types/DataTypes.sol";
/**
* @title IPool
* @author Aave
* @notice Defines the basic interface for an Aave Pool.
*/
interface IPoolV3 {
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
function withdraw(address asset, uint256 amount, address to) external returns (uint256);
function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf)
external;
function repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf)
external
returns (uint256);
function getUserAccountData(address user)
external
view
returns (
uint256 totalCollateralBase,
uint256 totalDebtBase,
uint256 availableBorrowsBase,
uint256 currentLiquidationThreshold,
uint256 ltv,
uint256 healthFactor
);
function setUserEMode(uint8 categoryId) external;
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;
function getUserEMode(address user) external view returns (uint256);
function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);
function getReserveAToken(address asset) external view returns (address);
function getReserveVariableDebtToken(address asset) external view returns (address);
}
"
},
"src/interfaces/aave/v3/IRewardsController.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.10;
/**
* @title IRewardsController
* @author Aave
* @notice Defines the basic interface for a Rewards Controller.
*/
interface IRewardsController {
/**
* @dev Emitted when a new address is whitelisted as claimer of rewards on behalf of a user
* @param user The address of the user
* @param claimer The address of the claimer
*/
event ClaimerSet(address indexed user, address indexed claimer);
/**
* @dev Emitted when rewards are claimed
* @param user The address of the user rewards has been claimed on behalf of
* @param reward The address of the token reward is claimed
* @param to The address of the receiver of the rewards
* @param claimer The address of the claimer
* @param amount The amount of rewards claimed
*/
event RewardsClaimed(
address indexed user, address indexed reward, address indexed to, address claimer, uint256 amount
);
/**
* @dev Emitted when a transfer strategy is installed for the reward distribution
* @param reward The address of the token reward
* @param transferStrategy The address of TransferStrategy contract
*/
event TransferStrategyInstalled(address indexed reward, address indexed transferStrategy);
/**
* @dev Emitted when the reward oracle is updated
* @param reward The address of the token reward
* @param rewardOracle The address of oracle
*/
event RewardOracleUpdated(address indexed reward, address indexed rewardOracle);
/**
* @dev Whitelists an address to claim the rewards on behalf of another address
* @param user The address of the user
* @param claimer The address of the claimer
*/
function setClaimer(address user, address claimer) external;
/**
* @dev Get the price aggregator oracle address
* @param reward The address of the reward
* @return The price oracle of the reward
*/
function getRewardOracle(address reward) external view returns (address);
/**
* @dev Returns the whitelisted claimer for a certain address (0x0 if not set)
* @param user The address of the user
* @return The claimer address
*/
function getClaimer(address user) external view returns (address);
/**
* @dev Returns the Transfer Strategy implementation contract address being used for a reward address
* @param reward The address of the reward
* @return The address of the TransferStrategy contract
*/
function getTransferStrategy(address reward) external view returns (address);
/**
* @dev Called by the corresponding asset on transfer hook in order to update the rewards distribution.
* @dev The units of `totalSupply` and `userBalance` should be the same.
* @param user The address of the user whose asset balance has changed
* @param totalSupply The total supply of the asset prior to user balance change
* @param userBalance The previous user balance prior to balance change
*
*/
function handleAction(address user, uint256 totalSupply, uint256 userBalance) external;
/**
* @dev Claims reward for a user to the desired address, on all the assets of the pool, accumulating the pending rewards
* @param assets List of assets to check eligible distributions before claiming rewards
* @param amount The amount of rewards to claim
* @param to The address that will be receiving the rewards
* @param reward The address of the reward token
* @return The amount of rewards claimed
*
*/
function claimRewards(address[] calldata assets, uint256 amount, address to, address reward)
external
returns (uint256);
/**
* @dev Claims reward for a user on behalf, on all the assets of the pool, accumulating the pending rewards. The
* caller must be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param amount The amount of rewards to claim
* @param user The address to check and claim rewards
* @param to The address that will be receiving the rewards
* @param reward The address of the reward token
* @return The amount of rewards claimed
*
*/
function claimRewardsOnBehalf(address[] calldata assets, uint256 amount, address user, address to, address reward)
external
returns (uint256);
/**
* @dev Claims reward for msg.sender, on all the assets of the pool, accumulating the pending rewards
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param amount The amount of rewards to claim
* @param reward The address of the reward token
* @return The amount of rewards claimed
*
*/
function claimRewardsToSelf(address[] calldata assets, uint256 amount, address reward) external returns (uint256);
/**
* @dev Claims all rewards for a user to the desired address, on all the assets of the pool, accumulating the pending rewards
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param to The address that will be receiving the rewards
* @return rewardsList List of addresses of the reward tokens
* @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardList"
*
*/
function claimAllRewards(address[] calldata assets, address to)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
/**
* @dev Claims all rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards. The caller must
* be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param user The address to check and claim rewards
* @param to The address that will be receiving the rewards
* @return rewardsList List of addresses of the reward tokens
* @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardsList"
*
*/
function claimAllRewardsOnBehalf(address[] calldata assets, address user, address to)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
/**
* @dev Claims all reward for msg.sender, on all the assets of the pool, accumulating the pending rewards
* @param assets The list of assets to check eligible distributions before claiming rewards
* @return rewardsList List of addresses of the reward tokens
* @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardsList"
*
*/
function claimAllRewardsToSelf(address[] calldata assets)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
}
"
},
"src/interfaces/mantleStandardBridge/IL1StandardBridge.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.25;
interface IL1StandardBridge {
/**
* @custom:legacy
* @notice Deposits some amount of ERC20 tokens into a target account on L2.
*
* @param _l1Token Address of the L1 token being deposited.
* @param _l2Token Address of the corresponding token on L2.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 to deposit.
* @param _minGasLimit Minimum gas limit for the deposit message on L2.
* @param _extraData Optional data to forward to L2. Data supplied here will not be used to
* execute any code on L2 and is only emitted as extra data for the
* convenience of off-chain tooling.
*/
function depositERC20To(
address _l1Token,
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;
}
"
},
"dependencies/@openzeppelin-contracts-5.0.2/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.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 SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @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(IERC20 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);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// 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 cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
"
},
"dependencies/@openzeppelin-contracts-upgradeable-5.0.2/access/OwnableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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 {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"dependencies/@openzeppelin-contracts-5.0.2/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) 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 FailedInnerCall();
}
}
}
"
},
"src/interfaces/paraswap/IParaSwapV62.sol": {
"content": "// SPDX-License-Identifier: MIT
// This file is part of the ParaSwap project: https://paraswap.io
pragma solidity ^0.8.25;
import "./AugustusV6Types.sol";
/// @title IGenericSwapExactAmountIn
/// @notice Interface for executing a generic swapExactAmountIn through an Augustus executor
interface IParaSwapV62 {
/// @notice Executes a generic swapExactAmountIn using the given executorData on the given executor
/// @param executor The address of the executor contract to use
/// @param swapData Generic data containing the swap information
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit The permit data
/// @param executorData The data to execute on the executor
/// @return receivedAmount The amount of destToken received after fees
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountIn(
address executor,
GenericData calldata swapData,
uint256 partnerAndFee,
bytes calldata permit,
bytes calldata executorData
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
/// @notice Executes a tryBatchFillTakerAmount or tryBatchFillMakerAmount call on AugustusRFQ
/// the function that is executed is defined by the direction flag in the data param
/// @param data Struct containing common data for AugustusRFQ
/// @param orders An array containing AugustusRFQ orderInfo data
/// @param permit Permit data for the swap
/// @return spentAmount The amount of tokens spent
/// @return receivedAmount The amount of tokens received
function swapOnAugustusRFQTryBatchFill(
AugustusRFQData calldata data,
OrderInfo[] calldata orders,
bytes calldata permit
)
external
payable
returns (uint256 spentAmount, uint256 receivedAmount);
/*//////////////////////////////////////////////////////////////
SWAP EXACT AMOUNT IN
//////////////////////////////////////////////////////////////*/
/// @notice Executes a swapExactAmountIn on Balancer V2 pools
/// @param balancerData Struct containing data for the swap
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit Permit data for the swap
/// @param data The calldata to execute
/// the first 20 bytes are the beneficiary address and the left most bit is the approve flag
/// @return receivedAmount The amount of destToken received after fees
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountInOnBalancerV2(
BalancerV2Data calldata balancerData,
uint256 partnerAndFee,
bytes calldata permit,
bytes calldata data
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
/*//////////////////////////////////////////////////////////////
SWAP EXACT AMOUNT IN
//////////////////////////////////////////////////////////////*/
/// @notice Executes a swapExactAmountIn on Curve V1 pools
/// @param curveV1Data Struct containing data for the swap
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit Permit data for the swap
/// @return receivedAmount The amount of destToken received after fees
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountInOnCurveV1(
CurveV1Data calldata curveV1Data,
uint256 partnerAndFee,
bytes calldata permit
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
/*//////////////////////////////////////////////////////////////
SWAP EXACT AMOUNT IN
//////////////////////////////////////////////////////////////*/
/// @notice Executes a swapExactAmountIn on Curve V2 pools
/// @param curveV2Data Struct containing data for the swap
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit Permit data for the swap
/// @return receivedAmount The amount of destToken received after fees
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountInOnCurveV2(
CurveV2Data calldata curveV2Data,
uint256 partnerAndFee,
bytes calldata permit
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
/// @notice Executes a swapExactAmountIn on Uniswap V2 pools
/// @param uniData struct containing data for the swap
/// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
/// 20 bytes is the partner address
/// @param permit The permit data
/// @return receivedAmount The amount of destToken received after fees
/// @return paraswapShare The share of the fees for Paraswap
/// @return partnerShare The share of the fees for the partner
function swapExactAmountInOnUniswapV2(
UniswapV2Data calldata uniData,
uint256 partnerAndFee,
bytes calldata permit
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
function swapExactAmountInOnUniswapV3(
UniswapV3Data calldata uniData,
uint256 partnerAndFee,
bytes calldata permit
)
external
payable
returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
function swapExactAmountInOutOnMakerPSM(
MakerPSMData calldata makerPSMData,
bytes calldata permit
)
external
returns (uint256 spentAmount, uint256 receivedAmount);
}"
},
"src/interfaces/aave/v3/libraries/types/DataTypes.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
library DataTypes {
struct ReserveData {
//stores the reserve configuration
ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
//the current supply rate. Expressed in ray
uint128 currentLiquidityRate;
//variable borrow index. Expressed in ray
uint128 variableBorrowIndex;
//the current variable borrow rate. Expressed in ray
uint128 currentVariableBorrowRate;
//the current stable borrow rate. Expressed in ray
uint128 currentStableBorrowRate;
//timestamp of last update
uint40 lastUpdateTimestamp;
//the id of the reserve. Represents the position in the list of the active reserves
uint16 id;
//aToken address
address aTokenAddress;
//stableDebtToken address
address stableDebtTokenAddress;
//variableDebtToken address
address variableDebtTokenAddress;
//address of the interest rate strategy
address interestRateStrategyAddress;
//the current treasury balance, scaled
uint128 accruedToTreasury;
//the outstanding unbacked aTokens minted through the bridging feature
uint128 unbacked;
//the outstanding debt borrowed against this asset in isolation mode
uint128 isolationModeTotalDebt;
}
struct ReserveConfigurationMap {
//bit 0-15: LTV
//bit 16-31: Liq. threshold
//bit 32-47: Liq. bonus
//bit 48-55: Decimals
//bit 56: reserve is active
//bit 57: reserve is frozen
//bit 58: borrowing is enabled
//bit 59: stable rate borrowing enabled
//bit 60: asset is paused
//bit 61: borrowing in isolation mode is enabled
//bit 62-63: reserved
//bit 64-79: reserve factor
//bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap
//bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap
//bit 152-167 liquidation protocol fee
//bit 168-175 eMode category
//bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled
//bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals
//bit 252-255 unused
uint256 data;
}
struct UserConfigurationMap {
/**
* @dev Bitmap of the users collaterals and borrows. It is divided in pairs of bits, one pair per asset.
* The first bit indicates if an asset is used as collateral by the user, the second whether an
* asset is borrowed by the user.
*/
uint256 data;
}
struct EModeCategory {
// each eMode category has a custom ltv and liquidation threshold
uint16 ltv;
uint16 liquidationThreshold;
uint16 liquidationBonus;
// each eMode category may or may not have a custom oracle to override the individual assets price oracles
address priceSource;
string label;
}
enum InterestRateMode {
NONE,
STABLE,
VARIABLE
}
struct ReserveCache {
uint256 currScaledVariableDebt;
uint256 nextScaledVariableDebt;
uint256 currPrincipalStableDebt;
uint256 currAvgStableBorrowRate;
uint256 currTotalStableDebt;
uint256 nextAvgStableBorrowRate;
uint256 nextTotalStableDebt;
uint256 currLiquidityIndex;
uint256 nextLiquidityIndex;
uint256 currVariableBorrowIndex;
uint256 nextVariableBorrowIndex;
uint256 currLiquidityRate;
uint256 currVariableBorrowRate;
uint256 reserveFactor;
ReserveConfigurationMap reserveConfiguration;
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
uint40 reserveLastUpdateTimestamp;
uint40 stableDebtLastUpdateTimestamp;
}
struct ExecuteLiquidationCallParams {
uint256 reservesCount;
uint256 debtToCover;
address collateralAsset;
address debtAsset;
address user;
bool receiveAToken;
address priceOracle;
uint8 userEModeCategory;
address priceOracleSentinel;
}
struct ExecuteSupplyParams {
address asset;
uint256 amount;
address onBehalfOf;
uint16 referralCode;
}
struct ExecuteBorrowParams {
address asset;
address user;
address onBehalfOf;
uint256 amount;
InterestRateMode interestRateMode;
uint16 referralCode;
bool releaseUnderlying;
uint256 maxStableRateBorrowSizePercent;
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address priceOracleSentinel;
}
struct ExecuteRepayParams {
address asset;
uint256 amount;
InterestRateMode interestRateMode;
address onBehalfOf;
bool useATokens;
}
struct ExecuteWithdrawParams {
address asset;
uint256 amount;
address to;
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
}
struct ExecuteSetUserEModeParams {
uint256 reservesCount;
address oracle;
uint8 categoryId;
}
struct FinalizeTransferParams {
address asset;
address from;
address to;
uint256 amount;
uint256 balanceFromBefore;
uint256 balanceToBefore;
uint256 reservesCount;
address oracle;
uint8 fromEModeCategory;
}
struct FlashloanParams {
address receiverAddress;
address[] assets;
uint256[] amounts;
uint256[] interestRateModes;
address onBehalfOf;
bytes params;
uint16 referralCode;
uint256 flashLoanPremiumToProtocol;
uint256 flashLoanPremiumTotal;
uint256 maxStableRateBorrowSizePercent;
uint256 reservesCount;
address addressesProvider;
uint8 userEModeCategory;
bool isAuthorizedFlashBorrower;
}
struct FlashloanSimpleParams {
address receiverAddress;
address asset;
uint256 amount;
bytes params;
uint16 referralCode;
uint256 flashLoanPremiumToProtocol;
uint256 flashLoanPremiumTotal;
}
struct FlashLoanRepaymentParams {
uint256 amount;
uint256 totalPremium;
uint256 flashLoanPremiumToProtocol;
address asset;
address receiverAddress;
uint16 referralCode;
}
struct CalculateUserAccountDataParams {
UserConfigurationMap userConfig;
uint256 reservesCount;
address user;
address oracle;
uint8 userEModeCategory;
}
struct ValidateBorrowParams {
ReserveCache reserveCache;
UserConfigurationMap userConfig;
address asset;
address userAddress;
uint256 amount;
InterestRateMode interestRateMode;
uint256 maxStableLoanPercent;
uint256 reservesCount;
address oracle;
uint8 userEModeCategory;
address priceOracleSentinel;
bool isolationModeActive;
address isolationModeCollateralAddress;
uint256 isolationModeDebtCeiling;
}
struct ValidateLiquidationCallParams {
ReserveCache debtReserveCache;
uint256 totalDebt;
uint256 healthFactor;
address priceOracleSentinel;
}
struct CalculateInterestRatesParams {
uint256 unbacked;
uint256 liquidityAdded;
uint256 liquidityTaken;
uint256 totalStableDebt;
uint256 totalVariableDebt;
uint256 averageStableBorrowRate;
uint256 reserveFactor;
address reserve;
address aToken;
}
struct InitReserveParams {
address asset;
address aTokenAddress;
address stableDebtAddress;
address variableDebtAddress;
address interestRateStrategyAddress;
uint16 reservesCount;
uint16 maxNumberReserves;
}
}
"
},
"dependencies/@openzeppelin-contracts-5.0.2/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
Submitted on: 2025-10-24 19:23:14
Comments
Log in to comment.
No comments yet.