Feature Tip: Add private address tag to any address under My Name Tag !
Contract Overview
Balance:
0 Ether
EtherValue:
$0.00
More Info
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x7eb391bab858dd17000d4843e7fc8e4f1750228327ab8d0df697425d5295cce8 | 0x60e06040 | 15840203 | 92 days 13 hrs ago | Gearbox Protocol: Deployer | IN | Contract Creation | 0 Ether | 0.00944756 |
[ Download CSV Export ]
View more zero value Internal Transactions in Advanced View mode
Similar Match Source Code
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0x824327a504fc574eC406a00eB02D9971518159cE
Contract Name:
UniversalAdapter
Compiler Version
v0.8.10+commit.fc410830
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IUniversalAdapter, RevocationPair } from "../interfaces/adapters/IUniversalAdapter.sol"; import { AdapterType } from "../interfaces/adapters/IAdapter.sol"; import { ICreditManagerV2 } from "../interfaces/ICreditManagerV2.sol"; import { ZeroAddressException } from "../interfaces/IErrors.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { UNIVERSAL_CONTRACT } from "../libraries/Constants.sol"; /// @title UniversalAdapter /// @dev Implements the initial version of universal adapter, which handles allowance revocations contract UniversalAdapter is IUniversalAdapter { /// @dev The target contract, which is always the same special address for the universal adapter address public immutable targetContract = UNIVERSAL_CONTRACT; /// @dev The credit manager this universal adapter connects to ICreditManagerV2 public immutable override creditManager; /// @dev The credit facade attached to the credit manager address public immutable override creditFacade; AdapterType public constant _gearboxAdapterType = AdapterType.UNIVERSAL; uint16 public constant _gearboxAdapterVersion = 1; /// @dev Constructor /// @param _creditManager Address of the Credit Manager constructor(address _creditManager) { if (_creditManager == address(0)) revert ZeroAddressException(); creditManager = ICreditManagerV2(_creditManager); creditFacade = ICreditManagerV2(_creditManager).creditFacade(); } /// @dev Sets allowances to zero for the provided spender/token pairs, for msg.sender's CA /// @param revocations Pairs of spenders/tokens to revoke allowances for function revokeAdapterAllowances(RevocationPair[] calldata revocations) external { address creditAccount = creditManager.getCreditAccountOrRevert( msg.sender ); _revokeAdapterAllowances(revocations, creditAccount); } /// @dev Sets allowances to zero for the provided spender/token pairs /// Checks that the msg.sender CA matches the expected account, since the /// Provided revocations can be specific to a particular CA /// @param revocations Pairs of spenders/tokens to revoke allowances for /// @param expectedCreditAccount Credit account that msg.sender is expected to have function revokeAdapterAllowances( RevocationPair[] calldata revocations, address expectedCreditAccount ) external { address creditAccount = creditManager.getCreditAccountOrRevert( msg.sender ); if (creditAccount != expectedCreditAccount) { revert UnexpectedCreditAccountException( expectedCreditAccount, creditAccount ); } _revokeAdapterAllowances(revocations, creditAccount); } /// @dev Internal implementation for allowance revocations /// Checks that there are no zero addresses in a pair and sets allowance to 1 /// through CreditManager.approveCreditAccount /// @param revocations Pairs of spenders/tokens to revoke allowances for /// @param creditAccount Credit account to revoke allowances for function _revokeAdapterAllowances( RevocationPair[] calldata revocations, address creditAccount ) internal { uint256 numRevocations = revocations.length; for (uint256 i; i < numRevocations; ) { address spender = revocations[i].spender; address token = revocations[i].token; if (spender == address(0) || token == address(0)) { revert ZeroAddressException(); } uint256 allowance = IERC20(token).allowance(creditAccount, spender); if (allowance > 1) { creditManager.approveCreditAccount( msg.sender, spender, token, 1 ); } unchecked { ++i; } } } /// @notice For demonstration purposes only. Not in V2 launch scope /// // function withdraw(address token, uint256 amount) external { // address creditAccount = creditManager.getCreditAccountOrRevert( // msg.sender // ); // if (creditManager.tokenMasksMap(token) == 0) // revert("Token contract is not allowed"); // creditManager.executeOrder( // msg.sender, // token, // abi.encodeWithSelector(IERC20.transfer.selector, msg.sender, amount) // ); // creditManager.fullCollateralCheck(creditAccount); // } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IAdapter } from "./IAdapter.sol"; struct RevocationPair { address spender; address token; } interface IUniversalAdapterExceptions { /// @dev Thrown when the Credit Account of msg.sender does not match the provided expected account error UnexpectedCreditAccountException(address expected, address actual); } interface IUniversalAdapter is IAdapter, IUniversalAdapterExceptions { /// @dev Sets allowances to zero for provided spender/token pairs, for msg.sender's CA /// @param revocations Pairs of spenders/tokens to revoke allowances for function revokeAdapterAllowances(RevocationPair[] calldata revocations) external; /// @dev Sets allowances to zero for the provided spender/token pairs /// Checks that the msg.sender CA matches the expected account, since /// provided revocations are specific to a particular CA /// @param revocations Pairs of spenders/tokens to revoke allowances for /// @param expectedCreditAccount Credit account that msg.sender is expected to have function revokeAdapterAllowances( RevocationPair[] calldata revocations, address expectedCreditAccount ) external; }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { ICreditManagerV2 } from "../ICreditManagerV2.sol"; enum AdapterType { ABSTRACT, UNISWAP_V2_ROUTER, UNISWAP_V3_ROUTER, CURVE_V1_EXCHANGE_ONLY, YEARN_V2, CURVE_V1_2ASSETS, CURVE_V1_3ASSETS, CURVE_V1_4ASSETS, CURVE_V1_STECRV_POOL, CURVE_V1_WRAPPER, CONVEX_V1_BASE_REWARD_POOL, CONVEX_V1_BOOSTER, CONVEX_V1_CLAIM_ZAP, LIDO_V1, UNIVERSAL, LIDO_WSTETH_V1 } interface IAdapterExceptions { /// @dev Thrown when the adapter attempts to use a token /// that is not recognized as collateral in the connected /// Credit Manager error TokenIsNotInAllowedList(address); } interface IAdapter is IAdapterExceptions { /// @dev Returns the Credit Manager connected to the adapter function creditManager() external view returns (ICreditManagerV2); /// @dev Returns the Credit Facade connected to the adapter's Credit Manager function creditFacade() external view returns (address); /// @dev Returns the address of the contract the adapter is interacting with function targetContract() external view returns (address); /// @dev Returns the adapter type function _gearboxAdapterType() external pure returns (AdapterType); /// @dev Returns the adapter version function _gearboxAdapterVersion() external pure returns (uint16); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; /// @dev Common contract exceptions /// @dev Thrown on attempting to set an important address to zero address error ZeroAddressException(); /// @dev Thrown on attempting to call a non-implemented function error NotImplementedException(); /// @dev Thrown on attempting to set an EOA as an important contract in the system error AddressIsNotContractException(address); /// @dev Thrown on attempting to use a non-ERC20 contract or an EOA as a token error IncorrectTokenContractException(); /// @dev Thrown on attempting to set a token price feed to an address that is not a /// correct price feed error IncorrectPriceFeedException(); /// @dev Thrown on attempting to call an access restricted function as a non-Configurator error CallerNotConfiguratorException(); /// @dev Thrown on attempting to pause a contract as a non-Pausable admin error CallerNotPausableAdminException(); /// @dev Thrown on attempting to pause a contract as a non-Unpausable admin error CallerNotUnPausableAdminException(); error TokenIsNotAddedToCreditManagerException(address token);
// SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; // Denominations uint256 constant WAD = 1e18; uint256 constant RAY = 1e27; // 25% of type(uint256).max uint256 constant ALLOWANCE_THRESHOLD = type(uint96).max >> 3; // FEE = 50% uint16 constant DEFAULT_FEE_INTEREST = 50_00; // 50% // LIQUIDATION_FEE 1.5% uint16 constant DEFAULT_FEE_LIQUIDATION = 1_50; // 1.5% // LIQUIDATION PREMIUM 4% uint16 constant DEFAULT_LIQUIDATION_PREMIUM = 4_00; // 4% // LIQUIDATION_FEE_EXPIRED 2% uint16 constant DEFAULT_FEE_LIQUIDATION_EXPIRED = 1_00; // 2% // LIQUIDATION PREMIUM EXPIRED 2% uint16 constant DEFAULT_LIQUIDATION_PREMIUM_EXPIRED = 2_00; // 2% // DEFAULT PROPORTION OF MAX BORROWED PER BLOCK TO MAX BORROWED PER ACCOUNT uint16 constant DEFAULT_LIMIT_PER_BLOCK_MULTIPLIER = 2; // Seconds in a year uint256 constant SECONDS_PER_YEAR = 365 days; uint256 constant SECONDS_PER_ONE_AND_HALF_YEAR = (SECONDS_PER_YEAR * 3) / 2; // OPERATIONS // Leverage decimals - 100 is equal to 2x leverage (100% * collateral amount + 100% * borrowed amount) uint8 constant LEVERAGE_DECIMALS = 100; // Maximum withdraw fee for pool in PERCENTAGE_FACTOR format uint8 constant MAX_WITHDRAW_FEE = 100; uint256 constant EXACT_INPUT = 1; uint256 constant EXACT_OUTPUT = 2; address constant UNIVERSAL_CONTRACT = 0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC;
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IPriceOracleV2 } from "./IPriceOracle.sol"; import { IVersion } from "./IVersion.sol"; enum ClosureAction { CLOSE_ACCOUNT, LIQUIDATE_ACCOUNT, LIQUIDATE_EXPIRED_ACCOUNT, LIQUIDATE_PAUSED } interface ICreditManagerV2Events { /// @dev Emits when a call to an external contract is made through the Credit Manager event ExecuteOrder(address indexed borrower, address indexed target); /// @dev Emits when a configurator is upgraded event NewConfigurator(address indexed newConfigurator); } interface ICreditManagerV2Exceptions { /// @dev Thrown if an access-restricted function is called by an address that is not /// the connected Credit Facade, or an allowed adapter error AdaptersOrCreditFacadeOnlyException(); /// @dev Thrown if an access-restricted function is called by an address that is not /// the connected Credit Facade error CreditFacadeOnlyException(); /// @dev Thrown if an access-restricted function is called by an address that is not /// the connected Credit Configurator error CreditConfiguratorOnlyException(); /// @dev Thrown on attempting to open a Credit Account for or transfer a Credit Account /// to the zero address or an address that already owns a Credit Account error ZeroAddressOrUserAlreadyHasAccountException(); /// @dev Thrown on attempting to execute an order to an address that is not an allowed /// target contract error TargetContractNotAllowedException(); /// @dev Thrown on failing a full collateral check after an operation error NotEnoughCollateralException(); /// @dev Thrown on attempting to receive a token that is not a collateral token /// or was forbidden error TokenNotAllowedException(); /// @dev Thrown if an attempt to approve a collateral token to a target contract failed error AllowanceFailedException(); /// @dev Thrown on attempting to perform an action for an address that owns no Credit Account error HasNoOpenedAccountException(); /// @dev Thrown on attempting to add a token that is already in a collateral list error TokenAlreadyAddedException(); /// @dev Thrown on configurator attempting to add more than 256 collateral tokens error TooManyTokensException(); /// @dev Thrown if more than the maximal number of tokens were enabled on a Credit Account, /// and there are not enough unused token to disable error TooManyEnabledTokensException(); /// @dev Thrown when a reentrancy into the contract is attempted error ReentrancyLockException(); } /// @notice All Credit Manager functions are access-restricted and can only be called /// by the Credit Facade or allowed adapters. Users are not allowed to /// interact with the Credit Manager directly interface ICreditManagerV2 is ICreditManagerV2Events, ICreditManagerV2Exceptions, IVersion { // // CREDIT ACCOUNT MANAGEMENT // /// @dev Opens credit account and borrows funds from the pool. /// - Takes Credit Account from the factory; /// - Requests the pool to lend underlying to the Credit Account /// /// @param borrowedAmount Amount to be borrowed by the Credit Account /// @param onBehalfOf The owner of the newly opened Credit Account function openCreditAccount(uint256 borrowedAmount, address onBehalfOf) external returns (address); /// @dev Closes a Credit Account - covers both normal closure and liquidation /// - Checks whether the contract is paused, and, if so, if the payer is an emergency liquidator. /// Only emergency liquidators are able to liquidate account while the CM is paused. /// Emergency liquidations do not pay a liquidator premium or liquidation fees. /// - Calculates payments to various recipients on closure: /// + Computes amountToPool, which is the amount to be sent back to the pool. /// This includes the principal, interest and fees, but can't be more than /// total position value /// + Computes remainingFunds during liquidations - these are leftover funds /// after paying the pool and the liquidator, and are sent to the borrower /// + Computes protocol profit, which includes interest and liquidation fees /// + Computes loss if the totalValue is less than borrow amount + interest /// - Checks the underlying token balance: /// + if it is larger than amountToPool, then the pool is paid fully from funds on the Credit Account /// + else tries to transfer the shortfall from the payer - either the borrower during closure, or liquidator during liquidation /// - Send assets to the "to" address, as long as they are not included into skipTokenMask /// - If convertWETH is true, the function converts WETH into ETH before sending /// - Returns the Credit Account back to factory /// /// @param borrower Borrower address /// @param closureActionType Whether the account is closed, liquidated or liquidated due to expiry /// @param totalValue Portfolio value for liqution, 0 for ordinary closure /// @param payer Address which would be charged if credit account has not enough funds to cover amountToPool /// @param to Address to which the leftover funds will be sent /// @param skipTokenMask Tokenmask contains 1 for tokens which needed to be skipped for sending /// @param convertWETH If true converts WETH to ETH function closeCreditAccount( address borrower, ClosureAction closureActionType, uint256 totalValue, address payer, address to, uint256 skipTokenMask, bool convertWETH ) external returns (uint256 remainingFunds); /// @dev Manages debt size for borrower: /// /// - Increase debt: /// + Increases debt by transferring funds from the pool to the credit account /// + Updates the cumulative index to keep interest the same. Since interest /// is always computed dynamically as borrowedAmount * (cumulativeIndexNew / cumulativeIndexOpen - 1), /// cumulativeIndexOpen needs to be updated, as the borrow amount has changed /// /// - Decrease debt: /// + Repays debt partially + all interest and fees accrued thus far /// + Updates cunulativeIndex to cumulativeIndex now /// /// @param creditAccount Address of the Credit Account to change debt for /// @param amount Amount to increase / decrease the principal by /// @param increase True to increase principal, false to decrease /// @return newBorrowedAmount The new debt principal function manageDebt( address creditAccount, uint256 amount, bool increase ) external returns (uint256 newBorrowedAmount); /// @dev Adds collateral to borrower's credit account /// @param payer Address of the account which will be charged to provide additional collateral /// @param creditAccount Address of the Credit Account /// @param token Collateral token to add /// @param amount Amount to add function addCollateral( address payer, address creditAccount, address token, uint256 amount ) external; /// @dev Transfers Credit Account ownership to another address /// @param from Address of previous owner /// @param to Address of new owner function transferAccountOwnership(address from, address to) external; /// @dev Requests the Credit Account to approve a collateral token to another contract. /// @param borrower Borrower's address /// @param targetContract Spender to change allowance for /// @param token Collateral token to approve /// @param amount New allowance amount function approveCreditAccount( address borrower, address targetContract, address token, uint256 amount ) external; /// @dev Requests a Credit Account to make a low-level call with provided data /// This is the intended pathway for state-changing interactions with 3rd-party protocols /// @param borrower Borrower's address /// @param targetContract Contract to be called /// @param data Data to pass with the call function executeOrder( address borrower, address targetContract, bytes memory data ) external returns (bytes memory); // // COLLATERAL VALIDITY AND ACCOUNT HEALTH CHECKS // /// @dev Enables a token on a Credit Account, including it /// into account health and total value calculations /// @param creditAccount Address of a Credit Account to enable the token for /// @param token Address of the token to be enabled function checkAndEnableToken(address creditAccount, address token) external; /// @dev Optimized health check for individual swap-like operations. /// @notice Fast health check assumes that only two tokens (input and output) /// participate in the operation and computes a % change in weighted value between /// inbound and outbound collateral. The cumulative negative change across several /// swaps in sequence cannot be larger than feeLiquidation (a fee that the /// protocol is ready to waive if needed). Since this records a % change /// between just two tokens, the corresponding % change in TWV will always be smaller, /// which makes this check safe. /// More details at https://dev.gearbox.fi/docs/documentation/risk/fast-collateral-check#fast-check-protection /// @param creditAccount Address of the Credit Account /// @param tokenIn Address of the token spent by the swap /// @param tokenOut Address of the token received from the swap /// @param balanceInBefore Balance of tokenIn before the operation /// @param balanceOutBefore Balance of tokenOut before the operation function fastCollateralCheck( address creditAccount, address tokenIn, address tokenOut, uint256 balanceInBefore, uint256 balanceOutBefore ) external; /// @dev Performs a full health check on an account, summing up /// value of all enabled collateral tokens /// @param creditAccount Address of the Credit Account to check function fullCollateralCheck(address creditAccount) external; /// @dev Checks that the number of enabled tokens on a Credit Account /// does not violate the maximal enabled token limit and tries /// to disable unused tokens if it does /// @param creditAccount Account to check enabled tokens for function checkAndOptimizeEnabledTokens(address creditAccount) external; /// @dev Disables a token on a credit account /// @notice Usually called by adapters to disable spent tokens during a multicall, /// but can also be called separately from the Credit Facade to remove /// unwanted tokens /// @return True if token mask was change otherwise False function disableToken(address creditAccount, address token) external returns (bool); // // GETTERS // /// @dev Returns the address of a borrower's Credit Account, or reverts if there is none. /// @param borrower Borrower's address function getCreditAccountOrRevert(address borrower) external view returns (address); /// @dev Computes amounts that must be sent to various addresses before closing an account /// @param totalValue Credit Accounts total value in underlying /// @param closureActionType Type of account closure /// * CLOSE_ACCOUNT: The account is healthy and is closed normally /// * LIQUIDATE_ACCOUNT: The account is unhealthy and is being liquidated to avoid bad debt /// * LIQUIDATE_EXPIRED_ACCOUNT: The account has expired and is being liquidated (lowered liquidation premium) /// * LIQUIDATE_PAUSED: The account is liquidated while the system is paused due to emergency (no liquidation premium) /// @param borrowedAmount Credit Account's debt principal /// @param borrowedAmountWithInterest Credit Account's debt principal + interest /// @return amountToPool Amount of underlying to be sent to the pool /// @return remainingFunds Amount of underlying to be sent to the borrower (only applicable to liquidations) /// @return profit Protocol's profit from fees (if any) /// @return loss Protocol's loss from bad debt (if any) function calcClosePayments( uint256 totalValue, ClosureAction closureActionType, uint256 borrowedAmount, uint256 borrowedAmountWithInterest ) external view returns ( uint256 amountToPool, uint256 remainingFunds, uint256 profit, uint256 loss ); /// @dev Calculates the debt accrued by a Credit Account /// @param creditAccount Address of the Credit Account /// @return borrowedAmount The debt principal /// @return borrowedAmountWithInterest The debt principal + accrued interest /// @return borrowedAmountWithInterestAndFees The debt principal + accrued interest and protocol fees function calcCreditAccountAccruedInterest(address creditAccount) external view returns ( uint256 borrowedAmount, uint256 borrowedAmountWithInterest, uint256 borrowedAmountWithInterestAndFees ); /// @dev Maps Credit Accounts to bit masks encoding their enabled token sets /// Only enabled tokens are counted as collateral for the Credit Account /// @notice An enabled token mask encodes an enabled token by setting /// the bit at the position equal to token's index to 1 function enabledTokensMap(address creditAccount) external view returns (uint256); /// @dev Maps the Credit Account to its current percentage drop across all swaps since /// the last full check, in RAY format function cumulativeDropAtFastCheckRAY(address creditAccount) external view returns (uint256); /// @dev Returns the collateral token at requested index and its liquidation threshold /// @param id The index of token to return function collateralTokens(uint256 id) external view returns (address token, uint16 liquidationThreshold); /// @dev Returns the collateral token with requested mask and its liquidationThreshold /// @param tokenMask Token mask corresponding to the token function collateralTokensByMask(uint256 tokenMask) external view returns (address token, uint16 liquidationThreshold); /// @dev Total number of known collateral tokens. function collateralTokensCount() external view returns (uint256); /// @dev Returns the mask for the provided token /// @param token Token to returns the mask for function tokenMasksMap(address token) external view returns (uint256); /// @dev Bit mask encoding a set of forbidden tokens function forbiddenTokenMask() external view returns (uint256); /// @dev Maps allowed adapters to their respective target contracts. function adapterToContract(address adapter) external view returns (address); /// @dev Maps 3rd party contracts to their respective adapters function contractToAdapter(address targetContract) external view returns (address); /// @dev Address of the underlying asset function underlying() external view returns (address); /// @dev Address of the connected pool function pool() external view returns (address); /// @dev Address of the connected pool /// @notice [DEPRECATED]: use pool() instead. function poolService() external view returns (address); /// @dev A map from borrower addresses to Credit Account addresses function creditAccounts(address borrower) external view returns (address); /// @dev Address of the connected Credit Configurator function creditConfigurator() external view returns (address); /// @dev Address of WETH function wethAddress() external view returns (address); /// @dev Returns the liquidation threshold for the provided token /// @param token Token to retrieve the LT for function liquidationThresholds(address token) external view returns (uint16); /// @dev The maximal number of enabled tokens on a single Credit Account function maxAllowedEnabledTokenLength() external view returns (uint8); /// @dev Maps addresses to their status as emergency liquidator. /// @notice Emergency liquidators are trusted addresses /// that are able to liquidate positions while the contracts are paused, /// e.g. when there is a risk of bad debt while an exploit is being patched. /// In the interest of fairness, emergency liquidators do not receive a premium /// And are compensated by the Gearbox DAO separately. function canLiquidateWhilePaused(address) external view returns (bool); /// @dev Returns the fee parameters of the Credit Manager /// @return feeInterest Percentage of interest taken by the protocol as profit /// @return feeLiquidation Percentage of account value taken by the protocol as profit /// during unhealthy account liquidations /// @return liquidationDiscount Multiplier that reduces the effective totalValue during unhealthy account liquidations, /// allowing the liquidator to take the unaccounted for remainder as premium. Equal to (1 - liquidationPremium) /// @return feeLiquidationExpired Percentage of account value taken by the protocol as profit /// during expired account liquidations /// @return liquidationDiscountExpired Multiplier that reduces the effective totalValue during expired account liquidations, /// allowing the liquidator to take the unaccounted for remainder as premium. Equal to (1 - liquidationPremiumExpired) function fees() external view returns ( uint16 feeInterest, uint16 feeLiquidation, uint16 liquidationDiscount, uint16 feeLiquidationExpired, uint16 liquidationDiscountExpired ); /// @dev Address of the connected Credit Facade function creditFacade() external view returns (address); /// @dev Address of the connected Price Oracle function priceOracle() external view returns (IPriceOracleV2); /// @dev Address of the universal adapter function universalAdapter() external view returns (address); /// @dev Contract's version function version() external view returns (uint256); /// @dev Paused() state function checkEmergencyPausable(address caller, bool state) external returns (bool); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IPriceOracleV2Events { /// @dev Emits when a new price feed is added event NewPriceFeed(address indexed token, address indexed priceFeed); } interface IPriceOracleV2Exceptions { /// @dev Thrown if a price feed returns 0 error ZeroPriceException(); /// @dev Thrown if the last recorded result was not updated in the last round error ChainPriceStaleException(); /// @dev Thrown on attempting to get a result for a token that does not have a price feed error PriceOracleNotExistsException(); } /// @title Price oracle interface interface IPriceOracleV2 is IPriceOracleV2Events, IPriceOracleV2Exceptions, IVersion { /// @dev Converts a quantity of an asset to USD (decimals = 8). /// @param amount Amount to convert /// @param token Address of the token to be converted function convertToUSD(uint256 amount, address token) external view returns (uint256); /// @dev Converts a quantity of USD (decimals = 8) to an equivalent amount of an asset /// @param amount Amount to convert /// @param token Address of the token converted to function convertFromUSD(uint256 amount, address token) external view returns (uint256); /// @dev Converts one asset into another /// /// @param amount Amount to convert /// @param tokenFrom Address of the token to convert from /// @param tokenTo Address of the token to convert to function convert( uint256 amount, address tokenFrom, address tokenTo ) external view returns (uint256); /// @dev Returns collateral values for two tokens, required for a fast check /// @param amountFrom Amount of the outbound token /// @param tokenFrom Address of the outbound token /// @param amountTo Amount of the inbound token /// @param tokenTo Address of the inbound token /// @return collateralFrom Value of the outbound token amount in USD /// @return collateralTo Value of the inbound token amount in USD function fastCheck( uint256 amountFrom, address tokenFrom, uint256 amountTo, address tokenTo ) external view returns (uint256 collateralFrom, uint256 collateralTo); /// @dev Returns token's price in USD (8 decimals) /// @param token The token to compute the price for function getPrice(address token) external view returns (uint256); /// @dev Returns the price feed address for the passed token /// @param token Token to get the price feed for function priceFeeds(address token) external view returns (address priceFeed); /// @dev Returns the price feed for the passed token, /// with additional parameters /// @param token Token to get the price feed for function priceFeedsWithFlags(address token) external view returns ( address priceFeed, bool skipCheck, uint256 decimals ); } interface IPriceOracleV2Ext is IPriceOracleV2 { /// @dev Sets a price feed if it doesn't exist, or updates an existing one /// @param token Address of the token to set the price feed for /// @param priceFeed Address of a USD price feed adhering to Chainlink's interface function addPriceFeed(address token, address priceFeed) external; }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; /// @title IVersion /// @dev Declares a version function which returns the contract's version interface IVersion { /// @dev Returns contract version function version() external view returns (uint256); }
{ "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_creditManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"TokenIsNotInAllowedList","type":"error"},{"inputs":[{"internalType":"address","name":"expected","type":"address"},{"internalType":"address","name":"actual","type":"address"}],"name":"UnexpectedCreditAccountException","type":"error"},{"inputs":[],"name":"ZeroAddressException","type":"error"},{"inputs":[],"name":"_gearboxAdapterType","outputs":[{"internalType":"enum AdapterType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_gearboxAdapterVersion","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creditFacade","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creditManager","outputs":[{"internalType":"contract ICreditManagerV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct RevocationPair[]","name":"revocations","type":"tuple[]"}],"name":"revokeAdapterAllowances","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct RevocationPair[]","name":"revocations","type":"tuple[]"},{"internalType":"address","name":"expectedCreditAccount","type":"address"}],"name":"revokeAdapterAllowances","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"targetContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e060405273cccccccccccccccccccccccccccccccccccccccc60805234801561002857600080fd5b5060405161093b38038061093b833981016040819052610047916100ee565b6001600160a01b03811661006e57604051635919af9760e11b815260040160405180910390fd5b6001600160a01b03811660a081905260408051632f7a188160e01b81529051632f7a1881916004808201926020929091908290030181865afa1580156100b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100dc91906100ee565b6001600160a01b031660c0525061011e565b60006020828403121561010057600080fd5b81516001600160a01b038116811461011757600080fd5b9392505050565b60805160a05160c0516107da6101616000396000608701526000818161012f015281816101aa0152818161026d015261055e0152600061010801526107da6000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063bd90df701161005b578063bd90df7014610103578063c12c21c01461012a578063ce30bbdb14610151578063e6d6b1531461016657600080fd5b80632f7a188114610082578063565a820d146100d357806378aa73a4146100e8575b600080fd5b6100a97f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100e66100e136600461061c565b610179565b005b6100f0600181565b60405161ffff90911681526020016100ca565b6100a97f000000000000000000000000000000000000000000000000000000000000000081565b6100a97f000000000000000000000000000000000000000000000000000000000000000081565b610159600e81565b6040516100ca919061065e565b6100e66101743660046106c4565b61023c565b6040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610206573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022a919061071b565b9050610237838383610389565b505050565b6040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa1580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed919061071b565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610378576040517f4050c5c000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80841660048301528216602482015260440160405180910390fd5b610383848483610389565b50505050565b8160005b818110156105c95760008585838181106103a9576103a961073f565b6103bf926020604090920201908101915061076e565b905060008686848181106103d5576103d561073f565b90506040020160200160208101906103ed919061076e565b905073ffffffffffffffffffffffffffffffffffffffff82161580610426575073ffffffffffffffffffffffffffffffffffffffff8116155b1561045d576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015283811660248301526000919083169063dd62ed3e90604401602060405180830381865afa1580156104d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f9919061078b565b905060018111156105bb576040517f46fb371d00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152600160648301527f000000000000000000000000000000000000000000000000000000000000000016906346fb371d90608401600060405180830381600087803b1580156105a257600080fd5b505af11580156105b6573d6000803e3d6000fd5b505050505b83600101935050505061038d565b5050505050565b60008083601f8401126105e257600080fd5b50813567ffffffffffffffff8111156105fa57600080fd5b6020830191508360208260061b850101111561061557600080fd5b9250929050565b6000806020838503121561062f57600080fd5b823567ffffffffffffffff81111561064657600080fd5b610652858286016105d0565b90969095509350505050565b6020810160108310610699577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b91905290565b73ffffffffffffffffffffffffffffffffffffffff811681146106c157600080fd5b50565b6000806000604084860312156106d957600080fd5b833567ffffffffffffffff8111156106f057600080fd5b6106fc868287016105d0565b90945092505060208401356107108161069f565b809150509250925092565b60006020828403121561072d57600080fd5b81516107388161069f565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561078057600080fd5b81356107388161069f565b60006020828403121561079d57600080fd5b505191905056fea2646970667358221220402b0a1f95cfb556799347c7988cb3210f85e46c52761b43a778a9ef6f27d1e764736f6c634300080a0033000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.
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.