Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x61012060 | 19306413 | 250 days ago | IN | 0 ETH | 0.01805662 |
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers. Name tag integration is not available in advanced view.
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | ||||
---|---|---|---|---|---|---|---|
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094992 | 6 hrs ago | 0 ETH | |||||
21094654 | 8 hrs ago | 0 ETH | |||||
21094654 | 8 hrs ago | 0 ETH | |||||
21094649 | 8 hrs ago | 0 ETH | |||||
21094649 | 8 hrs ago | 0 ETH | |||||
21094645 | 8 hrs ago | 0 ETH | |||||
21094645 | 8 hrs ago | 0 ETH | |||||
21094609 | 8 hrs ago | 0 ETH | |||||
21094609 | 8 hrs ago | 0 ETH | |||||
21093047 | 13 hrs ago | 0 ETH | |||||
21093047 | 13 hrs ago | 0 ETH | |||||
21088778 | 27 hrs ago | 0 ETH | |||||
21088778 | 27 hrs ago | 0 ETH | |||||
21088626 | 28 hrs ago | 0 ETH | |||||
21088626 | 28 hrs ago | 0 ETH | |||||
21088616 | 28 hrs ago | 0 ETH |
Loading...
Loading
Contract Name:
UnderlyingHoldingsOracle
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BSUL-1.1 pragma solidity =0.7.6; pragma abicoder v2; import {Constants} from "../../global/Constants.sol"; import {SafeUint256} from "../../math/SafeUint256.sol"; import {IERC20} from "../../../interfaces/IERC20.sol"; import {NotionalProxy} from "../../../interfaces/notional/NotionalProxy.sol"; import { IPrimeCashHoldingsOracle, DepositData, OracleData, RedeemData } from "../../../interfaces/notional/IPrimeCashHoldingsOracle.sol"; contract UnderlyingHoldingsOracle is IPrimeCashHoldingsOracle { using SafeUint256 for uint256; NotionalProxy internal immutable NOTIONAL; address internal immutable UNDERLYING_TOKEN; uint8 internal immutable UNDERLYING_DECIMALS; uint256 internal immutable UNDERLYING_PRECISION; bool internal immutable UNDERLYING_IS_ETH; constructor(NotionalProxy notional_, address underlying_) { bool underlyingIsEth = underlying_ == Constants.ETH_ADDRESS; uint8 underlyingDecimals = underlyingIsEth ? 18 : IERC20(underlying_).decimals(); NOTIONAL = notional_; UNDERLYING_TOKEN = underlying_; UNDERLYING_IS_ETH = underlyingIsEth; UNDERLYING_DECIMALS = underlyingDecimals; UNDERLYING_PRECISION = 10**underlyingDecimals; } /// @notice Returns a list of the various holdings for the prime cash /// currency function holdings() external view override returns (address[] memory) { return _holdings(); } /// @notice Returns the underlying token that all holdings can be redeemed /// for. function underlying() external view override returns (address) { return UNDERLYING_TOKEN; } /// @notice Returns the native decimal precision of the underlying token function decimals() external view override returns (uint8) { return UNDERLYING_DECIMALS; } /// @notice Returns the total underlying held by the caller in all the /// listed holdings function getTotalUnderlyingValueStateful() external override returns ( uint256 nativePrecision, uint256 internalPrecision ) { nativePrecision = _getTotalUnderlyingValueStateful(); internalPrecision = nativePrecision.mul(uint256(Constants.INTERNAL_TOKEN_PRECISION)).div(UNDERLYING_PRECISION); } function getTotalUnderlyingValueView() external view override returns ( uint256 nativePrecision, uint256 internalPrecision ) { nativePrecision = _getTotalUnderlyingValueView(); internalPrecision = nativePrecision.mul(uint256(Constants.INTERNAL_TOKEN_PRECISION)).div(UNDERLYING_PRECISION); } function holdingValuesInUnderlying() external view override returns (uint256[] memory) { return _holdingValuesInUnderlying(); } /// @notice Returns calldata for how to withdraw an amount function getRedemptionCalldata(uint256 withdrawAmount) external view override returns (RedeemData[] memory redeemData) { return _getRedemptionCalldata(withdrawAmount); } function getRedemptionCalldataForRebalancing( address[] calldata holdings_, uint256[] calldata withdrawAmounts ) external view override returns (RedeemData[] memory redeemData) { return _getRedemptionCalldataForRebalancing(holdings_, withdrawAmounts); } function getDepositCalldataForRebalancing( address[] calldata holdings_, uint256[] calldata depositAmounts ) external view override returns (DepositData[] memory depositData) { return _getDepositCalldataForRebalancing(holdings_, depositAmounts); } function _holdings() internal view virtual returns (address[] memory) { return new address[](0); } function _getTotalUnderlyingValueStateful() internal virtual returns (uint256) { return _getTotalUnderlyingValueView(); } function _getTotalUnderlyingValueView() internal view virtual returns (uint256) { address[] memory tokens = new address[](1); tokens[0] = UNDERLYING_TOKEN; return NOTIONAL.getStoredTokenBalances(tokens)[0]; } function _holdingValuesInUnderlying() internal view virtual returns (uint256[] memory) { return new uint256[](0); } /// @notice Returns calldata for how to withdraw an amount function _getRedemptionCalldata( uint256 /* withdrawAmount */ ) internal view virtual returns (RedeemData[] memory /* redeemData */) { /* No-op */ } function _getRedemptionCalldataForRebalancing( address[] calldata /* holdings_ */, uint256[] calldata /* withdrawAmounts */ ) internal view virtual returns (RedeemData[] memory /* redeemData */) { /* No-op */ } function _getDepositCalldataForRebalancing( address[] calldata /* holdings_ */, uint256[] calldata /* depositAmount */ ) internal view virtual returns (DepositData[] memory /* depositData */) { /* No-op */ } function getOracleData() external view virtual override returns (OracleData memory oracleData) { return oracleData; } }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; /// @title All shared constants for the Notional system should be declared here. library Constants { uint8 internal constant CETH_DECIMAL_PLACES = 8; // Token precision used for all internal balances, TokenHandler library ensures that we // limit the dust amount caused by precision mismatches int256 internal constant INTERNAL_TOKEN_PRECISION = 1e8; uint256 internal constant INCENTIVE_ACCUMULATION_PRECISION = 1e18; // ETH will be initialized as the first currency uint256 internal constant ETH_CURRENCY_ID = 1; uint8 internal constant ETH_DECIMAL_PLACES = 18; int256 internal constant ETH_DECIMALS = 1e18; address internal constant ETH_ADDRESS = address(0); // Used to prevent overflow when converting decimal places to decimal precision values via // 10**decimalPlaces. This is a safe value for int256 and uint256 variables. We apply this // constraint when storing decimal places in governance. uint256 internal constant MAX_DECIMAL_PLACES = 36; // Address of the account where fees are collected address internal constant FEE_RESERVE = 0x0000000000000000000000000000000000000FEE; // Address of the account where settlement funds are collected, this is only // used for off chain event tracking. address internal constant SETTLEMENT_RESERVE = 0x00000000000000000000000000000000000005e7; // Most significant bit bytes32 internal constant MSB = 0x8000000000000000000000000000000000000000000000000000000000000000; // Each bit set in this mask marks where an active market should be in the bitmap // if the first bit refers to the reference time. Used to detect idiosyncratic // fcash in the nToken accounts bytes32 internal constant ACTIVE_MARKETS_MASK = ( MSB >> ( 90 - 1) | // 3 month MSB >> (105 - 1) | // 6 month MSB >> (135 - 1) | // 1 year MSB >> (147 - 1) | // 2 year MSB >> (183 - 1) | // 5 year MSB >> (211 - 1) | // 10 year MSB >> (251 - 1) // 20 year ); // Basis for percentages int256 internal constant PERCENTAGE_DECIMALS = 100; // Min Buffer Scale and Buffer Scale are used in ExchangeRate to increase the maximum // possible buffer values at the higher end of the uint8 range. int256 internal constant MIN_BUFFER_SCALE = 150; int256 internal constant BUFFER_SCALE = 10; // Max number of traded markets, also used as the maximum number of assets in a portfolio array uint256 internal constant MAX_TRADED_MARKET_INDEX = 7; // Max number of fCash assets in a bitmap, this is based on the gas costs of calculating free collateral // for a bitmap portfolio uint256 internal constant MAX_BITMAP_ASSETS = 20; uint256 internal constant FIVE_MINUTES = 300; // Internal date representations, note we use a 6/30/360 week/month/year convention here uint256 internal constant DAY = 86400; // We use six day weeks to ensure that all time references divide evenly uint256 internal constant WEEK = DAY * 6; uint256 internal constant MONTH = WEEK * 5; uint256 internal constant QUARTER = MONTH * 3; uint256 internal constant YEAR = QUARTER * 4; // These constants are used in DateTime.sol uint256 internal constant DAYS_IN_WEEK = 6; uint256 internal constant DAYS_IN_MONTH = 30; uint256 internal constant DAYS_IN_QUARTER = 90; // Offsets for each time chunk denominated in days uint256 internal constant MAX_DAY_OFFSET = 90; uint256 internal constant MAX_WEEK_OFFSET = 360; uint256 internal constant MAX_MONTH_OFFSET = 2160; uint256 internal constant MAX_QUARTER_OFFSET = 7650; // Offsets for each time chunk denominated in bits uint256 internal constant WEEK_BIT_OFFSET = 90; uint256 internal constant MONTH_BIT_OFFSET = 135; uint256 internal constant QUARTER_BIT_OFFSET = 195; // Number of decimal places that rates are stored in, equals 100% int256 internal constant RATE_PRECISION = 1e9; // Used for prime cash scalars uint256 internal constant SCALAR_PRECISION = 1e18; // Used in prime rate lib int256 internal constant DOUBLE_SCALAR_PRECISION = 1e36; // One basis point in RATE_PRECISION terms uint256 internal constant BASIS_POINT = uint256(RATE_PRECISION / 10000); // Used to when calculating the amount to deleverage of a market when minting nTokens uint256 internal constant DELEVERAGE_BUFFER = 300 * BASIS_POINT; // Used for scaling cash group factors uint256 internal constant FIVE_BASIS_POINTS = 5 * BASIS_POINT; // Used for residual purchase incentive and cash withholding buffer uint256 internal constant TEN_BASIS_POINTS = 10 * BASIS_POINT; // Used for max oracle rate uint256 internal constant FIFTEEN_BASIS_POINTS = 15 * BASIS_POINT; // Used in max rate calculations uint256 internal constant MAX_LOWER_INCREMENT = 150; uint256 internal constant MAX_LOWER_INCREMENT_VALUE = 150 * 25 * BASIS_POINT; uint256 internal constant TWENTY_FIVE_BASIS_POINTS = 25 * BASIS_POINT; uint256 internal constant ONE_HUNDRED_FIFTY_BASIS_POINTS = 150 * BASIS_POINT; // This is the ABDK64x64 representation of RATE_PRECISION // RATE_PRECISION_64x64 = ABDKMath64x64.fromUint(RATE_PRECISION) int128 internal constant RATE_PRECISION_64x64 = 0x3b9aca000000000000000000; uint8 internal constant FCASH_ASSET_TYPE = 1; // Liquidity token asset types are 1 + marketIndex (where marketIndex is 1-indexed) uint8 internal constant MIN_LIQUIDITY_TOKEN_INDEX = 2; uint8 internal constant MAX_LIQUIDITY_TOKEN_INDEX = 8; uint8 internal constant VAULT_SHARE_ASSET_TYPE = 9; uint8 internal constant VAULT_DEBT_ASSET_TYPE = 10; uint8 internal constant VAULT_CASH_ASSET_TYPE = 11; // Used for tracking legacy nToken assets uint8 internal constant LEGACY_NTOKEN_ASSET_TYPE = 12; // Account context flags bytes1 internal constant HAS_ASSET_DEBT = 0x01; bytes1 internal constant HAS_CASH_DEBT = 0x02; bytes2 internal constant ACTIVE_IN_PORTFOLIO = 0x8000; bytes2 internal constant ACTIVE_IN_BALANCES = 0x4000; bytes2 internal constant UNMASK_FLAGS = 0x3FFF; uint16 internal constant MAX_CURRENCIES = uint16(UNMASK_FLAGS); // Equal to 100% of all deposit amounts for nToken liquidity across fCash markets. int256 internal constant DEPOSIT_PERCENT_BASIS = 1e8; // nToken Parameters: there are offsets in the nTokenParameters bytes6 variable returned // in nTokenHandler. Each constant represents a position in the byte array. uint8 internal constant LIQUIDATION_HAIRCUT_PERCENTAGE = 0; uint8 internal constant CASH_WITHHOLDING_BUFFER = 1; uint8 internal constant RESIDUAL_PURCHASE_TIME_BUFFER = 2; uint8 internal constant PV_HAIRCUT_PERCENTAGE = 3; uint8 internal constant RESIDUAL_PURCHASE_INCENTIVE = 4; uint8 internal constant MAX_MINT_DEVIATION_LIMIT = 5; // Liquidation parameters // Default percentage of collateral that a liquidator is allowed to liquidate, will be higher if the account // requires more collateral to be liquidated int256 internal constant DEFAULT_LIQUIDATION_PORTION = 40; // Percentage of local liquidity token cash claim delivered to the liquidator for liquidating liquidity tokens int256 internal constant TOKEN_REPO_INCENTIVE_PERCENT = 30; // Pause Router liquidation enabled states bytes1 internal constant LOCAL_CURRENCY_ENABLED = 0x01; bytes1 internal constant COLLATERAL_CURRENCY_ENABLED = 0x02; bytes1 internal constant LOCAL_FCASH_ENABLED = 0x04; bytes1 internal constant CROSS_CURRENCY_FCASH_ENABLED = 0x08; // Requires vault accounts to enter a position for a minimum of 1 min // to mitigate strange behavior where accounts may enter and exit using // flash loans or other MEV type behavior. uint256 internal constant VAULT_ACCOUNT_MIN_TIME = 1 minutes; // Placeholder constant to mark the variable rate prime cash maturity uint40 internal constant PRIME_CASH_VAULT_MATURITY = type(uint40).max; // This represents the maximum percent change allowed before and after // a rebalancing. 100_000 represents a 0.01% change // as a result of rebalancing. We should expect to never lose value as // a result of rebalancing, but some rounding errors may exist as a result // of redemption and deposit. int256 internal constant REBALANCING_UNDERLYING_DELTA_PERCENT = 100_000; // Ensures that the minimum total underlying held by the contract continues // to accrue interest so that money market oracle rates are properly updated // between rebalancing. With a minimum rebalancing cool down time of 6 hours // we would be able to detect at least 1 unit of accrual at 8 decimal precision // at an interest rate of 2.8 basis points (0.0288%) with 0.05e8 minimum balance // held in a given token. // // MIN_ACCRUAL * (86400 / REBALANCING_COOL_DOWN_HOURS) // MINIMUM_INTEREST_RATE = --------------------------------------------------- // MINIMUM_UNDERLYING_BALANCE int256 internal constant MIN_TOTAL_UNDERLYING_VALUE = 0.05e8; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; import {WETH9} from "../../interfaces/WETH9.sol"; import {IUpgradeableBeacon} from "../proxy/beacon/IBeacon.sol"; import {AggregatorV2V3Interface} from "../../interfaces/chainlink/AggregatorV2V3Interface.sol"; /// @title Hardcoded deployed contracts are listed here. These are hardcoded to reduce /// gas costs for immutable addresses. They must be updated per environment that Notional /// is deployed to. library Deployments { uint256 internal constant MAINNET = 1; uint256 internal constant ARBITRUM_ONE = 42161; uint256 internal constant LOCAL = 1337; // MAINNET: 0xCFEAead4947f0705A14ec42aC3D44129E1Ef3eD5 address internal constant NOTE_TOKEN_ADDRESS = 0xCFEAead4947f0705A14ec42aC3D44129E1Ef3eD5; // ARBITRUM: 0x019bE259BC299F3F653688c7655C87F998Bc7bC1 // address internal constant NOTE_TOKEN_ADDRESS = 0x019bE259BC299F3F653688c7655C87F998Bc7bC1; // MAINNET: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 WETH9 internal constant WETH = WETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // ARBITRUM: 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 // WETH9 internal constant WETH = WETH9(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1); // OPTIMISM: 0x4200000000000000000000000000000000000006 // Chainlink L2 Sequencer Uptime: https://docs.chain.link/data-feeds/l2-sequencer-feeds/ // MAINNET: NOT SET AggregatorV2V3Interface internal constant SEQUENCER_UPTIME_ORACLE = AggregatorV2V3Interface(address(0)); // ARBITRUM: 0xFdB631F5EE196F0ed6FAa767959853A9F217697D // AggregatorV2V3Interface internal constant SEQUENCER_UPTIME_ORACLE = AggregatorV2V3Interface(0xFdB631F5EE196F0ed6FAa767959853A9F217697D); enum BeaconType { NTOKEN, PCASH, PDEBT, WRAPPED_FCASH } // NOTE: these are temporary Beacon addresses IUpgradeableBeacon internal constant NTOKEN_BEACON = IUpgradeableBeacon(0xc4FD259b816d081C8bdd22D6bbd3495DB1573DB7); IUpgradeableBeacon internal constant PCASH_BEACON = IUpgradeableBeacon(0x1F681977aF5392d9Ca5572FB394BC4D12939A6A9); IUpgradeableBeacon internal constant PDEBT_BEACON = IUpgradeableBeacon(0xDF08039c0af34E34660aC7c2705C0Da953247640); // ARB: // IUpgradeableBeacon internal constant WRAPPED_FCASH_BEACON = IUpgradeableBeacon(0xD676d720E4e8B14F545F9116F0CAD47aF32329DD); IUpgradeableBeacon internal constant WRAPPED_FCASH_BEACON = IUpgradeableBeacon(0xEBe1BF1653d55d31F6ED38B1A4CcFE2A92338f66); // TODO: this will be set to the timestamp of the final settlement time in notional v2, // no assets can be settled prior to this date once the notional v3 upgrade is enabled. uint256 internal constant NOTIONAL_V2_FINAL_SETTLEMENT = 0; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import "../../interfaces/chainlink/AggregatorV2V3Interface.sol"; import "../../interfaces/notional/IPrimeCashHoldingsOracle.sol"; import "../../interfaces/notional/AssetRateAdapter.sol"; /// @notice Different types of internal tokens /// - UnderlyingToken: underlying asset for a cToken (except for Ether) /// - cToken: Compound interest bearing token /// - cETH: Special handling for cETH tokens /// - Ether: the one and only /// - NonMintable: tokens that do not have an underlying (therefore not cTokens) /// - aToken: Aave interest bearing tokens enum TokenType { UnderlyingToken, cToken, cETH, Ether, NonMintable, aToken } /// @notice Specifies the different trade action types in the system. Each trade action type is /// encoded in a tightly packed bytes32 object. Trade action type is the first big endian byte of the /// 32 byte trade action object. The schemas for each trade action type are defined below. enum TradeActionType { // (uint8 TradeActionType, uint8 MarketIndex, uint88 fCashAmount, uint32 minImpliedRate, uint120 unused) Lend, // (uint8 TradeActionType, uint8 MarketIndex, uint88 fCashAmount, uint32 maxImpliedRate, uint128 unused) Borrow, // (uint8 TradeActionType, uint8 MarketIndex, uint88 primeCashAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused) AddLiquidity, // (uint8 TradeActionType, uint8 MarketIndex, uint88 tokenAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused) RemoveLiquidity, // (uint8 TradeActionType, uint32 Maturity, int88 fCashResidualAmount, uint128 unused) PurchaseNTokenResidual, // (uint8 TradeActionType, address CounterpartyAddress, int88 fCashAmountToSettle) SettleCashDebt } /// @notice Specifies different deposit actions that can occur during BalanceAction or BalanceActionWithTrades enum DepositActionType { // No deposit action None, // Deposit asset cash, depositActionAmount is specified in asset cash external precision DepositAsset, // Deposit underlying tokens that are mintable to asset cash, depositActionAmount is specified in underlying token // external precision DepositUnderlying, // Deposits specified asset cash external precision amount into an nToken and mints the corresponding amount of // nTokens into the account DepositAssetAndMintNToken, // Deposits specified underlying in external precision, mints asset cash, and uses that asset cash to mint nTokens DepositUnderlyingAndMintNToken, // Redeems an nToken balance to asset cash. depositActionAmount is specified in nToken precision. Considered a deposit action // because it deposits asset cash into an account. If there are fCash residuals that cannot be sold off, will revert. RedeemNToken, // Converts specified amount of asset cash balance already in Notional to nTokens. depositActionAmount is specified in // Notional internal 8 decimal precision. ConvertCashToNToken } /// @notice Used internally for PortfolioHandler state enum AssetStorageState { NoChange, Update, Delete, RevertIfStored } /****** Calldata objects ******/ /// @notice Defines a batch lending action struct BatchLend { uint16 currencyId; // True if the contract should try to transfer underlying tokens instead of asset tokens bool depositUnderlying; // Array of tightly packed 32 byte objects that represent trades. See TradeActionType documentation bytes32[] trades; } /// @notice Defines a balance action for batchAction struct BalanceAction { // Deposit action to take (if any) DepositActionType actionType; uint16 currencyId; // Deposit action amount must correspond to the depositActionType, see documentation above. uint256 depositActionAmount; // Withdraw an amount of asset cash specified in Notional internal 8 decimal precision uint256 withdrawAmountInternalPrecision; // If set to true, will withdraw entire cash balance. Useful if there may be an unknown amount of asset cash // residual left from trading. bool withdrawEntireCashBalance; // If set to true, will redeem asset cash to the underlying token on withdraw. bool redeemToUnderlying; } /// @notice Defines a balance action with a set of trades to do as well struct BalanceActionWithTrades { DepositActionType actionType; uint16 currencyId; uint256 depositActionAmount; uint256 withdrawAmountInternalPrecision; bool withdrawEntireCashBalance; bool redeemToUnderlying; // Array of tightly packed 32 byte objects that represent trades. See TradeActionType documentation bytes32[] trades; } /****** In memory objects ******/ /// @notice Internal object that represents settled cash balances struct SettleAmount { uint16 currencyId; int256 positiveSettledCash; int256 negativeSettledCash; PrimeRate presentPrimeRate; } /// @notice Internal object that represents a token struct Token { address tokenAddress; bool hasTransferFee; int256 decimals; TokenType tokenType; uint256 deprecated_maxCollateralBalance; } /// @notice Internal object that represents an nToken portfolio struct nTokenPortfolio { CashGroupParameters cashGroup; PortfolioState portfolioState; int256 totalSupply; int256 cashBalance; uint256 lastInitializedTime; bytes6 parameters; address tokenAddress; } /// @notice Internal object used during liquidation struct LiquidationFactors { address account; // Aggregate free collateral of the account denominated in ETH underlying, 8 decimal precision int256 netETHValue; // Amount of net local currency asset cash before haircuts and buffers available int256 localPrimeAvailable; // Amount of net collateral currency asset cash before haircuts and buffers available int256 collateralAssetAvailable; // Haircut value of nToken holdings denominated in asset cash, will be local or collateral nTokens based // on liquidation type int256 nTokenHaircutPrimeValue; // nToken parameters for calculating liquidation amount bytes6 nTokenParameters; // ETH exchange rate from local currency to ETH ETHRate localETHRate; // ETH exchange rate from collateral currency to ETH ETHRate collateralETHRate; // Asset rate for the local currency, used in cross currency calculations to calculate local asset cash required PrimeRate localPrimeRate; // Used during currency liquidations if the account has liquidity tokens CashGroupParameters collateralCashGroup; // Used during currency liquidations if it is only a calculation, defaults to false bool isCalculation; } /// @notice Internal asset array portfolio state struct PortfolioState { // Array of currently stored assets PortfolioAsset[] storedAssets; // Array of new assets to add PortfolioAsset[] newAssets; uint256 lastNewAssetIndex; // Holds the length of stored assets after accounting for deleted assets uint256 storedAssetLength; } /// @notice In memory ETH exchange rate used during free collateral calculation. struct ETHRate { // The decimals (i.e. 10^rateDecimalPlaces) of the exchange rate, defined by the rate oracle int256 rateDecimals; // The exchange rate from base to ETH (if rate invert is required it is already done) int256 rate; // Amount of buffer as a multiple with a basis of 100 applied to negative balances. int256 buffer; // Amount of haircut as a multiple with a basis of 100 applied to positive balances int256 haircut; // Liquidation discount as a multiple with a basis of 100 applied to the exchange rate // as an incentive given to liquidators. int256 liquidationDiscount; } /// @notice Internal object used to handle balance state during a transaction struct BalanceState { uint16 currencyId; // Cash balance stored in balance state at the beginning of the transaction int256 storedCashBalance; // nToken balance stored at the beginning of the transaction int256 storedNTokenBalance; // The net cash change as a result of asset settlement or trading int256 netCashChange; // Amount of prime cash to redeem and withdraw from the system int256 primeCashWithdraw; // Net token transfers into or out of the account int256 netNTokenTransfer; // Net token supply change from minting or redeeming int256 netNTokenSupplyChange; // The last time incentives were claimed for this currency uint256 lastClaimTime; // Accumulator for incentives that the account no longer has a claim over uint256 accountIncentiveDebt; // Prime rate for converting prime cash balances PrimeRate primeRate; } /// @dev Asset rate used to convert between underlying cash and asset cash struct Deprecated_AssetRateParameters { // Address of the asset rate oracle AssetRateAdapter rateOracle; // The exchange rate from base to quote (if invert is required it is already done) int256 rate; // The decimals of the underlying, the rate converts to the underlying decimals int256 underlyingDecimals; } /// @dev Cash group when loaded into memory struct CashGroupParameters { uint16 currencyId; uint256 maxMarketIndex; PrimeRate primeRate; bytes32 data; } /// @dev A portfolio asset when loaded in memory struct PortfolioAsset { // Asset currency id uint16 currencyId; uint256 maturity; // Asset type, fCash or liquidity token. uint256 assetType; // fCash amount or liquidity token amount int256 notional; // Used for managing portfolio asset state uint256 storageSlot; // The state of the asset for when it is written to storage AssetStorageState storageState; } /// @dev Market object as represented in memory struct MarketParameters { bytes32 storageSlot; uint256 maturity; // Total amount of fCash available for purchase in the market. int256 totalfCash; // Total amount of cash available for purchase in the market. int256 totalPrimeCash; // Total amount of liquidity tokens (representing a claim on liquidity) in the market. int256 totalLiquidity; // This is the previous annualized interest rate in RATE_PRECISION that the market traded // at. This is used to calculate the rate anchor to smooth interest rates over time. uint256 lastImpliedRate; // Time lagged version of lastImpliedRate, used to value fCash assets at market rates while // remaining resistent to flash loan attacks. uint256 oracleRate; // This is the timestamp of the previous trade uint256 previousTradeTime; } /****** Storage objects ******/ /// @dev Token object in storage: /// 20 bytes for token address /// 1 byte for hasTransferFee /// 1 byte for tokenType /// 1 byte for tokenDecimals /// 9 bytes for maxCollateralBalance (may not always be set) struct TokenStorage { // Address of the token address tokenAddress; // Transfer fees will change token deposit behavior bool hasTransferFee; TokenType tokenType; uint8 decimalPlaces; uint72 deprecated_maxCollateralBalance; } /// @dev Exchange rate object as it is represented in storage, total storage is 25 bytes. struct ETHRateStorage { // Address of the rate oracle AggregatorV2V3Interface rateOracle; // The decimal places of precision that the rate oracle uses uint8 rateDecimalPlaces; // True of the exchange rate must be inverted bool mustInvert; // NOTE: both of these governance values are set with BUFFER_DECIMALS precision // Amount of buffer to apply to the exchange rate for negative balances. uint8 buffer; // Amount of haircut to apply to the exchange rate for positive balances uint8 haircut; // Liquidation discount in percentage point terms, 106 means a 6% discount uint8 liquidationDiscount; } /// @dev Asset rate oracle object as it is represented in storage, total storage is 21 bytes. struct AssetRateStorage { // Address of the rate oracle AssetRateAdapter rateOracle; // The decimal places of the underlying asset uint8 underlyingDecimalPlaces; } /// @dev Governance parameters for a cash group, total storage is 9 bytes + 7 bytes for liquidity token haircuts /// and 7 bytes for rate scalars, total of 23 bytes. Note that this is stored packed in the storage slot so there /// are no indexes stored for liquidityTokenHaircuts or rateScalars, maxMarketIndex is used instead to determine the /// length. struct CashGroupSettings { // Index of the AMMs on chain that will be made available. Idiosyncratic fCash // that is dated less than the longest AMM will be tradable. uint8 maxMarketIndex; // Time window in 5 minute increments that the rate oracle will be averaged over uint8 rateOracleTimeWindow5Min; // Absolute maximum discount factor as a discount from 1e9, specified in five basis points // subtracted from 1e9 uint8 maxDiscountFactor5BPS; // Share of the fees given to the protocol, denominated in percentage uint8 reserveFeeShare; // Debt buffer specified in 5 BPS increments uint8 debtBuffer25BPS; // fCash haircut specified in 5 BPS increments uint8 fCashHaircut25BPS; // Minimum oracle interest rates for fCash per market, specified in 25 bps increments uint8 minOracleRate25BPS; // If an account has fCash that is being liquidated, this is the discount that the liquidator can purchase it for uint8 liquidationfCashHaircut25BPS; // If an account has fCash that is being liquidated, this is the discount that the liquidator can purchase it for uint8 liquidationDebtBuffer25BPS; // Max oracle rate specified in 25bps increments as a discount from the max rate in the market. uint8 maxOracleRate25BPS; } /// @dev Holds account level context information used to determine settlement and /// free collateral actions. Total storage is 28 bytes struct AccountContext { // Used to check when settlement must be triggered on an account uint40 nextSettleTime; // For lenders that never incur debt, we use this flag to skip the free collateral check. bytes1 hasDebt; // Length of the account's asset array uint8 assetArrayLength; // If this account has bitmaps set, this is the corresponding currency id uint16 bitmapCurrencyId; // 9 total active currencies possible (2 bytes each) bytes18 activeCurrencies; // If this is set to true, the account can borrow variable prime cash and incur // negative cash balances inside BatchAction. This does not impact the settlement // of negative fCash to prime cash which will happen regardless of this setting. This // exists here mainly as a safety setting to ensure that accounts do not accidentally // incur negative cash balances. bool allowPrimeBorrow; } /// @dev Holds nToken context information mapped via the nToken address, total storage is /// 16 bytes struct nTokenContext { // Currency id that the nToken represents uint16 currencyId; // Annual incentive emission rate denominated in WHOLE TOKENS (multiply by // INTERNAL_TOKEN_PRECISION to get the actual rate) uint32 incentiveAnnualEmissionRate; // The last block time at utc0 that the nToken was initialized at, zero if it // has never been initialized uint32 lastInitializedTime; // Length of the asset array, refers to the number of liquidity tokens an nToken // currently holds uint8 assetArrayLength; // Each byte is a specific nToken parameter bytes6 nTokenParameters; // Reserved bytes for future usage bytes14 _unused; // Set to true if a secondary rewarder is set bool hasSecondaryRewarder; } /// @dev Holds account balance information, total storage 32 bytes struct BalanceStorage { // Number of nTokens held by the account uint80 nTokenBalance; // Last time the account claimed their nTokens uint32 lastClaimTime; // Incentives that the account no longer has a claim over uint56 accountIncentiveDebt; // Cash balance of the account int88 cashBalance; } /// @dev Holds information about a settlement rate, total storage 25 bytes struct SettlementRateStorage { uint40 blockTime; uint128 settlementRate; uint8 underlyingDecimalPlaces; } /// @dev Holds information about a market, total storage is 42 bytes so this spans /// two storage words struct MarketStorage { // Total fCash in the market uint80 totalfCash; // Total asset cash in the market uint80 totalPrimeCash; // Last annualized interest rate the market traded at uint32 lastImpliedRate; // Last recorded oracle rate for the market uint32 oracleRate; // Last time a trade was made uint32 previousTradeTime; // This is stored in slot + 1 uint80 totalLiquidity; } struct InterestRateParameters { // First kink for the utilization rate in RATE_PRECISION uint256 kinkUtilization1; // Second kink for the utilization rate in RATE_PRECISION uint256 kinkUtilization2; // First kink interest rate in RATE_PRECISION uint256 kinkRate1; // Second kink interest rate in RATE_PRECISION uint256 kinkRate2; // Max interest rate in RATE_PRECISION uint256 maxRate; // Minimum fee charged in RATE_PRECISION uint256 minFeeRate; // Maximum fee charged in RATE_PRECISION uint256 maxFeeRate; // Percentage of the interest rate that will be applied as a fee uint256 feeRatePercent; } // Specific interest rate curve settings for each market struct InterestRateCurveSettings { // First kink for the utilization rate, specified as a percentage // between 1-100 uint8 kinkUtilization1; // Second kink for the utilization rate, specified as a percentage // between 1-100 uint8 kinkUtilization2; // Interest rate at the first kink, set as 1/256 units from the kink // rate max uint8 kinkRate1; // Interest rate at the second kink, set as 1/256 units from the kink // rate max uint8 kinkRate2; // Max interest rate, set in units in 25bps increments less than or equal to 150 // and 150bps increments from 151 to 255. uint8 maxRateUnits; // Minimum fee charged in basis points uint8 minFeeRate5BPS; // Maximum fee charged in basis points uint8 maxFeeRate25BPS; // Percentage of the interest rate that will be applied as a fee uint8 feeRatePercent; } struct ifCashStorage { // Notional amount of fCash at the slot, limited to int128 to allow for // future expansion int128 notional; } /// @dev A single portfolio asset in storage, total storage of 19 bytes struct PortfolioAssetStorage { // Currency Id for the asset uint16 currencyId; // Maturity of the asset uint40 maturity; // Asset type (fCash or Liquidity Token marker) uint8 assetType; // Notional int88 notional; } /// @dev nToken total supply factors for the nToken, includes factors related /// to claiming incentives, total storage 32 bytes. This is the deprecated version struct nTokenTotalSupplyStorage_deprecated { // Total supply of the nToken uint96 totalSupply; // Integral of the total supply used for calculating the average total supply uint128 integralTotalSupply; // Last timestamp the supply value changed, used for calculating the integralTotalSupply uint32 lastSupplyChangeTime; } /// @dev nToken total supply factors for the nToken, includes factors related /// to claiming incentives, total storage 32 bytes. struct nTokenTotalSupplyStorage { // Total supply of the nToken uint96 totalSupply; // How many NOTE incentives should be issued per nToken in 1e18 precision uint128 accumulatedNOTEPerNToken; // Last timestamp when the accumulation happened uint32 lastAccumulatedTime; } /// @dev Used in view methods to return account balances in a developer friendly manner struct AccountBalance { uint16 currencyId; int256 cashBalance; int256 nTokenBalance; uint256 lastClaimTime; uint256 accountIncentiveDebt; } struct VaultConfigParams { uint16 flags; uint16 borrowCurrencyId; uint256 minAccountBorrowSize; uint16 minCollateralRatioBPS; uint8 feeRate5BPS; uint8 liquidationRate; uint8 reserveFeeShare; uint8 maxBorrowMarketIndex; uint16 maxDeleverageCollateralRatioBPS; uint16[2] secondaryBorrowCurrencies; uint16 maxRequiredAccountCollateralRatioBPS; uint256[2] minAccountSecondaryBorrow; uint8 excessCashLiquidationBonus; } struct VaultConfigStorage { // Vault Flags (documented in VaultConfiguration.sol) uint16 flags; // Primary currency the vault borrows in uint16 borrowCurrencyId; // Specified in whole tokens in 1e8 precision, allows a 4.2 billion min borrow size uint32 minAccountBorrowSize; // Minimum collateral ratio for a vault specified in basis points, valid values are greater than 10_000 // where the largest minimum collateral ratio is 65_536 which is much higher than anything reasonable. uint16 minCollateralRatioBPS; // Allows up to a 12.75% annualized fee uint8 feeRate5BPS; // A percentage that represents the share of the cash raised that will go to the liquidator uint8 liquidationRate; // A percentage of the fee given to the protocol uint8 reserveFeeShare; // Maximum market index where a vault can borrow from uint8 maxBorrowMarketIndex; // Maximum collateral ratio that a liquidator can push a an account to during deleveraging uint16 maxDeleverageCollateralRatioBPS; // An optional list of secondary borrow currencies uint16[2] secondaryBorrowCurrencies; // Required collateral ratio for accounts to stay inside a vault, prevents accounts // from "free riding" on vaults. Enforced on entry and exit, not on deleverage. uint16 maxRequiredAccountCollateralRatioBPS; // Specified in whole tokens in 1e8 precision, allows a 4.2 billion min borrow size uint32[2] minAccountSecondaryBorrow; // Specified as a percent discount off the exchange rate of the excess cash that will be paid to // the liquidator during liquidateExcessVaultCash uint8 excessCashLiquidationBonus; // 8 bytes left } struct VaultBorrowCapacityStorage { // Total fCash across all maturities that caps the borrow capacity uint80 maxBorrowCapacity; // Total fCash debt across all maturities uint80 totalfCashDebt; } struct VaultAccountSecondaryDebtShareStorage { // Maturity for the account's secondary borrows. This is stored separately from // the vault account maturity to ensure that we have access to the proper state // during a roll borrow position. It should never be allowed to deviate from the // vaultAccount.maturity value (unless it is cleared to zero). uint40 maturity; // Account debt for the first secondary currency in either fCash or pCash denomination uint80 accountDebtOne; // Account debt for the second secondary currency in either fCash or pCash denomination uint80 accountDebtTwo; } struct VaultConfig { address vault; uint16 flags; uint16 borrowCurrencyId; int256 minAccountBorrowSize; int256 feeRate; int256 minCollateralRatio; int256 liquidationRate; int256 reserveFeeShare; uint256 maxBorrowMarketIndex; int256 maxDeleverageCollateralRatio; uint16[2] secondaryBorrowCurrencies; PrimeRate primeRate; int256 maxRequiredAccountCollateralRatio; int256[2] minAccountSecondaryBorrow; int256 excessCashLiquidationBonus; } /// @notice Represents a Vault's current borrow and collateral state struct VaultStateStorage { // This represents the total amount of borrowing in the vault for the current // vault term. If the vault state is the prime cash maturity, this is stored in // prime cash debt denomination, if fCash then it is stored in internal underlying. uint80 totalDebt; // The total amount of prime cash in the pool held as a result of emergency settlement uint80 deprecated_totalPrimeCash; // Total vault shares in this maturity uint80 totalVaultShares; // Set to true if a vault's debt position has been migrated to the prime cash vault bool isSettled; // NOTE: 8 bits left // ----- This breaks into a new storage slot ------- // The total amount of strategy tokens held in the pool uint80 deprecated_totalStrategyTokens; // Valuation of a strategy token at settlement int80 deprecated_settlementStrategyTokenValue; // NOTE: 96 bits left } /// @notice Represents the remaining assets in a vault post settlement struct Deprecated_VaultSettledAssetsStorage { // Remaining strategy tokens that have not been withdrawn uint80 remainingStrategyTokens; // Remaining asset cash that has not been withdrawn int80 remainingPrimeCash; } struct VaultState { uint256 maturity; // Total debt is always denominated in underlying on the stack int256 totalDebtUnderlying; uint256 totalVaultShares; bool isSettled; } /// @notice Represents an account's position within an individual vault struct VaultAccountStorage { // Total amount of debt for the account in the primary borrowed currency. // If the account is borrowing prime cash, this is stored in prime cash debt // denomination, if fCash then it is stored in internal underlying. uint80 accountDebt; // Vault shares that the account holds uint80 vaultShares; // Maturity when the vault shares and fCash will mature uint40 maturity; // Last time when a vault was entered or exited, used to ensure that vault accounts do not // flash enter/exit. While there is no specified attack vector here, we can use it to prevent // an entire class of attacks from happening without reducing UX. // NOTE: in the original version this value was set to the block.number, however, in this // version it is being changed to time based. On ETH mainnet block heights are much smaller // than block times, accounts that migrate from lastEntryBlockHeight => lastUpdateBlockTime // will not see any issues with entering / exiting the protocol. uint32 lastUpdateBlockTime; // ---------------- Second Storage Slot ---------------------- // Cash balances held by the vault account as a result of lending at zero interest or due // to deleveraging (liquidation). In the previous version of leveraged vaults, accounts would // simply lend at zero interest which was not a problem. However, with vaults being able to // discount fCash to present value, lending at zero percent interest may have an adverse effect // on the account's collateral position (i.e. lending at zero puts them further into danger). // Holding cash against debt will eliminate that risk, making vault liquidation more similar to // regular Notional liquidation. uint80 primaryCash; uint80 secondaryCashOne; uint80 secondaryCashTwo; } struct VaultAccount { // On the stack, account debts are always in underlying int256 accountDebtUnderlying; uint256 maturity; uint256 vaultShares; address account; // This cash balance is used just within a transaction to track deposits // and withdraws for an account. Must be zeroed by the time we store the account int256 tempCashBalance; uint256 lastUpdateBlockTime; } // Used to hold vault account liquidation factors in memory struct VaultAccountHealthFactors { // Account's calculated collateral ratio int256 collateralRatio; // Total outstanding debt across all borrowed currencies in primary int256 totalDebtOutstandingInPrimary; // Total value of vault shares in underlying denomination int256 vaultShareValueUnderlying; // Debt outstanding in local currency denomination after present value and // account cash held netting applied. Can be positive if the account holds cash // in excess of debt. int256[3] netDebtOutstanding; } // PrimeCashInterestRateParameters take up 16 bytes, this takes up 32 bytes so we // can expand another 16 bytes to increase the storage slots a bit.... struct PrimeCashFactorsStorage { // Storage slot 1 [Prime Supply Factors, 248 bytes] uint40 lastAccrueTime; uint88 totalPrimeSupply; uint88 lastTotalUnderlyingValue; // Overflows at 429% interest using RATE_PRECISION uint32 oracleSupplyRate; bool allowDebt; // Storage slot 2 [Prime Debt Factors, 256 bytes] uint88 totalPrimeDebt; // Each one of these values below is stored as a FloatingPoint32 value which // gives us approx 7 digits of precision for each value. Because these are used // to maintain supply and borrow caps, they are not required to be exact. uint32 maxUnderlyingSupply; // The maximum utilization that prime debt is allowed to reach by users borrowing prime // debt via the markets directly. This cap is not applied to liquidations and settlement. uint8 maxPrimeDebtUtilization; uint120 _reserved; // Reserving the next 128 bytes for future use in case we decide to implement debt // caps on a currency. In that case, we will need to track the total fcash overall // and subtract the total debt held in vaults. // uint32 maxUnderlyingDebt; // uint32 totalfCashDebtOverall; // uint32 totalfCashDebtInVaults; // uint32 totalPrimeDebtInVaults; // 8 bytes left // Storage slot 3 [Prime Scalars, 240 bytes] // Scalars are stored in 18 decimal precision (i.e. double rate precision) and uint80 // maxes out at approx 1,210,000e18 // ln(1,210,000) = rate * years = 14 // Approx 46 years at 30% interest // Approx 233 years at 6% interest uint80 underlyingScalar; uint80 supplyScalar; uint80 debtScalar; // The time window in 5 min increments that the rate oracle will be averaged over uint8 rateOracleTimeWindow5Min; // 8 bytes left } struct PrimeCashFactors { uint256 lastAccrueTime; uint256 totalPrimeSupply; uint256 totalPrimeDebt; uint256 oracleSupplyRate; uint256 lastTotalUnderlyingValue; uint256 underlyingScalar; uint256 supplyScalar; uint256 debtScalar; uint256 rateOracleTimeWindow; } struct PrimeRate { int256 supplyFactor; int256 debtFactor; uint256 oracleSupplyRate; } struct PrimeSettlementRateStorage { uint80 supplyScalar; uint80 debtScalar; uint80 underlyingScalar; bool isSet; } struct PrimeCashHoldingsOracle { IPrimeCashHoldingsOracle oracle; } // Per currency rebalancing context struct RebalancingContextStorage { // Holds the previous supply factor to calculate the oracle money market rate uint128 previousSupplyFactorAtRebalance; // Rebalancing has a cool down period that sets the time averaging of the oracle money market rate uint40 rebalancingCooldownInSeconds; uint40 lastRebalanceTimestampInSeconds; // 48 bytes left } struct TotalfCashDebtStorage { uint80 totalfCashDebt; // These two variables are used to track fCash lend at zero // edge conditions for leveraged vaults. uint80 fCashDebtHeldInSettlementReserve; uint80 primeCashHeldInSettlementReserve; } struct RebalancingTargetData { uint8 targetUtilization; uint16 externalWithdrawThreshold; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity =0.7.6; import {Constants} from "../global/Constants.sol"; library SafeUint256 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); return a / b; } function max(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? x : y; } function min(uint256 x, uint256 y) internal pure returns (uint256) { return x < y ? x : y; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); return a % b; } function divInRatePrecision(uint256 x, uint256 y) internal pure returns (uint256) { return div(mul(x, uint256(Constants.RATE_PRECISION)), y); } function mulInRatePrecision(uint256 x, uint256 y) internal pure returns (uint256) { return div(mul(x, y), uint256(Constants.RATE_PRECISION)); } function divInScalarPrecision(uint256 x, uint256 y) internal pure returns (uint256) { return div(mul(x, Constants.SCALAR_PRECISION), y); } function mulInScalarPrecision(uint256 x, uint256 y) internal pure returns (uint256) { return div(mul(x, y), Constants.SCALAR_PRECISION); } function toUint8(uint256 x) internal pure returns (uint8) { require(x <= type(uint8).max); return uint8(x); } function toUint32(uint256 x) internal pure returns (uint32) { require(x <= type(uint32).max); return uint32(x); } function toUint40(uint256 x) internal pure returns (uint40) { require(x <= type(uint40).max); return uint40(x); } function toUint48(uint256 x) internal pure returns (uint48) { require(x <= type(uint48).max); return uint48(x); } function toUint56(uint256 x) internal pure returns (uint56) { require(x <= type(uint56).max); return uint56(x); } function toUint72(uint256 x) internal pure returns (uint72) { require(x <= type(uint72).max); return uint72(x); } function toUint80(uint256 x) internal pure returns (uint80) { require(x <= type(uint80).max); return uint80(x); } function toUint88(uint256 x) internal pure returns (uint88) { require(x <= type(uint88).max); return uint88(x); } function toUint104(uint256 x) internal pure returns (uint104) { require(x <= type(uint104).max); return uint104(x); } function toUint112(uint256 x) internal pure returns (uint112) { require(x <= type(uint112).max); return uint112(x); } function toUint128(uint256 x) internal pure returns (uint128) { require(x <= type(uint128).max); return uint128(x); } function toInt(uint256 x) internal pure returns (int256) { require (x <= uint256(type(int256).max)); // dev: toInt overflow return int256(x); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.3.2 (proxy/beacon/IBeacon.sol) pragma solidity >=0.7.6; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } interface IUpgradeableBeacon is IBeacon { function upgradeTo(address newImplementation) external; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; struct LendingPoolStorage { ILendingPool lendingPool; } interface ILendingPool { /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (ReserveData memory); struct ReserveData { ReserveConfigurationMap configuration; uint128 liquidityIndex; uint128 currentLiquidityRate; uint128 variableBorrowIndex; uint128 currentVariableBorrowRate; uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; uint16 id; address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; address interestRateStrategyAddress; uint128 accruedToTreasury; uint128 unbacked; uint128 isolationModeTotalDebt; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } struct UserConfigurationMap { uint256 data; } enum InterestRateMode {NONE, STABLE, VARIABLE} }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface AggregatorInterface { function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt); event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import "./AggregatorInterface.sol"; import "./AggregatorV3Interface.sol"; interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface { }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT pragma solidity >=0.7.6; /** * @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); function decimals() external view returns (uint8); /** * @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: BSUL-1.1 pragma solidity >=0.7.0; /// @notice Used as a wrapper for tokens that are interest bearing for an /// underlying token. Follows the cToken interface, however, can be adapted /// for other interest bearing tokens. interface AssetRateAdapter { function token() external view returns (address); function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function underlying() external view returns (address); function getExchangeRateStateful() external returns (int256); function getExchangeRateView() external view returns (int256); function getAnnualizedSupplyRate() external view returns (uint256); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.0; pragma abicoder v2; struct DepositData { address[] targets; bytes[] callData; uint256[] msgValue; uint256 underlyingDepositAmount; address assetToken; uint8 rebasingTokenBalanceAdjustment; } struct RedeemData { address[] targets; bytes[] callData; uint256 expectedUnderlying; address assetToken; uint8 rebasingTokenBalanceAdjustment; } struct OracleData { address holding; uint256 externalUnderlyingAvailableForWithdraw; uint256 currentExternalUnderlyingLend; uint256 maxExternalDeposit; } interface IPrimeCashHoldingsOracle { /// @notice Returns a list of the various holdings for the prime cash /// currency function holdings() external view returns (address[] memory); /// @notice Returns the underlying token that all holdings can be redeemed /// for. function underlying() external view returns (address); /// @notice Returns the native decimal precision of the underlying token function decimals() external view returns (uint8); /// @notice Returns the total underlying held by the caller in all the /// listed holdings function getTotalUnderlyingValueStateful() external returns ( uint256 nativePrecision, uint256 internalPrecision ); function getTotalUnderlyingValueView() external view returns ( uint256 nativePrecision, uint256 internalPrecision ); /// @notice Returns calldata for how to withdraw an amount function getRedemptionCalldata(uint256 withdrawAmount) external view returns ( RedeemData[] memory redeemData ); function holdingValuesInUnderlying() external view returns (uint256[] memory); function getRedemptionCalldataForRebalancing( address[] calldata _holdings, uint256[] calldata withdrawAmounts ) external view returns ( RedeemData[] memory redeemData ); function getDepositCalldataForRebalancing( address[] calldata _holdings, uint256[] calldata depositAmounts ) external view returns ( DepositData[] memory depositData ); function getOracleData() external view returns (OracleData memory); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; interface IRewarder { event RewardTransfer(address indexed rewardToken, address indexed account, uint256 amount); event RewardEmissionUpdate(uint256 emissionRatePerYear, uint256 endTime); function NTOKEN_ADDRESS() external returns(address); function CURRENCY_ID() external returns(uint16); function detached() external returns(bool); function claimRewards( address account, uint16 currencyId, uint256 nTokenBalanceBefore, uint256 nTokenBalanceAfter, uint256 totalSupply ) external; function getAccountRewardClaim(address account, uint32 blockTime) external returns (uint256); function getAccountRewardClaim(address account, uint256 nTokenBalanceAtDetach, bytes32[] calldata proof) external returns (uint256); function claimRewardsDirect(address account, uint256 nTokenBalanceAtDetach, bytes32[] calldata proof) external; function accumulatedRewardPerNToken() external returns (uint128); function lastAccumulatedTime() external returns (uint32); function emissionRatePerYear() external returns (uint128); function detach() external; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import { VaultConfigParams, VaultConfigStorage, VaultConfig, VaultState, VaultAccount, VaultAccountHealthFactors, PrimeRate } from "../../contracts/global/Types.sol"; interface IVaultAction { /// @notice Emitted when a new vault is listed or updated event VaultUpdated(address indexed vault, bool enabled, uint80 maxPrimaryBorrowCapacity); /// @notice Emitted when a vault's status is updated event VaultPauseStatus(address indexed vault, bool enabled); /// @notice Emitted when a vault's deleverage status is updated event VaultDeleverageStatus(address indexed vaultAddress, bool disableDeleverage); /// @notice Emitted when a secondary currency borrow capacity is updated event VaultUpdateSecondaryBorrowCapacity(address indexed vault, uint16 indexed currencyId, uint80 maxSecondaryBorrowCapacity); /// @notice Emitted when the borrow capacity on a vault changes event VaultBorrowCapacityChange(address indexed vault, uint16 indexed currencyId, uint256 totalUsedBorrowCapacity); /// @notice Emitted when a vault executes a secondary borrow event VaultSecondaryTransaction( address indexed vault, address indexed account, uint16 indexed currencyId, uint256 maturity, int256 netUnderlyingDebt, int256 netPrimeSupply ); /** Vault Action Methods */ /// @notice Governance only method to whitelist a particular vault function updateVault( address vaultAddress, VaultConfigParams memory vaultConfig, uint80 maxPrimaryBorrowCapacity ) external; /// @notice Governance only method to pause a particular vault function setVaultPauseStatus( address vaultAddress, bool enable ) external; function setVaultDeleverageStatus( address vaultAddress, bool disableDeleverage ) external; /// @notice Governance only method to set the borrow capacity function setMaxBorrowCapacity( address vaultAddress, uint80 maxVaultBorrowCapacity ) external; /// @notice Governance only method to update a vault's secondary borrow capacity function updateSecondaryBorrowCapacity( address vaultAddress, uint16 secondaryCurrencyId, uint80 maxBorrowCapacity ) external; function borrowSecondaryCurrencyToVault( address account, uint256 maturity, uint256[2] calldata underlyingToBorrow, uint32[2] calldata maxBorrowRate, uint32[2] calldata minRollLendRate ) external returns (int256[2] memory underlyingTokensTransferred); function repaySecondaryCurrencyFromVault( address account, uint256 maturity, uint256[2] calldata underlyingToRepay, uint32[2] calldata minLendRate ) external payable returns (int256[2] memory underlyingDepositExternal); function settleSecondaryBorrowForAccount(address vault, address account) external; } interface IVaultAccountAction { /** * @notice Borrows a specified amount of fCash in the vault's borrow currency and deposits it * all plus the depositAmountExternal into the vault to mint strategy tokens. * * @param account the address that will enter the vault * @param vault the vault to enter * @param depositAmountExternal some amount of additional collateral in the borrowed currency * to be transferred to vault * @param maturity the maturity to borrow at * @param fCash amount to borrow * @param maxBorrowRate maximum interest rate to borrow at * @param vaultData additional data to pass to the vault contract */ function enterVault( address account, address vault, uint256 depositAmountExternal, uint256 maturity, uint256 fCash, uint32 maxBorrowRate, bytes calldata vaultData ) external payable returns (uint256 strategyTokensAdded); /** * @notice Re-enters the vault at a longer dated maturity. The account's existing borrow * position will be closed and a new borrow position at the specified maturity will be * opened. All strategy token holdings will be rolled forward. * * @param account the address that will reenter the vault * @param vault the vault to reenter * @param fCashToBorrow amount of fCash to borrow in the next maturity * @param maturity new maturity to borrow at */ function rollVaultPosition( address account, address vault, uint256 fCashToBorrow, uint256 maturity, uint256 depositAmountExternal, uint32 minLendRate, uint32 maxBorrowRate, bytes calldata enterVaultData ) external payable returns (uint256 strategyTokensAdded); /** * @notice Prior to maturity, allows an account to withdraw their position from the vault. Will * redeem some number of vault shares to the borrow currency and close the borrow position by * lending `fCashToLend`. Any shortfall in cash from lending will be transferred from the account, * any excess profits will be transferred to the account. * * Post maturity, will net off the account's debt against vault cash balances and redeem all remaining * strategy tokens back to the borrowed currency and transfer the profits to the account. * * @param account the address that will exit the vault * @param vault the vault to enter * @param vaultSharesToRedeem amount of vault tokens to exit, only relevant when exiting pre-maturity * @param fCashToLend amount of fCash to lend * @param minLendRate the minimum rate to lend at * @param exitVaultData passed to the vault during exit * @return underlyingToReceiver amount of underlying tokens returned to the receiver on exit */ function exitVault( address account, address vault, address receiver, uint256 vaultSharesToRedeem, uint256 fCashToLend, uint32 minLendRate, bytes calldata exitVaultData ) external payable returns (uint256 underlyingToReceiver); function settleVaultAccount(address account, address vault) external; } interface IVaultLiquidationAction { event VaultDeleverageAccount( address indexed vault, address indexed account, uint16 currencyId, uint256 vaultSharesToLiquidator, int256 depositAmountPrimeCash ); event VaultLiquidatorProfit( address indexed vault, address indexed account, address indexed liquidator, uint256 vaultSharesToLiquidator, bool transferSharesToLiquidator ); event VaultAccountCashLiquidation( address indexed vault, address indexed account, address indexed liquidator, uint16 currencyId, int256 fCashDeposit, int256 cashToLiquidator ); /** * @notice If an account is below the minimum collateral ratio, this method wil deleverage (liquidate) * that account. `depositAmountExternal` in the borrow currency will be transferred from the liquidator * and used to offset the account's debt position. The liquidator will receive either vaultShares or * cash depending on the vault's configuration. * @param account the address that will exit the vault * @param vault the vault to enter * @param liquidator the address that will receive profits from liquidation * @param depositAmountPrimeCash amount of cash to deposit * @return vaultSharesFromLiquidation amount of vaultShares received from liquidation */ function deleverageAccount( address account, address vault, address liquidator, uint16 currencyIndex, int256 depositUnderlyingInternal ) external payable returns (uint256 vaultSharesFromLiquidation, int256 depositAmountPrimeCash); function liquidateVaultCashBalance( address account, address vault, address liquidator, uint256 currencyIndex, int256 fCashDeposit ) external returns (int256 cashToLiquidator); function liquidateExcessVaultCash( address account, address vault, address liquidator, uint256 excessCashIndex, uint256 debtIndex, uint256 _depositUnderlyingInternal ) external payable returns (int256 cashToLiquidator); } interface IVaultAccountHealth { function getVaultAccountHealthFactors(address account, address vault) external view returns ( VaultAccountHealthFactors memory h, int256[3] memory maxLiquidatorDepositUnderlying, uint256[3] memory vaultSharesToLiquidator ); function calculateDepositAmountInDeleverage( uint256 currencyIndex, VaultAccount memory vaultAccount, VaultConfig memory vaultConfig, VaultState memory vaultState, int256 depositUnderlyingInternal ) external returns (int256 depositInternal, uint256 vaultSharesToLiquidator, PrimeRate memory); function getfCashRequiredToLiquidateCash( uint16 currencyId, uint256 maturity, int256 vaultAccountCashBalance ) external view returns (int256 fCashRequired, int256 discountFactor); function checkVaultAccountCollateralRatio(address vault, address account, bool checkDebtCap) external; function getVaultAccount(address account, address vault) external view returns (VaultAccount memory); function getVaultAccountWithFeeAccrual( address account, address vault ) external view returns (VaultAccount memory, int256 accruedPrimeVaultFeeInUnderlying); function getVaultConfig(address vault) external view returns (VaultConfig memory vaultConfig); function getBorrowCapacity(address vault, uint16 currencyId) external view returns ( uint256 currentPrimeDebtUnderlying, uint256 totalfCashDebt, uint256 maxBorrowCapacity ); function getSecondaryBorrow(address vault, uint16 currencyId, uint256 maturity) external view returns (int256 totalDebt); /// @notice View method to get vault state function getVaultState(address vault, uint256 maturity) external view returns (VaultState memory vaultState); function getVaultAccountSecondaryDebt(address account, address vault) external view returns ( uint256 maturity, int256[2] memory accountSecondaryDebt, int256[2] memory accountSecondaryCashHeld ); function signedBalanceOfVaultTokenId(address account, uint256 id) external view returns (int256); } interface IVaultController is IVaultAccountAction, IVaultAction, IVaultLiquidationAction, IVaultAccountHealth {}
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import "../../contracts/global/Types.sol"; interface nERC1155Interface { event TransferSingle( address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value ); event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); event ApprovalForAll(address indexed account, address indexed operator, bool approved); event URI(string value, uint256 indexed id); function supportsInterface(bytes4 interfaceId) external pure returns (bool); function balanceOf(address account, uint256 id) external view returns (uint256); function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); function signedBalanceOf(address account, uint256 id) external view returns (int256); function signedBalanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (int256[] memory); function setApprovalForAll(address operator, bool approved) external; function isApprovedForAll(address account, address operator) external view returns (bool); function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external payable; function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external payable; function decodeToAssets(uint256[] calldata ids, uint256[] calldata amounts) external view returns (PortfolioAsset[] memory); function encodeToId( uint16 currencyId, uint40 maturity, uint8 assetType ) external pure returns (uint256 id); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import "../../contracts/global/Types.sol"; interface NotionalCalculations { function calculateNTokensToMint(uint16 currencyId, uint88 amountToDepositExternalPrecision) external view returns (uint256); function nTokenPresentValueAssetDenominated(uint16 currencyId) external view returns (int256); function nTokenPresentValueUnderlyingDenominated(uint16 currencyId) external view returns (int256); function convertNTokenToUnderlying(uint16 currencyId, int256 nTokenBalance) external view returns (int256); function getfCashAmountGivenCashAmount( uint16 currencyId, int88 netCashToAccount, uint256 marketIndex, uint256 blockTime ) external view returns (int256); function getCashAmountGivenfCashAmount( uint16 currencyId, int88 fCashAmount, uint256 marketIndex, uint256 blockTime ) external view returns (int256, int256); function nTokenGetClaimableIncentives(address account, uint256 blockTime) external view returns (uint256); function getPresentfCashValue( uint16 currencyId, uint256 maturity, int256 notional, uint256 blockTime, bool riskAdjusted ) external view returns (int256 presentValue); function getMarketIndex( uint256 maturity, uint256 blockTime ) external pure returns (uint8 marketIndex); function getfCashLendFromDeposit( uint16 currencyId, uint256 depositAmountExternal, uint256 maturity, uint32 minLendRate, uint256 blockTime, bool useUnderlying ) external view returns ( uint88 fCashAmount, uint8 marketIndex, bytes32 encodedTrade ); function getfCashBorrowFromPrincipal( uint16 currencyId, uint256 borrowedAmountExternal, uint256 maturity, uint32 maxBorrowRate, uint256 blockTime, bool useUnderlying ) external view returns ( uint88 fCashDebt, uint8 marketIndex, bytes32 encodedTrade ); function getDepositFromfCashLend( uint16 currencyId, uint256 fCashAmount, uint256 maturity, uint32 minLendRate, uint256 blockTime ) external view returns ( uint256 depositAmountUnderlying, uint256 depositAmountAsset, uint8 marketIndex, bytes32 encodedTrade ); function getPrincipalFromfCashBorrow( uint16 currencyId, uint256 fCashBorrow, uint256 maturity, uint32 maxBorrowRate, uint256 blockTime ) external view returns ( uint256 borrowAmountUnderlying, uint256 borrowAmountAsset, uint8 marketIndex, bytes32 encodedTrade ); function convertCashBalanceToExternal( uint16 currencyId, int256 cashBalanceInternal, bool useUnderlying ) external view returns (int256); function convertUnderlyingToPrimeCash( uint16 currencyId, int256 underlyingExternal ) external view returns (int256); function convertSettledfCash( uint16 currencyId, uint256 maturity, int256 fCashBalance, uint256 blockTime ) external view returns (int256 signedPrimeSupplyValue); function accruePrimeInterest( uint16 currencyId ) external returns (PrimeRate memory pr, PrimeCashFactors memory); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import "../../contracts/global/Deployments.sol"; import "../../contracts/global/Types.sol"; import "../../interfaces/chainlink/AggregatorV2V3Interface.sol"; import "../../interfaces/notional/NotionalGovernance.sol"; import "../../interfaces/notional/IRewarder.sol"; import "../../interfaces/aave/ILendingPool.sol"; import {IPrimeCashHoldingsOracle} from "../../interfaces/notional/IPrimeCashHoldingsOracle.sol"; interface NotionalGovernance { event ListCurrency(uint16 newCurrencyId); event UpdateETHRate(uint16 currencyId); event UpdateAssetRate(uint16 currencyId); event UpdateCashGroup(uint16 currencyId); event DeployNToken(uint16 currencyId, address nTokenAddress); event UpdateDepositParameters(uint16 currencyId); event UpdateInitializationParameters(uint16 currencyId); event UpdateTokenCollateralParameters(uint16 currencyId); event UpdateGlobalTransferOperator(address operator, bool approved); event UpdateAuthorizedCallbackContract(address operator, bool approved); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event PauseRouterAndGuardianUpdated(address indexed pauseRouter, address indexed pauseGuardian); event UpdateInterestRateCurve(uint16 indexed currencyId, uint8 indexed marketIndex); event UpdateMaxUnderlyingSupply(uint16 indexed currencyId, uint256 maxUnderlyingSupply); event PrimeProxyDeployed(uint16 indexed currencyId, address proxy, bool isCashProxy); function transferOwnership(address newOwner, bool direct) external; function claimOwnership() external; function upgradeBeacon(Deployments.BeaconType proxy, address newBeacon) external; function setPauseRouterAndGuardian(address pauseRouter_, address pauseGuardian_) external; function listCurrency( TokenStorage calldata underlyingToken, ETHRateStorage memory ethRate, InterestRateCurveSettings calldata primeDebtCurve, IPrimeCashHoldingsOracle primeCashHoldingsOracle, bool allowPrimeCashDebt, uint8 rateOracleTimeWindow5Min, string calldata underlyingName, string calldata underlyingSymbol ) external returns (uint16 currencyId); function enableCashGroup( uint16 currencyId, CashGroupSettings calldata cashGroup, string calldata underlyingName, string calldata underlyingSymbol ) external; function updateDepositParameters( uint16 currencyId, uint32[] calldata depositShares, uint32[] calldata leverageThresholds ) external; function updateInitializationParameters( uint16 currencyId, uint32[] calldata annualizedAnchorRates, uint32[] calldata proportions ) external; function updateTokenCollateralParameters( uint16 currencyId, uint8 residualPurchaseIncentive10BPS, uint8 pvHaircutPercentage, uint8 residualPurchaseTimeBufferHours, uint8 cashWithholdingBuffer10BPS, uint8 liquidationHaircutPercentage, uint8 maxMintDeviationPercentage ) external; function updateCashGroup(uint16 currencyId, CashGroupSettings calldata cashGroup) external; function updateInterestRateCurve( uint16 currencyId, uint8[] calldata marketIndices, InterestRateCurveSettings[] calldata settings ) external; function setMaxUnderlyingSupply( uint16 currencyId, uint256 maxUnderlyingSupply, uint8 maxPrimeDebtUtilization ) external; function updatePrimeCashHoldingsOracle( uint16 currencyId, IPrimeCashHoldingsOracle primeCashHoldingsOracle ) external; function updatePrimeCashCurve( uint16 currencyId, InterestRateCurveSettings calldata primeDebtCurve ) external; function enablePrimeDebt( uint16 currencyId, string calldata underlyingName, string calldata underlyingSymbol ) external; function updateETHRate( uint16 currencyId, AggregatorV2V3Interface rateOracle, bool mustInvert, uint8 buffer, uint8 haircut, uint8 liquidationDiscount ) external; function updateAuthorizedCallbackContract(address operator, bool approved) external; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import "../../contracts/global/Types.sol"; import "./nTokenERC20.sol"; import "./nERC1155Interface.sol"; import "./NotionalGovernance.sol"; import "./NotionalCalculations.sol"; import "./NotionalViews.sol"; import "./NotionalTreasury.sol"; import {IVaultController} from "./IVaultController.sol"; interface NotionalProxy is nTokenERC20, nERC1155Interface, NotionalGovernance, NotionalTreasury, NotionalCalculations, NotionalViews, IVaultController { /** User trading events */ event MarketsInitialized(uint16 currencyId); event SweepCashIntoMarkets(uint16 currencyId, int256 cashIntoMarkets); /// @notice Emitted once when incentives are migrated event IncentivesMigrated( uint16 currencyId, uint256 migrationEmissionRate, uint256 finalIntegralTotalSupply, uint256 migrationTime ); /// @notice Emitted if a token address is migrated event TokenMigrated(uint16 currencyId) ; /// @notice Emitted whenever an account context has updated event AccountContextUpdate(address indexed account); /// @notice Emitted when an account has assets that are settled event AccountSettled(address indexed account); /* Liquidation Events */ event LiquidateLocalCurrency( address indexed liquidated, address indexed liquidator, uint16 localCurrencyId, int256 netLocalFromLiquidator ); event LiquidateCollateralCurrency( address indexed liquidated, address indexed liquidator, uint16 localCurrencyId, uint16 collateralCurrencyId, int256 netLocalFromLiquidator, int256 netCollateralTransfer, int256 netNTokenTransfer ); event LiquidatefCashEvent( address indexed liquidated, address indexed liquidator, uint16 localCurrencyId, uint16 fCashCurrency, int256 netLocalFromLiquidator, uint256[] fCashMaturities, int256[] fCashNotionalTransfer ); event SetPrimeSettlementRate( uint256 indexed currencyId, uint256 indexed maturity, int256 supplyFactor, int256 debtFactor ); /// @notice Emits every time interest is accrued event PrimeCashInterestAccrued( uint16 indexed currencyId, uint256 underlyingScalar, uint256 supplyScalar, uint256 debtScalar ); event PrimeCashCurveChanged(uint16 indexed currencyId); event PrimeCashHoldingsOracleUpdated(uint16 indexed currencyId, address oracle); /** UUPS Upgradeable contract calls */ function upgradeTo(address newImplementation) external; function upgradeToAndCall(address newImplementation, bytes memory data) external payable; function getImplementation() external view returns (address); function owner() external view returns (address); function pauseRouter() external view returns (address); function pauseGuardian() external view returns (address); /** Initialize Markets Action */ function initializeMarkets(uint16 currencyId, bool isFirstInit) external; function sweepCashIntoMarkets(uint16 currencyId) external; /** Account Action */ function nTokenRedeem( address redeemer, uint16 currencyId, uint96 tokensToRedeem_ ) external returns (int256); function enablePrimeBorrow(bool allowPrimeBorrow) external; function enableBitmapCurrency(uint16 currencyId) external; function settleAccount(address account) external; function depositUnderlyingToken( address account, uint16 currencyId, uint256 amountExternalPrecision ) external payable returns (uint256); function depositAssetToken( address account, uint16 currencyId, uint256 amountExternalPrecision ) external returns (uint256); function withdraw( uint16 currencyId, uint88 amountInternalPrecision, bool redeemToUnderlying ) external returns (uint256); function withdrawViaProxy( uint16 currencyId, address owner, address receiver, address spender, uint88 withdrawAmountPrimeCash ) external returns (uint256); /** Batch Action */ function batchBalanceAction(address account, BalanceAction[] calldata actions) external payable; function batchBalanceAndTradeAction(address account, BalanceActionWithTrades[] calldata actions) external payable; function batchBalanceAndTradeActionWithCallback( address account, BalanceActionWithTrades[] calldata actions, bytes calldata callbackData ) external payable; function batchLend(address account, BatchLend[] calldata actions) external; /** Liquidation Action */ function calculateLocalCurrencyLiquidation( address liquidateAccount, uint16 localCurrency, uint96 maxNTokenLiquidation ) external returns (int256, int256); function liquidateLocalCurrency( address liquidateAccount, uint16 localCurrency, uint96 maxNTokenLiquidation ) external payable returns (int256, int256); function calculateCollateralCurrencyLiquidation( address liquidateAccount, uint16 localCurrency, uint16 collateralCurrency, uint128 maxCollateralLiquidation, uint96 maxNTokenLiquidation ) external returns (int256, int256, int256); function liquidateCollateralCurrency( address liquidateAccount, uint16 localCurrency, uint16 collateralCurrency, uint128 maxCollateralLiquidation, uint96 maxNTokenLiquidation, bool withdrawCollateral, bool redeemToUnderlying ) external payable returns (int256, int256, int256); function calculatefCashLocalLiquidation( address liquidateAccount, uint16 localCurrency, uint256[] calldata fCashMaturities, uint256[] calldata maxfCashLiquidateAmounts ) external returns (int256[] memory, int256); function liquidatefCashLocal( address liquidateAccount, uint16 localCurrency, uint256[] calldata fCashMaturities, uint256[] calldata maxfCashLiquidateAmounts ) external payable returns (int256[] memory, int256); function calculatefCashCrossCurrencyLiquidation( address liquidateAccount, uint16 localCurrency, uint16 fCashCurrency, uint256[] calldata fCashMaturities, uint256[] calldata maxfCashLiquidateAmounts ) external returns (int256[] memory, int256); function liquidatefCashCrossCurrency( address liquidateAccount, uint16 localCurrency, uint16 fCashCurrency, uint256[] calldata fCashMaturities, uint256[] calldata maxfCashLiquidateAmounts ) external payable returns (int256[] memory, int256); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import {IRewarder} from "./IRewarder.sol"; interface NotionalTreasury { event UpdateIncentiveEmissionRate(uint16 currencyId, uint32 newEmissionRate); event UpdateSecondaryIncentiveRewarder(uint16 indexed currencyId, address rewarder); struct RebalancingTargetConfig { address holding; uint8 targetUtilization; uint16 externalWithdrawThreshold; } /// @notice Emitted when reserve balance is updated event ReserveBalanceUpdated(uint16 indexed currencyId, int256 newBalance); /// @notice Emitted when reserve balance is harvested event ExcessReserveBalanceHarvested(uint16 indexed currencyId, int256 harvestAmount); /// @dev Emitted when treasury manager is updated event TreasuryManagerChanged(address indexed previousManager, address indexed newManager); /// @dev Emitted when reserve buffer value is updated event ReserveBufferUpdated(uint16 currencyId, uint256 bufferAmount); event RebalancingTargetsUpdated(uint16 currencyId, RebalancingTargetConfig[] targets); event RebalancingCooldownUpdated(uint16 currencyId, uint40 cooldownTimeInSeconds); event CurrencyRebalanced(uint16 currencyId, uint256 supplyFactor, uint256 annualizedInterestRate); /// @notice Emitted when the interest accrued on asset deposits is harvested event AssetInterestHarvested(uint16 indexed currencyId, address assetToken, uint256 harvestAmount); function transferReserveToTreasury(uint16[] calldata currencies) external returns (uint256[] memory); function harvestAssetInterest(uint16[] calldata currencies) external; function setTreasuryManager(address manager) external; function setRebalancingBot(address _rebalancingBot) external; function setReserveBuffer(uint16 currencyId, uint256 amount) external; function setReserveCashBalance(uint16 currencyId, int256 reserveBalance) external; function setRebalancingTargets(uint16 currencyId, RebalancingTargetConfig[] calldata targets) external; function setRebalancingCooldown(uint16 currencyId, uint40 cooldownTimeInSeconds) external; function checkRebalance() external view returns (uint16[] memory currencyIds); function rebalance(uint16 currencyId) external; function updateIncentiveEmissionRate(uint16 currencyId, uint32 newEmissionRate) external; function setSecondaryIncentiveRewarder(uint16 currencyId, IRewarder rewarder) external; }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; import "../../contracts/global/Types.sol"; interface NotionalViews { function getMaxCurrencyId() external view returns (uint16); function getCurrencyId(address tokenAddress) external view returns (uint16 currencyId); function getCurrency(uint16 currencyId) external view returns (Token memory assetToken, Token memory underlyingToken); function getRateStorage(uint16 currencyId) external view returns (ETHRateStorage memory ethRate, AssetRateStorage memory assetRate); function getCurrencyAndRates(uint16 currencyId) external view returns ( Token memory assetToken, Token memory underlyingToken, ETHRate memory ethRate, Deprecated_AssetRateParameters memory assetRate ); function getCashGroup(uint16 currencyId) external view returns (CashGroupSettings memory); function getCashGroupAndAssetRate(uint16 currencyId) external view returns (CashGroupSettings memory cashGroup, Deprecated_AssetRateParameters memory assetRate); function getInterestRateCurve(uint16 currencyId) external view returns ( InterestRateParameters[] memory nextInterestRateCurve, InterestRateParameters[] memory activeInterestRateCurve ); function getInitializationParameters(uint16 currencyId) external view returns (int256[] memory annualizedAnchorRates, int256[] memory proportions); function getDepositParameters(uint16 currencyId) external view returns (int256[] memory depositShares, int256[] memory leverageThresholds); function nTokenAddress(uint16 currencyId) external view returns (address); function pCashAddress(uint16 currencyId) external view returns (address); function pDebtAddress(uint16 currencyId) external view returns (address); function getNoteToken() external view returns (address); function getOwnershipStatus() external view returns (address owner, address pendingOwner); function getGlobalTransferOperatorStatus(address operator) external view returns (bool isAuthorized); function getAuthorizedCallbackContractStatus(address callback) external view returns (bool isAuthorized); function getSecondaryIncentiveRewarder(uint16 currencyId) external view returns (address incentiveRewarder); function getPrimeFactors(uint16 currencyId, uint256 blockTime) external view returns ( PrimeRate memory primeRate, PrimeCashFactors memory factors, uint256 maxUnderlyingSupply, uint256 totalUnderlyingSupply, uint256 maxUnderlyingDebt, uint256 totalUnderlyingDebt ); function getPrimeFactorsStored(uint16 currencyId) external view returns (PrimeCashFactors memory); function getPrimeCashHoldingsOracle(uint16 currencyId) external view returns (address); function getPrimeInterestRateCurve(uint16 currencyId) external view returns (InterestRateParameters memory); function getPrimeInterestRate(uint16 currencyId) external view returns ( uint256 annualDebtRatePreFee, uint256 annualDebtRatePostFee, uint256 annualSupplyRate ); function getTotalfCashDebtOutstanding(uint16 currencyId, uint256 maturity) external view returns ( int256 totalfCashDebt, int256 fCashDebtHeldInSettlementReserve, int256 primeCashHeldInSettlementReserve ); function getSettlementRate(uint16 currencyId, uint40 maturity) external view returns (PrimeRate memory); function getMarket( uint16 currencyId, uint256 maturity, uint256 settlementDate ) external view returns (MarketParameters memory); function getActiveMarkets(uint16 currencyId) external view returns (MarketParameters[] memory); function getActiveMarketsAtBlockTime(uint16 currencyId, uint32 blockTime) external view returns (MarketParameters[] memory); function getReserveBalance(uint16 currencyId) external view returns (int256 reserveBalance); function getNTokenPortfolio(address tokenAddress) external view returns (PortfolioAsset[] memory liquidityTokens, PortfolioAsset[] memory netfCashAssets); function getNTokenAccount(address tokenAddress) external view returns ( uint16 currencyId, uint256 totalSupply, uint256 incentiveAnnualEmissionRate, uint256 lastInitializedTime, bytes6 nTokenParameters, int256 cashBalance, uint256 accumulatedNOTEPerNToken, uint256 lastAccumulatedTime ); function getAccount(address account) external view returns ( AccountContext memory accountContext, AccountBalance[] memory accountBalances, PortfolioAsset[] memory portfolio ); function getAccountContext(address account) external view returns (AccountContext memory); function getAccountPrimeDebtBalance(uint16 currencyId, address account) external view returns ( int256 debtBalance ); function getAccountBalance(uint16 currencyId, address account) external view returns ( int256 cashBalance, int256 nTokenBalance, uint256 lastClaimTime ); function getBalanceOfPrimeCash( uint16 currencyId, address account ) external view returns (int256 cashBalance); function getAccountPortfolio(address account) external view returns (PortfolioAsset[] memory); function getfCashNotional( address account, uint16 currencyId, uint256 maturity ) external view returns (int256); function getAssetsBitmap(address account, uint16 currencyId) external view returns (bytes32); function getFreeCollateral(address account) external view returns (int256, int256[] memory); function getTreasuryManager() external view returns (address); function getReserveBuffer(uint16 currencyId) external view returns (uint256); function getRebalancingFactors(uint16 currencyId) external view returns (address holding, uint8 target, uint16 externalWithdrawThreshold, RebalancingContextStorage memory context); function getStoredTokenBalances(address[] calldata tokens) external view returns (uint256[] memory balances); function decodeERC1155Id(uint256 id) external view returns ( uint16 currencyId, uint256 maturity, uint256 assetType, address vaultAddress, bool isfCashDebt ); function encode( uint16 currencyId, uint256 maturity, uint256 assetType, address vaultAddress, bool isfCashDebt ) external pure returns (uint256); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; pragma abicoder v2; interface nTokenERC20 { event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); function nTokenTotalSupply(address nTokenAddress) external view returns (uint256); function nTokenBalanceOf(uint16 currencyId, address account) external view returns (uint256); function nTokenTransferAllowance( uint16 currencyId, address owner, address spender ) external view returns (uint256); function pCashTransferAllowance( uint16 currencyId, address owner, address spender ) external view returns (uint256); function nTokenTransferApprove( uint16 currencyId, address owner, address spender, uint256 amount ) external returns (bool); function pCashTransferApprove( uint16 currencyId, address owner, address spender, uint256 amount ) external returns (bool); function nTokenTransfer( uint16 currencyId, address from, address to, uint256 amount ) external returns (bool); function pCashTransfer( uint16 currencyId, address from, address to, uint256 amount ) external returns (bool); function nTokenTransferFrom( uint16 currencyId, address spender, address from, address to, uint256 amount ) external returns (bool); function pCashTransferFrom( uint16 currencyId, address spender, address from, address to, uint256 amount ) external returns (bool); function nTokenTransferApproveAll(address spender, uint256 amount) external returns (bool); function nTokenClaimIncentives() external returns (uint256); }
// SPDX-License-Identifier: BSUL-1.1 pragma solidity >=0.7.6; interface WETH9 { function deposit() external payable; function withdraw(uint256 wad) external; function transfer(address dst, uint256 wad) external returns (bool); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract NotionalProxy","name":"notional_","type":"address"},{"internalType":"address","name":"underlying_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"holdings_","type":"address[]"},{"internalType":"uint256[]","name":"depositAmounts","type":"uint256[]"}],"name":"getDepositCalldataForRebalancing","outputs":[{"components":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"bytes[]","name":"callData","type":"bytes[]"},{"internalType":"uint256[]","name":"msgValue","type":"uint256[]"},{"internalType":"uint256","name":"underlyingDepositAmount","type":"uint256"},{"internalType":"address","name":"assetToken","type":"address"},{"internalType":"uint8","name":"rebasingTokenBalanceAdjustment","type":"uint8"}],"internalType":"struct DepositData[]","name":"depositData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOracleData","outputs":[{"components":[{"internalType":"address","name":"holding","type":"address"},{"internalType":"uint256","name":"externalUnderlyingAvailableForWithdraw","type":"uint256"},{"internalType":"uint256","name":"currentExternalUnderlyingLend","type":"uint256"},{"internalType":"uint256","name":"maxExternalDeposit","type":"uint256"}],"internalType":"struct OracleData","name":"oracleData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"withdrawAmount","type":"uint256"}],"name":"getRedemptionCalldata","outputs":[{"components":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"bytes[]","name":"callData","type":"bytes[]"},{"internalType":"uint256","name":"expectedUnderlying","type":"uint256"},{"internalType":"address","name":"assetToken","type":"address"},{"internalType":"uint8","name":"rebasingTokenBalanceAdjustment","type":"uint8"}],"internalType":"struct RedeemData[]","name":"redeemData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"holdings_","type":"address[]"},{"internalType":"uint256[]","name":"withdrawAmounts","type":"uint256[]"}],"name":"getRedemptionCalldataForRebalancing","outputs":[{"components":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"bytes[]","name":"callData","type":"bytes[]"},{"internalType":"uint256","name":"expectedUnderlying","type":"uint256"},{"internalType":"address","name":"assetToken","type":"address"},{"internalType":"uint8","name":"rebasingTokenBalanceAdjustment","type":"uint8"}],"internalType":"struct RedeemData[]","name":"redeemData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalUnderlyingValueStateful","outputs":[{"internalType":"uint256","name":"nativePrecision","type":"uint256"},{"internalType":"uint256","name":"internalPrecision","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getTotalUnderlyingValueView","outputs":[{"internalType":"uint256","name":"nativePrecision","type":"uint256"},{"internalType":"uint256","name":"internalPrecision","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holdingValuesInUnderlying","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"holdings","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
61012060405234801561001157600080fd5b50604051610aeb380380610aeb8339810160408190526100309161011b565b6001600160a01b038116156000816100b857826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561007b57600080fd5b505afa15801561008f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b39190610154565b6100bb565b60125b6001600160601b0319606095861b81166080529390941b90921660a052151560f890811b610100527fff000000000000000000000000000000000000000000000000000000000000009083901b1660c0525060ff16600a0a60e052610194565b6000806040838503121561012d578182fd5b82516101388161017c565b60208401519092506101498161017c565b809150509250929050565b600060208284031215610165578081fd5b815160ff81168114610175578182fd5b9392505050565b6001600160a01b038116811461019157600080fd5b50565b60805160601c60a05160601c60c05160f81c60e0516101005160f81c61090c6101df600039508061020a5250806101835250806101bf52806102a25250806102f3525061090c6000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063871ade4311610066578063871ade4314610120578063a77c05b81461013b578063b5e4da2314610151578063e79bf13b14610164578063ef81f216146101795761009e565b8063313ce567146100a3578063395c46ba146100c15780636481c5e6146100d65780636f307dc3146100eb57806376cf13af14610100575b600080fd5b6100ab610181565b6040516100b891906108c8565b60405180910390f35b6100c96101a6565b6040516100b89190610842565b6100de6101b5565b6040516100b89190610886565b6100f36101bd565b6040516100b89190610682565b61011361010e36600461046f565b6101e1565b6040516100b891906106a9565b61012e61010e36600461046f565b6040516100b891906107a2565b6101436101f8565b6040516100b89291906108ba565b61012e61015f366004610586565b610243565b61016c6101a6565b6040516100b89190610696565b610143610254565b7f00000000000000000000000000000000000000000000000000000000000000005b90565b60606101b061025f565b905090565b6101a36103f5565b7f000000000000000000000000000000000000000000000000000000000000000090565b60606101ef85858585610271565b95945050505050565b60008061020361027b565b915061023d7f0000000000000000000000000000000000000000000000000000000000000000610237846305f5e100610398565b906103c6565b90509091565b606061024e826103e5565b92915050565b6000806102036103eb565b60408051600081526020810190915290565b6060949350505050565b604080516001808252818301909252600091829190602080830190803683370190505090507f0000000000000000000000000000000000000000000000000000000000000000816000815181106102ce57fe5b6001600160a01b039283166020918202929092010152604051631794b8ef60e01b81527f000000000000000000000000000000000000000000000000000000000000000090911690631794b8ef9061032a908490600401610696565b60006040518083038186803b15801561034257600080fd5b505afa158015610356573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261037e91908101906104d8565b60008151811061038a57fe5b602002602001015191505090565b6000826103a75750600061024e565b828202828482816103b457fe5b04146103bf57600080fd5b9392505050565b60008082116103d457600080fd5b8183816103dd57fe5b049392505050565b50606090565b60006101b061027b565b604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b60008083601f840112610437578081fd5b50813567ffffffffffffffff81111561044e578182fd5b602083019150836020808302850101111561046857600080fd5b9250929050565b60008060008060408587031215610484578384fd5b843567ffffffffffffffff8082111561049b578586fd5b6104a788838901610426565b909650945060208701359150808211156104bf578384fd5b506104cc87828801610426565b95989497509550505050565b600060208083850312156104ea578182fd5b825167ffffffffffffffff80821115610501578384fd5b818501915085601f830112610514578384fd5b81518181111561052057fe5b8381026040518582820101818110858211171561053957fe5b604052828152858101935084860182860187018a1015610557578788fd5b8795505b8386101561057957805185526001959095019493860193860161055b565b5098975050505050505050565b600060208284031215610597578081fd5b5035919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156105e35781516001600160a01b0316875295820195908201906001016105be565b509495945050505050565b60008282518085526020808601955080818302840101818601855b8481101561066e57601f1980878503018a5282518051808652895b8181101561063f578281018801518782018901528701610624565b8181111561064f578a8883890101525b509a86019a601f01909116939093018401925090830190600101610609565b5090979650505050505050565b60ff169052565b6001600160a01b0391909116815260200190565b6000602082526103bf60208301846105ab565b60208082528251828201819052600091906040908185019080840286018301878501865b8381101561079457603f19898403018552815160c081518186526106f3828701826105ab565b915050888201518582038a87015261070b82826105ee565b838a0151878203888c01528051808352908c0193508c9250908b01905b808310156107485783518252928b019260019290920191908b0190610728565b5060608481015190880152608080850151909350915061076a8388018361059e565b60a09384015193925061077f8784018561067b565b978a01979550505091870191506001016106cd565b509098975050505050505050565b60208082528251828201819052600091906040908185019080840286018301878501865b8381101561079457603f19898403018552815160a081518186526107ec828701826105ab565b915050888201518582038a87015261080482826105ee565b838a0151878b01526060808501516001600160a01b03169088015260809384015160ff169390960192909252505093860193908601906001016107c6565b6020808252825182820181905260009190848201906040850190845b8181101561087a5783518352928401929184019160010161085e565b50909695505050505050565b81516001600160a01b0316815260208083015190820152604080830151908201526060918201519181019190915260800190565b918252602082015260400190565b60ff9190911681526020019056fea2646970667358221220f29f75cdcedb65899ffd321d82e12827a756709fc7cff493424ae2b4b08d8a8664736f6c634300070600330000000000000000000000006e7058c91f85e0f6db4fc9da2ca41241f5e4263f0000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063871ade4311610066578063871ade4314610120578063a77c05b81461013b578063b5e4da2314610151578063e79bf13b14610164578063ef81f216146101795761009e565b8063313ce567146100a3578063395c46ba146100c15780636481c5e6146100d65780636f307dc3146100eb57806376cf13af14610100575b600080fd5b6100ab610181565b6040516100b891906108c8565b60405180910390f35b6100c96101a6565b6040516100b89190610842565b6100de6101b5565b6040516100b89190610886565b6100f36101bd565b6040516100b89190610682565b61011361010e36600461046f565b6101e1565b6040516100b891906106a9565b61012e61010e36600461046f565b6040516100b891906107a2565b6101436101f8565b6040516100b89291906108ba565b61012e61015f366004610586565b610243565b61016c6101a6565b6040516100b89190610696565b610143610254565b7f00000000000000000000000000000000000000000000000000000000000000125b90565b60606101b061025f565b905090565b6101a36103f5565b7f000000000000000000000000000000000000000000000000000000000000000090565b60606101ef85858585610271565b95945050505050565b60008061020361027b565b915061023d7f0000000000000000000000000000000000000000000000000de0b6b3a7640000610237846305f5e100610398565b906103c6565b90509091565b606061024e826103e5565b92915050565b6000806102036103eb565b60408051600081526020810190915290565b6060949350505050565b604080516001808252818301909252600091829190602080830190803683370190505090507f0000000000000000000000000000000000000000000000000000000000000000816000815181106102ce57fe5b6001600160a01b039283166020918202929092010152604051631794b8ef60e01b81527f0000000000000000000000006e7058c91f85e0f6db4fc9da2ca41241f5e4263f90911690631794b8ef9061032a908490600401610696565b60006040518083038186803b15801561034257600080fd5b505afa158015610356573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261037e91908101906104d8565b60008151811061038a57fe5b602002602001015191505090565b6000826103a75750600061024e565b828202828482816103b457fe5b04146103bf57600080fd5b9392505050565b60008082116103d457600080fd5b8183816103dd57fe5b049392505050565b50606090565b60006101b061027b565b604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b60008083601f840112610437578081fd5b50813567ffffffffffffffff81111561044e578182fd5b602083019150836020808302850101111561046857600080fd5b9250929050565b60008060008060408587031215610484578384fd5b843567ffffffffffffffff8082111561049b578586fd5b6104a788838901610426565b909650945060208701359150808211156104bf578384fd5b506104cc87828801610426565b95989497509550505050565b600060208083850312156104ea578182fd5b825167ffffffffffffffff80821115610501578384fd5b818501915085601f830112610514578384fd5b81518181111561052057fe5b8381026040518582820101818110858211171561053957fe5b604052828152858101935084860182860187018a1015610557578788fd5b8795505b8386101561057957805185526001959095019493860193860161055b565b5098975050505050505050565b600060208284031215610597578081fd5b5035919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156105e35781516001600160a01b0316875295820195908201906001016105be565b509495945050505050565b60008282518085526020808601955080818302840101818601855b8481101561066e57601f1980878503018a5282518051808652895b8181101561063f578281018801518782018901528701610624565b8181111561064f578a8883890101525b509a86019a601f01909116939093018401925090830190600101610609565b5090979650505050505050565b60ff169052565b6001600160a01b0391909116815260200190565b6000602082526103bf60208301846105ab565b60208082528251828201819052600091906040908185019080840286018301878501865b8381101561079457603f19898403018552815160c081518186526106f3828701826105ab565b915050888201518582038a87015261070b82826105ee565b838a0151878203888c01528051808352908c0193508c9250908b01905b808310156107485783518252928b019260019290920191908b0190610728565b5060608481015190880152608080850151909350915061076a8388018361059e565b60a09384015193925061077f8784018561067b565b978a01979550505091870191506001016106cd565b509098975050505050505050565b60208082528251828201819052600091906040908185019080840286018301878501865b8381101561079457603f19898403018552815160a081518186526107ec828701826105ab565b915050888201518582038a87015261080482826105ee565b838a0151878b01526060808501516001600160a01b03169088015260809384015160ff169390960192909252505093860193908601906001016107c6565b6020808252825182820181905260009190848201906040850190845b8181101561087a5783518352928401929184019160010161085e565b50909695505050505050565b81516001600160a01b0316815260208083015190820152604080830151908201526060918201519181019190915260800190565b918252602082015260400190565b60ff9190911681526020019056fea2646970667358221220f29f75cdcedb65899ffd321d82e12827a756709fc7cff493424ae2b4b08d8a8664736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000006e7058c91f85e0f6db4fc9da2ca41241f5e4263f0000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : notional_ (address): 0x6e7058c91F85E0F6db4fc9da2CA41241f5e4263f
Arg [1] : underlying_ (address): 0x0000000000000000000000000000000000000000
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000006e7058c91f85e0f6db4fc9da2ca41241f5e4263f
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.