Source Code
Latest 25 from a total of 69 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Close Credit Acc... | 17573088 | 1009 days ago | IN | 0 ETH | 0.00093441 | ||||
| Close Credit Acc... | 17573088 | 1009 days ago | IN | 0 ETH | 0.03348073 | ||||
| Multicall | 17573084 | 1009 days ago | IN | 0 ETH | 0.0060977 | ||||
| Multicall | 17573083 | 1009 days ago | IN | 0 ETH | 0.00772688 | ||||
| Close Credit Acc... | 17511979 | 1018 days ago | IN | 0 ETH | 0.02340133 | ||||
| Multicall | 17511971 | 1018 days ago | IN | 0 ETH | 0.00713389 | ||||
| Close Credit Acc... | 17507845 | 1018 days ago | IN | 0 ETH | 0.00373017 | ||||
| Multicall | 17507840 | 1018 days ago | IN | 0 ETH | 0.01415834 | ||||
| Close Credit Acc... | 17343965 | 1041 days ago | IN | 0 ETH | 0.01024011 | ||||
| Multicall | 17343962 | 1041 days ago | IN | 0 ETH | 0.02012367 | ||||
| Multicall | 17343955 | 1041 days ago | IN | 0 ETH | 0.01653863 | ||||
| Multicall | 17343953 | 1041 days ago | IN | 0 ETH | 0.02087771 | ||||
| Multicall | 17343950 | 1041 days ago | IN | 0 ETH | 0.01826731 | ||||
| Multicall | 17343945 | 1041 days ago | IN | 0 ETH | 0.02147395 | ||||
| Multicall | 17343944 | 1041 days ago | IN | 0 ETH | 0.05325348 | ||||
| Multicall | 17260129 | 1053 days ago | IN | 0 ETH | 0.06155039 | ||||
| Multicall | 17260124 | 1053 days ago | IN | 0 ETH | 0.01777307 | ||||
| Multicall | 17260082 | 1053 days ago | IN | 0 ETH | 0.02021313 | ||||
| Multicall | 17260071 | 1053 days ago | IN | 0 ETH | 0.03733242 | ||||
| Multicall | 17260022 | 1053 days ago | IN | 0 ETH | 0.03176597 | ||||
| Multicall | 17260017 | 1053 days ago | IN | 0 ETH | 0.02114251 | ||||
| Multicall | 17260007 | 1053 days ago | IN | 0 ETH | 0.022541 | ||||
| Multicall | 17260003 | 1053 days ago | IN | 0 ETH | 0.04194574 | ||||
| Multicall | 17260000 | 1053 days ago | IN | 0 ETH | 0.01806912 | ||||
| Multicall | 17144503 | 1069 days ago | IN | 0 ETH | 0.02160508 |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
CreditFacade
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 { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
// DATA
import { MultiCall } from "../libraries/MultiCall.sol";
import { Balance, BalanceOps } from "../libraries/Balances.sol";
/// INTERFACES
import { ICreditFacade, ICreditFacadeExtended } from "../interfaces/ICreditFacade.sol";
import { ICreditManagerV2, ClosureAction } from "../interfaces/ICreditManagerV2.sol";
import { IPriceOracleV2 } from "../interfaces/IPriceOracle.sol";
import { IDegenNFT } from "../interfaces/IDegenNFT.sol";
import { IWETH } from "../interfaces/external/IWETH.sol";
// CONSTANTS
import { LEVERAGE_DECIMALS } from "../libraries/Constants.sol";
import { PERCENTAGE_FACTOR } from "../libraries/PercentageMath.sol";
// EXCEPTIONS
import { ZeroAddressException } from "../interfaces/IErrors.sol";
struct Params {
/// @dev Maximal amount of new debt that can be taken per block
uint128 maxBorrowedAmountPerBlock;
/// @dev True if increasing debt is forbidden
bool isIncreaseDebtForbidden;
/// @dev Timestamp of the next expiration (for expirable Credit Facades only)
uint40 expirationDate;
}
struct Limits {
/// @dev Minimal borrowed amount per credit account
uint128 minBorrowedAmount;
/// @dev Maximum aborrowed amount per credit account
uint128 maxBorrowedAmount;
}
/// @title CreditFacade
/// @notice User interface for interacting with Credit Manager.
/// @dev CreditFacade provides an interface between the user and the Credit Manager. Direct interactions
/// with the Credit Manager are forbidden. There are two ways the Credit Manager can be interacted with:
/// - Through CreditFacade, which provides all the required account management function: open / close / liquidate / manageDebt,
/// as well as Multicalls that allow to perform multiple actions within a single transaction, with a single health check
/// - Through adapters, which call the Credit Manager directly, but only allow interactions with specific target contracts
contract CreditFacade is ICreditFacade, ReentrancyGuard {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
/// @dev Credit Manager connected to this Credit Facade
ICreditManagerV2 public immutable creditManager;
/// @dev Whether the whitelisted mode is active
bool public immutable whitelisted;
/// @dev Whether the Credit Facade implements expirable logic
bool public immutable expirable;
/// @dev Keeps frequently accessed parameters for storage access optimization
Params public override params;
/// @dev Keeps borrowing limits together for storage access optimization
Limits public override limits;
/// @dev Address of the underlying token
address public immutable underlying;
/// @dev A map that stores whether a user allows a transfer of an account from another user to themselves
mapping(address => mapping(address => bool))
public
override transfersAllowed;
/// @dev Address of WETH
address public immutable wethAddress;
/// @dev Address of the DegenNFT that gatekeeps account openings in whitelisted mode
address public immutable override degenNFT;
/// @dev Stores in a compressed state the last block where borrowing happened and the total amount borrowed in that block
uint256 internal totalBorrowedInBlock;
/// @dev Stores a set of contracts which have special restrictions applied for security (such as upgradeable contracts)
EnumerableSet.AddressSet internal upgradeableContracts;
/// @dev Contract version
uint256 public constant override version = 2;
/// @dev Restricts actions for users with opened credit accounts only
modifier creditConfiguratorOnly() {
if (msg.sender != creditManager.creditConfigurator())
revert CreditConfiguratorOnlyException();
_;
}
/// @dev Initializes creditFacade and connects it with CreditManager
/// @param _creditManager address of Credit Manager
/// @param _degenNFT address of the DegenNFT or address(0) if whitelisted mode is not used
/// @param _expirable Whether the CreditFacade can expire and implements expiration-related logic
constructor(
address _creditManager,
address _degenNFT,
bool _expirable
) {
// Additional check that _creditManager is not address(0)
if (_creditManager == address(0)) revert ZeroAddressException(); // F:[FA-1]
creditManager = ICreditManagerV2(_creditManager); // F:[FA-1A]
underlying = ICreditManagerV2(_creditManager).underlying(); // F:[FA-1A]
wethAddress = ICreditManagerV2(_creditManager).wethAddress(); // F:[FA-1A]
degenNFT = _degenNFT; // F:[FA-1A]
whitelisted = _degenNFT != address(0); // F:[FA-1A]
expirable = _expirable;
}
// Notice: ETH interactions
// CreditFacade implements a new flow for interacting with WETH compared to V1.
// During all actions, any sent ETH value is automatically wrapped into WETH and
// sent back to the message sender. This makes the protocol's behavior regarding
// ETH more flexible and consistent, since there is no need to pre-wrap WETH before
// interacting with the protocol, and no need to compute how much unused ETH has to be sent back.
/// @dev Opens credit account, borrows funds from the pool and pulls collateral
/// without any additional action.
/// - Performs sanity checks to determine whether opening an account is allowed
/// - Wraps ETH to WETH and sends it msg. sender is value > 0
/// - Requests CreditManager to open a Credit Account with a specified borrowed amount
/// - Transfers collateral in the underlying asset from the user
/// - Emits OpenCreditAccount event
///
/// More info: https://dev.gearbox.fi/developers/credit/credit_manager#open-credit-account
///
/// @param amount The amount of collateral provided by the borrower
/// @param onBehalfOf The address to open an account for. Transfers to it have to be allowed if
/// msg.sender != obBehalfOf
/// @param leverageFactor Percentage of the user's own funds to borrow. 100 is equal to 100% - borrows the same amount
/// as the user's own collateral, equivalent to 2x leverage.
/// @param referralCode Referral code that is used for potential rewards. 0 if no referral code provided.
function openCreditAccount(
uint256 amount,
address onBehalfOf,
uint16 leverageFactor,
uint16 referralCode
) external payable override nonReentrant {
uint256 borrowedAmount = (amount * leverageFactor) / LEVERAGE_DECIMALS; // F:[FA-5]
// Checks whether the new borrowed amount does not violate the block limit
_checkAndUpdateBorrowedBlockLimit(borrowedAmount); // F:[FA-11A]
// Checks that the borrowed amount is within the borrowing limits
_revertIfOutOfBorrowedLimits(borrowedAmount); // F:[FA-11B]
// Checks that the msg.sender can open an account for onBehalfOf
_revertIfOpenCreditAccountNotAllowed(onBehalfOf); // F:[FA-4A, 4B]
// Wraps ETH and sends it back to msg.sender
_wrapETH(); // F:[FA-3A]
// Gets the LT of the underlying
(, uint256 ltu) = creditManager.collateralTokens(0); // F:[FA-6]
// In order for the account to pass the health check after opening,
// the inequality "(amount + borrowedAmount) * LTU > borrowedAmount" must hold
// this can be transformed into "amount * LTU > borrowedAmount * (1 - LTU)"
if (amount * ltu <= borrowedAmount * (PERCENTAGE_FACTOR - ltu))
revert NotEnoughCollateralException(); // F:[FA-6]
// Opens credit accnount and borrows funds from the pool
// Returns the new credit account's address
address creditAccount = creditManager.openCreditAccount(
borrowedAmount,
onBehalfOf
); // F:[FA-5]
// Emits openCreditAccount event before adding collateral, so that order of events is correct
emit OpenCreditAccount(
onBehalfOf,
creditAccount,
borrowedAmount,
referralCode
); // F:[FA-5]
// Transfers collateral from the user to the new Credit Account
addCollateral(onBehalfOf, creditAccount, underlying, amount); // F:[FA-5]
}
/// @dev Opens a Credit Account and runs a batch of operations in a multicall
/// - Opens credit account with the desired borrowed amount
/// - Executes all operations in a multicall
/// - Checks that the new account has enough collateral
/// - Emits OpenCreditAccount event
///
/// @param borrowedAmount Debt size
/// @param onBehalfOf The address to open an account for. Transfers to it have to be allowed if
/// msg.sender != onBehalfOf
/// @param calls The array of MultiCall structs encoding the required operations. Generally must have
/// at least a call to addCollateral, as otherwise the health check at the end will fail.
/// @param referralCode Referral code which is used for potential rewards. 0 if no referral code provided
function openCreditAccountMulticall(
uint256 borrowedAmount,
address onBehalfOf,
MultiCall[] calldata calls,
uint16 referralCode
) external payable override nonReentrant {
// Checks whether the new borrowed amount does not violate the block limit
_checkAndUpdateBorrowedBlockLimit(borrowedAmount); // F:[FA-11]
// Checks that the msg.sender can open an account for onBehalfOf
_revertIfOpenCreditAccountNotAllowed(onBehalfOf); // F:[FA-4A, 4B]
// Checks that the borrowed amount is within the borrowing limits
_revertIfOutOfBorrowedLimits(borrowedAmount); // F:[FA-11B]
// Wraps ETH and sends it back to msg.sender address
_wrapETH(); // F:[FA-3B]
// Requests the Credit Manager to open a Credit Account
address creditAccount = creditManager.openCreditAccount(
borrowedAmount,
onBehalfOf
); // F:[FA-8]
// emits a new event
emit OpenCreditAccount(
onBehalfOf,
creditAccount,
borrowedAmount,
referralCode
); // F:[FA-8]
// F:[FA-10]: no free flashloans through opening a Credit Account
// and immediately decreasing debt
if (calls.length != 0)
_multicall(calls, onBehalfOf, creditAccount, false, true); // F:[FA-8]
// Checks that the new credit account has enough collateral to cover the debt
creditManager.fullCollateralCheck(creditAccount); // F:[FA-8, 9]
}
/// @dev Runs a batch of transactions within a multicall and closes the account
/// - Wraps ETH to WETH and sends it msg.sender if value > 0
/// - Executes the multicall - the main purpose of a multicall when closing is to convert all assets to underlying
/// in order to pay the debt.
/// - Closes credit account:
/// + Checks the underlying balance: if it is greater than the amount paid to the pool, transfers the underlying
/// from the Credit Account and proceeds. If not, tries to transfer the shortfall from msg.sender.
/// + Transfers all enabled assets with non-zero balances to the "to" address, unless they are marked
/// to be skipped in skipTokenMask
/// + If convertWETH is true, converts WETH into ETH before sending to the recipient
/// - Emits a CloseCreditAccount event
///
/// @param to Address to send funds to during account closing
/// @param skipTokenMask Uint-encoded bit mask where 1's mark tokens that shouldn't be transferred
/// @param convertWETH If true, converts WETH into ETH before sending to "to"
/// @param calls The array of MultiCall structs encoding the operations to execute before closing the account.
function closeCreditAccount(
address to,
uint256 skipTokenMask,
bool convertWETH,
MultiCall[] calldata calls
) external payable override nonReentrant {
// Check for existing CA
address creditAccount = creditManager.getCreditAccountOrRevert(
msg.sender
); // F:[FA-2]
// Wraps ETH and sends it back to msg.sender
_wrapETH(); // F:[FA-3C]
// [FA-13]: Calls to CreditFacade are forbidden during closure
if (calls.length != 0)
_multicall(calls, msg.sender, creditAccount, true, false); // F:[FA-2, 12, 13]
// Requests the Credit manager to close the Credit Account
creditManager.closeCreditAccount(
msg.sender,
ClosureAction.CLOSE_ACCOUNT,
0,
msg.sender,
to,
skipTokenMask,
convertWETH
); // F:[FA-2, 12]
// Emits a CloseCreditAccount event
emit CloseCreditAccount(msg.sender, to); // F:[FA-12]
}
/// @dev Runs a batch of transactions within a multicall and liquidates the account
/// - Computes the total value and checks that hf < 1. An account can't be liquidated when hf >= 1.
/// Total value has to be computed before the multicall, otherwise the liquidator would be able
/// to manipulate it.
/// - Wraps ETH to WETH and sends it to msg.sender (liquidator) if value > 0
/// - Executes the multicall - the main purpose of a multicall when liquidating is to convert all assets to underlying
/// in order to pay the debt.
/// - Liquidate credit account:
/// + Computes the amount that needs to be paid to the pool. If totalValue * liquidationDiscount < borrow + interest + fees,
/// only totalValue * liquidationDiscount has to be paid. Since liquidationDiscount < 1, the liquidator can take
/// totalValue * (1 - liquidationDiscount) as premium. Also computes the remaining funds to be sent to borrower
/// as totalValue * liquidationDiscount - amountToPool.
/// + Checks the underlying balance: if it is greater than amountToPool + remainingFunds, transfers the underlying
/// from the Credit Account and proceeds. If not, tries to transfer the shortfall from the liquidator.
/// + Transfers all enabled assets with non-zero balances to the "to" address, unless they are marked
/// to be skipped in skipTokenMask. If the liquidator is confident that all assets were converted
/// during the multicall, they can set the mask to uint256.max - 1, to only transfer the underlying
/// + If convertWETH is true, converts WETH into ETH before sending
/// - Emits LiquidateCreditAccount event
///
/// @param to Address to send funds to after liquidation
/// @param skipTokenMask Uint-encoded bit mask where 1's mark tokens that shouldn't be transferred
/// @param convertWETH If true, converts WETH into ETH before sending to "to"
/// @param calls The array of MultiCall structs encoding the operations to execute before liquidating the account.
function liquidateCreditAccount(
address borrower,
address to,
uint256 skipTokenMask,
bool convertWETH,
MultiCall[] calldata calls
) external payable override nonReentrant {
// Checks that the CA exists to revert early for late liquidations and save gas
address creditAccount = creditManager.getCreditAccountOrRevert(
borrower
); // F:[FA-2]
// Checks that the to address is not zero
if (to == address(0)) revert ZeroAddressException(); // F:[FA-16A]
// Checks that the account hf < 1 and computes the totalValue
// before the multicall
(bool isLiquidatable, uint256 totalValue) = _isAccountLiquidatable(
creditAccount
); // F:[FA-14]
// An account can't be liquidated if hf >= 1
if (!isLiquidatable)
revert CantLiquidateWithSuchHealthFactorException(); // F:[FA-14]
// Wraps ETH and sends it back to msg.sender
_wrapETH(); // F:[FA-3D]
// Checks if the liquidation is done while the contract is paused
bool emergencyLiquidation = _checkIfEmergencyLiquidator(true);
if (calls.length != 0)
_multicall(calls, borrower, creditAccount, true, false); // F:[FA-15]
if (emergencyLiquidation) {
_checkIfEmergencyLiquidator(false);
}
// Liquidates the CA and sends the remaining funds to the borrower
uint256 remainingFunds = creditManager.closeCreditAccount(
borrower,
ClosureAction.LIQUIDATE_ACCOUNT,
totalValue,
msg.sender,
to,
skipTokenMask,
convertWETH
); // F:[FA-15]
emit LiquidateCreditAccount(borrower, msg.sender, to, remainingFunds); // F:[FA-15]
}
/// @dev Runs a batch of transactions within a multicall and liquidates the account when
/// this Credit Facade is expired
/// The general flow of liquidation is nearly the same as normal liquidations, with two main differences:
/// - An account can be liquidated on an expired Credit Facade even with hf > 1. However,
/// no accounts can be liquidated through this function if the Credit Facade is not expired.
/// - Liquidation premiums and fees for liquidating expired accounts are reduced.
/// It is still possible to normally liquidate an underwater Credit Account, even when the Credit Facade
/// is expired.
/// @param to Address to send funds to after liquidation
/// @param skipTokenMask Uint-encoded bit mask where 1's mark tokens that shouldn't be transferred
/// @param convertWETH If true, converts WETH into ETH before sending to "to"
/// @param calls The array of MultiCall structs encoding the operations to execute before liquidating the account.
/// @notice See more at https://dev.gearbox.fi/docs/documentation/credit/liquidation#liquidating-accounts-by-expiration
function liquidateExpiredCreditAccount(
address borrower,
address to,
uint256 skipTokenMask,
bool convertWETH,
MultiCall[] calldata calls
) external payable override nonReentrant {
// Checks that the CA exists to revert early for late liquidations and save gas
address creditAccount = creditManager.getCreditAccountOrRevert(
borrower
);
// Checks that the to address is not zero
if (to == address(0)) revert ZeroAddressException();
// Checks that this Credit Facade is expired and reverts if not
if (!_isExpired()) {
revert CantLiquidateNonExpiredException(); // F: [FA-47,48]
}
// Calculates the total value of an account
(uint256 totalValue, ) = calcTotalValue(creditAccount);
// Wraps ETH and sends it back to msg.sender address
_wrapETH();
// Checks if the liquidsation during pause
bool emergencyLiquidation = _checkIfEmergencyLiquidator(true);
if (calls.length != 0)
_multicall(calls, borrower, creditAccount, true, false); // F:[FA-49]
if (emergencyLiquidation) {
_checkIfEmergencyLiquidator(false);
}
// Liquidates the CA and sends the remaining funds to the borrower
uint256 remainingFunds = creditManager.closeCreditAccount(
borrower,
ClosureAction.LIQUIDATE_EXPIRED_ACCOUNT,
totalValue,
msg.sender,
to,
skipTokenMask,
convertWETH
); // F:[FA-49]
// Emits event
emit LiquidateExpiredCreditAccount(
borrower,
msg.sender,
to,
remainingFunds
); // F:[FA-49]
}
/// @dev Increases debt for msg.sender's Credit Account
/// - Borrows the requested amount from the pool
/// - Updates the CA's borrowAmount / cumulativeIndexOpen
/// to correctly compute interest going forward
/// - Performs a full collateral check
///
/// @param amount Amount to borrow
function increaseDebt(uint256 amount) external override nonReentrant {
address creditAccount = creditManager.getCreditAccountOrRevert(
msg.sender
); // F:[FA-2]
_increaseDebt(msg.sender, creditAccount, amount);
// Checks that the credit account has enough collateral to cover the new borrowed amount
creditManager.fullCollateralCheck(creditAccount); // F:[FA-17]
}
/// @dev IMPLEMENTATION: increaseDebt
function _increaseDebt(
address borrower,
address creditAccount,
uint256 amount
) internal {
// It is forbidden to take new debt if increaseDebtForbidden mode is enabled
if (params.isIncreaseDebtForbidden)
revert IncreaseDebtForbiddenException(); // F:[FA-18C]
// Checks that the borrowed amount does not violate the per block limit
_checkAndUpdateBorrowedBlockLimit(amount); // F:[FA-18A]
// Checks that there are no forbidden tokens, as borrowing
// is prohibited when forbidden tokens are enabled on the account
_checkForbiddenTokens(creditAccount);
// Requests the Credit Manager to borrow additional funds from the pool
uint256 newBorrowedAmount = creditManager.manageDebt(
creditAccount,
amount,
true
); // F:[FA-17]
// Checks that the new total borrowed amount is within bounds
_revertIfOutOfBorrowedLimits(newBorrowedAmount); // F:[FA-18B]
// Emits event
emit IncreaseBorrowedAmount(borrower, amount); // F:[FA-17]
}
/// @dev Checks that there are no intersections between the user's enabled tokens
/// and the set of forbidden tokens
/// @notice The main purpose of forbidding tokens is to prevent exposing
/// pool funds to dangerous or exploited collateral, without immediately
/// liquidating accounts that hold the forbidden token
/// There are two ways pool funds can be exposed:
/// - The CA owner tries to swap borrowed funds to the forbidden asset:
/// this will be blocked by checkAndEnableToken, which is invoked for tokenOut
/// after every operation;
/// - The CA owner with an already enabled forbidden token transfers it
/// to the account - they can't use addCollateral / enableToken due to checkAndEnableToken,
/// but can transfer the token directly when it is enabled and it will be counted in the collateral -
/// an borrows against it. This check is used to prevent this.
/// If the owner has a forbidden token and want to take more debt, they must first
/// dispose of the token and disable it.
function _checkForbiddenTokens(address creditAccount) internal view {
uint256 enabledTokenMask = creditManager.enabledTokensMap(
creditAccount
);
uint256 forbiddenTokenMask = creditManager.forbiddenTokenMask();
if (enabledTokenMask & forbiddenTokenMask > 0) {
revert ActionProhibitedWithForbiddenTokensException();
}
}
/// @dev Decrease debt
/// - Decreases the debt by paying the requested amount + accrued interest + fees back to the pool
/// - It's also include to this payment interest accrued at the moment and fees
/// - Updates cunulativeIndex to cumulativeIndex now
///
/// @param amount Amount to increase borrowed amount
function decreaseDebt(uint256 amount) external override nonReentrant {
address creditAccount = creditManager.getCreditAccountOrRevert(
msg.sender
); // F:[FA-2]
_decreaseDebt(msg.sender, creditAccount, amount); // F:[FA-19]
// We need this check, cause after paying debt back, it potentially could be
// another portfolio structure, which has lower Hf
creditManager.fullCollateralCheck(creditAccount); // F:[FA-19]
}
/// @dev IMPLEMENTATION: decreaseDebt
function _decreaseDebt(
address borrower,
address creditAccount,
uint256 amount
) internal {
// Requests the creditManager to reduce the borrowed sum by amount
uint256 newBorrowedAmount = creditManager.manageDebt(
creditAccount,
amount,
false
); // F:[FA-19]
// Checks that the new borrowed amount is within limits
_revertIfOutOfBorrowedLimits(newBorrowedAmount); // F:[FA-20]
// Emits an event
emit DecreaseBorrowedAmount(borrower, amount); // F:[FA-19]
}
/// @dev Adds collateral to borrower's credit account
/// @param onBehalfOf Address of the borrower whose account is funded
/// @param token Address of a collateral token
/// @param amount Amount to add
function addCollateral(
address onBehalfOf,
address token,
uint256 amount
) external payable override nonReentrant {
// Wraps ETH and sends it back to msg.sender
_wrapETH(); // F:[FA-3E]
// Checks that onBehalfOf has an account
address creditAccount = creditManager.getCreditAccountOrRevert(
onBehalfOf
); // F:[FA-2]
addCollateral(onBehalfOf, creditAccount, token, amount);
// Since this action can enable new tokens, Credit Manager
// needs to check that the max enabled token limit is not
// breached
creditManager.checkAndOptimizeEnabledTokens(creditAccount); // F: [FA-21C]
}
function addCollateral(
address onBehalfOf,
address creditAccount,
address token,
uint256 amount
) internal {
// Checks that msg.sender can transfer funds to onBehalfOf's account
// This is done to prevent malicious actors sending bad collateral
// to users
// mgs.sender can only add collateral if transfer are approved
// from itself to onBehalfOf
_revertIfActionOnAccountNotAllowed(onBehalfOf); // F: [FA-21A]
// Requests Credit Manager to transfer collateral to the Credit Account
creditManager.addCollateral(msg.sender, creditAccount, token, amount); // F:[FA-21]
// Emits event
emit AddCollateral(onBehalfOf, token, amount); // F:[FA-21]
}
/// @dev Executes a batch of transactions within a Multicall, to manage an existing account
/// - Wraps ETH and sends it back to msg.sender, if value > 0
/// - Executes the Multicall
/// - Performs a fullCollateralCheck to verify that hf > 1 after all actions
/// @param calls The array of MultiCall structs encoding the operations to execute.
function multicall(MultiCall[] calldata calls)
external
payable
override
nonReentrant
{
// Checks that msg.sender has an account
address creditAccount = creditManager.getCreditAccountOrRevert(
msg.sender
);
// Wraps ETH and sends it back to msg.sender
_wrapETH(); // F:[FA-3F]
if (calls.length != 0) {
_multicall(calls, msg.sender, creditAccount, false, false);
// Performs a fullCollateralCheck
// During a multicall, all intermediary health checks are skipped,
// as one fullCollateralCheck at the end is sufficient
creditManager.fullCollateralCheck(creditAccount);
}
}
/// @dev IMPLEMENTATION: multicall
/// - Transfers ownership from borrower to this contract, as most adapter and Credit Manager functions retrieve
/// the Credit Account by msg.sender
/// - Executes the provided list of calls:
/// + if targetContract == address(this), parses call data in the struct and calls the appropriate function (see _processCreditFacadeMulticall below)
/// + if targetContract == adapter, calls the adapter with call data as provided. Adapters skip health checks when Credit Facade is the msg.sender,
/// as it performs the necessary health checks on its own
/// @param borrower Owner of the Credit Account
/// @param creditAccount Credit Account address
/// @param isClosure Whether the multicall is being invoked during a closure action. Calls to Credit Facade are forbidden inside
/// multicalls on closure.
/// @param increaseDebtWasCalled True if debt was increased before or during the multicall. Used to prevent free flashloans by
/// increasing and decreasing debt within a single multicall.
function _multicall(
MultiCall[] calldata calls,
address borrower,
address creditAccount,
bool isClosure,
bool increaseDebtWasCalled
) internal {
// Takes ownership of the Credit Account
creditManager.transferAccountOwnership(borrower, address(this)); // F:[FA-26]
// Emits event for multicall start - used in analytics to track actions within multicalls
emit MultiCallStarted(borrower); // F:[FA-26]
// Declares the expectedBalances array, which can later be used for slippage control
Balance[] memory expectedBalances;
uint256 len = calls.length; // F:[FA-26]
for (uint256 i = 0; i < len; ) {
MultiCall calldata mcall = calls[i]; // F:[FA-26]
// Reverts of calldata has less than 4 bytes
if (mcall.callData.length < 4) revert IncorrectCallDataException(); // F:[FA-22]
if (mcall.target == address(this)) {
// No internal calls on closure except slippage control, to avoid loss manipulation
if (isClosure) {
bytes4 method = bytes4(mcall.callData);
if (
method !=
ICreditFacadeExtended.revertIfReceivedLessThan.selector
) revert ForbiddenDuringClosureException(); // F:[FA-13]
}
//
// CREDIT FACADE
//
// increaseDebtWasCalled and expectedBalances are parameters that persist throughout multicall,
// therefore they are passed to the internal function processor, which returns updated values
(
increaseDebtWasCalled,
expectedBalances
) = _processCreditFacadeMulticall(
borrower,
creditAccount,
mcall.callData,
increaseDebtWasCalled,
expectedBalances
);
} else {
//
// ADAPTERS
//
// Checks that the target is an allowed adapter and not CreditManager
// As CreditFacade has powerful permissions in CreditManagers,
// functionCall to it is strictly forbidden, even if
// the Configurator adds it as an adapter
if (
creditManager.adapterToContract(mcall.target) ==
address(0) ||
mcall.target == address(creditManager)
) revert TargetContractNotAllowedException(); // F:[FA-24]
// Makes a call
mcall.target.functionCall(mcall.callData); // F:[FA-29]
}
unchecked {
++i;
}
}
// If expectedBalances was set by calling revertIfGetLessThan,
// checks that actual token balances are not less than expected balances
if (expectedBalances.length != 0)
_compareBalances(expectedBalances, creditAccount);
// Emits event for multicall end - used in analytics to track actions within multicalls
emit MultiCallFinished(); // F:[FA-27,27,29]
// Returns ownership back to the borrower
creditManager.transferAccountOwnership(address(this), borrower); // F:[FA-27,27,29]
}
/// @dev Internal function for processing calls to Credit Facade within the multicall
/// @param borrower Original owner of the Credit Account
/// @param creditAccount Credit Account address
/// @param callData Call data of the currently processed call
/// @param increaseDebtWasCalledBefore Whether debt was increased before entering the function
/// @param expectedBalances Array of expected balances before entering the function
function _processCreditFacadeMulticall(
address borrower,
address creditAccount,
bytes calldata callData,
bool increaseDebtWasCalledBefore,
Balance[] memory expectedBalancesBefore
)
internal
returns (bool increaseDebtWasCalled, Balance[] memory expectedBalances)
{
increaseDebtWasCalled = increaseDebtWasCalledBefore;
expectedBalances = expectedBalancesBefore;
bytes4 method = bytes4(callData);
//
// REVERT_IF_GET_LESS_THAN
//
// This is an extension function that instructs CreditFacade to check token balances at the end
// Used to control slippage after the entire sequence of operations, since tracking slippage
// On each operation is not ideal
if (method == ICreditFacadeExtended.revertIfReceivedLessThan.selector) {
// Method can only be called once since the provided Balance array
// contains deltas that are added to the current balances
// Calling this function again could potentially override old values
// and cause confusion, especially if called later in the MultiCall
if (expectedBalances.length != 0)
revert ExpectedBalancesAlreadySetException(); // F:[FA-45A]
// Retrieves the balance list from calldata
expectedBalances = abi.decode(callData[4:], (Balance[])); // F:[FA-45]
// Sets expected balances to currentBalance + delta
expectedBalances = _storeBalances(expectedBalances, creditAccount); // F:[FA-45]
}
//
// ADD COLLATERAL
//
else if (method == ICreditFacade.addCollateral.selector) {
// Parses parameters from calldata
(address onBehalfOf, address token, uint256 amount) = abi.decode(
callData[4:],
(address, address, uint256)
); // F:[FA-26, 27]
// In case onBehalfOf isn't the owner of the currently processed account,
// retrieves onBehalfOf's account
addCollateral(
onBehalfOf,
onBehalfOf == borrower
? creditAccount
: creditManager.getCreditAccountOrRevert(onBehalfOf),
token,
amount
); // F:[FA-26, 27]
}
//
// INCREASE DEBT
//
else if (method == ICreditFacade.increaseDebt.selector) {
// Sets increaseDebtWasCalled to prevent debt reductions afterwards,
// as that could be used to get free flash loans
increaseDebtWasCalled = true; // F:[FA-28]
// Parses parameters from calldata
uint256 amount = abi.decode(callData[4:], (uint256)); // F:[FA-26]
_increaseDebt(borrower, creditAccount, amount); // F:[FA-26]
}
//
// DECREASE DEBT
//
else if (method == ICreditFacade.decreaseDebt.selector) {
// it's forbidden to call decreaseDebt after increaseDebt, in the same multicall
if (increaseDebtWasCalled)
revert IncreaseAndDecreaseForbiddenInOneCallException(); // F:[FA-28]
// Parses parameters from calldata
uint256 amount = abi.decode(callData[4:], (uint256)); // F:[FA-27]
_decreaseDebt(borrower, creditAccount, amount); // F:[FA-27]
}
//
// ENABLE TOKEN
//
else if (method == ICreditFacade.enableToken.selector) {
// Parses token
address token = abi.decode(callData[4:], (address)); // F: [FA-53]
// Executes enableToken for creditAccount
_enableToken(borrower, creditAccount, token); // F: [FA-53]
}
//
// DISABLE TOKEN
//
// This is an extenstion method used to disable tokens on a Credit Account
// Can be used to remove troublesome tokens (e.g., forbidden tokens) from an account
else if (method == ICreditFacadeExtended.disableToken.selector) {
// Parses token
address token = abi.decode(callData[4:], (address)); // F: [FA-54]
// Executes disableToken for creditAccount
_disableToken(borrower, creditAccount, token); // F: [FA-54]
} else {
// Reverts if the passed selector is unrecognized
revert UnknownMethodException(); // F:[FA-23]
}
}
/// @dev Adds expected deltas to current balances on a Credit account and returns the result
/// @param expected Expected changes to existing balances
/// @param creditAccount Credit Account to compute balances for
function _storeBalances(Balance[] memory expected, address creditAccount)
internal
view
returns (Balance[] memory)
{
uint256 len = expected.length; // F:[FA-45]
for (uint256 i = 0; i < len; ) {
expected[i].balance += IERC20(expected[i].token).balanceOf(
creditAccount
); // F:[FA-45]
unchecked {
++i;
}
}
return expected; // F:[FA-45]
}
/// @dev Compares current balances to previously saved expected balances.
/// Reverts if at least one balance is lower than expected
/// @param expected Expected balances after all operations
/// @param creditAccount Credit Account to check
function _compareBalances(Balance[] memory expected, address creditAccount)
internal
view
{
uint256 len = expected.length; // F:[FA-45]
for (uint256 i = 0; i < len; ) {
if (
IERC20(expected[i].token).balanceOf(creditAccount) <
expected[i].balance
) revert BalanceLessThanMinimumDesiredException(expected[i].token); // F:[FA-45]
unchecked {
++i;
}
}
}
/// @dev Sets token allowance from msg.sender's Credit Account to a connected target contract
/// @param targetContract Contract to set allowance to. Cannot be in the list of upgradeable contracts
/// @param token Token address
/// @param amount Allowance amount
function approve(
address targetContract,
address token,
uint256 amount
) external override nonReentrant {
// Checks that targetContract is a non-zero address and is not in the upgradeable contracts list
// If an upgradeable contract is compromised, and an attacker is able to call transferFrom from it,
// they would be able to steal funds from Credit Accounts while circumventing all health checks
// Thus, this action is only allowed for immutable and highly secure contracts
if (
creditManager.contractToAdapter(targetContract) == address(0) ||
upgradeableContracts.contains(targetContract)
)
// F: [FA-51]
revert TargetContractNotAllowedException(); // F:[FA-30]
// Requests Credit Manager to set token allowance from Credit Account to contract
creditManager.approveCreditAccount(
msg.sender,
targetContract,
token,
amount
); // F:[FA-31]
}
/// @dev Transfers credit account to another user
/// By default, this action is forbidden, and the user has to approve transfers from sender to itself
/// by calling approveAccountTransfer.
/// This is done to prevent malicious actors from transferring compromised accounts to other users.
/// @param to Address to transfer the account to
function transferAccountOwnership(address to)
external
override
nonReentrant
{
// In whitelisted mode only select addresses can have Credit Accounts
// So this action is prohibited
if (whitelisted) revert NotAllowedInWhitelistedMode(); // F:[FA-32]
address creditAccount = creditManager.getCreditAccountOrRevert(
msg.sender
); // F:[FA-2]
// Checks that transfer is allowed
if (!transfersAllowed[msg.sender][to])
revert AccountTransferNotAllowedException(); // F:[FA-33]
/// Checks that the account hf > 1, as it is forbidden to transfer
/// accounts that are liquidatable
(bool isLiquidatable, ) = _isAccountLiquidatable(creditAccount); // F:[FA-34]
if (isLiquidatable) revert CantTransferLiquidatableAccountException(); // F:[FA-34]
// Requests the Credit Manager to transfer the account
creditManager.transferAccountOwnership(msg.sender, to); // F:[FA-35]
// Emits event
emit TransferAccount(msg.sender, to); // F:[FA-35]
}
/// @dev Verifies that the msg.sender can open an account for onBehalfOf
/// - For expirable Credit Facade, expiration date must not be reached
/// - For whitelisted mode, msg.sender must open the account for themselves
/// and have at least one DegenNFT to burn
/// - Otherwise, checks that account transfers from msg.sender to onBehalfOf
/// are approved
/// @param onBehalfOf Account which would own credit account
function _revertIfOpenCreditAccountNotAllowed(address onBehalfOf) internal {
// Opening new Credit Accounts is prohibited in increaseDebtForbidden mode
if (params.isIncreaseDebtForbidden)
revert IncreaseDebtForbiddenException(); // F:[FA-7]
// Checks that this CreditFacade is not expired
if (_isExpired()) {
revert OpenAccountNotAllowedAfterExpirationException(); // F: [FA-46]
}
// F:[FA-5] covers case when degenNFT == address(0)
if (degenNFT != address(0)) {
// F:[FA-4B]
// In whitelisted mode, users can only open an account by burning a DegenNFT
// And opening an account for another address is forbidden
if (whitelisted && msg.sender != onBehalfOf)
revert NotAllowedInWhitelistedMode(); // F:[FA-4B]
IDegenNFT(degenNFT).burn(onBehalfOf, 1); // F:[FA-4B]
}
_revertIfActionOnAccountNotAllowed(onBehalfOf);
}
/// @dev Checks if the message sender is allowed to do an action on a CA
/// @param onBehalfOf The account which owns the target CA
function _revertIfActionOnAccountNotAllowed(address onBehalfOf)
internal
view
{
// msg.sender must either be the account owner themselves,
// or be approved for transfers
if (
msg.sender != onBehalfOf &&
!transfersAllowed[msg.sender][onBehalfOf]
) revert AccountTransferNotAllowedException(); // F:[FA-04C]
}
/// @dev Checks that the per-block borrow limit was not violated and updates the
/// amount borrowed in current block
function _checkAndUpdateBorrowedBlockLimit(uint256 amount) internal {
// Skipped in whitelisted mode, since there is a strict limit on the number
// of credit accounts that can be opened, which implies a limit on borrowing
if (!whitelisted) {
uint256 _limitPerBlock = params.maxBorrowedAmountPerBlock; // F:[FA-18]
// If the limit is unit128.max, the check is disabled
// F:[FA-36] test case when _limitPerBlock == type(uint128).max
if (_limitPerBlock != type(uint128).max) {
(
uint64 lastBlock,
uint128 lastLimit
) = getTotalBorrowedInBlock(); // F:[FA-18, 37]
uint256 newLimit = (lastBlock == block.number)
? amount + lastLimit // F:[FA-37]
: amount; // F:[FA-18, 37]
if (newLimit > _limitPerBlock)
revert BorrowedBlockLimitException(); // F:[FA-18]
_updateTotalBorrowedInBlock(uint128(newLimit)); // F:[FA-37]
}
}
}
/// @dev Checks that the borrowed principal is within borrowing limits
/// @param borrowedAmount The current principal of a Credit Account
function _revertIfOutOfBorrowedLimits(uint256 borrowedAmount)
internal
view
{
// Checks that amount is in limits
if (
borrowedAmount < uint256(limits.minBorrowedAmount) ||
borrowedAmount > uint256(limits.maxBorrowedAmount)
) revert BorrowAmountOutOfLimitsException(); // F:
}
function _checkIfEmergencyLiquidator(bool state) internal returns (bool) {
return creditManager.checkEmergencyPausable(msg.sender, state);
}
/// @dev Returns the last block where debt was taken,
/// and the total amount borrowed in that block
function getTotalBorrowedInBlock()
public
view
returns (uint64 blockLastUpdate, uint128 borrowedInBlock)
{
blockLastUpdate = uint64(totalBorrowedInBlock >> 128); // F:[FA-37]
borrowedInBlock = uint128(totalBorrowedInBlock & type(uint128).max); // F:[FA-37]
}
/// @dev Saves the total amount borrowed in the current block for future checks
/// @param borrowedInBlock Updated total borrowed amount
function _updateTotalBorrowedInBlock(uint128 borrowedInBlock) internal {
totalBorrowedInBlock = uint256(block.number << 128) | borrowedInBlock; // F:[FA-37]
}
/// @dev Approves account transfer from another user to msg.sender
/// @param from Address for which account transfers are allowed/forbidden
/// @param state True is transfer is allowed, false if forbidden
function approveAccountTransfer(address from, bool state)
external
override
nonReentrant
{
transfersAllowed[from][msg.sender] = state; // F:[FA-38]
// Emits event
emit TransferAccountAllowed(from, msg.sender, state); // F:[FA-38]
}
/// @dev Enables token in enabledTokenMask for the Credit Account of msg.sender
/// @param token Address of token to enable
function enableToken(address token) external override nonReentrant {
address creditAccount = creditManager.getCreditAccountOrRevert(
msg.sender
); // F:[FA-2]
_enableToken(msg.sender, creditAccount, token);
// Since this action potentially increases the number of enabled tokens,
// the Credit Manager is requested to check that the max limit for enabled tokens
// is not violated
creditManager.checkAndOptimizeEnabledTokens(creditAccount); // F: [FA-39A]
}
/// @dev IMPLEMENTATION: enableToken
/// @param creditAccount Account for which the token is enabled
/// @param token Collateral token to enabled
function _enableToken(
address borrower,
address creditAccount,
address token
) internal {
// Will revert if the token is not known or forbidden,
// If the token is disabled, adds the respective bit to the mask, otherwise does nothing
creditManager.checkAndEnableToken(creditAccount, token); // F:[FA-39]
// Emits event
emit TokenEnabled(borrower, token);
}
function _disableToken(
address borrower,
address creditAccount,
address token
) internal {
// If the token is enabled, removes a respective bit from the mask,
// otherwise does nothing
if (creditManager.disableToken(creditAccount, token)) {
// Emits event
emit TokenDisabled(borrower, token);
} // F: [FA-54]
}
//
// GETTERS
//
/// @dev Returns true if token is a collateral token and is not forbidden,
/// otherwise returns false
/// @param token Token to check
function isTokenAllowed(address token)
public
view
override
returns (bool allowed)
{
uint256 tokenMask = creditManager.tokenMasksMap(token); // F:[FA-40]
allowed =
(tokenMask != 0) &&
(creditManager.forbiddenTokenMask() & tokenMask == 0); // F:[FA-40]
}
/// @dev Calculates total value for provided Credit Account in underlying
/// More: https://dev.gearbox.fi/developers/credit/economy#totalUSD-value
///
/// @param creditAccount Credit Account address
/// @return total Total value in underlying
/// @return twv Total weighted (discounted by liquidation thresholds) value in underlying
function calcTotalValue(address creditAccount)
public
view
override
returns (uint256 total, uint256 twv)
{
IPriceOracleV2 priceOracle = IPriceOracleV2(
creditManager.priceOracle()
); // F:[FA-41]
(uint256 totalUSD, uint256 twvUSD) = _calcTotalValueUSD(
priceOracle,
creditAccount
);
total = priceOracle.convertFromUSD(totalUSD, underlying); // F:[FA-41]
twv =
priceOracle.convertFromUSD(twvUSD, underlying) /
PERCENTAGE_FACTOR; // F:[FA-41]
}
/// @dev Calculates total value for provided Credit Account in USD
/// @param priceOracle Oracle used to convert assets to USD
/// @param creditAccount Address of the Credit Account
/// @return totalUSD Total value of the account in USD
/// @return twvUSD Total weighted (discounted by liquidation thresholds) value in USD
function _calcTotalValueUSD(
IPriceOracleV2 priceOracle,
address creditAccount
) internal view returns (uint256 totalUSD, uint256 twvUSD) {
uint256 tokenMask = 1;
uint256 enabledTokensMask = creditManager.enabledTokensMap(
creditAccount
); // F:[FA-41]
while (tokenMask <= enabledTokensMask) {
if (enabledTokensMask & tokenMask != 0) {
(address token, uint16 liquidationThreshold) = creditManager
.collateralTokensByMask(tokenMask);
uint256 balance = IERC20(token).balanceOf(creditAccount); // F:[FA-41]
if (balance > 1) {
uint256 value = priceOracle.convertToUSD(balance, token); // F:[FA-41]
unchecked {
totalUSD += value; // F:[FA-41]
}
twvUSD += value * liquidationThreshold; // F:[FA-41]
}
} // T:[FA-41]
tokenMask = tokenMask << 1; // F:[FA-41]
}
}
/**
* @dev Calculates health factor for the credit account
*
* sum(asset[i] * liquidation threshold[i])
* Hf = --------------------------------------------
* borrowed amount + interest accrued + fees
*
*
* More info: https://dev.gearbox.fi/developers/credit/economy#health-factor
*
* @param creditAccount Credit account address
* @return hf = Health factor in bp (see PERCENTAGE FACTOR in PercentageMath.sol)
*/
function calcCreditAccountHealthFactor(address creditAccount)
public
view
override
returns (uint256 hf)
{
(, uint256 twv) = calcTotalValue(creditAccount); // F:[FA-42]
(, , uint256 borrowAmountWithInterestAndFees) = creditManager
.calcCreditAccountAccruedInterest(creditAccount); // F:[FA-42]
hf = (twv * PERCENTAGE_FACTOR) / borrowAmountWithInterestAndFees; // F:[FA-42]
}
/// @dev Returns true if the borrower has an open Credit Account
/// @param borrower Borrower address
function hasOpenedCreditAccount(address borrower)
public
view
override
returns (bool)
{
return creditManager.creditAccounts(borrower) != address(0); // F:[FA-43]
}
/// @dev Wraps ETH into WETH and sends it back to msg.sender
function _wrapETH() internal {
if (msg.value > 0) {
IWETH(wethAddress).deposit{ value: msg.value }(); // F:[FA-3]
IWETH(wethAddress).transfer(msg.sender, msg.value); // F:[FA-3]
}
}
/// @dev Checks if account is liquidatable (i.e., hf < 1)
/// @param creditAccount Address of credit account to check
/// @return isLiquidatable True if account can be liquidated
/// @return totalValue Total value of the Credit Account in underlying
function _isAccountLiquidatable(address creditAccount)
internal
view
returns (bool isLiquidatable, uint256 totalValue)
{
IPriceOracleV2 priceOracle = IPriceOracleV2(
creditManager.priceOracle()
); // F:[FA-14]
(uint256 totalUSD, uint256 twvUSD) = _calcTotalValueUSD(
priceOracle,
creditAccount
);
// Computes total value in underlying
totalValue = priceOracle.convertFromUSD(totalUSD, underlying); // F:[FA-14]
(, , uint256 borrowAmountWithInterestAndFees) = creditManager
.calcCreditAccountAccruedInterest(creditAccount); // F:[FA-14]
// borrowAmountPlusInterestRateUSD x 10000 to be compared with USD values multiplied by LTs
uint256 borrowAmountPlusInterestRateUSD = priceOracle.convertToUSD(
borrowAmountWithInterestAndFees,
underlying
) * PERCENTAGE_FACTOR;
// Checks that current Hf < 1
isLiquidatable = twvUSD < borrowAmountPlusInterestRateUSD;
}
/// @dev Returns whether the Credit Facade is expired
function _isExpired() internal view returns (bool isExpired) {
isExpired = (expirable) && (block.timestamp >= params.expirationDate); // F: [FA-46,47,48]
}
//
// CONFIGURATION
//
/// @dev Sets the increaseDebtForbidden mode
/// @notice increaseDebtForbidden can be used to secure pool funds
/// without pausing the entire system. E.g., if a bug is reported
/// that can potentially lead to loss of funds, but there is no
/// immediate threat, new borrowing can be stopped, while other
/// functionality (trading, closing/liquidating accounts) is retained
function setIncreaseDebtForbidden(bool _mode)
external
creditConfiguratorOnly // F:[FA-44]
{
params.isIncreaseDebtForbidden = _mode;
}
/// @dev Sets borrowing limit per single block
/// @notice Borrowing limit per block in conjunction with
/// the monitoring system serves to minimize loss from hacks
/// While an attacker would be able to steal, in worst case,
/// up to (limitPerBlock * n blocks) of funds, the monitoring
/// system would pause the contracts after detecting suspicious
/// activity
function setLimitPerBlock(uint128 newLimit)
external
creditConfiguratorOnly // F:[FA-44]
{
params.maxBorrowedAmountPerBlock = newLimit;
}
/// @dev Sets Credit Facade expiration date
/// @notice See more at https://dev.gearbox.fi/docs/documentation/credit/liquidation#liquidating-accounts-by-expiration
function setExpirationDate(uint40 newExpirationDate)
external
creditConfiguratorOnly
{
if (!expirable) {
revert NotAllowedWhenNotExpirableException();
}
params.expirationDate = newExpirationDate;
}
/// @dev Sets borrowing limits per single Credit Account
/// @param _minBorrowedAmount The minimal borrowed amount per Credit Account. Minimal amount can be relevant
/// for liquidations, since very small amounts will make liquidations unprofitable for liquidators
/// @param _maxBorrowedAmount The maximal borrowed amount per Credit Account. Used to limit exposure per a single
/// credit account - especially relevant in whitelisted mode.
function setCreditAccountLimits(
uint128 _minBorrowedAmount,
uint128 _maxBorrowedAmount
) external creditConfiguratorOnly {
limits.minBorrowedAmount = _minBorrowedAmount; // F:
limits.maxBorrowedAmount = _maxBorrowedAmount; // F:
}
//
// CONTRACT WATCHLIST CONFIGURATION AND GETTERS
//
/// @dev Change upgradable contract state (add/remove depending on addOrRemove param).
/// Direct approvals are forbidden for contracts marked as "upgradeable" for
/// security reasions
/// @param addr Address to add to / remove from the list
/// @param addOrRemove True to be added, false to be removed
/// @notice Upgradeable contracts are contracts with an upgradeable proxy
/// Or other practices and patterns potentially detrimental to security
/// Contracts from the list have certain restrictions applied to them
function setUpgradeable(address addr, bool addOrRemove)
external
creditConfiguratorOnly
{
if (addOrRemove) {
upgradeableContracts.add(addr); // F: [FA-50]
} else {
upgradeableContracts.remove(addr); // F: [FA-50]
}
}
/// @dev Returns whether the address is in the list of upgradeable contracts
/// @param addr Address to check
function isUpgradeableContract(address addr) external view returns (bool) {
return upgradeableContracts.contains(addr); // F: [FA-50]
}
/// @dev Returns the entire upgradeable contract list
function upgradeableContractsList()
external
view
returns (address[] memory)
{
return upgradeableContracts.values(); // F: [FA-50]
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(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) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(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) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason 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 {
// 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// 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
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)
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.
*
* ```
* 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.
*/
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) {
return _values(set._inner);
}
// 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;
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 on 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;
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
struct MultiCall {
address target;
bytes callData;
}
library MultiCallOps {
function copyMulticall(MultiCall memory call)
internal
pure
returns (MultiCall memory)
{
return MultiCall({ target: call.target, callData: call.callData });
}
function trim(MultiCall[] memory calls)
internal
pure
returns (MultiCall[] memory trimmed)
{
uint256 len = calls.length;
if (len == 0) return calls;
uint256 foundLen;
while (calls[foundLen].target != address(0)) {
unchecked {
++foundLen;
if (foundLen == len) return calls;
}
}
if (foundLen > 0) return copy(calls, foundLen);
}
function copy(MultiCall[] memory calls, uint256 len)
internal
pure
returns (MultiCall[] memory res)
{
res = new MultiCall[](len);
for (uint256 i; i < len; ) {
res[i] = copyMulticall(calls[i]);
unchecked {
++i;
}
}
}
function clone(MultiCall[] memory calls)
internal
pure
returns (MultiCall[] memory res)
{
return copy(calls, calls.length);
}
function append(MultiCall[] memory calls, MultiCall memory newCall)
internal
pure
returns (MultiCall[] memory res)
{
uint256 len = calls.length;
res = new MultiCall[](len + 1);
for (uint256 i; i < len; ) {
res[i] = copyMulticall(calls[i]);
unchecked {
++i;
}
}
res[len] = copyMulticall(newCall);
}
function prepend(MultiCall[] memory calls, MultiCall memory newCall)
internal
pure
returns (MultiCall[] memory res)
{
uint256 len = calls.length;
res = new MultiCall[](len + 1);
res[0] = copyMulticall(newCall);
for (uint256 i = 1; i < len + 1; ) {
res[i] = copyMulticall(calls[i]);
unchecked {
++i;
}
}
}
function concat(MultiCall[] memory calls1, MultiCall[] memory calls2)
internal
pure
returns (MultiCall[] memory res)
{
uint256 len1 = calls1.length;
uint256 lenTotal = len1 + calls2.length;
if (lenTotal == calls1.length) return clone(calls1);
if (lenTotal == calls2.length) return clone(calls2);
res = new MultiCall[](lenTotal);
for (uint256 i; i < lenTotal; ) {
res[i] = (i < len1)
? copyMulticall(calls1[i])
: copyMulticall(calls2[i - len1]);
unchecked {
++i;
}
}
}
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
import { Balance } from "../libraries/Balances.sol";
import { MultiCall } from "../libraries/MultiCall.sol";
import { ICreditManagerV2, ICreditManagerV2Exceptions } from "./ICreditManagerV2.sol";
import { IVersion } from "./IVersion.sol";
interface ICreditFacadeExtended {
/// @dev Stores expected balances (computed as current balance + passed delta)
/// and compare with actual balances at the end of a multicall, reverts
/// if at least one is less than expected
/// @param expected Array of expected balance changes
/// @notice This is an extenstion function that does not exist in the Credit Facade
/// itself and can only be used within a multicall
function revertIfReceivedLessThan(Balance[] memory expected) external;
/// @dev Enables token in enabledTokenMask for the Credit Account of msg.sender
/// @param token Address of token to enable
function enableToken(address token) external;
/// @dev Disables a token on the caller's Credit Account
/// @param token Token to disable
/// @notice This is an extenstion function that does not exist in the Credit Facade
/// itself and can only be used within a multicall
function disableToken(address token) external;
/// @dev Adds collateral to borrower's credit account
/// @param onBehalfOf Address of the borrower whose account is funded
/// @param token Address of a collateral token
/// @param amount Amount to add
function addCollateral(
address onBehalfOf,
address token,
uint256 amount
) external payable;
/// @dev Increases debt for msg.sender's Credit Account
/// - Borrows the requested amount from the pool
/// - Updates the CA's borrowAmount / cumulativeIndexOpen
/// to correctly compute interest going forward
/// - Performs a full collateral check
///
/// @param amount Amount to borrow
function increaseDebt(uint256 amount) external;
/// @dev Decrease debt
/// - Decreases the debt by paying the requested amount + accrued interest + fees back to the pool
/// - It's also include to this payment interest accrued at the moment and fees
/// - Updates cunulativeIndex to cumulativeIndex now
///
/// @param amount Amount to increase borrowed amount
function decreaseDebt(uint256 amount) external;
}
interface ICreditFacadeEvents {
/// @dev Emits when a new Credit Account is opened through the
/// Credit Facade
event OpenCreditAccount(
address indexed onBehalfOf,
address indexed creditAccount,
uint256 borrowAmount,
uint16 referralCode
);
/// @dev Emits when the account owner closes their CA normally
event CloseCreditAccount(address indexed borrower, address indexed to);
/// @dev Emits when a Credit Account is liquidated due to low health factor
event LiquidateCreditAccount(
address indexed borrower,
address indexed liquidator,
address indexed to,
uint256 remainingFunds
);
/// @dev Emits when a Credit Account is liquidated due to expiry
event LiquidateExpiredCreditAccount(
address indexed borrower,
address indexed liquidator,
address indexed to,
uint256 remainingFunds
);
/// @dev Emits when the account owner increases CA's debt
event IncreaseBorrowedAmount(address indexed borrower, uint256 amount);
/// @dev Emits when the account owner reduces CA's debt
event DecreaseBorrowedAmount(address indexed borrower, uint256 amount);
/// @dev Emits when the account owner add new collateral to a CA
event AddCollateral(
address indexed onBehalfOf,
address indexed token,
uint256 value
);
/// @dev Emits when a multicall is started
event MultiCallStarted(address indexed borrower);
/// @dev Emits when a multicall is finished
event MultiCallFinished();
/// @dev Emits when Credit Account ownership is transferred
event TransferAccount(address indexed oldOwner, address indexed newOwner);
/// @dev Emits when the user changes approval for account transfers to itself from another address
event TransferAccountAllowed(
address indexed from,
address indexed to,
bool state
);
/// @dev Emits when the account owner enables a token on their CA
event TokenEnabled(address indexed borrower, address indexed token);
/// @dev Emits when the account owner disables a token on their CA
event TokenDisabled(address indexed borrower, address indexed token);
}
interface ICreditFacadeExceptions is ICreditManagerV2Exceptions {
/// @dev Thrown if the CreditFacade is not expirable, and an aciton is attempted that
/// requires expirability
error NotAllowedWhenNotExpirableException();
/// @dev Thrown if whitelisted mode is enabled, and an action is attempted that is
/// not allowed in whitelisted mode
error NotAllowedInWhitelistedMode();
/// @dev Thrown if a user attempts to transfer a CA to an address that didn't allow it
error AccountTransferNotAllowedException();
/// @dev Thrown if a liquidator tries to liquidate an account with a health factor above 1
error CantLiquidateWithSuchHealthFactorException();
/// @dev Thrown if a liquidator tries to liquidate an account by expiry while a Credit Facade is not expired
error CantLiquidateNonExpiredException();
/// @dev Thrown if call data passed to a multicall is too short
error IncorrectCallDataException();
/// @dev Thrown inside account closure multicall if the borrower attempts an action that is forbidden on closing
/// an account
error ForbiddenDuringClosureException();
/// @dev Thrown if debt increase and decrease are subsequently attempted in one multicall
error IncreaseAndDecreaseForbiddenInOneCallException();
/// @dev Thrown if a selector that doesn't match any allowed function is passed to the Credit Facade
/// during a multicall
error UnknownMethodException();
/// @dev Thrown if a user tries to open an account or increase debt with increaseDebtForbidden mode on
error IncreaseDebtForbiddenException();
/// @dev Thrown if the account owner tries to transfer an unhealthy account
error CantTransferLiquidatableAccountException();
/// @dev Thrown if too much new debt was taken within a single block
error BorrowedBlockLimitException();
/// @dev Thrown if the new debt principal for a CA falls outside of borrowing limits
error BorrowAmountOutOfLimitsException();
/// @dev Thrown if one of the balances on a Credit Account is less than expected
/// at the end of a multicall, if revertIfReceivedLessThan was called
error BalanceLessThanMinimumDesiredException(address);
/// @dev Thrown if a user attempts to open an account on a Credit Facade that has expired
error OpenAccountNotAllowedAfterExpirationException();
/// @dev Thrown if expected balances are attempted to be set through revertIfReceivedLessThan twice
error ExpectedBalancesAlreadySetException();
/// @dev Thrown if a Credit Account has enabled forbidden tokens and the owner attempts to perform an action
/// that is not allowed with any forbidden tokens enabled
error ActionProhibitedWithForbiddenTokensException();
}
interface ICreditFacade is
ICreditFacadeEvents,
ICreditFacadeExceptions,
IVersion
{
//
// CREDIT ACCOUNT MANAGEMENT
//
/// @dev Opens credit account, borrows funds from the pool and pulls collateral
/// without any additional action.
/// @param amount The amount of collateral provided by the borrower
/// @param onBehalfOf The address to open an account for. Transfers to it have to be allowed if
/// msg.sender != obBehalfOf
/// @param leverageFactor Percentage of the user's own funds to borrow. 100 is equal to 100% - borrows the same amount
/// as the user's own collateral, equivalent to 2x leverage.
/// @param referralCode Referral code that is used for potential rewards. 0 if no referral code provided.
function openCreditAccount(
uint256 amount,
address onBehalfOf,
uint16 leverageFactor,
uint16 referralCode
) external payable;
/// @dev Opens a Credit Account and runs a batch of operations in a multicall
/// @param borrowedAmount Debt size
/// @param onBehalfOf The address to open an account for. Transfers to it have to be allowed if
/// msg.sender != obBehalfOf
/// @param calls The array of MultiCall structs encoding the required operations. Generally must have
/// at least a call to addCollateral, as otherwise the health check at the end will fail.
/// @param referralCode Referral code which is used for potential rewards. 0 if no referral code provided
function openCreditAccountMulticall(
uint256 borrowedAmount,
address onBehalfOf,
MultiCall[] calldata calls,
uint16 referralCode
) external payable;
/// @dev Runs a batch of transactions within a multicall and closes the account
/// - Wraps ETH to WETH and sends it msg.sender if value > 0
/// - Executes the multicall - the main purpose of a multicall when closing is to convert all assets to underlying
/// in order to pay the debt.
/// - Closes credit account:
/// + Checks the underlying balance: if it is greater than the amount paid to the pool, transfers the underlying
/// from the Credit Account and proceeds. If not, tries to transfer the shortfall from msg.sender.
/// + Transfers all enabled assets with non-zero balances to the "to" address, unless they are marked
/// to be skipped in skipTokenMask
/// + If convertWETH is true, converts WETH into ETH before sending to the recipient
/// - Emits a CloseCreditAccount event
///
/// @param to Address to send funds to during account closing
/// @param skipTokenMask Uint-encoded bit mask where 1's mark tokens that shouldn't be transferred
/// @param convertWETH If true, converts WETH into ETH before sending to "to"
/// @param calls The array of MultiCall structs encoding the operations to execute before closing the account.
function closeCreditAccount(
address to,
uint256 skipTokenMask,
bool convertWETH,
MultiCall[] calldata calls
) external payable;
/// @dev Runs a batch of transactions within a multicall and liquidates the account
/// - Computes the total value and checks that hf < 1. An account can't be liquidated when hf >= 1.
/// Total value has to be computed before the multicall, otherwise the liquidator would be able
/// to manipulate it.
/// - Wraps ETH to WETH and sends it to msg.sender (liquidator) if value > 0
/// - Executes the multicall - the main purpose of a multicall when liquidating is to convert all assets to underlying
/// in order to pay the debt.
/// - Liquidate credit account:
/// + Computes the amount that needs to be paid to the pool. If totalValue * liquidationDiscount < borrow + interest + fees,
/// only totalValue * liquidationDiscount has to be paid. Since liquidationDiscount < 1, the liquidator can take
/// totalValue * (1 - liquidationDiscount) as premium. Also computes the remaining funds to be sent to borrower
/// as totalValue * liquidationDiscount - amountToPool.
/// + Checks the underlying balance: if it is greater than amountToPool + remainingFunds, transfers the underlying
/// from the Credit Account and proceeds. If not, tries to transfer the shortfall from the liquidator.
/// + Transfers all enabled assets with non-zero balances to the "to" address, unless they are marked
/// to be skipped in skipTokenMask. If the liquidator is confident that all assets were converted
/// during the multicall, they can set the mask to uint256.max - 1, to only transfer the underlying
/// + If convertWETH is true, converts WETH into ETH before sending
/// - Emits LiquidateCreditAccount event
///
/// @param to Address to send funds to after liquidation
/// @param skipTokenMask Uint-encoded bit mask where 1's mark tokens that shouldn't be transferred
/// @param convertWETH If true, converts WETH into ETH before sending to "to"
/// @param calls The array of MultiCall structs encoding the operations to execute before liquidating the account.
function liquidateCreditAccount(
address borrower,
address to,
uint256 skipTokenMask,
bool convertWETH,
MultiCall[] calldata calls
) external payable;
/// @dev Runs a batch of transactions within a multicall and liquidates the account when
/// this Credit Facade is expired
/// The general flow of liquidation is nearly the same as normal liquidations, with two main differences:
/// - An account can be liquidated on an expired Credit Facade even with hf > 1. However,
/// no accounts can be liquidated through this function if the Credit Facade is not expired.
/// - Liquidation premiums and fees for liquidating expired accounts are reduced.
/// It is still possible to normally liquidate an underwater Credit Account, even when the Credit Facade
/// is expired.
/// @param to Address to send funds to after liquidation
/// @param skipTokenMask Uint-encoded bit mask where 1's mark tokens that shouldn't be transferred
/// @param convertWETH If true, converts WETH into ETH before sending to "to"
/// @param calls The array of MultiCall structs encoding the operations to execute before liquidating the account.
/// @notice See more at https://dev.gearbox.fi/docs/documentation/credit/liquidation#liquidating-accounts-by-expiration
function liquidateExpiredCreditAccount(
address borrower,
address to,
uint256 skipTokenMask,
bool convertWETH,
MultiCall[] calldata calls
) external payable;
/// @dev Increases debt for msg.sender's Credit Account
/// - Borrows the requested amount from the pool
/// - Updates the CA's borrowAmount / cumulativeIndexOpen
/// to correctly compute interest going forward
/// - Performs a full collateral check
///
/// @param amount Amount to borrow
function increaseDebt(uint256 amount) external;
/// @dev Decrease debt
/// - Decreases the debt by paying the requested amount + accrued interest + fees back to the pool
/// - It's also include to this payment interest accrued at the moment and fees
/// - Updates cunulativeIndex to cumulativeIndex now
///
/// @param amount Amount to increase borrowed amount
function decreaseDebt(uint256 amount) external;
/// @dev Adds collateral to borrower's credit account
/// @param onBehalfOf Address of the borrower whose account is funded
/// @param token Address of a collateral token
/// @param amount Amount to add
function addCollateral(
address onBehalfOf,
address token,
uint256 amount
) external payable;
/// @dev Executes a batch of transactions within a Multicall, to manage an existing account
/// - Wraps ETH and sends it back to msg.sender, if value > 0
/// - Executes the Multicall
/// - Performs a fullCollateralCheck to verify that hf > 1 after all actions
/// @param calls The array of MultiCall structs encoding the operations to execute.
function multicall(MultiCall[] calldata calls) external payable;
/// @dev Returns true if the borrower has an open Credit Account
/// @param borrower Borrower address
function hasOpenedCreditAccount(address borrower)
external
view
returns (bool);
/// @dev Sets token allowance from msg.sender's Credit Account to a connected target contract
/// @param targetContract Contract to set allowance to. Cannot be in the list of upgradeable contracts
/// @param token Token address
/// @param amount Allowance amount
function approve(
address targetContract,
address token,
uint256 amount
) external;
/// @dev Approves account transfer from another user to msg.sender
/// @param from Address for which account transfers are allowed/forbidden
/// @param state True is transfer is allowed, false if forbidden
function approveAccountTransfer(address from, bool state) external;
/// @dev Enables token in enabledTokenMask for the Credit Account of msg.sender
/// @param token Address of token to enable
function enableToken(address token) external;
/// @dev Transfers credit account to another user
/// By default, this action is forbidden, and the user has to approve transfers from sender to itself
/// by calling approveAccountTransfer.
/// This is done to prevent malicious actors from transferring compromised accounts to other users.
/// @param to Address to transfer the account to
function transferAccountOwnership(address to) external;
//
// GETTERS
//
/// @dev Calculates total value for provided Credit Account in underlying
///
/// @param creditAccount Credit Account address
/// @return total Total value in underlying
/// @return twv Total weighted (discounted by liquidation thresholds) value in underlying
function calcTotalValue(address creditAccount)
external
view
returns (uint256 total, uint256 twv);
/**
* @dev Calculates health factor for the credit account
*
* sum(asset[i] * liquidation threshold[i])
* Hf = --------------------------------------------
* borrowed amount + interest accrued + fees
*
*
* More info: https://dev.gearbox.fi/developers/credit/economy#health-factor
*
* @param creditAccount Credit account address
* @return hf = Health factor in bp (see PERCENTAGE FACTOR in PercentageMath.sol)
*/
function calcCreditAccountHealthFactor(address creditAccount)
external
view
returns (uint256 hf);
/// @dev Returns true if token is a collateral token and is not forbidden,
/// otherwise returns false
/// @param token Token to check
function isTokenAllowed(address token) external view returns (bool);
/// @dev Returns the CreditManager connected to this Credit Facade
function creditManager() external view returns (ICreditManagerV2);
/// @dev Returns true if 'from' is allowed to transfer Credit Accounts to 'to'
/// @param from Sender address to check allowance for
/// @param to Receiver address to check allowance for
function transfersAllowed(address from, address to)
external
view
returns (bool);
/// @return maxBorrowedAmountPerBlock Maximal amount of new debt that can be taken per block
/// @return isIncreaseDebtForbidden True if increasing debt is forbidden
/// @return expirationDate Timestamp of the next expiration (for expirable Credit Facades only)
function params()
external
view
returns (
uint128 maxBorrowedAmountPerBlock,
bool isIncreaseDebtForbidden,
uint40 expirationDate
);
/// @return minBorrowedAmount Minimal borrowed amount per credit account
/// @return maxBorrowedAmount Maximal borrowed amount per credit account
function limits()
external
view
returns (uint128 minBorrowedAmount, uint128 maxBorrowedAmount);
/// @dev Address of the DegenNFT that gatekeeps account openings in whitelisted mode
function degenNFT() external view returns (address);
/// @dev Address of the underlying asset
function underlying() external view returns (address);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
struct Balance {
address token;
uint256 balance;
}
library BalanceOps {
error UnknownToken(address);
function copyBalance(Balance memory b)
internal
pure
returns (Balance memory)
{
return Balance({ token: b.token, balance: b.balance });
}
function addBalance(
Balance[] memory b,
address token,
uint256 amount
) internal pure {
b[getIndex(b, token)].balance += amount;
}
function subBalance(
Balance[] memory b,
address token,
uint256 amount
) internal pure {
b[getIndex(b, token)].balance -= amount;
}
function getBalance(Balance[] memory b, address token)
internal
pure
returns (uint256 amount)
{
return b[getIndex(b, token)].balance;
}
function setBalance(
Balance[] memory b,
address token,
uint256 amount
) internal pure {
b[getIndex(b, token)].balance = amount;
}
function getIndex(Balance[] memory b, address token)
internal
pure
returns (uint256 index)
{
for (uint256 i; i < b.length; ) {
if (b[i].token == token) {
return i;
}
unchecked {
++i;
}
}
revert UnknownToken(token);
}
function copy(Balance[] memory b, uint256 len)
internal
pure
returns (Balance[] memory res)
{
res = new Balance[](len);
for (uint256 i; i < len; ) {
res[i] = copyBalance(b[i]);
unchecked {
++i;
}
}
}
function clone(Balance[] memory b)
internal
pure
returns (Balance[] memory)
{
return copy(b, b.length);
}
function getModifiedAfterSwap(
Balance[] memory b,
address tokenFrom,
uint256 amountFrom,
address tokenTo,
uint256 amountTo
) internal pure returns (Balance[] memory res) {
res = copy(b, b.length);
setBalance(res, tokenFrom, getBalance(b, tokenFrom) - amountFrom);
setBalance(res, tokenTo, getBalance(b, tokenTo) + amountTo);
}
}// 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; // 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 { IVersion } from "./IVersion.sol";
import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
interface IDegenNFTExceptions {
/// @dev Thrown if an access-restricted function was called by non-CreditFacade
error CreditFacadeOrConfiguratorOnlyException();
/// @dev Thrown if an access-restricted function was called by non-minter
error MinterOnlyException();
/// @dev Thrown if trying to add a burner address that is not a correct Credit Facade
error InvalidCreditFacadeException();
/// @dev Thrown if the account's balance is not sufficient for an action (usually a burn)
error InsufficientBalanceException();
}
interface IDegenNFTEvents {
/// @dev Minted when new minter set
event NewMinterSet(address indexed);
/// @dev Minted each time when new credit facade added
event NewCreditFacadeAdded(address indexed);
/// @dev Minted each time when new credit facade added
event NewCreditFacadeRemoved(address indexed);
}
interface IDegenNFT is
IDegenNFTExceptions,
IDegenNFTEvents,
IVersion,
IERC721Metadata
{
/// @dev address of the current minter
function minter() external view returns (address);
/// @dev Stores the total number of tokens on holder accounts
function totalSupply() external view returns (uint256);
/// @dev Stores the base URI for NFT metadata
function baseURI() external view returns (string memory);
/// @dev Mints a specified amount of tokens to the address
/// @param to Address the tokens are minted to
/// @param amount The number of tokens to mint
function mint(address to, uint256 amount) external;
/// @dev Burns a number of tokens from a specified address
/// @param from The address a token will be burnt from
/// @param amount The number of tokens to burn
function burn(address from, uint256 amount) external;
}// 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: agpl-3.0
pragma solidity ^0.8.10;
import { Errors } from "./Errors.sol";
uint16 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals
uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2;
/**
* @title PercentageMath library
* @author Aave
* @notice Provides functions to perform percentage calculations
* @dev Percentages are defined by default with 2 decimals of precision (100.00). The precision is indicated by PERCENTAGE_FACTOR
* @dev Operations are rounded half up
**/
library PercentageMath {
/**
* @dev Executes a percentage multiplication
* @param value The value of which the percentage needs to be calculated
* @param percentage The percentage of the value to be calculated
* @return The percentage of value
**/
function percentMul(uint256 value, uint256 percentage)
internal
pure
returns (uint256)
{
if (value == 0 || percentage == 0) {
return 0; // T:[PM-1]
}
// require(
// value <= (type(uint256).max - HALF_PERCENT) / percentage,
// Errors.MATH_MULTIPLICATION_OVERFLOW
// ); // T:[PM-1]
return (value * percentage + HALF_PERCENT) / PERCENTAGE_FACTOR; // T:[PM-1]
}
/**
* @dev Executes a percentage division
* @param value The value of which the percentage needs to be calculated
* @param percentage The percentage of the value to be calculated
* @return The value divided the percentage
**/
function percentDiv(uint256 value, uint256 percentage)
internal
pure
returns (uint256)
{
require(percentage != 0, Errors.MATH_DIVISION_BY_ZERO); // T:[PM-2]
uint256 halfPercentage = percentage / 2; // T:[PM-2]
// require(
// value <= (type(uint256).max - halfPercentage) / PERCENTAGE_FACTOR,
// Errors.MATH_MULTIPLICATION_OVERFLOW
// ); // T:[PM-2]
return (value * PERCENTAGE_FACTOR + halfPercentage) / percentage;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.7.4;
interface IWETH {
/// @dev Deposits native ETH into the contract and mints WETH
function deposit() external payable;
/// @dev Transfers WETH to another account
function transfer(address to, uint256 value) external returns (bool);
/// @dev Burns WETH from msg.sender and send back native ETH
function withdraw(uint256) external;
}// 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: 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Holdings, 2022
pragma solidity ^0.8.10;
/// @title Errors library
library Errors {
//
// COMMON
//
string public constant ZERO_ADDRESS_IS_NOT_ALLOWED = "Z0";
string public constant NOT_IMPLEMENTED = "NI";
string public constant INCORRECT_PATH_LENGTH = "PL";
string public constant INCORRECT_ARRAY_LENGTH = "CR";
string public constant REGISTERED_CREDIT_ACCOUNT_MANAGERS_ONLY = "CP";
string public constant REGISTERED_POOLS_ONLY = "RP";
string public constant INCORRECT_PARAMETER = "IP";
//
// MATH
//
string public constant MATH_MULTIPLICATION_OVERFLOW = "M1";
string public constant MATH_ADDITION_OVERFLOW = "M2";
string public constant MATH_DIVISION_BY_ZERO = "M3";
//
// POOL
//
string public constant POOL_CONNECTED_CREDIT_MANAGERS_ONLY = "PS0";
string public constant POOL_INCOMPATIBLE_CREDIT_ACCOUNT_MANAGER = "PS1";
string public constant POOL_MORE_THAN_EXPECTED_LIQUIDITY_LIMIT = "PS2";
string public constant POOL_INCORRECT_WITHDRAW_FEE = "PS3";
string public constant POOL_CANT_ADD_CREDIT_MANAGER_TWICE = "PS4";
//
// ACCOUNT FACTORY
//
string public constant AF_CANT_CLOSE_CREDIT_ACCOUNT_IN_THE_SAME_BLOCK =
"AF1";
string public constant AF_MINING_IS_FINISHED = "AF2";
string public constant AF_CREDIT_ACCOUNT_NOT_IN_STOCK = "AF3";
string public constant AF_EXTERNAL_ACCOUNTS_ARE_FORBIDDEN = "AF4";
//
// ADDRESS PROVIDER
//
string public constant AS_ADDRESS_NOT_FOUND = "AP1";
//
// CONTRACTS REGISTER
//
string public constant CR_POOL_ALREADY_ADDED = "CR1";
string public constant CR_CREDIT_MANAGER_ALREADY_ADDED = "CR2";
//
// CREDIT ACCOUNT
//
string public constant CA_CONNECTED_CREDIT_MANAGER_ONLY = "CA1";
string public constant CA_FACTORY_ONLY = "CA2";
//
// ACL
//
string public constant ACL_CALLER_NOT_PAUSABLE_ADMIN = "ACL1";
string public constant ACL_CALLER_NOT_CONFIGURATOR = "ACL2";
//
// WETH GATEWAY
//
string public constant WG_DESTINATION_IS_NOT_WETH_COMPATIBLE = "WG1";
string public constant WG_RECEIVE_IS_NOT_ALLOWED = "WG2";
string public constant WG_NOT_ENOUGH_FUNDS = "WG3";
//
// TOKEN DISTRIBUTOR
//
string public constant TD_WALLET_IS_ALREADY_CONNECTED_TO_VC = "TD1";
string public constant TD_INCORRECT_WEIGHTS = "TD2";
string public constant TD_NON_ZERO_BALANCE_AFTER_DISTRIBUTION = "TD3";
string public constant TD_CONTRIBUTOR_IS_NOT_REGISTERED = "TD4";
}{
"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
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_creditManager","type":"address"},{"internalType":"address","name":"_degenNFT","type":"address"},{"internalType":"bool","name":"_expirable","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccountTransferNotAllowedException","type":"error"},{"inputs":[],"name":"ActionProhibitedWithForbiddenTokensException","type":"error"},{"inputs":[],"name":"AdaptersOrCreditFacadeOnlyException","type":"error"},{"inputs":[],"name":"AllowanceFailedException","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"BalanceLessThanMinimumDesiredException","type":"error"},{"inputs":[],"name":"BorrowAmountOutOfLimitsException","type":"error"},{"inputs":[],"name":"BorrowedBlockLimitException","type":"error"},{"inputs":[],"name":"CantLiquidateNonExpiredException","type":"error"},{"inputs":[],"name":"CantLiquidateWithSuchHealthFactorException","type":"error"},{"inputs":[],"name":"CantTransferLiquidatableAccountException","type":"error"},{"inputs":[],"name":"CreditConfiguratorOnlyException","type":"error"},{"inputs":[],"name":"CreditFacadeOnlyException","type":"error"},{"inputs":[],"name":"ExpectedBalancesAlreadySetException","type":"error"},{"inputs":[],"name":"ForbiddenDuringClosureException","type":"error"},{"inputs":[],"name":"HasNoOpenedAccountException","type":"error"},{"inputs":[],"name":"IncorrectCallDataException","type":"error"},{"inputs":[],"name":"IncreaseAndDecreaseForbiddenInOneCallException","type":"error"},{"inputs":[],"name":"IncreaseDebtForbiddenException","type":"error"},{"inputs":[],"name":"NotAllowedInWhitelistedMode","type":"error"},{"inputs":[],"name":"NotAllowedWhenNotExpirableException","type":"error"},{"inputs":[],"name":"NotEnoughCollateralException","type":"error"},{"inputs":[],"name":"OpenAccountNotAllowedAfterExpirationException","type":"error"},{"inputs":[],"name":"ReentrancyLockException","type":"error"},{"inputs":[],"name":"TargetContractNotAllowedException","type":"error"},{"inputs":[],"name":"TokenAlreadyAddedException","type":"error"},{"inputs":[],"name":"TokenNotAllowedException","type":"error"},{"inputs":[],"name":"TooManyEnabledTokensException","type":"error"},{"inputs":[],"name":"TooManyTokensException","type":"error"},{"inputs":[],"name":"UnknownMethodException","type":"error"},{"inputs":[],"name":"ZeroAddressException","type":"error"},{"inputs":[],"name":"ZeroAddressOrUserAlreadyHasAccountException","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"AddCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"CloseCreditAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DecreaseBorrowedAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IncreaseBorrowedAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"remainingFunds","type":"uint256"}],"name":"LiquidateCreditAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"remainingFunds","type":"uint256"}],"name":"LiquidateExpiredCreditAccount","type":"event"},{"anonymous":false,"inputs":[],"name":"MultiCallFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"}],"name":"MultiCallStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":true,"internalType":"address","name":"creditAccount","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"OpenCreditAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"TokenDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"TokenEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"TransferAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"bool","name":"state","type":"bool"}],"name":"TransferAccountAllowed","type":"event"},{"inputs":[{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"state","type":"bool"}],"name":"approveAccountTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"}],"name":"calcCreditAccountHealthFactor","outputs":[{"internalType":"uint256","name":"hf","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creditAccount","type":"address"}],"name":"calcTotalValue","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"twv","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"skipTokenMask","type":"uint256"},{"internalType":"bool","name":"convertWETH","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct MultiCall[]","name":"calls","type":"tuple[]"}],"name":"closeCreditAccount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"creditManager","outputs":[{"internalType":"contract ICreditManagerV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decreaseDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"degenNFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"enableToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expirable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalBorrowedInBlock","outputs":[{"internalType":"uint64","name":"blockLastUpdate","type":"uint64"},{"internalType":"uint128","name":"borrowedInBlock","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"hasOpenedCreditAccount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"increaseDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenAllowed","outputs":[{"internalType":"bool","name":"allowed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isUpgradeableContract","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limits","outputs":[{"internalType":"uint128","name":"minBorrowedAmount","type":"uint128"},{"internalType":"uint128","name":"maxBorrowedAmount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"skipTokenMask","type":"uint256"},{"internalType":"bool","name":"convertWETH","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct MultiCall[]","name":"calls","type":"tuple[]"}],"name":"liquidateCreditAccount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"skipTokenMask","type":"uint256"},{"internalType":"bool","name":"convertWETH","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct MultiCall[]","name":"calls","type":"tuple[]"}],"name":"liquidateExpiredCreditAccount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct MultiCall[]","name":"calls","type":"tuple[]"}],"name":"multicall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint16","name":"leverageFactor","type":"uint16"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"openCreditAccount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"borrowedAmount","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct MultiCall[]","name":"calls","type":"tuple[]"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"openCreditAccountMulticall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"params","outputs":[{"internalType":"uint128","name":"maxBorrowedAmountPerBlock","type":"uint128"},{"internalType":"bool","name":"isIncreaseDebtForbidden","type":"bool"},{"internalType":"uint40","name":"expirationDate","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_minBorrowedAmount","type":"uint128"},{"internalType":"uint128","name":"_maxBorrowedAmount","type":"uint128"}],"name":"setCreditAccountLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint40","name":"newExpirationDate","type":"uint40"}],"name":"setExpirationDate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_mode","type":"bool"}],"name":"setIncreaseDebtForbidden","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"newLimit","type":"uint128"}],"name":"setLimitPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"addOrRemove","type":"bool"}],"name":"setUpgradeable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"transferAccountOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"transfersAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"upgradeableContractsList","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wethAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6101406040523480156200001257600080fd5b50604051620062cb380380620062cb833981016040819052620000359162000198565b60016000556001600160a01b0383166200006257604051635919af9760e11b815260040160405180910390fd5b6001600160a01b038316608081905260408051636f307dc360e01b81529051636f307dc3916004808201926020929091908290030181865afa158015620000ad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d39190620001ea565b6001600160a01b031660e0816001600160a01b031681525050826001600160a01b0316634f0e0ef36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200012b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001519190620001ea565b6001600160a01b039081166101005291909116610120819052151560a052151560c052506200020f565b80516001600160a01b03811681146200019357600080fd5b919050565b600080600060608486031215620001ae57600080fd5b620001b9846200017b565b9250620001c9602085016200017b565b915060408401518015158114620001df57600080fd5b809150509250925092565b600060208284031215620001fd57600080fd5b62000208826200017b565b9392505050565b60805160a05160c05160e0516101005161012051615eac6200041f60003960008181610521015281816141640152614264015260008181610315015281816136bf015261376f01526000818161045d01528181611cc10152818161269e0152818161275c015281816134a9015261361d0152600081816105db01528181612deb01526142fd0152600081816102e101528181610d6801528181613f6301526141a001526000818161060f0152818161096201528181610a8d01528181610b5f01528181610c6701528181610def01528181610f6d015281816110d801528181611198015281816112b8015281816113fb015281816115d6015281816116b30152818161178b015281816118ad01528181611aa801528181611bd501528181611deb01528181611f2b0152818161204d01528181612195015281816122e0015281816124b601528181612588015281816125be0152818161288c0152818161297001528181612a2f01528181612b7a01528181612c9e01528181612cf801528181612ed701528181612f5101528181612fea0152818161317701528181613300015281816133c90152818161356e0152818161385c0152818161395e01528181613a2b01528181613c3401528181613d3c01528181613eb7015281816143a3015281816144980152818161455e0152818161478a015281816147fd01528181614afe015261524c0152615eac6000f3fe6080604052600436106102335760003560e01c806382871ace11610138578063c7de38a6116100b0578063dfd594651161007f578063eb9606df11610064578063eb9606df146107a8578063f9eaee0d146107c8578063ffd9b907146107e857600080fd5b8063dfd5946514610768578063e1f21c671461078857600080fd5b8063c7de38a614610651578063caa5c23f14610686578063cff0ab9614610699578063d9ccbec11461072d57600080fd5b80639be0536a11610107578063b1836d32116100ec578063b1836d32146105c9578063c12c21c0146105fd578063c690908a1461063157600080fd5b80639be0536a146105875780639c55a054146105a957600080fd5b806382871ace14610492578063860aefcf146104a55780639408b63f1461050f5780639b67ab301461054357600080fd5b806359781034116101cb5780636a03706f1161019a5780636d19b4861161017f5780636d19b4861461042b5780636f307dc31461044b5780637071b7c51461047f57600080fd5b80636a03706f146103f85780636c8f225d1461041857600080fd5b8063597810341461039f5780635d91a0e0146103b25780635f73fbec146103c5578063601d66f6146103d857600080fd5b80633d9287fa116102075780633d9287fa146102cf5780634f0e0ef3146103035780635019e20a1461035c57806354fd4d501461037c57600080fd5b8062842b5714610238578063256ac9151461025a5780632a7ba1f71461028f5780632b7c7b11146102af575b600080fd5b34801561024457600080fd5b50610258610253366004615499565b610808565b005b34801561026657600080fd5b5061027a6102753660046154d2565b610918565b60405190151581526020015b60405180910390f35b34801561029b57600080fd5b506102586102aa3660046154ef565b6109eb565b3480156102bb57600080fd5b506102586102ca3660046154ef565b610bc5565b3480156102db57600080fd5b5061027a7f000000000000000000000000000000000000000000000000000000000000000081565b34801561030f57600080fd5b506103377f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610286565b34801561036857600080fd5b506102586103773660046154d2565b610cf4565b34801561038857600080fd5b50610391600281565b604051908152602001610286565b6102586103ad366004615508565b611016565b6102586103c0366004615595565b6111ff565b6102586103d336600461561a565b611534565b3480156103e457600080fd5b506102586103f33660046156b2565b611789565b34801561040457600080fd5b50610258610413366004615499565b6118ab565b6102586104263660046156f5565b6119c3565b34801561043757600080fd5b5061027a6104463660046154d2565b611cf4565b34801561045757600080fd5b506103377f000000000000000000000000000000000000000000000000000000000000000081565b61025861048d366004615748565b611d07565b6102586104a0366004615595565b611f94565b3480156104b157600080fd5b506002546104e6906fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610286565b34801561051b57600080fd5b506103377f000000000000000000000000000000000000000000000000000000000000000081565b34801561054f57600080fd5b506004546040805167ffffffffffffffff608084901c1681526fffffffffffffffffffffffffffffffff909216602083015201610286565b34801561059357600080fd5b5061059c6122cd565b60405161028691906157bc565b3480156105b557600080fd5b506102586105c4366004615816565b6122de565b3480156105d557600080fd5b5061027a7f000000000000000000000000000000000000000000000000000000000000000081565b34801561060957600080fd5b506103377f000000000000000000000000000000000000000000000000000000000000000081565b34801561063d57600080fd5b5061025861064c3660046154d2565b612414565b34801561065d57600080fd5b5061067161066c3660046154d2565b6125b7565b60408051928352602083019190915201610286565b610258610694366004615831565b6127ea565b3480156106a557600080fd5b506001546106f8906fffffffffffffffffffffffffffffffff811690700100000000000000000000000000000000810460ff169071010000000000000000000000000000000000900464ffffffffff1683565b604080516fffffffffffffffffffffffffffffffff9094168452911515602084015264ffffffffff1690820152606001610286565b34801561073957600080fd5b5061027a610748366004615873565b600360209081526000928352604080842090915290825290205460ff1681565b34801561077457600080fd5b506103916107833660046154d2565b6129d7565b34801561079457600080fd5b506102586107a3366004615508565b612ac1565b3480156107b457600080fd5b506102586107c33660046158a1565b612cf6565b3480156107d457600080fd5b5061027a6107e33660046154d2565b612e8d565b3480156107f457600080fd5b506102586108033660046158c8565b612fe8565b6002600054141561087a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600090815573ffffffffffffffffffffffffffffffffffffffff8316808252600360209081526040808420338086529083529381902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081527f9b3258bc4904fd6426b99843e206c6c7cdb1fd0f040121c25b71dafbb3851ee0910160405180910390a350506001600055565b6040517f055ee9b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063055ee9b590602401602060405180830381865afa1580156109a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109cd91906158e5565b73ffffffffffffffffffffffffffffffffffffffff16141592915050565b60026000541415610a58576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0d91906158e5565b9050610b1a338284613121565b6040517f9537301800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000000000000000000000000000000000000000000016906395373018906024015b600060405180830381600087803b158015610ba457600080fd5b505af1158015610bb8573d6000803e3d6000fd5b5050600160005550505050565b60026000541415610c32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610cc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce791906158e5565b9050610b1a338284613247565b60026000541415610d61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b60026000557f000000000000000000000000000000000000000000000000000000000000000015610dbe576040517f5aa6676700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6f91906158e5565b33600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915290205490915060ff16610edc576040517f85b0772600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610ee7826133c2565b5090508015610f22576040517ff713841e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fe1998cf900000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063e1998cf990604401600060405180830381600087803b158015610fb157600080fd5b505af1158015610fc5573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff861692503391507f93c70cc9715bef0d83edf2095f3595402279d274f402a73ffc17f1bcb19d863d90600090a35050600160005550565b60026000541415611083576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b60026000556110906136b7565b6040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063e958b70490602401602060405180830381865afa158015611121573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114591906158e5565b9050611153848285856137f9565b6040517f29df0b9300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000000000000000000000000000000000000000000016906329df0b9390602401600060405180830381600087803b1580156111dc57600080fd5b505af11580156111f0573d6000803e3d6000fd5b50506001600055505050505050565b6002600054141561126c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e958b70490602401602060405180830381865afa1580156112ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132391906158e5565b905073ffffffffffffffffffffffffffffffffffffffff8616611372576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008061137e836133c2565b91509150816113b9576040517f1fdd676f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113c16136b7565b60006113cd6001613925565b905084156113e5576113e586868c87600160006139e0565b80156113f7576113f56000613925565b505b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632362a2d88c600186338f8f8f6040518863ffffffff1660e01b815260040161145f979695949392919061593d565b6020604051808303816000875af115801561147e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a29190615999565b90508973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff167f7dfecd8419723a9d3954585a30c2a270165d70aafa146c11c1e1b88ae14390648460405161151a91815260200190565b60405180910390a450506001600055505050505050505050565b600260005414156115a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015611632573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165691906158e5565b90506116606136b7565b81156116765761167683833384600160006139e0565b6040517f2362a2d800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690632362a2d8906116f5903390600090819083908d908d908d9060040161593d565b6020604051808303816000875af1158015611714573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117389190615999565b5060405173ffffffffffffffffffffffffffffffffffffffff87169033907f460ad03b1cf79b1d64d3aefa28475f110ab66e84649c52bb41ed796b9b39198190600090a35050600160005550505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181891906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461187c576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002911617600255565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193a91906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461199e576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80156119b4576119af600583613f1d565b505050565b6119af600583613f3f565b5050565b60026000541415611a30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556064611a4761ffff8516876159e1565b611a519190615a1e565b9050611a5c81613f61565b611a6581614052565b611a6e846140d2565b611a766136b7565b6040517f172c48c7000000000000000000000000000000000000000000000000000000008152600060048201819052907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063172c48c7906024016040805180830381865afa158015611b03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b279190615a59565b61ffff169150611b3b905081612710615a88565b611b4590836159e1565b611b4f82886159e1565b11611b86576040517f532e7bb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f8fe3f93f0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff86811660248301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638fe3f93f906044016020604051808303816000875af1158015611c20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4491906158e5565b90508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167ffa2baf5d3eb95569f312f22477b246f9d4c50276f1cb3ded8e1aeadcbc07a7638587604051611cb292919091825261ffff16602082015260400190565b60405180910390a3611ce686827f00000000000000000000000000000000000000000000000000000000000000008a6137f9565b505060016000555050505050565b6000611d016005836142ca565b92915050565b60026000541415611d74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b6002600055611d8285613f61565b611d8b846140d2565b611d9485614052565b611d9c6136b7565b6040517f8fe3f93f0000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff85811660248301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638fe3f93f906044016020604051808303816000875af1158015611e36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5a91906158e5565b90508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167ffa2baf5d3eb95569f312f22477b246f9d4c50276f1cb3ded8e1aeadcbc07a7638885604051611ec892919091825261ffff16602082015260400190565b60405180910390a38215611ee657611ee684848784600060016139e0565b6040517f9537301800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f00000000000000000000000000000000000000000000000000000000000000001690639537301890602401600060405180830381600087803b158015611f6f57600080fd5b505af1158015611f83573d6000803e3d6000fd5b505060016000555050505050505050565b60026000541415612001576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e958b70490602401602060405180830381865afa158015612094573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b891906158e5565b905073ffffffffffffffffffffffffffffffffffffffff8616612107576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61210f6142f9565b612145576040517f7e52ccb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612150826125b7565b50905061215b6136b7565b60006121676001613925565b9050831561217f5761217f85858b86600160006139e0565b80156121915761218f6000613925565b505b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632362a2d88b600286338e8e8e6040518863ffffffff1660e01b81526004016121f9979695949392919061593d565b6020604051808303816000875af1158015612218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223c9190615999565b90508873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167ffada13ff2d5e1a1d9da37ad4a4130893b34e3c69c32b17f87ec31fd661b86707846040516122b491815260200190565b60405180910390a4505060016000555050505050505050565b60606122d96005614349565b905090565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236d91906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146123d1576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b60026000541415612481576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015612512573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253691906158e5565b9050612543338284614356565b6040517f29df0b9300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000000000000000000000000000000000000000000016906329df0b9390602401610b8a565b60008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632630c12f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264b91906158e5565b905060008061265a8387614449565b6040517f7afb01040000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116602483015292945090925090841690637afb010490604401602060405180830381865afa1580156126f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127189190615999565b6040517f7afb01040000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116602483015291965061271091851690637afb010490604401602060405180830381865afa1580156127b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d69190615999565b6127e09190615a1e565b9350505050915091565b60026000541415612857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa1580156128e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290c91906158e5565b90506129166136b7565b81156129cd5761292b838333846000806139e0565b6040517f9537301800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f00000000000000000000000000000000000000000000000000000000000000001690639537301890602401600060405180830381600087803b1580156129b457600080fd5b505af11580156129c8573d6000803e3d6000fd5b505050505b5050600160005550565b6000806129e3836125b7565b6040517f3192195c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152919350600092507f000000000000000000000000000000000000000000000000000000000000000090911690633192195c90602401606060405180830381865afa158015612a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9c9190615a9f565b9250829150612aaf9050612710846159e1565b612ab99190615a1e565b949350505050565b60026000541415612b2e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517ffdd5764500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063fdd5764590602401602060405180830381865afa158015612bc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be591906158e5565b73ffffffffffffffffffffffffffffffffffffffff161480612c0d5750612c0d6005846142ca565b15612c44576040517ffc1a554300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f46fb371d00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390527f000000000000000000000000000000000000000000000000000000000000000016906346fb371d90608401600060405180830381600087803b158015612ce257600080fd5b505af1158015611ce6573d6000803e3d6000fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8591906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612de9576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000000612e40576040517f50dd11fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001805464ffffffffff90921671010000000000000000000000000000000000027fffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffffff909216919091179055565b6040517ff67c5bd000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063f67c5bd090602401602060405180830381865afa158015612f1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f429190615999565b90508015801590612fe15750807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639fd12b776040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fde9190615999565b16155b9392505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613053573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061307791906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146130db576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018054911515700100000000000000000000000000000000027fffffffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffff909216919091179055565b6040517f94cf073a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260248201839052600060448301819052917f0000000000000000000000000000000000000000000000000000000000000000909116906394cf073a906064016020604051808303816000875af11580156131c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131e69190615999565b90506131f181614052565b8373ffffffffffffffffffffffffffffffffffffffff167f98274bf834d179ee08dc0604071b0dc90b54731bd5f725a5a96a39a86bce025a8360405161323991815260200190565b60405180910390a250505050565b600154700100000000000000000000000000000000900460ff1615613298576040517f7615238d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6132a181613f61565b6132aa82614742565b6040517f94cf073a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260248201839052600160448301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906394cf073a906064016020604051808303816000875af115801561334b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336f9190615999565b905061337a81614052565b8373ffffffffffffffffffffffffffffffffffffffff167f9cac51154cc0d835e2f9c9d1f59a9344588cee107f4203bf58a8c797e3a58c458360405161323991815260200190565b60008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632630c12f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613432573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061345691906158e5565b90506000806134658387614449565b6040517f7afb01040000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116602483015292945090925090841690637afb010490604401602060405180830381865afa1580156134ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135239190615999565b6040517f3192195c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529195506000917f00000000000000000000000000000000000000000000000000000000000000001690633192195c90602401606060405180830381865afa1580156135b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d99190615a9f565b6040517ff9a650300000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660248301529194506000935061271092509087169063f9a6503090604401602060405180830381865afa158015613679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369d9190615999565b6136a791906159e1565b9092109794965093945050505050565b34156137f7577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561372557600080fd5b505af1158015613739573d6000803e3d6000fd5b50506040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201523460248201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16935063a9059cbb925060440190506020604051808303816000875af11580156137d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137f59190615acd565b505b565b613802846148c6565b6040517f830aa74500000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390527f0000000000000000000000000000000000000000000000000000000000000000169063830aa74590608401600060405180830381600087803b1580156138a057600080fd5b505af11580156138b4573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fa32435755c235de2976ed44a75a2f85cb01faf0c894f639fe0c32bb9455fea8f8360405161391791815260200190565b60405180910390a350505050565b6040517feb99c2bf00000000000000000000000000000000000000000000000000000000815233600482015281151560248201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063eb99c2bf906044016020604051808303816000875af11580156139bc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d019190615acd565b6040517fe1998cf900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301523060248301527f0000000000000000000000000000000000000000000000000000000000000000169063e1998cf990604401600060405180830381600087803b158015613a6f57600080fd5b505af1158015613a83573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff871692507f4ad424605b950d17d87835716d98c0cac1f6ff9c38114e63304902188a6908119150600090a260608560005b81811015613e315736898983818110613ae957613ae9615aea565b9050602002810190613afb9190615b19565b90506004613b0c6020830183615b57565b90501015613b46576040517fe2b0e50600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b30613b5460208301836154d2565b73ffffffffffffffffffffffffffffffffffffffff161415613c30578515613c0d576000613b856020830183615b57565b613b8e91615bbc565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f81314b590000000000000000000000000000000000000000000000000000000014613c0b576040517f5fb9107f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b613c268888613c1f6020850185615b57565b8989614954565b9095509350613e28565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ff687543613c7b60208501856154d2565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401602060405180830381865afa158015613ce4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d0891906158e5565b73ffffffffffffffffffffffffffffffffffffffff161480613d81575073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016613d6960208301836154d2565b73ffffffffffffffffffffffffffffffffffffffff16145b15613db8576040517ffc1a554300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613e26613dc86020830183615b57565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613e0a9250505060208401846154d2565b73ffffffffffffffffffffffffffffffffffffffff1690614dcb565b505b50600101613ace565b50815115613e4357613e438286614e0d565b6040517f60c8e8938c9a0c0d88a98d6f1c562ce68077e12bf3edb8047378f2f736cb45b490600090a16040517fe1998cf900000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff87811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063e1998cf990604401600060405180830381600087803b158015613efb57600080fd5b505af1158015613f0f573d6000803e3d6000fd5b505050505050505050505050565b6000612fe18373ffffffffffffffffffffffffffffffffffffffff8416614f64565b6000612fe18373ffffffffffffffffffffffffffffffffffffffff8416614fb3565b7f00000000000000000000000000000000000000000000000000000000000000006137f5576001546fffffffffffffffffffffffffffffffff9081169081146119bf57600454608081901c906fffffffffffffffffffffffffffffffff16600067ffffffffffffffff83164314613fd85784613ff4565b613ff46fffffffffffffffffffffffffffffffff831686615c04565b905083811115614030576040517f675f1a5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff81164360801b176004555050505050565b6002546fffffffffffffffffffffffffffffffff1681108061409b575060025470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681115b156137f5576040517fce16799400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600154700100000000000000000000000000000000900460ff1615614123576040517f7615238d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61412b6142f9565b15614162576040517fcba1df9b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16156142c1577f000000000000000000000000000000000000000000000000000000000000000080156141e157503373ffffffffffffffffffffffffffffffffffffffff821614155b15614218576040517f5aa6676700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f9dc29fac00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600160248301527f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90604401600060405180830381600087803b1580156142a857600080fd5b505af11580156142bc573d6000803e3d6000fd5b505050505b6137f5816148c6565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001830160205260408120541515612fe1565b60007f000000000000000000000000000000000000000000000000000000000000000080156122d957505060015471010000000000000000000000000000000000900464ffffffffff1642101590565b60606000612fe1836150a6565b6040517f51e3f16000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015282811660248301527f000000000000000000000000000000000000000000000000000000000000000016906351e3f16090604401600060405180830381600087803b1580156143e757600080fd5b505af11580156143fb573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8085169350861691507fdf498aa1c340e992665d6fb4f3be8436d452c45a630cb6d7fab7963da39bac8790600090a3505050565b6040517f8991b2f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600091829160019183917f00000000000000000000000000000000000000000000000000000000000000001690638991b2f190602401602060405180830381865afa1580156144df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145039190615999565b90505b808211614739578082161561472d576040517fe75538c700000000000000000000000000000000000000000000000000000000815260048101839052600090819073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063e75538c7906024016040805180830381865afa1580156145a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145c89190615a59565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a811660048301529294509092506000918416906370a0823190602401602060405180830381865afa15801561463d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146619190615999565b90506001811115614729576040517ff9a650300000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff8481166024830152600091908b169063f9a6503090604401602060405180830381865afa1580156146e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147079190615999565b97880197905061471b61ffff8416826159e1565b6147259088615c04565b9650505b5050505b600182901b9150614506565b50509250929050565b6040517f8991b2f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638991b2f190602401602060405180830381865afa1580156147d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147f79190615999565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639fd12b776040518163ffffffff1660e01b8152600401602060405180830381865afa158015614866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061488a9190615999565b9050818116156119af576040517faea975da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff82161480159061491d575033600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16155b156137f5576040517f85b0772600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160006149628688615bbc565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f81314b59000000000000000000000000000000000000000000000000000000001415614a14578151156149e7576040517fe61eedf500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6149f4866004818a615c1c565b810190614a019190615ced565b9150614a0d8289615102565b9150614dbf565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f59781034000000000000000000000000000000000000000000000000000000001415614b7f5760008080614a6f896004818d615c1c565b810190614a7c9190615508565b925092509250614b77838d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614614b6e576040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e958b70490602401602060405180830381865afa158015614b45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b6991906158e5565b614b70565b8c5b84846137f9565b505050614dbf565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f2b7c7b11000000000000000000000000000000000000000000000000000000001415614bfc57600192506000614bdc876004818b615c1c565b810190614be991906154ef565b9050614bf68a8a83613247565b50614dbf565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f2a7ba1f7000000000000000000000000000000000000000000000000000000001415614ca7578215614c7e576040517fc0b0caa800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000614c8d876004818b615c1c565b810190614c9a91906154ef565b9050614bf68a8a83613121565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fc690908a000000000000000000000000000000000000000000000000000000001415614d1a576000614d00876004818b615c1c565b810190614d0d91906154d2565b9050614bf68a8a83614356565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f23e27a64000000000000000000000000000000000000000000000000000000001415614d8d576000614d73876004818b615c1c565b810190614d8091906154d2565b9050614bf68a8a836151ff565b6040517f1e9e7e7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50965096945050505050565b6060612fe183836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061531d565b815160005b81811015614f5e57838181518110614e2c57614e2c615aea565b602002602001015160200151848281518110614e4a57614e4a615aea565b6020908102919091010151516040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906370a0823190602401602060405180830381865afa158015614ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ee79190615999565b1015614f5657838181518110614eff57614eff615aea565b6020908102919091010151516040517f2f42bd8700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610871565b600101614e12565b50505050565b6000818152600183016020526040812054614fab57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611d01565b506000611d01565b6000818152600183016020526040812054801561509c576000614fd7600183615a88565b8554909150600090614feb90600190615a88565b905081811461505057600086600001828154811061500b5761500b615aea565b906000526020600020015490508087600001848154811061502e5761502e615aea565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061506157615061615db8565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611d01565b6000915050611d01565b6060816000018054806020026020016040519081016040528092919081815260200182805480156150f657602002820191906000526020600020905b8154815260200190600101908083116150e2575b50505050509050919050565b815160609060005b818110156151f65784818151811061512457615124615aea565b6020908102919091010151516040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906370a0823190602401602060405180830381865afa15801561519d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151c19190615999565b8582815181106151d3576151d3615aea565b60200260200101516020018181516151eb9190615c04565b90525060010161510a565b50929392505050565b6040517f0d8f9cee00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015282811660248301527f00000000000000000000000000000000000000000000000000000000000000001690630d8f9cee906044016020604051808303816000875af1158015615295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152b99190615acd565b156119af578073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f69db9e9764da61b6681b89fb0f5be018506e0342036e56b59c3015a620d6097760405160405180910390a3505050565b6060612ab9848460008585843b615390576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610871565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516153b99190615e13565b60006040518083038185875af1925050503d80600081146153f6576040519150601f19603f3d011682016040523d82523d6000602084013e6153fb565b606091505b509150915061540b828286615416565b979650505050505050565b60608315615425575081612fe1565b8251156154355782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108719190615e25565b73ffffffffffffffffffffffffffffffffffffffff811681146137f557600080fd5b80151581146137f557600080fd5b600080604083850312156154ac57600080fd5b82356154b781615469565b915060208301356154c78161548b565b809150509250929050565b6000602082840312156154e457600080fd5b8135612fe181615469565b60006020828403121561550157600080fd5b5035919050565b60008060006060848603121561551d57600080fd5b833561552881615469565b9250602084013561553881615469565b929592945050506040919091013590565b60008083601f84011261555b57600080fd5b50813567ffffffffffffffff81111561557357600080fd5b6020830191508360208260051b850101111561558e57600080fd5b9250929050565b60008060008060008060a087890312156155ae57600080fd5b86356155b981615469565b955060208701356155c981615469565b94506040870135935060608701356155e08161548b565b9250608087013567ffffffffffffffff8111156155fc57600080fd5b61560889828a01615549565b979a9699509497509295939492505050565b60008060008060006080868803121561563257600080fd5b853561563d81615469565b94506020860135935060408601356156548161548b565b9250606086013567ffffffffffffffff81111561567057600080fd5b61567c88828901615549565b969995985093965092949392505050565b80356fffffffffffffffffffffffffffffffff811681146156ad57600080fd5b919050565b600080604083850312156156c557600080fd5b6156ce8361568d565b91506156dc6020840161568d565b90509250929050565b61ffff811681146137f557600080fd5b6000806000806080858703121561570b57600080fd5b84359350602085013561571d81615469565b9250604085013561572d816156e5565b9150606085013561573d816156e5565b939692955090935050565b60008060008060006080868803121561576057600080fd5b85359450602086013561577281615469565b9350604086013567ffffffffffffffff81111561578e57600080fd5b61579a88828901615549565b90945092505060608601356157ae816156e5565b809150509295509295909350565b6020808252825182820181905260009190848201906040850190845b8181101561580a57835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016157d8565b50909695505050505050565b60006020828403121561582857600080fd5b612fe18261568d565b6000806020838503121561584457600080fd5b823567ffffffffffffffff81111561585b57600080fd5b61586785828601615549565b90969095509350505050565b6000806040838503121561588657600080fd5b823561589181615469565b915060208301356154c781615469565b6000602082840312156158b357600080fd5b813564ffffffffff81168114612fe157600080fd5b6000602082840312156158da57600080fd5b8135612fe18161548b565b6000602082840312156158f757600080fd5b8151612fe181615469565b60048110615939577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9052565b73ffffffffffffffffffffffffffffffffffffffff888116825260e0820190615969602084018a615902565b6040830197909752948616606082015292909416608083015260a082015291151560c09092019190915292915050565b6000602082840312156159ab57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615615a1957615a196159b2565b500290565b600082615a54577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008060408385031215615a6c57600080fd5b8251615a7781615469565b60208401519092506154c7816156e5565b600082821015615a9a57615a9a6159b2565b500390565b600080600060608486031215615ab457600080fd5b8351925060208401519150604084015190509250925092565b600060208284031215615adf57600080fd5b8151612fe18161548b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112615b4d57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112615b8c57600080fd5b83018035915067ffffffffffffffff821115615ba757600080fd5b60200191503681900382131561558e57600080fd5b7fffffffff000000000000000000000000000000000000000000000000000000008135818116916004851015615bfc5780818660040360031b1b83161692505b505092915050565b60008219821115615c1757615c176159b2565b500190565b60008085851115615c2c57600080fd5b83861115615c3957600080fd5b5050820193919092039150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715615c9857615c98615c46565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715615ce557615ce5615c46565b604052919050565b60006020808385031215615d0057600080fd5b823567ffffffffffffffff80821115615d1857600080fd5b818501915085601f830112615d2c57600080fd5b813581811115615d3e57615d3e615c46565b615d4c848260051b01615c9e565b818152848101925060069190911b830184019087821115615d6c57600080fd5b928401925b8184101561540b5760408489031215615d8a5760008081fd5b615d92615c75565b8435615d9d81615469565b81528486013586820152835260409093019291840191615d71565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60005b83811015615e02578181015183820152602001615dea565b83811115614f5e5750506000910152565b60008251615b4d818460208701615de7565b6020815260008251806020840152615e44816040850160208701615de7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220baa6c03543b02db27f26fa90739513563ee9439a591e2377e0e017e69ccc513364736f6c634300080a0033000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8000000000000000000000000b829a5b349b01fc71afe46e50dd6ec0222a6e5990000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106102335760003560e01c806382871ace11610138578063c7de38a6116100b0578063dfd594651161007f578063eb9606df11610064578063eb9606df146107a8578063f9eaee0d146107c8578063ffd9b907146107e857600080fd5b8063dfd5946514610768578063e1f21c671461078857600080fd5b8063c7de38a614610651578063caa5c23f14610686578063cff0ab9614610699578063d9ccbec11461072d57600080fd5b80639be0536a11610107578063b1836d32116100ec578063b1836d32146105c9578063c12c21c0146105fd578063c690908a1461063157600080fd5b80639be0536a146105875780639c55a054146105a957600080fd5b806382871ace14610492578063860aefcf146104a55780639408b63f1461050f5780639b67ab301461054357600080fd5b806359781034116101cb5780636a03706f1161019a5780636d19b4861161017f5780636d19b4861461042b5780636f307dc31461044b5780637071b7c51461047f57600080fd5b80636a03706f146103f85780636c8f225d1461041857600080fd5b8063597810341461039f5780635d91a0e0146103b25780635f73fbec146103c5578063601d66f6146103d857600080fd5b80633d9287fa116102075780633d9287fa146102cf5780634f0e0ef3146103035780635019e20a1461035c57806354fd4d501461037c57600080fd5b8062842b5714610238578063256ac9151461025a5780632a7ba1f71461028f5780632b7c7b11146102af575b600080fd5b34801561024457600080fd5b50610258610253366004615499565b610808565b005b34801561026657600080fd5b5061027a6102753660046154d2565b610918565b60405190151581526020015b60405180910390f35b34801561029b57600080fd5b506102586102aa3660046154ef565b6109eb565b3480156102bb57600080fd5b506102586102ca3660046154ef565b610bc5565b3480156102db57600080fd5b5061027a7f000000000000000000000000000000000000000000000000000000000000000181565b34801561030f57600080fd5b506103377f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610286565b34801561036857600080fd5b506102586103773660046154d2565b610cf4565b34801561038857600080fd5b50610391600281565b604051908152602001610286565b6102586103ad366004615508565b611016565b6102586103c0366004615595565b6111ff565b6102586103d336600461561a565b611534565b3480156103e457600080fd5b506102586103f33660046156b2565b611789565b34801561040457600080fd5b50610258610413366004615499565b6118ab565b6102586104263660046156f5565b6119c3565b34801561043757600080fd5b5061027a6104463660046154d2565b611cf4565b34801561045757600080fd5b506103377f000000000000000000000000853d955acef822db058eb8505911ed77f175b99e81565b61025861048d366004615748565b611d07565b6102586104a0366004615595565b611f94565b3480156104b157600080fd5b506002546104e6906fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610286565b34801561051b57600080fd5b506103377f000000000000000000000000b829a5b349b01fc71afe46e50dd6ec0222a6e59981565b34801561054f57600080fd5b506004546040805167ffffffffffffffff608084901c1681526fffffffffffffffffffffffffffffffff909216602083015201610286565b34801561059357600080fd5b5061059c6122cd565b60405161028691906157bc565b3480156105b557600080fd5b506102586105c4366004615816565b6122de565b3480156105d557600080fd5b5061027a7f000000000000000000000000000000000000000000000000000000000000000081565b34801561060957600080fd5b506103377f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d881565b34801561063d57600080fd5b5061025861064c3660046154d2565b612414565b34801561065d57600080fd5b5061067161066c3660046154d2565b6125b7565b60408051928352602083019190915201610286565b610258610694366004615831565b6127ea565b3480156106a557600080fd5b506001546106f8906fffffffffffffffffffffffffffffffff811690700100000000000000000000000000000000810460ff169071010000000000000000000000000000000000900464ffffffffff1683565b604080516fffffffffffffffffffffffffffffffff9094168452911515602084015264ffffffffff1690820152606001610286565b34801561073957600080fd5b5061027a610748366004615873565b600360209081526000928352604080842090915290825290205460ff1681565b34801561077457600080fd5b506103916107833660046154d2565b6129d7565b34801561079457600080fd5b506102586107a3366004615508565b612ac1565b3480156107b457600080fd5b506102586107c33660046158a1565b612cf6565b3480156107d457600080fd5b5061027a6107e33660046154d2565b612e8d565b3480156107f457600080fd5b506102586108033660046158c8565b612fe8565b6002600054141561087a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600090815573ffffffffffffffffffffffffffffffffffffffff8316808252600360209081526040808420338086529083529381902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081527f9b3258bc4904fd6426b99843e206c6c7cdb1fd0f040121c25b71dafbb3851ee0910160405180910390a350506001600055565b6040517f055ee9b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015260009182917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063055ee9b590602401602060405180830381865afa1580156109a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109cd91906158e5565b73ffffffffffffffffffffffffffffffffffffffff16141592915050565b60026000541415610a58576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0d91906158e5565b9050610b1a338284613121565b6040517f9537301800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d816906395373018906024015b600060405180830381600087803b158015610ba457600080fd5b505af1158015610bb8573d6000803e3d6000fd5b5050600160005550505050565b60026000541415610c32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610cc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce791906158e5565b9050610b1a338284613247565b60026000541415610d61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b60026000557f000000000000000000000000000000000000000000000000000000000000000115610dbe576040517f5aa6676700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201526000907f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015610e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6f91906158e5565b33600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915290205490915060ff16610edc576040517f85b0772600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610ee7826133c2565b5090508015610f22576040517ff713841e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fe1998cf900000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e1998cf990604401600060405180830381600087803b158015610fb157600080fd5b505af1158015610fc5573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff861692503391507f93c70cc9715bef0d83edf2095f3595402279d274f402a73ffc17f1bcb19d863d90600090a35050600160005550565b60026000541415611083576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b60026000556110906136b7565b6040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526000917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d89091169063e958b70490602401602060405180830381865afa158015611121573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114591906158e5565b9050611153848285856137f9565b6040517f29df0b9300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d816906329df0b9390602401600060405180830381600087803b1580156111dc57600080fd5b505af11580156111f0573d6000803e3d6000fd5b50506001600055505050505050565b6002600054141561126c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e958b70490602401602060405180830381865afa1580156112ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132391906158e5565b905073ffffffffffffffffffffffffffffffffffffffff8616611372576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008061137e836133c2565b91509150816113b9576040517f1fdd676f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113c16136b7565b60006113cd6001613925565b905084156113e5576113e586868c87600160006139e0565b80156113f7576113f56000613925565b505b60007f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff16632362a2d88c600186338f8f8f6040518863ffffffff1660e01b815260040161145f979695949392919061593d565b6020604051808303816000875af115801561147e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a29190615999565b90508973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff167f7dfecd8419723a9d3954585a30c2a270165d70aafa146c11c1e1b88ae14390648460405161151a91815260200190565b60405180910390a450506001600055505050505050505050565b600260005414156115a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015611632573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165691906158e5565b90506116606136b7565b81156116765761167683833384600160006139e0565b6040517f2362a2d800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d81690632362a2d8906116f5903390600090819083908d908d908d9060040161593d565b6020604051808303816000875af1158015611714573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117389190615999565b5060405173ffffffffffffffffffffffffffffffffffffffff87169033907f460ad03b1cf79b1d64d3aefa28475f110ab66e84649c52bb41ed796b9b39198190600090a35050600160005550505050565b7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181891906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461187c576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002911617600255565b7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193a91906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461199e576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80156119b4576119af600583613f1d565b505050565b6119af600583613f3f565b5050565b60026000541415611a30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556064611a4761ffff8516876159e1565b611a519190615a1e565b9050611a5c81613f61565b611a6581614052565b611a6e846140d2565b611a766136b7565b6040517f172c48c7000000000000000000000000000000000000000000000000000000008152600060048201819052907f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063172c48c7906024016040805180830381865afa158015611b03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b279190615a59565b61ffff169150611b3b905081612710615a88565b611b4590836159e1565b611b4f82886159e1565b11611b86576040517f532e7bb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f8fe3f93f0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff86811660248301526000917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d890911690638fe3f93f906044016020604051808303816000875af1158015611c20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4491906158e5565b90508073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167ffa2baf5d3eb95569f312f22477b246f9d4c50276f1cb3ded8e1aeadcbc07a7638587604051611cb292919091825261ffff16602082015260400190565b60405180910390a3611ce686827f000000000000000000000000853d955acef822db058eb8505911ed77f175b99e8a6137f9565b505060016000555050505050565b6000611d016005836142ca565b92915050565b60026000541415611d74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b6002600055611d8285613f61565b611d8b846140d2565b611d9485614052565b611d9c6136b7565b6040517f8fe3f93f0000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff85811660248301526000917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d890911690638fe3f93f906044016020604051808303816000875af1158015611e36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5a91906158e5565b90508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167ffa2baf5d3eb95569f312f22477b246f9d4c50276f1cb3ded8e1aeadcbc07a7638885604051611ec892919091825261ffff16602082015260400190565b60405180910390a38215611ee657611ee684848784600060016139e0565b6040517f9537301800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d81690639537301890602401600060405180830381600087803b158015611f6f57600080fd5b505af1158015611f83573d6000803e3d6000fd5b505060016000555050505050505050565b60026000541415612001576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e958b70490602401602060405180830381865afa158015612094573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b891906158e5565b905073ffffffffffffffffffffffffffffffffffffffff8616612107576040517fb2335f2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61210f6142f9565b612145576040517f7e52ccb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612150826125b7565b50905061215b6136b7565b60006121676001613925565b9050831561217f5761217f85858b86600160006139e0565b80156121915761218f6000613925565b505b60007f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff16632362a2d88b600286338e8e8e6040518863ffffffff1660e01b81526004016121f9979695949392919061593d565b6020604051808303816000875af1158015612218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223c9190615999565b90508873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff168b73ffffffffffffffffffffffffffffffffffffffff167ffada13ff2d5e1a1d9da37ad4a4130893b34e3c69c32b17f87ec31fd661b86707846040516122b491815260200190565b60405180910390a4505060016000555050505050505050565b60606122d96005614349565b905090565b7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236d91906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146123d1576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b60026000541415612481576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa158015612512573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253691906158e5565b9050612543338284614356565b6040517f29df0b9300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d816906329df0b9390602401610b8a565b60008060007f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff16632630c12f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264b91906158e5565b905060008061265a8387614449565b6040517f7afb01040000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000853d955acef822db058eb8505911ed77f175b99e8116602483015292945090925090841690637afb010490604401602060405180830381865afa1580156126f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127189190615999565b6040517f7afb01040000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000853d955acef822db058eb8505911ed77f175b99e8116602483015291965061271091851690637afb010490604401602060405180830381865afa1580156127b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d69190615999565b6127e09190615a1e565b9350505050915091565b60026000541415612857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517fe958b7040000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063e958b70490602401602060405180830381865afa1580156128e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290c91906158e5565b90506129166136b7565b81156129cd5761292b838333846000806139e0565b6040517f9537301800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d81690639537301890602401600060405180830381600087803b1580156129b457600080fd5b505af11580156129c8573d6000803e3d6000fd5b505050505b5050600160005550565b6000806129e3836125b7565b6040517f3192195c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152919350600092507f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d890911690633192195c90602401606060405180830381865afa158015612a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9c9190615a9f565b9250829150612aaf9050612710846159e1565b612ab99190615a1e565b949350505050565b60026000541415612b2e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610871565b600260009081556040517ffdd5764500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063fdd5764590602401602060405180830381865afa158015612bc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be591906158e5565b73ffffffffffffffffffffffffffffffffffffffff161480612c0d5750612c0d6005846142ca565b15612c44576040517ffc1a554300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f46fb371d00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d816906346fb371d90608401600060405180830381600087803b158015612ce257600080fd5b505af1158015611ce6573d6000803e3d6000fd5b7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8591906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612de9576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000000612e40576040517f50dd11fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001805464ffffffffff90921671010000000000000000000000000000000000027fffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffffff909216919091179055565b6040517ff67c5bd000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015260009182917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063f67c5bd090602401602060405180830381865afa158015612f1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f429190615999565b90508015801590612fe15750807f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff16639fd12b776040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fde9190615999565b16155b9392505050565b7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff1663f9aa028a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613053573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061307791906158e5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146130db576040517feee4716900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018054911515700100000000000000000000000000000000027fffffffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffff909216919091179055565b6040517f94cf073a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260248201839052600060448301819052917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8909116906394cf073a906064016020604051808303816000875af11580156131c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131e69190615999565b90506131f181614052565b8373ffffffffffffffffffffffffffffffffffffffff167f98274bf834d179ee08dc0604071b0dc90b54731bd5f725a5a96a39a86bce025a8360405161323991815260200190565b60405180910390a250505050565b600154700100000000000000000000000000000000900460ff1615613298576040517f7615238d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6132a181613f61565b6132aa82614742565b6040517f94cf073a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015260248201839052600160448301526000917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8909116906394cf073a906064016020604051808303816000875af115801561334b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336f9190615999565b905061337a81614052565b8373ffffffffffffffffffffffffffffffffffffffff167f9cac51154cc0d835e2f9c9d1f59a9344588cee107f4203bf58a8c797e3a58c458360405161323991815260200190565b60008060007f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff16632630c12f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613432573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061345691906158e5565b90506000806134658387614449565b6040517f7afb01040000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000853d955acef822db058eb8505911ed77f175b99e8116602483015292945090925090841690637afb010490604401602060405180830381865afa1580156134ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135239190615999565b6040517f3192195c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88811660048301529195506000917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d81690633192195c90602401606060405180830381865afa1580156135b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d99190615a9f565b6040517ff9a650300000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000853d955acef822db058eb8505911ed77f175b99e811660248301529194506000935061271092509087169063f9a6503090604401602060405180830381865afa158015613679573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369d9190615999565b6136a791906159e1565b9092109794965093945050505050565b34156137f7577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561372557600080fd5b505af1158015613739573d6000803e3d6000fd5b50506040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201523460248201527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16935063a9059cbb925060440190506020604051808303816000875af11580156137d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137f59190615acd565b505b565b613802846148c6565b6040517f830aa74500000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063830aa74590608401600060405180830381600087803b1580156138a057600080fd5b505af11580156138b4573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fa32435755c235de2976ed44a75a2f85cb01faf0c894f639fe0c32bb9455fea8f8360405161391791815260200190565b60405180910390a350505050565b6040517feb99c2bf00000000000000000000000000000000000000000000000000000000815233600482015281151560248201526000907f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff169063eb99c2bf906044016020604051808303816000875af11580156139bc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d019190615acd565b6040517fe1998cf900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301523060248301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e1998cf990604401600060405180830381600087803b158015613a6f57600080fd5b505af1158015613a83573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff871692507f4ad424605b950d17d87835716d98c0cac1f6ff9c38114e63304902188a6908119150600090a260608560005b81811015613e315736898983818110613ae957613ae9615aea565b9050602002810190613afb9190615b19565b90506004613b0c6020830183615b57565b90501015613b46576040517fe2b0e50600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b30613b5460208301836154d2565b73ffffffffffffffffffffffffffffffffffffffff161415613c30578515613c0d576000613b856020830183615b57565b613b8e91615bbc565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f81314b590000000000000000000000000000000000000000000000000000000014613c0b576040517f5fb9107f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b613c268888613c1f6020850185615b57565b8989614954565b9095509350613e28565b60007f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff1663ff687543613c7b60208501856154d2565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401602060405180830381865afa158015613ce4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d0891906158e5565b73ffffffffffffffffffffffffffffffffffffffff161480613d81575073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d816613d6960208301836154d2565b73ffffffffffffffffffffffffffffffffffffffff16145b15613db8576040517ffc1a554300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613e26613dc86020830183615b57565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613e0a9250505060208401846154d2565b73ffffffffffffffffffffffffffffffffffffffff1690614dcb565b505b50600101613ace565b50815115613e4357613e438286614e0d565b6040517f60c8e8938c9a0c0d88a98d6f1c562ce68077e12bf3edb8047378f2f736cb45b490600090a16040517fe1998cf900000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff87811660248301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e1998cf990604401600060405180830381600087803b158015613efb57600080fd5b505af1158015613f0f573d6000803e3d6000fd5b505050505050505050505050565b6000612fe18373ffffffffffffffffffffffffffffffffffffffff8416614f64565b6000612fe18373ffffffffffffffffffffffffffffffffffffffff8416614fb3565b7f00000000000000000000000000000000000000000000000000000000000000016137f5576001546fffffffffffffffffffffffffffffffff9081169081146119bf57600454608081901c906fffffffffffffffffffffffffffffffff16600067ffffffffffffffff83164314613fd85784613ff4565b613ff46fffffffffffffffffffffffffffffffff831686615c04565b905083811115614030576040517f675f1a5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff81164360801b176004555050505050565b6002546fffffffffffffffffffffffffffffffff1681108061409b575060025470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681115b156137f5576040517fce16799400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600154700100000000000000000000000000000000900460ff1615614123576040517f7615238d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61412b6142f9565b15614162576040517fcba1df9b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000b829a5b349b01fc71afe46e50dd6ec0222a6e59973ffffffffffffffffffffffffffffffffffffffff16156142c1577f000000000000000000000000000000000000000000000000000000000000000180156141e157503373ffffffffffffffffffffffffffffffffffffffff821614155b15614218576040517f5aa6676700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f9dc29fac00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600160248301527f000000000000000000000000b829a5b349b01fc71afe46e50dd6ec0222a6e5991690639dc29fac90604401600060405180830381600087803b1580156142a857600080fd5b505af11580156142bc573d6000803e3d6000fd5b505050505b6137f5816148c6565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001830160205260408120541515612fe1565b60007f000000000000000000000000000000000000000000000000000000000000000080156122d957505060015471010000000000000000000000000000000000900464ffffffffff1642101590565b60606000612fe1836150a6565b6040517f51e3f16000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015282811660248301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d816906351e3f16090604401600060405180830381600087803b1580156143e757600080fd5b505af11580156143fb573d6000803e3d6000fd5b505060405173ffffffffffffffffffffffffffffffffffffffff8085169350861691507fdf498aa1c340e992665d6fb4f3be8436d452c45a630cb6d7fab7963da39bac8790600090a3505050565b6040517f8991b2f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600091829160019183917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d81690638991b2f190602401602060405180830381865afa1580156144df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145039190615999565b90505b808211614739578082161561472d576040517fe75538c700000000000000000000000000000000000000000000000000000000815260048101839052600090819073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e75538c7906024016040805180830381865afa1580156145a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145c89190615a59565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a811660048301529294509092506000918416906370a0823190602401602060405180830381865afa15801561463d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146619190615999565b90506001811115614729576040517ff9a650300000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff8481166024830152600091908b169063f9a6503090604401602060405180830381865afa1580156146e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147079190615999565b97880197905061471b61ffff8416826159e1565b6147259088615c04565b9650505b5050505b600182901b9150614506565b50509250929050565b6040517f8991b2f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000917f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d890911690638991b2f190602401602060405180830381865afa1580156147d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147f79190615999565b905060007f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d873ffffffffffffffffffffffffffffffffffffffff16639fd12b776040518163ffffffff1660e01b8152600401602060405180830381865afa158015614866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061488a9190615999565b9050818116156119af576040517faea975da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff82161480159061491d575033600090815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16155b156137f5576040517f85b0772600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b818160006149628688615bbc565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f81314b59000000000000000000000000000000000000000000000000000000001415614a14578151156149e7576040517fe61eedf500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6149f4866004818a615c1c565b810190614a019190615ced565b9150614a0d8289615102565b9150614dbf565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f59781034000000000000000000000000000000000000000000000000000000001415614b7f5760008080614a6f896004818d615c1c565b810190614a7c9190615508565b925092509250614b77838d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614614b6e576040517fe958b70400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8169063e958b70490602401602060405180830381865afa158015614b45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b6991906158e5565b614b70565b8c5b84846137f9565b505050614dbf565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f2b7c7b11000000000000000000000000000000000000000000000000000000001415614bfc57600192506000614bdc876004818b615c1c565b810190614be991906154ef565b9050614bf68a8a83613247565b50614dbf565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f2a7ba1f7000000000000000000000000000000000000000000000000000000001415614ca7578215614c7e576040517fc0b0caa800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000614c8d876004818b615c1c565b810190614c9a91906154ef565b9050614bf68a8a83613121565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fc690908a000000000000000000000000000000000000000000000000000000001415614d1a576000614d00876004818b615c1c565b810190614d0d91906154d2565b9050614bf68a8a83614356565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f23e27a64000000000000000000000000000000000000000000000000000000001415614d8d576000614d73876004818b615c1c565b810190614d8091906154d2565b9050614bf68a8a836151ff565b6040517f1e9e7e7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50965096945050505050565b6060612fe183836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061531d565b815160005b81811015614f5e57838181518110614e2c57614e2c615aea565b602002602001015160200151848281518110614e4a57614e4a615aea565b6020908102919091010151516040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906370a0823190602401602060405180830381865afa158015614ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ee79190615999565b1015614f5657838181518110614eff57614eff615aea565b6020908102919091010151516040517f2f42bd8700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610871565b600101614e12565b50505050565b6000818152600183016020526040812054614fab57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611d01565b506000611d01565b6000818152600183016020526040812054801561509c576000614fd7600183615a88565b8554909150600090614feb90600190615a88565b905081811461505057600086600001828154811061500b5761500b615aea565b906000526020600020015490508087600001848154811061502e5761502e615aea565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061506157615061615db8565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611d01565b6000915050611d01565b6060816000018054806020026020016040519081016040528092919081815260200182805480156150f657602002820191906000526020600020905b8154815260200190600101908083116150e2575b50505050509050919050565b815160609060005b818110156151f65784818151811061512457615124615aea565b6020908102919091010151516040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906370a0823190602401602060405180830381865afa15801561519d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151c19190615999565b8582815181106151d3576151d3615aea565b60200260200101516020018181516151eb9190615c04565b90525060010161510a565b50929392505050565b6040517f0d8f9cee00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015282811660248301527f000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d81690630d8f9cee906044016020604051808303816000875af1158015615295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906152b99190615acd565b156119af578073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f69db9e9764da61b6681b89fb0f5be018506e0342036e56b59c3015a620d6097760405160405180910390a3505050565b6060612ab9848460008585843b615390576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610871565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516153b99190615e13565b60006040518083038185875af1925050503d80600081146153f6576040519150601f19603f3d011682016040523d82523d6000602084013e6153fb565b606091505b509150915061540b828286615416565b979650505050505050565b60608315615425575081612fe1565b8251156154355782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108719190615e25565b73ffffffffffffffffffffffffffffffffffffffff811681146137f557600080fd5b80151581146137f557600080fd5b600080604083850312156154ac57600080fd5b82356154b781615469565b915060208301356154c78161548b565b809150509250929050565b6000602082840312156154e457600080fd5b8135612fe181615469565b60006020828403121561550157600080fd5b5035919050565b60008060006060848603121561551d57600080fd5b833561552881615469565b9250602084013561553881615469565b929592945050506040919091013590565b60008083601f84011261555b57600080fd5b50813567ffffffffffffffff81111561557357600080fd5b6020830191508360208260051b850101111561558e57600080fd5b9250929050565b60008060008060008060a087890312156155ae57600080fd5b86356155b981615469565b955060208701356155c981615469565b94506040870135935060608701356155e08161548b565b9250608087013567ffffffffffffffff8111156155fc57600080fd5b61560889828a01615549565b979a9699509497509295939492505050565b60008060008060006080868803121561563257600080fd5b853561563d81615469565b94506020860135935060408601356156548161548b565b9250606086013567ffffffffffffffff81111561567057600080fd5b61567c88828901615549565b969995985093965092949392505050565b80356fffffffffffffffffffffffffffffffff811681146156ad57600080fd5b919050565b600080604083850312156156c557600080fd5b6156ce8361568d565b91506156dc6020840161568d565b90509250929050565b61ffff811681146137f557600080fd5b6000806000806080858703121561570b57600080fd5b84359350602085013561571d81615469565b9250604085013561572d816156e5565b9150606085013561573d816156e5565b939692955090935050565b60008060008060006080868803121561576057600080fd5b85359450602086013561577281615469565b9350604086013567ffffffffffffffff81111561578e57600080fd5b61579a88828901615549565b90945092505060608601356157ae816156e5565b809150509295509295909350565b6020808252825182820181905260009190848201906040850190845b8181101561580a57835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016157d8565b50909695505050505050565b60006020828403121561582857600080fd5b612fe18261568d565b6000806020838503121561584457600080fd5b823567ffffffffffffffff81111561585b57600080fd5b61586785828601615549565b90969095509350505050565b6000806040838503121561588657600080fd5b823561589181615469565b915060208301356154c781615469565b6000602082840312156158b357600080fd5b813564ffffffffff81168114612fe157600080fd5b6000602082840312156158da57600080fd5b8135612fe18161548b565b6000602082840312156158f757600080fd5b8151612fe181615469565b60048110615939577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9052565b73ffffffffffffffffffffffffffffffffffffffff888116825260e0820190615969602084018a615902565b6040830197909752948616606082015292909416608083015260a082015291151560c09092019190915292915050565b6000602082840312156159ab57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615615a1957615a196159b2565b500290565b600082615a54577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008060408385031215615a6c57600080fd5b8251615a7781615469565b60208401519092506154c7816156e5565b600082821015615a9a57615a9a6159b2565b500390565b600080600060608486031215615ab457600080fd5b8351925060208401519150604084015190509250925092565b600060208284031215615adf57600080fd5b8151612fe18161548b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112615b4d57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112615b8c57600080fd5b83018035915067ffffffffffffffff821115615ba757600080fd5b60200191503681900382131561558e57600080fd5b7fffffffff000000000000000000000000000000000000000000000000000000008135818116916004851015615bfc5780818660040360031b1b83161692505b505092915050565b60008219821115615c1757615c176159b2565b500190565b60008085851115615c2c57600080fd5b83861115615c3957600080fd5b5050820193919092039150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715615c9857615c98615c46565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715615ce557615ce5615c46565b604052919050565b60006020808385031215615d0057600080fd5b823567ffffffffffffffff80821115615d1857600080fd5b818501915085601f830112615d2c57600080fd5b813581811115615d3e57615d3e615c46565b615d4c848260051b01615c9e565b818152848101925060069190911b830184019087821115615d6c57600080fd5b928401925b8184101561540b5760408489031215615d8a5760008081fd5b615d92615c75565b8435615d9d81615469565b81528486013586820152835260409093019291840191615d71565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60005b83811015615e02578181015183820152602001615dea565b83811115614f5e5750506000910152565b60008251615b4d818460208701615de7565b6020815260008251806020840152615e44816040850160208701615de7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea2646970667358221220baa6c03543b02db27f26fa90739513563ee9439a591e2377e0e017e69ccc513364736f6c634300080a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8000000000000000000000000b829a5b349b01fc71afe46e50dd6ec0222a6e5990000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _creditManager (address): 0xA3E1e0d58FE8dD8C9dd48204699a1178f1B274D8
Arg [1] : _degenNFT (address): 0xB829a5b349b01fc71aFE46E50dD6Ec0222A6E599
Arg [2] : _expirable (bool): False
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000a3e1e0d58fe8dd8c9dd48204699a1178f1b274d8
Arg [1] : 000000000000000000000000b829a5b349b01fc71afe46e50dd6ec0222a6e599
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.