Source Code
Overview
MON Balance
MON Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 38193718 | 60 days ago | Contract Creation | 0 MON |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x4F0EBb2a...be6853A5E The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
PoolQuotaKeeperV3
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 1000 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
pragma abicoder v1;
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
// LIBS & TRAITS
import {ACLTrait} from "../traits/ACLTrait.sol";
import {ContractsRegisterTrait} from "../traits/ContractsRegisterTrait.sol";
import {SanityCheckTrait} from "../traits/SanityCheckTrait.sol";
import {QuotasLogic} from "../libraries/QuotasLogic.sol";
import {IPoolV3} from "../interfaces/IPoolV3.sol";
import {IPoolQuotaKeeperV3, TokenQuotaParams, AccountQuota} from "../interfaces/IPoolQuotaKeeperV3.sol";
import {ICreditManagerV3} from "../interfaces/ICreditManagerV3.sol";
import {IRateKeeper} from "../interfaces/base/IRateKeeper.sol";
import {PERCENTAGE_FACTOR, RAY} from "../libraries/Constants.sol";
import {MarketHelper} from "../libraries/MarketHelper.sol";
// EXCEPTIONS
import "../interfaces/IExceptions.sol";
/// @title Pool quota keeper V3
/// @notice In Gearbox V3, quotas are used to limit the system exposure to risky assets.
/// In order for a risky token to be counted towards credit account's collateral, account owner must "purchase"
/// a quota for this token, which entails two kinds of payments:
/// * interest that accrues over time with rates determined by the gauge (more suited to leveraged farming), and
/// * increase fee that is charged when additional quota is purchased (more suited to leveraged trading).
/// Quota keeper stores information about quotas of accounts in all credit managers connected to the pool, and
/// performs calculations that help to keep pool's expected liquidity and credit managers' debt consistent.
contract PoolQuotaKeeperV3 is IPoolQuotaKeeperV3, ACLTrait, ContractsRegisterTrait, SanityCheckTrait {
using EnumerableSet for EnumerableSet.AddressSet;
using QuotasLogic for TokenQuotaParams;
using MarketHelper for IPoolV3;
/// @notice Contract version
uint256 public constant override version = 3_10;
/// @notice Contract type
bytes32 public constant override contractType = "POOL_QUOTA_KEEPER";
/// @notice Address of the underlying token
address public immutable override underlying;
/// @notice Address of the pool
address public immutable override pool;
/// @dev The list of all allowed credit managers
EnumerableSet.AddressSet internal creditManagerSet;
/// @dev The list of all quoted tokens
EnumerableSet.AddressSet internal quotaTokensSet;
/// @dev Mapping from token to global token quota params
mapping(address => TokenQuotaParams) internal totalQuotaParams;
/// @dev Mapping from (creditAccount, token) to account's token quota params
mapping(address => mapping(address => AccountQuota)) internal accountQuotas;
/// @notice Address of the gauge
/// @dev Any contract that implements the `IRateKeeper` interface can be used everywhere where
/// the term "gauge" is mentioned, the older name stays for backward compatibility
address public override gauge;
/// @notice Timestamp of the last quota rates update
uint40 public override lastQuotaRateUpdate;
/// @dev Ensures that function caller is gauge
modifier gaugeOnly() {
_revertIfCallerNotGauge();
_;
}
/// @dev Ensures that function caller is an allowed credit manager
modifier creditManagerOnly() {
_revertIfCallerNotCreditManager();
_;
}
/// @notice Constructor
/// @param _pool Pool address
constructor(address _pool)
ACLTrait(IPoolV3(_pool).getACL())
ContractsRegisterTrait(IPoolV3(_pool).getContractsRegister())
{
pool = _pool; // U:[PQK-1]
underlying = IPoolV3(_pool).asset(); // U:[PQK-1]
}
// ----------------- //
// QUOTAS MANAGEMENT //
// ----------------- //
/// @notice Updates credit account's quota for a token
/// - Updates account's interest index
/// - Updates account's quota by requested delta subject to the total quota limit
/// - Checks that the resulting quota is no less than the user-specified min desired value
/// and no more than system-specified max allowed value
/// - Updates pool's quota revenue
/// @param creditAccount Credit account to update the quota for
/// @param token Token to update the quota for
/// @param requestedChange Requested quota change in pool's underlying asset units
/// @param minQuota Minimum deisred quota amount
/// @param maxQuota Maximum allowed quota amount
/// @return caQuotaInterestChange Token quota interest accrued by account since the last update
/// @return fees Quota increase fees, if any
/// @return enableToken Whether the token needs to be enabled as collateral
/// @return disableToken Whether the token needs to be disabled as collateral
function updateQuota(address creditAccount, address token, int96 requestedChange, uint96 minQuota, uint96 maxQuota)
external
override
creditManagerOnly // U:[PQK-4]
returns (uint128 caQuotaInterestChange, uint128 fees, bool enableToken, bool disableToken)
{
int96 quotaChange;
(caQuotaInterestChange, fees, quotaChange, enableToken, disableToken) =
_updateQuota(creditAccount, token, requestedChange, minQuota, maxQuota);
if (quotaChange != 0) {
emit UpdateQuota({creditAccount: creditAccount, token: token, quotaChange: quotaChange});
}
}
/// @dev Implementation of `updateQuota`
function _updateQuota(address creditAccount, address token, int96 requestedChange, uint96 minQuota, uint96 maxQuota)
internal
returns (uint128 caQuotaInterestChange, uint128 fees, int96 quotaChange, bool enableToken, bool disableToken)
{
AccountQuota storage accountQuota = accountQuotas[creditAccount][token];
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token];
uint96 quoted = accountQuota.quota;
(uint16 rate, uint192 tqCumulativeIndexLU, uint16 quotaIncreaseFee) =
_getTokenQuotaParamsOrRevert(tokenQuotaParams);
if (rate == 0) revert TokenIsNotQuotedException(); // U:[PQK-14]
uint192 cumulativeIndexNow = QuotasLogic.cumulativeIndexSince(tqCumulativeIndexLU, rate, lastQuotaRateUpdate);
// Accrued quota interest depends on the quota and thus must be computed before updating it
caQuotaInterestChange =
QuotasLogic.calcAccruedQuotaInterest(quoted, cumulativeIndexNow, accountQuota.cumulativeIndexLU); // U:[PQK-15]
uint96 newQuoted;
quotaChange = requestedChange;
if (quotaChange > 0) {
(uint96 totalQuoted, uint96 limit) = _getTokenQuotaTotalAndLimit(tokenQuotaParams);
quotaChange = QuotasLogic.calcActualQuotaChange(totalQuoted, limit, quotaChange); // U:[PQK-15]
fees = uint128(uint256(uint96(quotaChange)) * quotaIncreaseFee / PERCENTAGE_FACTOR); // U:[PQK-15]
newQuoted = quoted + uint96(quotaChange);
if (quoted == 0 && newQuoted != 0) {
enableToken = true; // U:[PQK-15]
}
tokenQuotaParams.totalQuoted = totalQuoted + uint96(quotaChange); // U:[PQK-15]
} else {
if (quotaChange == type(int96).min) {
// `quoted` is at most `type(int96).max` so cast is safe
quotaChange = -int96(quoted);
}
// `-quotaChange` is non-negative and at most `type(int96).max` so cast is safe
uint96 absoluteChange = uint96(-quotaChange);
newQuoted = quoted - absoluteChange;
tokenQuotaParams.totalQuoted -= absoluteChange; // U:[PQK-15]
if (quoted != 0 && newQuoted == 0) {
disableToken = true; // U:[PQK-15]
}
}
if (newQuoted < minQuota || newQuoted > maxQuota) revert QuotaIsOutOfBoundsException(); // U:[PQK-15]
accountQuota.quota = newQuoted; // U:[PQK-15]
accountQuota.cumulativeIndexLU = cumulativeIndexNow; // U:[PQK-15]
int256 quotaRevenueChange = QuotasLogic.calcQuotaRevenueChange(rate, int256(quotaChange)); // U:[PQK-15]
if (quotaRevenueChange != 0) {
IPoolV3(pool).updateQuotaRevenue(quotaRevenueChange); // U:[PQK-15]
}
}
/// @notice Removes credit account's quotas for provided tokens
/// - Sets account's tokens quotas to zero
/// - Optionally sets quota limits for tokens to zero, effectively preventing further exposure
/// to them in extreme cases (e.g., liquidations with loss)
/// - Does not update account's interest indexes (can be skipped since quotas are zero)
/// - Decreases pool's quota revenue
/// @param creditAccount Credit account to remove quotas for
/// @param tokens Array of tokens to remove quotas for
/// @param setLimitsToZero Whether tokens quota limits should be set to zero
function removeQuotas(address creditAccount, address[] calldata tokens, bool setLimitsToZero)
external
override
creditManagerOnly // U:[PQK-4]
{
int256 quotaRevenueChange;
uint256 len = tokens.length;
for (uint256 i; i < len;) {
address token = tokens[i];
AccountQuota storage accountQuota = accountQuotas[creditAccount][token];
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token];
uint96 quoted = accountQuota.quota;
if (quoted != 0) {
uint16 rate = tokenQuotaParams.rate;
quotaRevenueChange += QuotasLogic.calcQuotaRevenueChange(rate, -int256(uint256(quoted))); // U:[PQK-16]
tokenQuotaParams.totalQuoted -= quoted; // U:[PQK-16]
accountQuota.quota = 0; // U:[PQK-16]
// `quoted` is at most `type(int96).max` so cast is safe
emit UpdateQuota({creditAccount: creditAccount, token: token, quotaChange: -int96(quoted)});
}
if (setLimitsToZero) {
_setTokenLimit({tokenQuotaParams: tokenQuotaParams, token: token, limit: 0}); // U:[PQK-16]
}
unchecked {
++i;
}
}
if (quotaRevenueChange != 0) {
IPoolV3(pool).updateQuotaRevenue(quotaRevenueChange); // U:[PQK-16]
}
}
/// @notice Updates credit account's interest indexes for provided tokens
/// @param creditAccount Credit account to accrue interest for
/// @param tokens Array tokens to accrue interest for
function accrueQuotaInterest(address creditAccount, address[] calldata tokens)
external
override
creditManagerOnly // U:[PQK-4]
{
uint256 len = tokens.length;
uint40 lastQuotaRateUpdate_ = lastQuotaRateUpdate;
unchecked {
for (uint256 i; i < len; ++i) {
address token = tokens[i];
AccountQuota storage accountQuota = accountQuotas[creditAccount][token];
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token];
(uint16 rate, uint192 tqCumulativeIndexLU,) = _getTokenQuotaParamsOrRevert(tokenQuotaParams); // U:[PQK-17]
if (rate == 0) revert TokenIsNotQuotedException(); // U:[PQK-17]
accountQuota.cumulativeIndexLU =
QuotasLogic.cumulativeIndexSince(tqCumulativeIndexLU, rate, lastQuotaRateUpdate_); // U:[PQK-17]
}
}
}
/// @notice Returns credit account's token quota and interest accrued since the last update
/// @param creditAccount Account to compute the values for
/// @param token Token to compute the values for
/// @return quoted Account's token quota
/// @return outstandingInterest Quota interest accrued since the last update
function getQuotaAndOutstandingInterest(address creditAccount, address token)
external
view
override
returns (uint96 quoted, uint128 outstandingInterest)
{
AccountQuota storage accountQuota = accountQuotas[creditAccount][token];
uint192 cumulativeIndexNow = cumulativeIndex(token);
quoted = accountQuota.quota;
uint192 aqCumulativeIndexLU = accountQuota.cumulativeIndexLU;
outstandingInterest = QuotasLogic.calcAccruedQuotaInterest(quoted, cumulativeIndexNow, aqCumulativeIndexLU); // U:[PQK-15]
}
/// @notice Returns current quota interest index for a token in ray
function cumulativeIndex(address token) public view override returns (uint192) {
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token];
(uint16 rate, uint192 tqCumulativeIndexLU,) = _getTokenQuotaParamsOrRevert(tokenQuotaParams);
return QuotasLogic.cumulativeIndexSince(tqCumulativeIndexLU, rate, lastQuotaRateUpdate);
}
/// @notice Returns quota interest rate for a token in bps
function getQuotaRate(address token) external view override returns (uint16) {
return totalQuotaParams[token].rate;
}
/// @notice Returns an array of all quoted tokens
function quotedTokens() external view override returns (address[] memory) {
return quotaTokensSet.values();
}
/// @notice Whether a token is quoted
function isQuotedToken(address token) external view override returns (bool) {
return quotaTokensSet.contains(token);
}
/// @notice Returns account's quota params for a token
function getQuota(address creditAccount, address token)
external
view
override
returns (uint96 quota, uint192 cumulativeIndexLU)
{
AccountQuota storage aq = accountQuotas[creditAccount][token];
return (aq.quota, aq.cumulativeIndexLU);
}
/// @notice Returns global quota params for a token
function getTokenQuotaParams(address token)
external
view
override
returns (
uint16 rate,
uint192 cumulativeIndexLU,
uint16 quotaIncreaseFee,
uint96 totalQuoted,
uint96 limit,
bool isActive
)
{
TokenQuotaParams memory tq = totalQuotaParams[token];
rate = tq.rate;
cumulativeIndexLU = tq.cumulativeIndexLU;
quotaIncreaseFee = tq.quotaIncreaseFee;
totalQuoted = tq.totalQuoted;
limit = tq.limit;
isActive = rate != 0;
}
/// @notice Returns the pool's quota revenue (in units of underlying per year)
function poolQuotaRevenue() external view virtual override returns (uint256 quotaRevenue) {
address[] memory tokens = quotaTokensSet.values();
uint256 len = tokens.length;
for (uint256 i; i < len;) {
address token = tokens[i];
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token];
(uint16 rate,,) = _getTokenQuotaParamsOrRevert(tokenQuotaParams);
(uint256 totalQuoted,) = _getTokenQuotaTotalAndLimit(tokenQuotaParams);
quotaRevenue += totalQuoted * rate / PERCENTAGE_FACTOR;
unchecked {
++i;
}
}
}
/// @notice Returns the list of allowed credit managers
function creditManagers() external view override returns (address[] memory) {
return creditManagerSet.values(); // U:[PQK-10]
}
// ------------- //
// CONFIGURATION //
// ------------- //
/// @notice Adds a new quota token
/// @param token Address of the token
/// @custom:expects Gauge ensures that `token` is not pool's underlying
function addQuotaToken(address token)
external
override
gaugeOnly // U:[PQK-3]
{
if (quotaTokensSet.contains(token)) {
revert TokenAlreadyAddedException(); // U:[PQK-6]
}
// The rate will be set during a general epoch update in the gauge
quotaTokensSet.add(token); // U:[PQK-5]
totalQuotaParams[token].cumulativeIndexLU = 1; // U:[PQK-5]
emit AddQuotaToken(token); // U:[PQK-5]
}
/// @notice Updates quota rates
/// - Updates global token cumulative indexes before changing rates
/// - Queries new rates for all quoted tokens from the gauge
/// - Sets new pool quota revenue
function updateRates()
external
override
gaugeOnly // U:[PQK-3]
{
address[] memory tokens = quotaTokensSet.values();
uint16[] memory rates = IRateKeeper(gauge).getRates(tokens); // U:[PQK-7]
uint256 quotaRevenue;
uint256 timestampLU = lastQuotaRateUpdate;
uint256 len = tokens.length;
for (uint256 i; i < len;) {
address token = tokens[i];
uint16 rate = rates[i];
if (rate == 0) revert IncorrectParameterException(); // U:[PQK-7B]
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token]; // U:[PQK-7]
(uint16 prevRate, uint192 tqCumulativeIndexLU,) = _getTokenQuotaParamsOrRevert(tokenQuotaParams);
tokenQuotaParams.cumulativeIndexLU =
QuotasLogic.cumulativeIndexSince(tqCumulativeIndexLU, prevRate, timestampLU); // U:[PQK-7]
tokenQuotaParams.rate = rate; // U:[PQK-7]
quotaRevenue += uint256(tokenQuotaParams.totalQuoted) * rate / PERCENTAGE_FACTOR; // U:[PQK-7]
emit UpdateTokenQuotaRate(token, rate); // U:[PQK-7]
unchecked {
++i;
}
}
IPoolV3(pool).setQuotaRevenue(quotaRevenue); // U:[PQK-7]
lastQuotaRateUpdate = uint40(block.timestamp); // U:[PQK-7]
}
/// @notice Sets a new gauge contract to compute quota rates
/// @param _gauge Address of the new gauge contract
function setGauge(address _gauge)
external
override
configuratorOnly // U:[PQK-2]
nonZeroAddress(_gauge) // U:[PQK-8]
{
if (gauge == _gauge) return;
if (IRateKeeper(_gauge).pool() != pool) {
revert IncompatibleGaugeException(); // U:[PQK-8]
}
uint256 len = quotaTokensSet.length();
for (uint256 i; i < len;) {
if (!IRateKeeper(_gauge).isTokenAdded(quotaTokensSet.at(i))) {
revert TokenIsNotQuotedException(); // U:[PQK-8]
}
unchecked {
++i;
}
}
gauge = _gauge; // U:[PQK-8]
emit SetGauge(_gauge); // U:[PQK-8]
}
/// @notice Adds an address to the set of allowed credit managers
/// @param _creditManager Address of the new credit manager
function addCreditManager(address _creditManager)
external
override
configuratorOnly // U:[PQK-2]
nonZeroAddress(_creditManager)
registeredCreditManagerOnly(_creditManager) // U:[PQK-9]
{
if (ICreditManagerV3(_creditManager).pool() != pool) {
revert IncompatibleCreditManagerException(); // U:[PQK-9]
}
if (!creditManagerSet.contains(_creditManager)) {
creditManagerSet.add(_creditManager); // U:[PQK-10]
emit AddCreditManager(_creditManager); // U:[PQK-10]
}
}
/// @notice Sets the total quota limit for a token
/// @param token Address of token to set the limit for
/// @param limit The limit to set
function setTokenLimit(address token, uint96 limit)
external
override
configuratorOnly // U:[PQK-2]
{
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token];
_setTokenLimit(tokenQuotaParams, token, limit);
}
/// @dev Implementation of `setTokenLimit`
function _setTokenLimit(TokenQuotaParams storage tokenQuotaParams, address token, uint96 limit) internal {
if (!isInitialised(tokenQuotaParams)) {
revert TokenIsNotQuotedException(); // U:[PQK-11]
}
if (limit > uint96(type(int96).max)) {
revert IncorrectParameterException(); // U:[PQK-12]
}
if (tokenQuotaParams.limit != limit) {
tokenQuotaParams.limit = limit; // U:[PQK-12]
emit SetTokenLimit(token, limit); // U:[PQK-12]
}
}
/// @notice Sets the one-time quota increase fee for a token
/// @param token Token to set the fee for
/// @param fee The new fee value in bps
function setTokenQuotaIncreaseFee(address token, uint16 fee)
external
override
configuratorOnly // U:[PQK-2]
{
if (fee > PERCENTAGE_FACTOR) {
revert IncorrectParameterException();
}
TokenQuotaParams storage tokenQuotaParams = totalQuotaParams[token]; // U:[PQK-13]
if (!isInitialised(tokenQuotaParams)) {
revert TokenIsNotQuotedException();
}
if (tokenQuotaParams.quotaIncreaseFee != fee) {
tokenQuotaParams.quotaIncreaseFee = fee; // U:[PQK-13]
emit SetQuotaIncreaseFee(token, fee); // U:[PQK-13]
}
}
// --------- //
// INTERNALS //
// --------- //
/// @dev Whether quota params for token are initialized
function isInitialised(TokenQuotaParams storage tokenQuotaParams) internal view returns (bool) {
return tokenQuotaParams.cumulativeIndexLU != 0;
}
/// @dev Efficiently loads quota params of a token from storage
function _getTokenQuotaParamsOrRevert(TokenQuotaParams storage tokenQuotaParams)
internal
view
returns (uint16 rate, uint192 cumulativeIndexLU, uint16 quotaIncreaseFee)
{
// rate = tokenQuotaParams.rate;
// cumulativeIndexLU = tokenQuotaParams.cumulativeIndexLU;
// quotaIncreaseFee = tokenQuotaParams.quotaIncreaseFee;
assembly {
let data := sload(tokenQuotaParams.slot)
rate := and(data, 0xFFFF)
cumulativeIndexLU := and(shr(16, data), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
quotaIncreaseFee := shr(208, data)
}
if (cumulativeIndexLU == 0) {
revert TokenIsNotQuotedException(); // U:[PQK-14]
}
}
/// @dev Efficiently loads quota and limit of a token from storage
function _getTokenQuotaTotalAndLimit(TokenQuotaParams storage tokenQuotaParams)
internal
view
returns (uint96 totalQuoted, uint96 limit)
{
// totalQuoted = tokenQuotaParams.totalQuoted;
// limit = tokenQuotaParams.limit;
assembly {
let data := sload(add(tokenQuotaParams.slot, 1))
totalQuoted := and(data, 0xFFFFFFFFFFFFFFFFFFFFFFFF)
limit := shr(96, data)
}
}
/// @dev Reverts if `msg.sender` is not an allowed credit manager
function _revertIfCallerNotCreditManager() internal view {
if (!creditManagerSet.contains(msg.sender)) {
revert CallerNotCreditManagerException(); // U:[PQK-4]
}
}
/// @dev Reverts if `msg.sender` is not gauge
function _revertIfCallerNotGauge() internal view {
if (msg.sender != gauge) revert CallerNotGaugeException(); // U:[PQK-3]
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://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.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(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);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @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 Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.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 Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_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. 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 {
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);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @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 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* _Available since v4.7._
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IACL} from "../interfaces/base/IACL.sol";
import {IACLTrait} from "../interfaces/base/IACLTrait.sol";
import {
AddressIsNotContractException,
CallerNotConfiguratorException,
CallerNotPausableAdminException,
CallerNotUnpausableAdminException,
ZeroAddressException
} from "../interfaces/IExceptions.sol";
/// @title ACL trait
/// @notice Utility class for ACL (access-control list) consumers
abstract contract ACLTrait is IACLTrait {
using Address for address;
/// @notice ACL contract address
address public immutable override acl;
/// @dev Ensures that function caller has configurator role
modifier configuratorOnly() {
_ensureCallerIsConfigurator();
_;
}
/// @dev Ensures that function caller has pausable admin role
modifier pausableAdminsOnly() {
_ensureCallerIsPausableAdmin();
_;
}
/// @dev Ensures that function caller has unpausable admin role
modifier unpausableAdminsOnly() {
_ensureCallerIsUnpausableAdmin();
_;
}
/// @notice Constructor
/// @param _acl ACL contract address
constructor(address _acl) {
if (_acl == address(0)) revert ZeroAddressException();
if (!_acl.isContract()) revert AddressIsNotContractException(_acl);
acl = _acl;
}
/// @dev Reverts if the caller is not the configurator
/// @dev Used to cut contract size on modifiers
function _ensureCallerIsConfigurator() internal view {
if (!_isConfigurator(msg.sender)) revert CallerNotConfiguratorException();
}
/// @dev Checks whether given account has configurator role
function _isConfigurator(address account) internal view returns (bool) {
return IACL(acl).isConfigurator(account);
}
/// @dev Reverts if the caller is not pausable admin
/// @dev Used to cut contract size on modifiers
function _ensureCallerIsPausableAdmin() internal view {
if (!_hasRole("PAUSABLE_ADMIN", msg.sender)) revert CallerNotPausableAdminException();
}
/// @dev Reverts if the caller is not unpausable admin
/// @dev Used to cut contract size on modifiers
function _ensureCallerIsUnpausableAdmin() internal view {
if (!_hasRole("UNPAUSABLE_ADMIN", msg.sender)) revert CallerNotUnpausableAdminException();
}
/// @dev Whether account `account` has role `role`
/// @dev Used to cut contract size on external calls
function _hasRole(bytes32 role, address account) internal view returns (bool) {
return IACL(acl).hasRole(role, account);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
pragma abicoder v1;
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {IACLTrait} from "./base/IACLTrait.sol";
import {IContractsRegisterTrait} from "./base/IContractsRegisterTrait.sol";
import {IVersion} from "./base/IVersion.sol";
interface IPoolV3Events {
/// @notice Emitted when depositing liquidity with referral code
event Refer(address indexed onBehalfOf, uint256 indexed referralCode, uint256 amount);
/// @notice Emitted when credit account borrows funds from the pool
event Borrow(address indexed creditManager, address indexed creditAccount, uint256 amount);
/// @notice Emitted when credit account's debt is repaid to the pool
event Repay(address indexed creditManager, uint256 borrowedAmount, uint256 profit, uint256 loss);
/// @notice Emitted when incurred loss can't be fully covered by burning treasury's shares
event IncurUncoveredLoss(address indexed creditManager, uint256 loss);
/// @notice Emitted when new interest rate model contract is set
event SetInterestRateModel(address indexed newInterestRateModel);
/// @notice Emitted when new pool quota keeper contract is set
event SetPoolQuotaKeeper(address indexed newPoolQuotaKeeper);
/// @notice Emitted when new total debt limit is set
event SetTotalDebtLimit(uint256 limit);
/// @notice Emitted when new credit manager is connected to the pool
event AddCreditManager(address indexed creditManager);
/// @notice Emitted when new debt limit is set for a credit manager
event SetCreditManagerDebtLimit(address indexed creditManager, uint256 newLimit);
/// @notice Emitted when new withdrawal fee is set
event SetWithdrawFee(uint256 fee);
}
/// @title Pool V3 interface
interface IPoolV3 is IVersion, IACLTrait, IContractsRegisterTrait, IPoolV3Events, IERC4626, IERC20Permit {
function underlyingToken() external view returns (address);
function treasury() external view returns (address);
function withdrawFee() external view returns (uint16);
function creditManagers() external view returns (address[] memory);
function availableLiquidity() external view returns (uint256);
function expectedLiquidity() external view returns (uint256);
function expectedLiquidityLU() external view returns (uint256);
// ---------------- //
// ERC-4626 LENDING //
// ---------------- //
function depositWithReferral(uint256 assets, address receiver, uint256 referralCode)
external
returns (uint256 shares);
function mintWithReferral(uint256 shares, address receiver, uint256 referralCode)
external
returns (uint256 assets);
// --------- //
// BORROWING //
// --------- //
function totalBorrowed() external view returns (uint256);
function totalDebtLimit() external view returns (uint256);
function creditManagerBorrowed(address creditManager) external view returns (uint256);
function creditManagerDebtLimit(address creditManager) external view returns (uint256);
function creditManagerBorrowable(address creditManager) external view returns (uint256 borrowable);
function lendCreditAccount(uint256 borrowedAmount, address creditAccount) external;
function repayCreditAccount(uint256 repaidAmount, uint256 profit, uint256 loss) external;
// ------------- //
// INTEREST RATE //
// ------------- //
function interestRateModel() external view returns (address);
function baseInterestRate() external view returns (uint256);
function supplyRate() external view returns (uint256);
function baseInterestIndex() external view returns (uint256);
function baseInterestIndexLU() external view returns (uint256);
function lastBaseInterestUpdate() external view returns (uint40);
// ------ //
// QUOTAS //
// ------ //
function poolQuotaKeeper() external view returns (address);
function quotaRevenue() external view returns (uint256);
function lastQuotaRevenueUpdate() external view returns (uint40);
function updateQuotaRevenue(int256 quotaRevenueDelta) external;
function setQuotaRevenue(uint256 newQuotaRevenue) external;
// ------------- //
// CONFIGURATION //
// ------------- //
function setInterestRateModel(address newInterestRateModel) external;
function setPoolQuotaKeeper(address newPoolQuotaKeeper) external;
function setTotalDebtLimit(uint256 newLimit) external;
function setCreditManagerDebtLimit(address creditManager, uint256 newLimit) external;
function setWithdrawFee(uint256 newWithdrawFee) external;
function pause() external;
function unpause() external;
}// SPDX-License-Identifier: BUSL-1.1 // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; bytes32 constant AP_GEAR_TOKEN = "GLOBAL::GEAR_TOKEN"; bytes32 constant AP_INSTANCE_MANAGER_PROXY = "INSTANCE_MANAGER_PROXY"; bytes32 constant AP_CROSS_CHAIN_GOVERNANCE_PROXY = "CROSS_CHAIN_GOVERNANCE_PROXY"; bytes32 constant AP_PRICE_FEED_STORE = "PRICE_FEED_STORE"; uint256 constant NO_VERSION_CONTROL = 0; uint256 constant WAD = 1e18; uint256 constant RAY = 1e27; uint16 constant PERCENTAGE_FACTOR = 1e4; uint256 constant SECONDS_PER_YEAR = 365 days; uint256 constant EPOCH_LENGTH = 7 days; uint256 constant FIRST_EPOCH_TIMESTAMP = 1702900800; uint256 constant EPOCHS_TO_WITHDRAW = 4; uint8 constant MAX_SANE_ENABLED_TOKENS = 20; uint256 constant MAX_SANE_EPOCH_LENGTH = 28 days; uint256 constant MAX_SANE_ACTIVE_BOTS = 5; uint8 constant MAX_WITHDRAW_FEE = 100; uint8 constant DEFAULT_LIMIT_PER_BLOCK_MULTIPLIER = 2; uint8 constant BOT_PERMISSIONS_SET_FLAG = 1; uint256 constant UNDERLYING_TOKEN_MASK = 1; address constant INACTIVE_CREDIT_ACCOUNT_ADDRESS = address(1);
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
interface IACL {
function isConfigurator(address account) external view returns (bool);
function hasRole(bytes32 role, address account) external view returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {RAY, SECONDS_PER_YEAR, PERCENTAGE_FACTOR} from "../libraries/Constants.sol";
uint192 constant RAY_DIVIDED_BY_PERCENTAGE = uint192(RAY / PERCENTAGE_FACTOR);
/// @title Quotas logic library
library QuotasLogic {
/// @dev Computes the new interest index value, given the previous value, the interest rate, and time delta
/// @dev Unlike pool's base interest, interest on quotas is not compounding, so additive index is used
function cumulativeIndexSince(uint192 cumulativeIndexLU, uint16 rate, uint256 lastQuotaRateUpdate)
internal
view
returns (uint192)
{
// cast is safe since both summands are of the same order as `RAY` which is roughly `2**90`
return uint192(
uint256(cumulativeIndexLU)
+ RAY_DIVIDED_BY_PERCENTAGE * (block.timestamp - lastQuotaRateUpdate) * rate / SECONDS_PER_YEAR
); // U:[QL-1]
}
/// @dev Computes interest accrued on the quota since the last update
function calcAccruedQuotaInterest(uint96 quoted, uint192 cumulativeIndexNow, uint192 cumulativeIndexLU)
internal
pure
returns (uint128)
{
// cast is safe since `quoted` is `uint96` and index change is of the same order as `RAY`
return uint128(uint256(quoted) * (cumulativeIndexNow - cumulativeIndexLU) / RAY); // U:[QL-2]
}
/// @dev Computes the pool quota revenue change given the current rate and the quota change
function calcQuotaRevenueChange(uint16 rate, int256 change) internal pure returns (int256) {
return change * int256(uint256(rate)) / int16(PERCENTAGE_FACTOR);
}
/// @dev Upper-bounds requested quota increase such that the resulting total quota doesn't exceed the limit
function calcActualQuotaChange(uint96 totalQuoted, uint96 limit, int96 requestedChange)
internal
pure
returns (int96 quotaChange)
{
if (totalQuoted >= limit) {
return 0;
}
unchecked {
uint96 maxQuotaCapacity = limit - totalQuoted;
// The function is never called with `requestedChange < 0`, so casting it to `uint96` is safe
// `limit` is at most `type(int96).max`, so casting `maxQuotaCapacity` to `int96` is safe
return uint96(requestedChange) > maxQuotaCapacity ? int96(maxQuotaCapacity) : requestedChange;
}
}
}// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; // ------- // // GENERAL // // ------- // /// @notice Thrown on attempting to set an important address to zero address error ZeroAddressException(); /// @notice Thrown when attempting to pass a zero amount to a funding-related operation error AmountCantBeZeroException(); /// @notice Thrown on incorrect input parameter error IncorrectParameterException(); /// @notice Thrown when balance is insufficient to perform an operation error InsufficientBalanceException(); /// @notice Thrown if parameter is out of range error ValueOutOfRangeException(); /// @notice Thrown when trying to send ETH to a contract that is not allowed to receive ETH directly error ReceiveIsNotAllowedException(); /// @notice Thrown on attempting to set an EOA as an important contract in the system error AddressIsNotContractException(address); /// @notice Thrown on attempting to receive a token that is not a collateral token or was forbidden error TokenNotAllowedException(); /// @notice Thrown on attempting to add a token that is already in a collateral list error TokenAlreadyAddedException(); /// @notice Thrown when attempting to use quota-related logic for a token that is not quoted in quota keeper error TokenIsNotQuotedException(); /// @notice Thrown on attempting to interact with an address that is not a valid target contract error TargetContractNotAllowedException(); /// @notice Thrown if function is not implemented error NotImplementedException(); // ------------------ // // CONTRACTS REGISTER // // ------------------ // /// @notice Thrown when an address is expected to be a registered credit manager, but is not error RegisteredCreditManagerOnlyException(); /// @notice Thrown when an address is expected to be a registered pool, but is not error RegisteredPoolOnlyException(); // ---------------- // // ADDRESS PROVIDER // // ---------------- // /// @notice Reverts if address key isn't found in address provider error AddressNotFoundException(); // ----------------- // // POOL, PQK, GAUGES // // ----------------- // /// @notice Thrown by pool-adjacent contracts when a credit manager being connected has a wrong pool address error IncompatibleCreditManagerException(); /// @notice Thrown when attempting to set an incompatible successor staking contract error IncompatibleSuccessorException(); /// @notice Thrown when attempting to vote in a non-approved contract error VotingContractNotAllowedException(); /// @notice Thrown when attempting to unvote more votes than there are error InsufficientVotesException(); /// @notice Thrown when attempting to borrow more than the second point on a two-point curve error BorrowingMoreThanU2ForbiddenException(); /// @notice Thrown when a credit manager attempts to borrow more than its limit in the current block, or in general error CreditManagerCantBorrowException(); /// @notice Thrown when attempting to connect a quota keeper to an incompatible pool error IncompatiblePoolQuotaKeeperException(); /// @notice Thrown when attempting to connect a gauge to an incompatible pool quota keeper error IncompatibleGaugeException(); /// @notice Thrown when the quota is outside of min/max bounds error QuotaIsOutOfBoundsException(); // -------------- // // CREDIT MANAGER // // -------------- // /// @notice Thrown on failing a full collateral check after multicall error NotEnoughCollateralException(); /// @notice Thrown if an attempt to approve a collateral token to adapter's target contract fails error AllowanceFailedException(); /// @notice Thrown on attempting to perform an action for a credit account that does not exist error CreditAccountDoesNotExistException(); /// @notice Thrown on configurator attempting to add more than 255 collateral tokens error TooManyTokensException(); /// @notice Thrown if more than the maximum number of tokens were enabled on a credit account error TooManyEnabledTokensException(); /// @notice Thrown when attempting to execute a protocol interaction without active credit account set error ActiveCreditAccountNotSetException(); /// @notice Thrown when trying to update credit account's debt more than once in the same block error DebtUpdatedTwiceInOneBlockException(); /// @notice Thrown when trying to repay all debt while having active quotas error DebtToZeroWithActiveQuotasException(); /// @notice Thrown when a zero-debt account attempts to update quota error UpdateQuotaOnZeroDebtAccountException(); /// @notice Thrown when attempting to close an account with non-zero debt error CloseAccountWithNonZeroDebtException(); /// @notice Thrown when value of funds remaining on the account after liquidation is insufficient error InsufficientRemainingFundsException(); /// @notice Thrown when Credit Facade tries to write over a non-zero active Credit Account error ActiveCreditAccountOverridenException(); // ------------------- // // CREDIT CONFIGURATOR // // ------------------- // /// @notice Thrown on attempting to use a non-ERC20 contract or an EOA as a token error IncorrectTokenContractException(); /// @notice Thrown if the newly set LT if zero or greater than the underlying's LT error IncorrectLiquidationThresholdException(); /// @notice Thrown if borrowing limits are incorrect: minLimit > maxLimit or maxLimit > blockLimit error IncorrectLimitsException(); /// @notice Thrown if the new expiration date is less than the current expiration date or current timestamp error IncorrectExpirationDateException(); /// @notice Thrown if a contract returns a wrong credit manager or reverts when trying to retrieve it error IncompatibleContractException(); /// @notice Thrown if attempting to forbid an adapter that is not registered in the credit manager error AdapterIsNotRegisteredException(); /// @notice Thrown if new credit configurator's set of allowed adapters differs from the current one error IncorrectAdaptersSetException(); /// @notice Thrown if attempting to schedule a token's LT ramping that is too short in duration error RampDurationTooShortException(); /// @notice Thrown if attempting to set liquidation fees such that the sum of premium and fee changes error InconsistentLiquidationFeesException(); /// @notice Thrown if attempting to set expired liquidation fees such that the sum of premium and fee changes error InconsistentExpiredLiquidationFeesException(); // ------------- // // CREDIT FACADE // // ------------- // /// @notice Thrown when attempting to perform an action that is forbidden in whitelisted mode error ForbiddenInWhitelistedModeException(); /// @notice Thrown if credit facade is not expirable, and attempted aciton requires expirability error NotAllowedWhenNotExpirableException(); /// @notice Thrown if a selector that doesn't match any allowed function is passed to the credit facade in a multicall error UnknownMethodException(bytes4 selector); /// @notice Thrown if a liquidator tries to liquidate an account with a health factor above 1 error CreditAccountNotLiquidatableException(); /// @notice Thrown if a liquidator tries to liquidate an account with loss but violates the loss policy error CreditAccountNotLiquidatableWithLossException(); /// @notice Thrown if too much new debt was taken within a single block error BorrowedBlockLimitException(); /// @notice Thrown if the new debt principal for a credit account falls outside of borrowing limits error BorrowAmountOutOfLimitsException(); /// @notice Thrown if a user attempts to open an account via an expired credit facade error NotAllowedAfterExpirationException(); /// @notice Thrown if expected balances are attempted to be set twice without performing a slippage check error ExpectedBalancesAlreadySetException(); /// @notice Thrown if attempting to perform a slippage check when excepted balances are not set error ExpectedBalancesNotSetException(); /// @notice Thrown if balance of at least one token is less than expected during a slippage check error BalanceLessThanExpectedException(address token); /// @notice Thrown when trying to perform an action that is forbidden when credit account has enabled forbidden tokens error ForbiddenTokensException(uint256 forbiddenTokensMask); /// @notice Thrown when forbidden token quota is increased during the multicall error ForbiddenTokenQuotaIncreasedException(address token); /// @notice Thrown when enabled forbidden token balance is increased during the multicall error ForbiddenTokenBalanceIncreasedException(address token); /// @notice Thrown when the remaining token balance is increased during the liquidation error RemainingTokenBalanceIncreasedException(address token); /// @notice Thrown if `botMulticall` is called by an address that is not approved by account owner or is forbidden error NotApprovedBotException(address bot); /// @notice Thrown when attempting to perform a multicall action with no permission for it error NoPermissionException(uint256 permission); /// @notice Thrown when attempting to give a bot unexpected permissions error UnexpectedPermissionsException(uint256 permissions); /// @notice Thrown when a custom HF parameter lower than 10000 is passed into the full collateral check error CustomHealthFactorTooLowException(); /// @notice Thrown when submitted collateral hint is not a valid token mask error InvalidCollateralHintException(uint256 mask); /// @notice Thrown when trying to seize underlying token during partial liquidation error UnderlyingIsNotLiquidatableException(); /// @notice Thrown when amount of collateral seized during partial liquidation is less than required error SeizedLessThanRequiredException(uint256 seizedAmount); // ------ // // ACCESS // // ------ // /// @notice Thrown on attempting to call an access restricted function not as credit account owner error CallerNotCreditAccountOwnerException(); /// @notice Thrown on attempting to call an access restricted function not as configurator error CallerNotConfiguratorException(); /// @notice Thrown on attempting to call an access-restructed function not as account factory error CallerNotAccountFactoryException(); /// @notice Thrown on attempting to call an access restricted function not as credit manager error CallerNotCreditManagerException(); /// @notice Thrown on attempting to call an access restricted function not as credit facade error CallerNotCreditFacadeException(); /// @notice Thrown on attempting to pause a contract without pausable admin rights error CallerNotPausableAdminException(); /// @notice Thrown on attempting to unpause a contract without unpausable admin rights error CallerNotUnpausableAdminException(); /// @notice Thrown on attempting to call an access restricted function not as gauge error CallerNotGaugeException(); /// @notice Thrown on attempting to call an access restricted function not as quota keeper error CallerNotPoolQuotaKeeperException(); /// @notice Thrown on attempting to call an access restricted function not as voter error CallerNotVoterException(); /// @notice Thrown on attempting to call an access restricted function not as allowed adapter error CallerNotAdapterException(); /// @notice Thrown on attempting to call an access restricted function not as migrator error CallerNotMigratorException(); /// @notice Thrown when an address that is not the designated executor attempts to execute a transaction error CallerNotExecutorException(); /// @notice Thrown on attempting to call an access restricted function not as veto admin error CallerNotVetoAdminException(); // -------- // // BOT LIST // // -------- // /// @notice Thrown when attempting to set non-zero permissions for a forbidden bot error InvalidBotException(); /// @notice Thrown when attempting to set permissions for a bot that don't meet its requirements error IncorrectBotPermissionsException(); /// @notice Thrown when attempting to set non-zero permissions for too many bots error TooManyActiveBotsException(); // --------------- // // ACCOUNT FACTORY // // --------------- // /// @notice Thrown when trying to deploy second master credit account for a credit manager error MasterCreditAccountAlreadyDeployedException(); /// @notice Thrown when trying to rescue funds from a credit account that is currently in use error CreditAccountIsInUseException(); // ------------ // // PRICE ORACLE // // ------------ // /// @notice Thrown on attempting to set a token price feed to an address that is not a correct price feed error IncorrectPriceFeedException(); /// @notice Thrown on attempting to interact with a price feed for a token not added to the price oracle error PriceFeedDoesNotExistException(); /// @notice Thrown when trying to apply an on-demand price update to a non-updatable price feed error PriceFeedIsNotUpdatableException(); /// @notice Thrown when price feed returns incorrect price for a token error IncorrectPriceException(); /// @notice Thrown when token's price feed becomes stale error StalePriceException();
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ICreditManagerV3} from "../interfaces/ICreditManagerV3.sol";
import {IPoolV3} from "../interfaces/IPoolV3.sol";
interface IMarketConfigurator {
function acl() external view returns (address);
function contractsRegister() external view returns (address);
function treasury() external view returns (address);
}
/// @title Market helper library
/// @notice Helper functions to retrieve ACL, contracts register and treasury from a pool or credit manager
/// @dev Accounts for different versions of markets within the new permissionless framework
library MarketHelper {
/// @notice Retrieves the ACL address from a pool
function getACL(IPoolV3 pool) internal view returns (address) {
if (_version(pool) < 3_10) return _marketConfigurator(pool).acl();
return pool.acl();
}
/// @notice Retrieves the ACL address from a credit manager
function getACL(ICreditManagerV3 creditManager) internal view returns (address) {
return getACL(_pool(creditManager));
}
/// @notice Retrieves the contracts register address from a pool
function getContractsRegister(IPoolV3 pool) internal view returns (address) {
if (_version(pool) < 3_10) return _marketConfigurator(pool).contractsRegister();
return pool.contractsRegister();
}
/// @notice Retrieves the contracts register address from a credit manager
function getContractsRegister(ICreditManagerV3 creditManager) internal view returns (address) {
return getContractsRegister(_pool(creditManager));
}
/// @notice Retrieves the treasury address from a pool
function getTreasury(IPoolV3 pool) internal view returns (address) {
if (_version(pool) < 3_10) return _marketConfigurator(pool).treasury();
return pool.treasury();
}
/// @notice Retrieves the treasury address from a credit manager
function getTreasury(ICreditManagerV3 creditManager) internal view returns (address) {
return getTreasury(_pool(creditManager));
}
/// @dev Retrieves the version of a pool
function _version(IPoolV3 pool) private view returns (uint256) {
return pool.version();
}
/// @dev Retrieves the market configurator (owner of both new and old ACLs) of a pool
function _marketConfigurator(IPoolV3 pool) private view returns (IMarketConfigurator) {
return IMarketConfigurator(Ownable(pool.acl()).owner());
}
/// @dev Retrieves the pool credit manager is connected to
function _pool(ICreditManagerV3 creditManager) private view returns (IPoolV3) {
return IPoolV3(creditManager.pool());
}
}// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {ZeroAddressException} from "../interfaces/IExceptions.sol";
/// @title Sanity check trait
abstract contract SanityCheckTrait {
/// @dev Ensures that passed address is non-zero
modifier nonZeroAddress(address addr) {
_revertIfZeroAddress(addr);
_;
}
/// @dev Reverts if address is zero
function _revertIfZeroAddress(address addr) private pure {
if (addr == address(0)) revert ZeroAddressException();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/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.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @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].
*
* CAUTION: See Security Considerations above.
*/
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);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
/// @title Version interface
/// @notice Defines contract version and type
interface IVersion {
/// @notice Contract version
function version() external view returns (uint256);
/// @notice Contract type
function contractType() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
interface IACLTrait {
function acl() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {IVersion} from "./base/IVersion.sol";
/// @notice Debt management type
/// - `INCREASE_DEBT` borrows additional funds from the pool, updates account's debt and cumulative interest index
/// - `DECREASE_DEBT` repays debt components (quota interest and fees -> base interest and fees -> debt principal)
/// and updates all corresponding state variables (base interest index, quota interest and fees, debt).
/// When repaying all the debt, ensures that account has no enabled quotas.
enum ManageDebtAction {
INCREASE_DEBT,
DECREASE_DEBT
}
/// @notice Collateral/debt calculation mode
/// - `GENERIC_PARAMS` returns generic data like account debt and cumulative indexes
/// - `DEBT_ONLY` is same as `GENERIC_PARAMS` but includes more detailed debt info, like accrued base/quota
/// interest and fees
/// - `FULL_COLLATERAL_CHECK_LAZY` checks whether account is sufficiently collateralized in a lazy fashion,
/// i.e. it stops iterating over collateral tokens once TWV reaches the desired target.
/// Since it may return underestimated TWV, it's only available for internal use.
/// - `DEBT_COLLATERAL` is same as `DEBT_ONLY` but also returns total value and total LT-weighted value of
/// account's tokens, this mode is used during account liquidation
/// - `DEBT_COLLATERAL_SAFE_PRICES` is same as `DEBT_COLLATERAL` but uses safe prices from price oracle
enum CollateralCalcTask {
GENERIC_PARAMS,
DEBT_ONLY,
FULL_COLLATERAL_CHECK_LAZY,
DEBT_COLLATERAL,
DEBT_COLLATERAL_SAFE_PRICES
}
struct CreditAccountInfo {
uint256 debt;
uint256 cumulativeIndexLastUpdate;
uint128 cumulativeQuotaInterest;
uint128 quotaFees;
uint256 enabledTokensMask;
uint16 flags;
uint64 lastDebtUpdate;
address borrower;
}
struct CollateralDebtData {
uint256 debt;
uint256 cumulativeIndexNow;
uint256 cumulativeIndexLastUpdate;
uint128 cumulativeQuotaInterest;
uint256 accruedInterest;
uint256 accruedFees;
uint256 totalDebtUSD;
uint256 totalValue;
uint256 totalValueUSD;
uint256 twvUSD;
uint256 enabledTokensMask;
uint256 quotedTokensMask;
address[] quotedTokens;
address _poolQuotaKeeper;
}
struct CollateralTokenData {
address token;
uint16 ltInitial;
uint16 ltFinal;
uint40 timestampRampStart;
uint24 rampDuration;
}
interface ICreditManagerV3Events {
/// @notice Emitted when new credit configurator is set
event SetCreditConfigurator(address indexed newConfigurator);
}
/// @title Credit manager V3 interface
interface ICreditManagerV3 is IVersion, ICreditManagerV3Events {
function pool() external view returns (address);
function underlying() external view returns (address);
function creditFacade() external view returns (address);
function creditConfigurator() external view returns (address);
function accountFactory() external view returns (address);
function name() external view returns (string memory);
// ------------------ //
// ACCOUNT MANAGEMENT //
// ------------------ //
function openCreditAccount(address onBehalfOf) external returns (address);
function closeCreditAccount(address creditAccount) external;
function liquidateCreditAccount(
address creditAccount,
CollateralDebtData calldata collateralDebtData,
address to,
bool isExpired
) external returns (uint256 remainingFunds, uint256 loss);
function manageDebt(address creditAccount, uint256 amount, uint256 enabledTokensMask, ManageDebtAction action)
external
returns (uint256 newDebt, uint256, uint256);
function addCollateral(address payer, address creditAccount, address token, uint256 amount)
external
returns (uint256);
function withdrawCollateral(address creditAccount, address token, uint256 amount, address to)
external
returns (uint256);
function externalCall(address creditAccount, address target, bytes calldata callData)
external
returns (bytes memory result);
function approveToken(address creditAccount, address token, address spender, uint256 amount) external;
// -------- //
// ADAPTERS //
// -------- //
function adapterToContract(address adapter) external view returns (address targetContract);
function contractToAdapter(address targetContract) external view returns (address adapter);
function execute(bytes calldata data) external returns (bytes memory result);
function approveCreditAccount(address token, uint256 amount) external;
function setActiveCreditAccount(address creditAccount) external;
function getActiveCreditAccountOrRevert() external view returns (address creditAccount);
// ----------------- //
// COLLATERAL CHECKS //
// ----------------- //
function priceOracle() external view returns (address);
function fullCollateralCheck(
address creditAccount,
uint256 enabledTokensMask,
uint256[] calldata collateralHints,
uint16 minHealthFactor,
bool useSafePrices
) external returns (uint256);
function isLiquidatable(address creditAccount, uint16 minHealthFactor) external view returns (bool);
function calcDebtAndCollateral(address creditAccount, CollateralCalcTask task)
external
view
returns (CollateralDebtData memory cdd);
// ------ //
// QUOTAS //
// ------ //
function poolQuotaKeeper() external view returns (address);
function quotedTokensMask() external view returns (uint256);
function updateQuota(address creditAccount, address token, int96 quotaChange, uint96 minQuota, uint96 maxQuota)
external
returns (uint256 tokensToEnable, uint256 tokensToDisable);
// --------------------- //
// CREDIT MANAGER PARAMS //
// --------------------- //
function maxEnabledTokens() external view returns (uint8);
function fees()
external
view
returns (
uint16 feeInterest,
uint16 feeLiquidation,
uint16 liquidationDiscount,
uint16 feeLiquidationExpired,
uint16 liquidationDiscountExpired
);
function collateralTokensCount() external view returns (uint8);
function getTokenMaskOrRevert(address token) external view returns (uint256 tokenMask);
function getTokenByMask(uint256 tokenMask) external view returns (address token);
function liquidationThresholds(address token) external view returns (uint16 lt);
function ltParams(address token)
external
view
returns (uint16 ltInitial, uint16 ltFinal, uint40 timestampRampStart, uint24 rampDuration);
function collateralTokenByMask(uint256 tokenMask)
external
view
returns (address token, uint16 liquidationThreshold);
// ------------ //
// ACCOUNT INFO //
// ------------ //
function creditAccountInfo(address creditAccount)
external
view
returns (
uint256 debt,
uint256 cumulativeIndexLastUpdate,
uint128 cumulativeQuotaInterest,
uint128 quotaFees,
uint256 enabledTokensMask,
uint16 flags,
uint64 lastDebtUpdate,
address borrower
);
function getBorrowerOrRevert(address creditAccount) external view returns (address borrower);
function flagsOf(address creditAccount) external view returns (uint16);
function setFlagFor(address creditAccount, uint16 flag, bool value) external;
function enabledTokensMaskOf(address creditAccount) external view returns (uint256);
function creditAccounts() external view returns (address[] memory);
function creditAccounts(uint256 offset, uint256 limit) external view returns (address[] memory);
function creditAccountsLen() external view returns (uint256);
// ------------- //
// CONFIGURATION //
// ------------- //
function addToken(address token) external;
function setCollateralTokenData(
address token,
uint16 ltInitial,
uint16 ltFinal,
uint40 timestampRampStart,
uint24 rampDuration
) external;
function setFees(
uint16 feeInterest,
uint16 feeLiquidation,
uint16 liquidationDiscount,
uint16 feeLiquidationExpired,
uint16 liquidationDiscountExpired
) external;
function setContractAllowance(address adapter, address targetContract) external;
function setCreditFacade(address creditFacade) external;
function setPriceOracle(address priceOracle) external;
function setCreditConfigurator(address creditConfigurator) external;
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {IStateSerializer} from "./IStateSerializer.sol";
import {IVersion} from "./IVersion.sol";
/// @title Rate keeper interface
/// @notice Generic interface for a contract that can provide rates to the quota keeper
/// @dev Bots must have type `RATE_KEEPER::{POSTFIX}`
interface IRateKeeper is IVersion, IStateSerializer {
/// @notice Pool rates are provided for
function pool() external view returns (address);
/// @notice Adds token to the rate keeper
/// @dev Must add token to the quota keeper in case it's not already there
function addToken(address token) external;
/// @notice Whether token is added to the rate keeper
function isTokenAdded(address token) external view returns (bool);
/// @notice Returns quota rates for a list of tokens, must return non-zero rates for added tokens
/// and revert if some tokens are not recognized
function getRates(address[] calldata tokens) external view returns (uint16[] memory);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {IACLTrait} from "./base/IACLTrait.sol";
import {IContractsRegisterTrait} from "./base/IContractsRegisterTrait.sol";
import {IVersion} from "./base/IVersion.sol";
struct TokenQuotaParams {
uint16 rate;
uint192 cumulativeIndexLU;
uint16 quotaIncreaseFee;
uint96 totalQuoted;
uint96 limit;
}
struct AccountQuota {
uint96 quota;
uint192 cumulativeIndexLU;
}
interface IPoolQuotaKeeperV3Events {
/// @notice Emitted when account's quota for a token is updated
event UpdateQuota(address indexed creditAccount, address indexed token, int96 quotaChange);
/// @notice Emitted when token's quota rate is updated
event UpdateTokenQuotaRate(address indexed token, uint16 rate);
/// @notice Emitted when the gauge is updated
event SetGauge(address indexed newGauge);
/// @notice Emitted when a new credit manager is allowed
event AddCreditManager(address indexed creditManager);
/// @notice Emitted when a new token is added as quoted
event AddQuotaToken(address indexed token);
/// @notice Emitted when a new total quota limit is set for a token
event SetTokenLimit(address indexed token, uint96 limit);
/// @notice Emitted when a new one-time quota increase fee is set for a token
event SetQuotaIncreaseFee(address indexed token, uint16 fee);
}
/// @title Pool quota keeper V3 interface
interface IPoolQuotaKeeperV3 is IPoolQuotaKeeperV3Events, IVersion, IACLTrait, IContractsRegisterTrait {
function pool() external view returns (address);
function underlying() external view returns (address);
// ----------------- //
// QUOTAS MANAGEMENT //
// ----------------- //
function updateQuota(address creditAccount, address token, int96 requestedChange, uint96 minQuota, uint96 maxQuota)
external
returns (uint128 caQuotaInterestChange, uint128 fees, bool enableToken, bool disableToken);
function removeQuotas(address creditAccount, address[] calldata tokens, bool setLimitsToZero) external;
function accrueQuotaInterest(address creditAccount, address[] calldata tokens) external;
function getQuotaRate(address) external view returns (uint16);
function cumulativeIndex(address token) external view returns (uint192);
function isQuotedToken(address token) external view returns (bool);
function getQuota(address creditAccount, address token)
external
view
returns (uint96 quota, uint192 cumulativeIndexLU);
function getTokenQuotaParams(address token)
external
view
returns (
uint16 rate,
uint192 cumulativeIndexLU,
uint16 quotaIncreaseFee,
uint96 totalQuoted,
uint96 limit,
bool isActive
);
function getQuotaAndOutstandingInterest(address creditAccount, address token)
external
view
returns (uint96 quoted, uint128 outstandingInterest);
function poolQuotaRevenue() external view returns (uint256);
function lastQuotaRateUpdate() external view returns (uint40);
// ------------- //
// CONFIGURATION //
// ------------- //
function gauge() external view returns (address);
function setGauge(address _gauge) external;
function creditManagers() external view returns (address[] memory);
function addCreditManager(address _creditManager) external;
function quotedTokens() external view returns (address[] memory);
function addQuotaToken(address token) external;
function updateRates() external;
function setTokenLimit(address token, uint96 limit) external;
function setTokenQuotaIncreaseFee(address token, uint16 fee) external;
}// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IContractsRegister} from "../interfaces/base/IContractsRegister.sol";
import {IContractsRegisterTrait} from "../interfaces/base/IContractsRegisterTrait.sol";
import {
AddressIsNotContractException,
RegisteredCreditManagerOnlyException,
RegisteredPoolOnlyException,
ZeroAddressException
} from "../interfaces/IExceptions.sol";
/// @title Contracts register trait
/// @notice Trait that simplifies validation of pools and credit managers
abstract contract ContractsRegisterTrait is IContractsRegisterTrait {
using Address for address;
/// @notice Contracts register contract address
address public immutable override contractsRegister;
/// @dev Ensures that given address is a registered pool
modifier registeredPoolOnly(address addr) {
_ensureRegisteredPool(addr);
_;
}
/// @dev Ensures that given address is a registered credit manager
modifier registeredCreditManagerOnly(address addr) {
_ensureRegisteredCreditManager(addr);
_;
}
/// @notice Constructor
/// @param _contractsRegister Contracts register address
constructor(address _contractsRegister) {
if (_contractsRegister == address(0)) revert ZeroAddressException();
if (!_contractsRegister.isContract()) revert AddressIsNotContractException(_contractsRegister);
contractsRegister = _contractsRegister;
}
/// @dev Ensures that given address is a registered pool
function _ensureRegisteredPool(address addr) internal view {
if (!IContractsRegister(contractsRegister).isPool(addr)) revert RegisteredPoolOnlyException();
}
/// @dev Ensures that given address is a registered credit manager
function _ensureRegisteredCreditManager(address addr) internal view {
if (!IContractsRegister(contractsRegister).isCreditManager(addr)) revert RegisteredCreditManagerOnlyException();
}
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
/// @title State serializer interface
/// @notice Generic interface for a contract that can serialize its state into a bytes array
interface IStateSerializer {
/// @notice Serializes the state of the contract into a bytes array `serializedData`
function serialize() external view returns (bytes memory serializedData);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
interface IContractsRegister {
function isPool(address) external view returns (bool);
function getPools() external view returns (address[] memory);
function isCreditManager(address) external view returns (bool);
function getCreditManagers() external view returns (address[] memory);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
interface IContractsRegisterTrait {
function contractsRegister() external view returns (address);
}{
"remappings": [
"@1inch/=lib/@1inch/",
"@gearbox-protocol/=lib/@gearbox-protocol/",
"@openzeppelin/=lib/@openzeppelin/",
"@redstone-finance/=node_modules/@redstone-finance/",
"@solady/=lib/@solady/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/@openzeppelin/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin/=lib/@openzeppelin/contracts/"
],
"optimizer": {
"runs": 1000,
"enabled": true
},
"metadata": {
"bytecodeHash": "none",
"useLiteralContent": true
},
"evmVersion": "shanghai",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_pool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"AddressIsNotContractException","type":"error"},{"inputs":[],"name":"CallerNotConfiguratorException","type":"error"},{"inputs":[],"name":"CallerNotCreditManagerException","type":"error"},{"inputs":[],"name":"CallerNotGaugeException","type":"error"},{"inputs":[],"name":"IncompatibleCreditManagerException","type":"error"},{"inputs":[],"name":"IncompatibleGaugeException","type":"error"},{"inputs":[],"name":"IncorrectParameterException","type":"error"},{"inputs":[],"name":"QuotaIsOutOfBoundsException","type":"error"},{"inputs":[],"name":"RegisteredCreditManagerOnlyException","type":"error"},{"inputs":[],"name":"TokenAlreadyAddedException","type":"error"},{"inputs":[],"name":"TokenIsNotQuotedException","type":"error"},{"inputs":[],"name":"ZeroAddressException","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creditManager","type":"address"}],"name":"AddCreditManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"AddQuotaToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newGauge","type":"address"}],"name":"SetGauge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint16","name":"fee","type":"uint16"}],"name":"SetQuotaIncreaseFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint96","name":"limit","type":"uint96"}],"name":"SetTokenLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creditAccount","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"int96","name":"quotaChange","type":"int96"}],"name":"UpdateQuota","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint16","name":"rate","type":"uint16"}],"name":"UpdateTokenQuotaRate","type":"event"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"accrueQuotaInterest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acl","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creditManager","type":"address"}],"name":"addCreditManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addQuotaToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractType","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractsRegister","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creditManagers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"cumulativeIndex","outputs":[{"internalType":"uint192","name":"","type":"uint192"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getQuota","outputs":[{"internalType":"uint96","name":"quota","type":"uint96"},{"internalType":"uint192","name":"cumulativeIndexLU","type":"uint192"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getQuotaAndOutstandingInterest","outputs":[{"internalType":"uint96","name":"quoted","type":"uint96"},{"internalType":"uint128","name":"outstandingInterest","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getQuotaRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenQuotaParams","outputs":[{"internalType":"uint16","name":"rate","type":"uint16"},{"internalType":"uint192","name":"cumulativeIndexLU","type":"uint192"},{"internalType":"uint16","name":"quotaIncreaseFee","type":"uint16"},{"internalType":"uint96","name":"totalQuoted","type":"uint96"},{"internalType":"uint96","name":"limit","type":"uint96"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isQuotedToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastQuotaRateUpdate","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolQuotaRevenue","outputs":[{"internalType":"uint256","name":"quotaRevenue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quotedTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bool","name":"setLimitsToZero","type":"bool"}],"name":"removeQuotas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge","type":"address"}],"name":"setGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint96","name":"limit","type":"uint96"}],"name":"setTokenLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint16","name":"fee","type":"uint16"}],"name":"setTokenQuotaIncreaseFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"int96","name":"requestedChange","type":"int96"},{"internalType":"uint96","name":"minQuota","type":"uint96"},{"internalType":"uint96","name":"maxQuota","type":"uint96"}],"name":"updateQuota","outputs":[{"internalType":"uint128","name":"caQuotaInterestChange","type":"uint128"},{"internalType":"uint128","name":"fees","type":"uint128"},{"internalType":"bool","name":"enableToken","type":"bool"},{"internalType":"bool","name":"disableToken","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateRates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x61010060405234801562000011575f80fd5b5060405162002666380380620026668339818101604052602081101562000036575f80fd5b50516200004c6001600160a01b0382166200019e565b620000606001600160a01b03831662000264565b6001600160a01b0381166200008857604051635919af9760e11b815260040160405180910390fd5b6001600160a01b0381163b620000c15760405163df4c572d60e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6001600160a01b039081166080528116620000ef57604051635919af9760e11b815260040160405180910390fd5b6001600160a01b0381163b620001245760405163df4c572d60e01b81526001600160a01b0382166004820152602401620000b8565b6001600160a01b0390811660a052811660e0819052604080516338d52e0f60e01b815290516338d52e0f916004808201926020929091908290030181865afa15801562000173573d5f803e3d5ffd5b505050506040513d602081101562000189575f80fd5b50516001600160a01b031660c0525062000449565b5f610136620001ad83620002fe565b10156200022757620001bf8262000362565b6001600160a01b0316637a0c7b216040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001fb573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000221919062000402565b92915050565b816001600160a01b0316637a0c7b216040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001fb573d5f803e3d5ffd5b5f6101366200027383620002fe565b1015620002c157620002858262000362565b6001600160a01b031663de2873596040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001fb573d5f803e3d5ffd5b816001600160a01b031663de2873596040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001fb573d5f803e3d5ffd5b5f816001600160a01b03166354fd4d506040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200033c573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000221919062000431565b5f816001600160a01b031663de2873596040518163ffffffff1660e01b8152600401602060405180830381865afa158015620003a0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620003c6919062000402565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001fb573d5f803e3d5ffd5b5f6020828403121562000413575f80fd5b81516001600160a01b03811681146200042a575f80fd5b9392505050565b5f6020828403121562000442575f80fd5b5051919050565b60805160a05160c05160e0516121b8620004ae5f395f81816102d901528181610e2401528181610f0201528181611231015281816115d10152611b4701525f6104fa01525f81816105210152611d2601525f81816106ea0152611e5901526121b85ff3fe608060405234801561000f575f80fd5b50600436106101a5575f3560e01c80637a0c7b21116100e8578063dac5443111610093578063e26b2f631161006e578063e26b2f631461074d578063eb9860a314610772578063f3ef18131461077a578063fcde5ddc146107db575f80fd5b8063dac54431146106dd578063de287359146106e5578063e08a03db1461070c575f80fd5b8063bd42a06f116100c3578063bd42a06f1461058a578063cb2ef6f71461067d578063d9b94b06146106a4575f80fd5b80637a0c7b211461051c578063a6f19c8414610543578063b26453f614610556575f80fd5b8063364395ee1161015357806355a68ed31161012e57806355a68ed3146103ed5780635827923714610412578063604ca15f146104695780636f307dc3146104f5575f80fd5b8063364395ee146103a55780633c3821f4146103ca57806354fd4d50146103d2575f80fd5b8063112024ff11610183578063112024ff146102a257806316f0115b146102d457806326d6a2f414610317575f80fd5b8063099b9bd7146101a95780630ab3640f146101da5780630db1b8ca14610226575b5f80fd5b6101d8600480360360408110156101be575f80fd5b5080356001600160a01b0316906020013561ffff16610859565b005b61020f600480360360208110156101ef575f80fd5b50356001600160a01b03165f9081526004602052604090205461ffff1690565b6040805161ffff9092168252519081900360200190f35b6101d86004803603604081101561023b575f80fd5b6001600160a01b038235169190810190604081016020820135640100000000811115610265575f80fd5b820183602082011115610276575f80fd5b80359060200191846020830284011164010000000083111715610297575f80fd5b50909250905061095f565b6006546102ba90600160a01b900464ffffffffff1681565b6040805164ffffffffff9092168252519081900360200190f35b6102fb7f000000000000000000000000000000000000000000000000000000000000000081565b604080516001600160a01b039092168252519081900360200190f35b61037a6004803603604081101561032c575f80fd5b506001600160a01b03813581165f90815260056020908152604080832094820135909316825292909252902080546001909101546001600160601b03909116916001600160c01b0390911690565b604080516001600160601b0390931683526001600160c01b0390911660208301528051918290030190f35b6101d8600480360360208110156103ba575f80fd5b50356001600160a01b0316610a6b565b6101d8610b39565b6103db61013681565b60408051918252519081900360200190f35b6101d860048036036020811015610402575f80fd5b50356001600160a01b0316610ed9565b61041a6110cf565b6040805160208082528351818301528351919283929083019185810191028083835f5b8381101561045557818101518382015260200161043d565b505050509050019250505060405180910390f35b6104b8600480360360a081101561047e575f80fd5b506001600160a01b0381358116916020810135909116906040810135600b0b906001600160601b03606082013581169160800135166110e0565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152901515828401521515606082015290519081900360800190f35b6102fb7f000000000000000000000000000000000000000000000000000000000000000081565b6102fb7f000000000000000000000000000000000000000000000000000000000000000081565b6006546102fb906001600160a01b031681565b6101d86004803603604081101561056b575f80fd5b5080356001600160a01b031690602001356001600160601b031661116e565b61062f6004803603602081101561059f575f80fd5b50356001600160a01b03165f90815260046020908152604091829020825160a081018452815461ffff8082168084526201000083046001600160c01b0316958401869052600160d01b909204169482018590526001909201546001600160601b03808216606084018190526c01000000000000000000000000909204166080909201829052919492939285151590565b6040805161ffff97881681526001600160c01b03909616602087015293909516848401526001600160601b03918216606085015216608083015291151560a082015290519081900360c00190f35b6103db7f504f4f4c5f51554f54415f4b454550455200000000000000000000000000000081565b6106c9600480360360208110156106b9575f80fd5b50356001600160a01b0316611198565b604080519115158252519081900360200190f35b61041a6111b9565b6102fb7f000000000000000000000000000000000000000000000000000000000000000081565b61073160048036036020811015610721575f80fd5b50356001600160a01b03166111c4565b604080516001600160c01b039092168252519081900360200190f35b6101d860048036036020811015610762575f80fd5b50356001600160a01b0316611213565b6103db61134b565b6107a76004803603604081101561078f575f80fd5b506001600160a01b03813581169160200135166113f8565b604080516001600160601b0390931683526fffffffffffffffffffffffffffffffff90911660208301528051918290030190f35b6101d8600480360360608110156107f0575f80fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561081a575f80fd5b82018360208201111561082b575f80fd5b8035906020019184602083028401116401000000008311171561084c575f80fd5b9193509150351515611461565b610861611650565b61271061ffff82161115610888576040516347fbaa9760e01b815260040160405180910390fd5b6001600160a01b0382165f90815260046020526040902080546201000090046001600160c01b03166108cd57604051632fed18cf60e21b815260040160405180910390fd5b805461ffff838116600160d01b909204161461095a57805461ffff8316600160d01b81027fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117825560408051918252516001600160a01b038516917f1f985277936e1ecc9dd715575b48f1c6f18902eeb1a1b3a32779122296e64a66919081900360200190a25b505050565b610967611691565b6006548190600160a01b900464ffffffffff165f5b82811015610a63575f85858381811061099757610997611fd4565b6001600160a01b038a81165f9081526005602090815260408083209482029690960135909216808252928252848120600490925293842091945092909150806109df836116d6565b50915091508161ffff165f03610a0857604051632fed18cf60e21b815260040160405180910390fd5b610a1a81838964ffffffffff16611718565b600194850180547fffffffffffffffff000000000000000000000000000000000000000000000000166001600160c01b039290921691909117905550505091909101905061097c565b505050505050565b610a73611789565b6001600160a01b0381165f9081526003602052604090205415610ac2576040517f2e5a5c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610acd6002826117cd565b506001600160a01b0381165f8181526004602052604080822080547fffffffffffff000000000000000000000000000000000000000000000000ffff1662010000179055517f7401ff10219be3dd6d26cc491114a8ae5a0e13ac3af651aae1286afad365947d9190a250565b610b41611789565b5f610b4c60026117e1565b6006546040517f67bd79a20000000000000000000000000000000000000000000000000000000081526020600482018181528451602484015284519495505f946001600160a01b03909416936367bd79a2938793839260449092019181860191028083838b5b83811015610bca578181015183820152602001610bb2565b50505050905001925050505f60405180830381865afa158015610bef573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526020811015610c16575f80fd5b8101908080516040519392919084640100000000821115610c35575f80fd5b908301906020820185811115610c49575f80fd5b8251866020820283011164010000000082111715610c65575f80fd5b8252508151602091820192820191028083835f5b83811015610c91578181015183820152602001610c79565b5050505091909101604052505060065485519394505f93600160a01b90910464ffffffffff1692509050825b81811015610e21575f868281518110610cd857610cd8611fd4565b602002602001015190505f868381518110610cf557610cf5611fd4565b602002602001015190508061ffff165f03610d23576040516347fbaa9760e01b815260040160405180910390fd5b6001600160a01b0382165f9081526004602052604081209080610d45836116d6565b5091509150610d5581838a611718565b83547fffffffffffff000000000000000000000000000000000000000000000000000016620100006001600160c01b03929092169190910261ffff19161761ffff85169081178455600184015461271091610db8916001600160601b0316611ffc565b610dc29190612027565b610dcc908a61203a565b6040805161ffff871681529051919a506001600160a01b038716917ffb19913ea8fcd2e3d22d200707473d031876b05d1ecb42173e73292ed910ac859181900360200190a28560010195505050505050610cbd565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663275df3ad846040518263ffffffff1660e01b8152600401808281526020019150505f604051808303815f87803b158015610e85575f80fd5b505af1158015610e97573d5f803e3d5ffd5b5050600680547fffffffffffffff0000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b4264ffffffffff160217905550505050505050565b610ee1611650565b80610eeb816117ed565b6006546001600160a01b038381169116146110cb577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f66573d5f803e3d5ffd5b505050506040513d6020811015610f7b575f80fd5b50516001600160a01b031614610fbd576040517f92c025e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f610fc86002611830565b90505f5b8181101561106a576001600160a01b03841663a36532b2610fee600284611839565b6040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050602060405180830381865afa15801561102e573d5f803e3d5ffd5b505050506040513d6020811015611043575f80fd5b505161106257604051632fed18cf60e21b815260040160405180910390fd5b600101610fcc565b50600680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a6905f90a2505b5050565b60606110db60026117e1565b905090565b5f805f806110ec611691565b5f6110fa8a8a8a8a8a611844565b9398509196509094509092509050600b81900b1561116157886001600160a01b03168a6001600160a01b03167f22cce666192befd41ad1b89f8592d35a7ce7c6960853f89ada56db03bb61b096836040518082600b0b815260200191505060405180910390a35b5095509550955095915050565b611176611650565b6001600160a01b0382165f90815260046020526040902061095a818484611bd5565b6001600160a01b0381165f9081526003602052604081205415155b92915050565b60606110db5f6117e1565b6001600160a01b0381165f90815260046020526040812081806111e6836116d6565b50600654919350915061120a9082908490600160a01b900464ffffffffff16611718565b95945050505050565b61121b611650565b80611225816117ed565b8161122f81611cee565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611295573d5f803e3d5ffd5b505050506040513d60208110156112aa575f80fd5b50516001600160a01b0316146112ec576040517f2e47790c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0383165f9081526001602052604090205461095a576113125f846117cd565b506040516001600160a01b038416907fbca7ba46bb626fab79d5a673d0d8293df21968a25350c4d71433f98600618f5f905f90a2505050565b5f8061135760026117e1565b80519091505f5b818110156113f2575f83828151811061137957611379611fd4565b6020908102919091018101516001600160a01b0381165f908152600490925260408220909250906113a9826116d6565b505060018301549091506001600160601b03166127106113cd61ffff841683611ffc565b6113d79190612027565b6113e1908961203a565b97508460010194505050505061135e565b50505090565b6001600160a01b038083165f908152600560209081526040808320938516835292905290812081908161142a856111c4565b825460018401546001600160601b0390911695509091506001600160c01b0316611455858383611dc5565b93505050509250929050565b611469611691565b5f82815b818110156115c8575f86868381811061148857611488611fd4565b6001600160a01b038b81165f9081526005602090815260408083209482029690960135909216808252928252848120600490925293909320835491945091506001600160601b031680156115a857815461ffff166114f7816114f26001600160601b03851661204d565b611e03565b6115019089612067565b60018401805491995083915f906115229084906001600160601b031661208e565b82546001600160601b039182166101009390930a92830291909202199091161790555083546bffffffffffffffffffffffff191684556001600160a01b03808616908d167f22cce666192befd41ad1b89f8592d35a7ce7c6960853f89ada56db03bb61b096611590856120b5565b60408051600b9290920b8252519081900360200190a3505b87156115b9576115b982855f611bd5565b8460010194505050505061146d565b508115610a63577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d6458eea836040518263ffffffff1660e01b8152600401808281526020019150505f604051808303815f87803b158015611632575f80fd5b505af1158015611644573d5f803e3d5ffd5b50505050505050505050565b61165933611e1f565b61168f576040517f61081c1500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b335f9081526001602052604090205461168f576040517f1f51116700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805461ffff811690601081901c6001600160c01b03169060d01c5f82900361171157604051632fed18cf60e21b815260040160405180910390fd5b9193909250565b5f6301e1338061ffff841661172d84426120de565b6117456127106b033b2e3c9fd0803ce8000000612027565b6001600160c01b03166117589190611ffc565b6117629190611ffc565b61176c9190612027565b61177f906001600160c01b03861661203a565b90505b9392505050565b6006546001600160a01b0316331461168f576040517f5dd0cb2400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611782836001600160a01b038416611ec4565b60605f61178283611f10565b6001600160a01b03811661182d576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b5f6111b3825490565b5f6117828383611f69565b6001600160a01b038086165f908152600560209081526040808320938816835292815282822060049091529181208254919283928392839283929091906001600160601b0316838080611896856116d6565b9250925092508261ffff165f036118c057604051632fed18cf60e21b815260040160405180910390fd5b6006545f906118e09084908690600160a01b900464ffffffffff16611718565b60018801549091506118fe90869083906001600160c01b0316611dc5565b9b505f8f9a505f8b600b0b13156119c95760018701546001600160601b0381169060601c61192d82828f611f8f565b9c5061271061ffff168561ffff168e6001600160601b031661194f9190611ffc565b6119599190612027565b9d506119658d896120f1565b92506001600160601b03881615801561198657506001600160601b03831615155b156119905760019b505b61199a8d836120f1565b60018a0180546bffffffffffffffffffffffff19166001600160601b039290921691909117905550611a739050565b6b800000000000000000000000600b8c900b016119ec576119e9866120b5565b9a505b5f6119f68c6120b5565b9050611a02818861208e565b60018901805491935082915f90611a239084906001600160601b031661208e565b92506101000a8154816001600160601b0302191690836001600160601b03160217905550866001600160601b03165f14158015611a6757506001600160601b038216155b15611a7157600199505b505b8e6001600160601b0316816001600160601b03161080611aa457508d6001600160601b0316816001600160601b0316115b15611adb576040517fba04a99a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b87546bffffffffffffffffffffffff19166001600160601b0382161788556001880180547fffffffffffffffff000000000000000000000000000000000000000000000000166001600160c01b0384161790555f611b3d86600b8e900b611e03565b90508015611bbf577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d6458eea826040518263ffffffff1660e01b8152600401808281526020019150505f604051808303815f87803b158015611ba8575f80fd5b505af1158015611bba573d5f803e3d5ffd5b505050505b5050505050505050509550955095509550959050565b82546201000090046001600160c01b0316611c0357604051632fed18cf60e21b815260040160405180910390fd5b6b7fffffffffffffffffffffff6001600160601b0382161115611c39576040516347fbaa9760e01b815260040160405180910390fd5b60018301546001600160601b038281166c01000000000000000000000000909204161461095a576001830180546001600160601b0383166c0100000000000000000000000081027fffffffffffffffff000000000000000000000000ffffffffffffffffffffffff9092169190911790915560408051918252516001600160a01b038416917f86089ad7ab4cb6d03a20ccb3176599b628f4a4b80ceacf88369108bf10ffa1c9919081900360200190a2505050565b6040517f6fbc6f6b0000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f00000000000000000000000000000000000000000000000000000000000000001690636fbc6f6b90602401602060405180830381865afa158015611d6b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d8f9190612111565b61182d576040517fbc6a488a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6b033b2e3c9fd0803ce8000000611ddd8385612130565b611df9906001600160c01b03166001600160601b038716611ffc565b61177f9190612027565b5f612710611e1561ffff851684612150565b611782919061217f565b6040517f5f259aba0000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301525f917f000000000000000000000000000000000000000000000000000000000000000090911690635f259aba90602401602060405180830381865afa158015611ea0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b39190612111565b5f818152600183016020526040812054611f0957508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556111b3565b505f6111b3565b6060815f01805480602002602001604051908101604052809291908181526020018280548015611f5d57602002820191905f5260205f20905b815481526020019060010190808311611f49575b50505050509050919050565b5f825f018281548110611f7e57611f7e611fd4565b905f5260205f200154905092915050565b5f826001600160601b0316846001600160601b031610611fb057505f611782565b8383036001600160601b0380821690841611611fcc578261120a565b949350505050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176111b3576111b3611fe8565b634e487b7160e01b5f52601260045260245ffd5b5f8261203557612035612013565b500490565b808201808211156111b3576111b3611fe8565b5f600160ff1b820361206157612061611fe8565b505f0390565b8082018281125f83128015821682158216171561208657612086611fe8565b505092915050565b6001600160601b038281168282160390808211156120ae576120ae611fe8565b5092915050565b5f81600b0b6b7fffffffffffffffffffffff1981036120d6576120d6611fe8565b5f0392915050565b818103818111156111b3576111b3611fe8565b6001600160601b038181168382160190808211156120ae576120ae611fe8565b5f60208284031215612121575f80fd5b81518015158114611782575f80fd5b6001600160c01b038281168282160390808211156120ae576120ae611fe8565b8082025f8212600160ff1b8414161561216b5761216b611fe8565b81810583148215176111b3576111b3611fe8565b5f8261218d5761218d612013565b600160ff1b82145f19841416156121a6576121a6611fe8565b50059056fea164736f6c6343000817000a000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106101a5575f3560e01c80637a0c7b21116100e8578063dac5443111610093578063e26b2f631161006e578063e26b2f631461074d578063eb9860a314610772578063f3ef18131461077a578063fcde5ddc146107db575f80fd5b8063dac54431146106dd578063de287359146106e5578063e08a03db1461070c575f80fd5b8063bd42a06f116100c3578063bd42a06f1461058a578063cb2ef6f71461067d578063d9b94b06146106a4575f80fd5b80637a0c7b211461051c578063a6f19c8414610543578063b26453f614610556575f80fd5b8063364395ee1161015357806355a68ed31161012e57806355a68ed3146103ed5780635827923714610412578063604ca15f146104695780636f307dc3146104f5575f80fd5b8063364395ee146103a55780633c3821f4146103ca57806354fd4d50146103d2575f80fd5b8063112024ff11610183578063112024ff146102a257806316f0115b146102d457806326d6a2f414610317575f80fd5b8063099b9bd7146101a95780630ab3640f146101da5780630db1b8ca14610226575b5f80fd5b6101d8600480360360408110156101be575f80fd5b5080356001600160a01b0316906020013561ffff16610859565b005b61020f600480360360208110156101ef575f80fd5b50356001600160a01b03165f9081526004602052604090205461ffff1690565b6040805161ffff9092168252519081900360200190f35b6101d86004803603604081101561023b575f80fd5b6001600160a01b038235169190810190604081016020820135640100000000811115610265575f80fd5b820183602082011115610276575f80fd5b80359060200191846020830284011164010000000083111715610297575f80fd5b50909250905061095f565b6006546102ba90600160a01b900464ffffffffff1681565b6040805164ffffffffff9092168252519081900360200190f35b6102fb7f000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d81565b604080516001600160a01b039092168252519081900360200190f35b61037a6004803603604081101561032c575f80fd5b506001600160a01b03813581165f90815260056020908152604080832094820135909316825292909252902080546001909101546001600160601b03909116916001600160c01b0390911690565b604080516001600160601b0390931683526001600160c01b0390911660208301528051918290030190f35b6101d8600480360360208110156103ba575f80fd5b50356001600160a01b0316610a6b565b6101d8610b39565b6103db61013681565b60408051918252519081900360200190f35b6101d860048036036020811015610402575f80fd5b50356001600160a01b0316610ed9565b61041a6110cf565b6040805160208082528351818301528351919283929083019185810191028083835f5b8381101561045557818101518382015260200161043d565b505050509050019250505060405180910390f35b6104b8600480360360a081101561047e575f80fd5b506001600160a01b0381358116916020810135909116906040810135600b0b906001600160601b03606082013581169160800135166110e0565b604080516fffffffffffffffffffffffffffffffff9586168152939094166020840152901515828401521515606082015290519081900360800190f35b6102fb7f00000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a81565b6102fb7f00000000000000000000000077609fa5169d5ef611f73c00d29bf07cd42294cb81565b6006546102fb906001600160a01b031681565b6101d86004803603604081101561056b575f80fd5b5080356001600160a01b031690602001356001600160601b031661116e565b61062f6004803603602081101561059f575f80fd5b50356001600160a01b03165f90815260046020908152604091829020825160a081018452815461ffff8082168084526201000083046001600160c01b0316958401869052600160d01b909204169482018590526001909201546001600160601b03808216606084018190526c01000000000000000000000000909204166080909201829052919492939285151590565b6040805161ffff97881681526001600160c01b03909616602087015293909516848401526001600160601b03918216606085015216608083015291151560a082015290519081900360c00190f35b6103db7f504f4f4c5f51554f54415f4b454550455200000000000000000000000000000081565b6106c9600480360360208110156106b9575f80fd5b50356001600160a01b0316611198565b604080519115158252519081900360200190f35b61041a6111b9565b6102fb7f000000000000000000000000d8e38e9bad429c4ca79af585aa2580a44489718081565b61073160048036036020811015610721575f80fd5b50356001600160a01b03166111c4565b604080516001600160c01b039092168252519081900360200190f35b6101d860048036036020811015610762575f80fd5b50356001600160a01b0316611213565b6103db61134b565b6107a76004803603604081101561078f575f80fd5b506001600160a01b03813581169160200135166113f8565b604080516001600160601b0390931683526fffffffffffffffffffffffffffffffff90911660208301528051918290030190f35b6101d8600480360360608110156107f0575f80fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561081a575f80fd5b82018360208201111561082b575f80fd5b8035906020019184602083028401116401000000008311171561084c575f80fd5b9193509150351515611461565b610861611650565b61271061ffff82161115610888576040516347fbaa9760e01b815260040160405180910390fd5b6001600160a01b0382165f90815260046020526040902080546201000090046001600160c01b03166108cd57604051632fed18cf60e21b815260040160405180910390fd5b805461ffff838116600160d01b909204161461095a57805461ffff8316600160d01b81027fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117825560408051918252516001600160a01b038516917f1f985277936e1ecc9dd715575b48f1c6f18902eeb1a1b3a32779122296e64a66919081900360200190a25b505050565b610967611691565b6006548190600160a01b900464ffffffffff165f5b82811015610a63575f85858381811061099757610997611fd4565b6001600160a01b038a81165f9081526005602090815260408083209482029690960135909216808252928252848120600490925293842091945092909150806109df836116d6565b50915091508161ffff165f03610a0857604051632fed18cf60e21b815260040160405180910390fd5b610a1a81838964ffffffffff16611718565b600194850180547fffffffffffffffff000000000000000000000000000000000000000000000000166001600160c01b039290921691909117905550505091909101905061097c565b505050505050565b610a73611789565b6001600160a01b0381165f9081526003602052604090205415610ac2576040517f2e5a5c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610acd6002826117cd565b506001600160a01b0381165f8181526004602052604080822080547fffffffffffff000000000000000000000000000000000000000000000000ffff1662010000179055517f7401ff10219be3dd6d26cc491114a8ae5a0e13ac3af651aae1286afad365947d9190a250565b610b41611789565b5f610b4c60026117e1565b6006546040517f67bd79a20000000000000000000000000000000000000000000000000000000081526020600482018181528451602484015284519495505f946001600160a01b03909416936367bd79a2938793839260449092019181860191028083838b5b83811015610bca578181015183820152602001610bb2565b50505050905001925050505f60405180830381865afa158015610bef573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526020811015610c16575f80fd5b8101908080516040519392919084640100000000821115610c35575f80fd5b908301906020820185811115610c49575f80fd5b8251866020820283011164010000000082111715610c65575f80fd5b8252508151602091820192820191028083835f5b83811015610c91578181015183820152602001610c79565b5050505091909101604052505060065485519394505f93600160a01b90910464ffffffffff1692509050825b81811015610e21575f868281518110610cd857610cd8611fd4565b602002602001015190505f868381518110610cf557610cf5611fd4565b602002602001015190508061ffff165f03610d23576040516347fbaa9760e01b815260040160405180910390fd5b6001600160a01b0382165f9081526004602052604081209080610d45836116d6565b5091509150610d5581838a611718565b83547fffffffffffff000000000000000000000000000000000000000000000000000016620100006001600160c01b03929092169190910261ffff19161761ffff85169081178455600184015461271091610db8916001600160601b0316611ffc565b610dc29190612027565b610dcc908a61203a565b6040805161ffff871681529051919a506001600160a01b038716917ffb19913ea8fcd2e3d22d200707473d031876b05d1ecb42173e73292ed910ac859181900360200190a28560010195505050505050610cbd565b507f000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d6001600160a01b031663275df3ad846040518263ffffffff1660e01b8152600401808281526020019150505f604051808303815f87803b158015610e85575f80fd5b505af1158015610e97573d5f803e3d5ffd5b5050600680547fffffffffffffff0000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b4264ffffffffff160217905550505050505050565b610ee1611650565b80610eeb816117ed565b6006546001600160a01b038381169116146110cb577f000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d6001600160a01b0316826001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f66573d5f803e3d5ffd5b505050506040513d6020811015610f7b575f80fd5b50516001600160a01b031614610fbd576040517f92c025e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f610fc86002611830565b90505f5b8181101561106a576001600160a01b03841663a36532b2610fee600284611839565b6040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050602060405180830381865afa15801561102e573d5f803e3d5ffd5b505050506040513d6020811015611043575f80fd5b505161106257604051632fed18cf60e21b815260040160405180910390fd5b600101610fcc565b50600680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a6905f90a2505b5050565b60606110db60026117e1565b905090565b5f805f806110ec611691565b5f6110fa8a8a8a8a8a611844565b9398509196509094509092509050600b81900b1561116157886001600160a01b03168a6001600160a01b03167f22cce666192befd41ad1b89f8592d35a7ce7c6960853f89ada56db03bb61b096836040518082600b0b815260200191505060405180910390a35b5095509550955095915050565b611176611650565b6001600160a01b0382165f90815260046020526040902061095a818484611bd5565b6001600160a01b0381165f9081526003602052604081205415155b92915050565b60606110db5f6117e1565b6001600160a01b0381165f90815260046020526040812081806111e6836116d6565b50600654919350915061120a9082908490600160a01b900464ffffffffff16611718565b95945050505050565b61121b611650565b80611225816117ed565b8161122f81611cee565b7f000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d6001600160a01b0316836001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611295573d5f803e3d5ffd5b505050506040513d60208110156112aa575f80fd5b50516001600160a01b0316146112ec576040517f2e47790c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0383165f9081526001602052604090205461095a576113125f846117cd565b506040516001600160a01b038416907fbca7ba46bb626fab79d5a673d0d8293df21968a25350c4d71433f98600618f5f905f90a2505050565b5f8061135760026117e1565b80519091505f5b818110156113f2575f83828151811061137957611379611fd4565b6020908102919091018101516001600160a01b0381165f908152600490925260408220909250906113a9826116d6565b505060018301549091506001600160601b03166127106113cd61ffff841683611ffc565b6113d79190612027565b6113e1908961203a565b97508460010194505050505061135e565b50505090565b6001600160a01b038083165f908152600560209081526040808320938516835292905290812081908161142a856111c4565b825460018401546001600160601b0390911695509091506001600160c01b0316611455858383611dc5565b93505050509250929050565b611469611691565b5f82815b818110156115c8575f86868381811061148857611488611fd4565b6001600160a01b038b81165f9081526005602090815260408083209482029690960135909216808252928252848120600490925293909320835491945091506001600160601b031680156115a857815461ffff166114f7816114f26001600160601b03851661204d565b611e03565b6115019089612067565b60018401805491995083915f906115229084906001600160601b031661208e565b82546001600160601b039182166101009390930a92830291909202199091161790555083546bffffffffffffffffffffffff191684556001600160a01b03808616908d167f22cce666192befd41ad1b89f8592d35a7ce7c6960853f89ada56db03bb61b096611590856120b5565b60408051600b9290920b8252519081900360200190a3505b87156115b9576115b982855f611bd5565b8460010194505050505061146d565b508115610a63577f000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d6001600160a01b031663d6458eea836040518263ffffffff1660e01b8152600401808281526020019150505f604051808303815f87803b158015611632575f80fd5b505af1158015611644573d5f803e3d5ffd5b50505050505050505050565b61165933611e1f565b61168f576040517f61081c1500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b335f9081526001602052604090205461168f576040517f1f51116700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805461ffff811690601081901c6001600160c01b03169060d01c5f82900361171157604051632fed18cf60e21b815260040160405180910390fd5b9193909250565b5f6301e1338061ffff841661172d84426120de565b6117456127106b033b2e3c9fd0803ce8000000612027565b6001600160c01b03166117589190611ffc565b6117629190611ffc565b61176c9190612027565b61177f906001600160c01b03861661203a565b90505b9392505050565b6006546001600160a01b0316331461168f576040517f5dd0cb2400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f611782836001600160a01b038416611ec4565b60605f61178283611f10565b6001600160a01b03811661182d576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b5f6111b3825490565b5f6117828383611f69565b6001600160a01b038086165f908152600560209081526040808320938816835292815282822060049091529181208254919283928392839283929091906001600160601b0316838080611896856116d6565b9250925092508261ffff165f036118c057604051632fed18cf60e21b815260040160405180910390fd5b6006545f906118e09084908690600160a01b900464ffffffffff16611718565b60018801549091506118fe90869083906001600160c01b0316611dc5565b9b505f8f9a505f8b600b0b13156119c95760018701546001600160601b0381169060601c61192d82828f611f8f565b9c5061271061ffff168561ffff168e6001600160601b031661194f9190611ffc565b6119599190612027565b9d506119658d896120f1565b92506001600160601b03881615801561198657506001600160601b03831615155b156119905760019b505b61199a8d836120f1565b60018a0180546bffffffffffffffffffffffff19166001600160601b039290921691909117905550611a739050565b6b800000000000000000000000600b8c900b016119ec576119e9866120b5565b9a505b5f6119f68c6120b5565b9050611a02818861208e565b60018901805491935082915f90611a239084906001600160601b031661208e565b92506101000a8154816001600160601b0302191690836001600160601b03160217905550866001600160601b03165f14158015611a6757506001600160601b038216155b15611a7157600199505b505b8e6001600160601b0316816001600160601b03161080611aa457508d6001600160601b0316816001600160601b0316115b15611adb576040517fba04a99a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b87546bffffffffffffffffffffffff19166001600160601b0382161788556001880180547fffffffffffffffff000000000000000000000000000000000000000000000000166001600160c01b0384161790555f611b3d86600b8e900b611e03565b90508015611bbf577f000000000000000000000000c4173359087ce643235420b7bc610d9b0cf2b82d6001600160a01b031663d6458eea826040518263ffffffff1660e01b8152600401808281526020019150505f604051808303815f87803b158015611ba8575f80fd5b505af1158015611bba573d5f803e3d5ffd5b505050505b5050505050505050509550955095509550959050565b82546201000090046001600160c01b0316611c0357604051632fed18cf60e21b815260040160405180910390fd5b6b7fffffffffffffffffffffff6001600160601b0382161115611c39576040516347fbaa9760e01b815260040160405180910390fd5b60018301546001600160601b038281166c01000000000000000000000000909204161461095a576001830180546001600160601b0383166c0100000000000000000000000081027fffffffffffffffff000000000000000000000000ffffffffffffffffffffffff9092169190911790915560408051918252516001600160a01b038416917f86089ad7ab4cb6d03a20ccb3176599b628f4a4b80ceacf88369108bf10ffa1c9919081900360200190a2505050565b6040517f6fbc6f6b0000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f00000000000000000000000077609fa5169d5ef611f73c00d29bf07cd42294cb1690636fbc6f6b90602401602060405180830381865afa158015611d6b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d8f9190612111565b61182d576040517fbc6a488a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6b033b2e3c9fd0803ce8000000611ddd8385612130565b611df9906001600160c01b03166001600160601b038716611ffc565b61177f9190612027565b5f612710611e1561ffff851684612150565b611782919061217f565b6040517f5f259aba0000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301525f917f000000000000000000000000d8e38e9bad429c4ca79af585aa2580a44489718090911690635f259aba90602401602060405180830381865afa158015611ea0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b39190612111565b5f818152600183016020526040812054611f0957508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556111b3565b505f6111b3565b6060815f01805480602002602001604051908101604052809291908181526020018280548015611f5d57602002820191905f5260205f20905b815481526020019060010190808311611f49575b50505050509050919050565b5f825f018281548110611f7e57611f7e611fd4565b905f5260205f200154905092915050565b5f826001600160601b0316846001600160601b031610611fb057505f611782565b8383036001600160601b0380821690841611611fcc578261120a565b949350505050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176111b3576111b3611fe8565b634e487b7160e01b5f52601260045260245ffd5b5f8261203557612035612013565b500490565b808201808211156111b3576111b3611fe8565b5f600160ff1b820361206157612061611fe8565b505f0390565b8082018281125f83128015821682158216171561208657612086611fe8565b505092915050565b6001600160601b038281168282160390808211156120ae576120ae611fe8565b5092915050565b5f81600b0b6b7fffffffffffffffffffffff1981036120d6576120d6611fe8565b5f0392915050565b818103818111156111b3576111b3611fe8565b6001600160601b038181168382160190808211156120ae576120ae611fe8565b5f60208284031215612121575f80fd5b81518015158114611782575f80fd5b6001600160c01b038281168282160390808211156120ae576120ae611fe8565b8082025f8212600160ff1b8414161561216b5761216b611fe8565b81810583148215176111b3576111b3611fe8565b5f8261218d5761218d612013565b600160ff1b82145f19841416156121a6576121a6611fe8565b50059056fea164736f6c6343000817000a
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in MON
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.