More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 2,051 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Do Leveraged N T... | 373596905 | 155 days ago | IN | 0 ETH | 0.00000698 | ||||
| Do Leveraged N T... | 373290692 | 156 days ago | IN | 0 ETH | 0.00000747 | ||||
| Do Leveraged N T... | 358858238 | 197 days ago | IN | 0 ETH | 0.00000564 | ||||
| Do Leveraged N T... | 358855790 | 197 days ago | IN | 0 ETH | 0.00000803 | ||||
| Do Leveraged N T... | 339759284 | 253 days ago | IN | 0 ETH | 0.00000779 | ||||
| Do Leveraged N T... | 337206306 | 260 days ago | IN | 0 ETH | 0.00000603 | ||||
| Do Leveraged N T... | 313883231 | 328 days ago | IN | 0 ETH | 0.00001086 | ||||
| Do Leveraged N T... | 313838922 | 328 days ago | IN | 0.0001 ETH | 0.00000938 | ||||
| Do Leveraged N T... | 313835407 | 328 days ago | IN | 0 ETH | 0.00000164 | ||||
| Do Leveraged N T... | 313835392 | 328 days ago | IN | 0 ETH | 0.00000887 | ||||
| Do Leveraged N T... | 313833020 | 328 days ago | IN | 0 ETH | 0.00000864 | ||||
| Do Leveraged N T... | 313806528 | 328 days ago | IN | 0 ETH | 0.00000478 | ||||
| Do Leveraged N T... | 311781764 | 334 days ago | IN | 0.005 ETH | 0.00000575 | ||||
| Do Leveraged N T... | 306857245 | 348 days ago | IN | 0 ETH | 0.00000618 | ||||
| Do Leveraged N T... | 302480476 | 361 days ago | IN | 0 ETH | 0.00000985 | ||||
| Do Leveraged N T... | 302189826 | 362 days ago | IN | 0 ETH | 0.0000085 | ||||
| Do Leveraged N T... | 301750187 | 363 days ago | IN | 0 ETH | 0.00000743 | ||||
| Do Leveraged N T... | 301521999 | 364 days ago | IN | 0 ETH | 0.00000812 | ||||
| Do Leveraged N T... | 300707840 | 366 days ago | IN | 0 ETH | 0.00000637 | ||||
| Do Leveraged N T... | 300513897 | 367 days ago | IN | 0 ETH | 0.00000641 | ||||
| Do Leveraged N T... | 299260035 | 370 days ago | IN | 0 ETH | 0.00000656 | ||||
| Do Leveraged N T... | 298802091 | 372 days ago | IN | 0 ETH | 0.00000803 | ||||
| Do Leveraged N T... | 298480507 | 373 days ago | IN | 0 ETH | 0.00016218 | ||||
| Do Leveraged N T... | 298480211 | 373 days ago | IN | 0 ETH | 0.00019737 | ||||
| Do Leveraged N T... | 298478392 | 373 days ago | IN | 0 ETH | 0.00035891 |
Latest 25 internal transactions (View All)
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 313838922 | 328 days ago | 0.0001 ETH | ||||
| 311781764 | 334 days ago | 0.005 ETH | ||||
| 298475953 | 373 days ago | 0.01 ETH | ||||
| 268483916 | 460 days ago | 1.45 ETH | ||||
| 262349158 | 478 days ago | 2.1498 ETH | ||||
| 262212225 | 478 days ago | 4.3 ETH | ||||
| 260988334 | 482 days ago | 1.83 ETH | ||||
| 260590791 | 483 days ago | 0.33 ETH | ||||
| 259978149 | 485 days ago | 2.99 ETH | ||||
| 259649395 | 486 days ago | 7 ETH | ||||
| 257932778 | 491 days ago | 3 ETH | ||||
| 257932216 | 491 days ago | 2 ETH | ||||
| 254216271 | 502 days ago | 0.002 ETH | ||||
| 252781771 | 506 days ago | 0.09 ETH | ||||
| 252530921 | 506 days ago | 0.1 ETH | ||||
| 247242017 | 522 days ago | 0.4916 ETH | ||||
| 247211013 | 522 days ago | 0.00440148 ETH | ||||
| 246880878 | 523 days ago | 0.4916 ETH | ||||
| 246791100 | 523 days ago | 5 ETH | ||||
| 246266340 | 525 days ago | 3 ETH | ||||
| 246212710 | 525 days ago | 0.004 ETH | ||||
| 246210530 | 525 days ago | 0.0004 ETH | ||||
| 246156214 | 525 days ago | 3 ETH | ||||
| 244502510 | 530 days ago | 5 ETH | ||||
| 244388868 | 530 days ago | 9.9 ETH |
Cross-Chain Transactions
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity =0.7.6;
pragma abicoder v2;
import "../../global/Types.sol";
import "../../../interfaces/notional/NotionalProxy.sol";
import "../../../interfaces/notional/NotionalCallback.sol";
contract LeveragedNTokenAdapter is NotionalCallback {
struct EncodedData {
uint16 currencyId;
uint256 depositActionAmount;
}
string public constant name = "Leveraged NToken Adapter";
NotionalProxy public immutable Notional;
constructor(NotionalProxy notional) { Notional = notional; }
/**
* Batch Balance and Trade Action does not allow for margin deposit along with converting cash
* balances to nTokens. Therefore, we use two authorized callback calls here to deposit margin,
* borrow cash, and then convert some amount of cash to nTokens in a single transaction. These
* methods use the `WithCallback` method that allows for Notional to perform ERC20 transfers
* to take advantage of any existing token approvals.
*/
function doLeveragedNToken(
BalanceActionWithTrades[] calldata borrowAction,
uint256 convertCashAmount
) external payable {
require(borrowAction.length == 1); // dev: borrow action length
require(borrowAction[0].actionType == DepositActionType.DepositUnderlying); // dev: deposit type
bytes memory callbackData = abi.encode(borrowAction[0].currencyId, convertCashAmount);
Notional.batchBalanceAndTradeActionWithCallback{value: msg.value}(
msg.sender, borrowAction, callbackData
);
}
function notionalCallback(
address sender,
address account,
bytes calldata callbackData
) external override {
require(msg.sender == address(Notional) && sender == address(this), "Unauthorized callback");
// If callback data is empty then exit, this is the second callback to convert cash balances
if (callbackData.length == 0) return;
EncodedData memory data = abi.decode(callbackData, (EncodedData));
BalanceActionWithTrades[] memory action = new BalanceActionWithTrades[](1);
action[0].actionType = DepositActionType.ConvertCashToNToken;
action[0].currencyId = data.currencyId;
action[0].withdrawAmountInternalPrecision = 0;
action[0].withdrawEntireCashBalance = false;
// NOTE: this must always be set to true in v3
action[0].redeemToUnderlying = true;
if (data.depositActionAmount == 0) {
(int256 cashBalance, /* */, /* */) = Notional.getAccountBalance(data.currencyId, account);
require(cashBalance > 0);
action[0].depositActionAmount = uint256(cashBalance);
} else {
action[0].depositActionAmount = data.depositActionAmount;
}
Notional.batchBalanceAndTradeActionWithCallback(account, action, "");
}
}// SPDX-License-Identifier: GPL-3.0-only
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);
IUpgradeableBeacon internal constant WRAPPED_FCASH_BEACON = IUpgradeableBeacon(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
// 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: GPL-3.0-only
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
bytes5 nTokenParameters;
// Reserved bytes for future usage
bytes15 _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;
uint128 _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;
}// 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: GPL-3.0-only
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);
// refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.
struct ReserveData {
//stores the reserve configuration
ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
//variable borrow index. Expressed in ray
uint128 variableBorrowIndex;
//the current supply rate. Expressed in ray
uint128 currentLiquidityRate;
//the current variable borrow rate. Expressed in ray
uint128 currentVariableBorrowRate;
//the current stable borrow rate. Expressed in ray
uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
//tokens addresses
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
//address of the interest rate strategy
address interestRateStrategyAddress;
//the id of the reserve. Represents the position in the list of the active reserves
uint8 id;
}
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: GPL-v3
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: GPL-v3
pragma solidity >=0.7.0;
pragma abicoder v2;
struct DepositData {
address[] targets;
bytes[] callData;
uint256[] msgValue;
uint256 underlyingDepositAmount;
address assetToken;
}
struct RedeemData {
address[] targets;
bytes[] callData;
uint256 expectedUnderlying;
address assetToken;
}
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
);
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.7.6;
interface IRewarder {
function claimRewards(
address account,
uint16 currencyId,
uint256 nTokenBalanceBefore,
uint256 nTokenBalanceAfter,
int256 netNTokenSupplyChange,
uint256 NOTETokensClaimed
) external;
}// SPDX-License-Identifier: GPL-v3
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) 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: GPL-3.0-only
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: GPL-3.0-only
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: GPL-3.0-only
pragma solidity >=0.7.6;
interface NotionalCallback {
function notionalCallback(address sender, address account, bytes calldata callbackdata) external;
}// SPDX-License-Identifier: GPL-3.0-only
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";
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 UpdateSecondaryIncentiveRewarder(uint16 indexed currencyId, address rewarder);
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
) 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
) 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: GPL-3.0-only
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 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_,
bool sellTokenAssets,
bool acceptResidualAssets
) 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);
/** 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: GPL-3.0-only
pragma solidity >=0.7.6;
pragma abicoder v2;
interface NotionalTreasury {
event UpdateIncentiveEmissionRate(uint16 currencyId, uint32 newEmissionRate);
struct RebalancingTargetConfig {
address holding;
uint8 target;
}
/// @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);
function claimCOMPAndTransfer(address[] calldata ctokens) external returns (uint256);
function transferReserveToTreasury(uint16[] calldata currencies)
external
returns (uint256[] memory);
function setTreasuryManager(address manager) 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 rebalance(uint16[] calldata currencyId) external;
function updateIncentiveEmissionRate(uint16 currencyId, uint32 newEmissionRate) external;
}// SPDX-License-Identifier: GPL-3.0-only
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
);
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,
bytes5 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 getRebalancingTarget(uint16 currencyId, address holding) external view returns (uint8);
function getRebalancingCooldown(uint16 currencyId) external view returns (uint40);
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: GPL-3.0-only
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: GPL-3.0-only
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
Contract ABI
API[{"inputs":[{"internalType":"contract NotionalProxy","name":"notional","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Notional","outputs":[{"internalType":"contract NotionalProxy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum DepositActionType","name":"actionType","type":"uint8"},{"internalType":"uint16","name":"currencyId","type":"uint16"},{"internalType":"uint256","name":"depositActionAmount","type":"uint256"},{"internalType":"uint256","name":"withdrawAmountInternalPrecision","type":"uint256"},{"internalType":"bool","name":"withdrawEntireCashBalance","type":"bool"},{"internalType":"bool","name":"redeemToUnderlying","type":"bool"},{"internalType":"bytes32[]","name":"trades","type":"bytes32[]"}],"internalType":"struct BalanceActionWithTrades[]","name":"borrowAction","type":"tuple[]"},{"internalType":"uint256","name":"convertCashAmount","type":"uint256"}],"name":"doLeveragedNToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"name":"notionalCallback","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a060405234801561001057600080fd5b50604051610c42380380610c4283398101604081905261002f91610044565b60601b6001600160601b031916608052610072565b600060208284031215610055578081fd5b81516001600160a01b038116811461006b578182fd5b9392505050565b60805160601c610b9f6100a36000398061010152806101df528061025f52806103fa52806104ee5250610b9f6000f3fe60806040526004361061003f5760003560e01c806306fdde0314610044578063221c3b4c1461006f578063a5b77b6b14610091578063aa1a0cae146100a6575b600080fd5b34801561005057600080fd5b506100596100c6565b6040516100669190610a7f565b60405180910390f35b34801561007b57600080fd5b506100846100ff565b6040516100669190610a6b565b6100a461009f36600461067c565b610123565b005b3480156100b257600080fd5b506100a46100c13660046105f3565b610254565b6040518060400160405280601881526020017f4c6576657261676564204e546f6b656e2041646170746572000000000000000081525081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001821461013057600080fd5b60028383600081811061013f57fe5b90506020028101906101519190610af2565b61015f9060208101906106f1565b600681111561016a57fe5b1461017457600080fd5b60008383600081811061018357fe5b90506020028101906101959190610af2565b6101a690604081019060200161078f565b826040516020016101b8929190610ade565b60408051601f1981840301815290829052635950d8e960e01b825291506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635950d8e990349061021c903390899089908890600401610876565b6000604051808303818588803b15801561023557600080fd5b505af1158015610249573d6000803e3d6000fd5b505050505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561029457506001600160a01b03841630145b6102b95760405162461bcd60e51b81526004016102b090610a92565b60405180910390fd5b806102c35761055a565b60006102d18284018461073f565b60408051600180825281830190925291925060009190816020015b6102f4610560565b8152602001906001900390816102ec57905050905060068160008151811061031857fe5b602002602001015160000190600681111561032f57fe5b9081600681111561033c57fe5b90525081518151829060009061034e57fe5b60200260200101516020019061ffff16908161ffff168152505060008160008151811061037757fe5b6020026020010151606001818152505060008160008151811061039657fe5b602002602001015160800190151590811515815250506001816000815181106103bb57fe5b602002602001015160a00190151590811515815250508160200151600014156104b457815160405163fc1b134560e01b81526000916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163fc1b13459161042f918a90600401610ac1565b60606040518083038186803b15801561044757600080fd5b505afa15801561045b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047f9190610712565b505090506000811361049057600080fd5b808260008151811061049e57fe5b60200260200101516040018181525050506104d7565b8160200151816000815181106104c657fe5b602002602001015160400181815250505b604051635950d8e960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635950d8e9906105259088908590600401610994565b600060405180830381600087803b15801561053f57600080fd5b505af1158015610553573d6000803e3d6000fd5b5050505050505b50505050565b6040805160e081019091528060008152602001600061ffff1681526020016000815260200160008152602001600015158152602001600015158152602001606081525090565b80356001600160a01b03811681146105bd57600080fd5b919050565b803580151581146105bd57600080fd5b8035600781106105bd57600080fd5b803561ffff811681146105bd57600080fd5b60008060008060608587031215610608578384fd5b610611856105a6565b935061061f602086016105a6565b9250604085013567ffffffffffffffff8082111561063b578384fd5b818701915087601f83011261064e578384fd5b81358181111561065c578485fd5b88602082850101111561066d578485fd5b95989497505060200194505050565b600080600060408486031215610690578283fd5b833567ffffffffffffffff808211156106a7578485fd5b818601915086601f8301126106ba578485fd5b8135818111156106c8578586fd5b87602080830285010111156106db578586fd5b6020928301989097509590910135949350505050565b600060208284031215610702578081fd5b61070b826105d2565b9392505050565b600080600060608486031215610726578283fd5b8351925060208401519150604084015190509250925092565b600060408284031215610750578081fd5b6040516040810181811067ffffffffffffffff8211171561076d57fe5b604052610779836105e1565b8152602083013560208201528091505092915050565b6000602082840312156107a0578081fd5b61070b826105e1565b81835260006001600160fb1b038311156107c1578081fd5b6020830280836020870137939093016020019283525090919050565b6000815180845260208085019450808401835b8381101561080c578151875295820195908201906001016107f0565b509495945050505050565b15159052565b60008151808452815b8181101561084257602081850181015186830182015201610826565b818111156108535782602083870101525b50601f01601f19169290920160200192915050565b6007811061087257fe5b9052565b6001600160a01b038516815260606020808301829052828201859052600091906080908185018782028601830189865b8a81101561097157888303607f190184528135368d900360de190181126108cb578889fd5b8c0160e06108e1856108dc846105d2565b610868565b61ffff6108ef8884016105e1565b16858801526040828101359086015288820135898601526109118883016105c2565b61091d89870182610817565b5060a061092b8184016105c2565b61093782880182610817565b505060c061094781840184610b1a565b9350828288015261095b83880185836107a9565b97890197965050509286019250506001016108a6565b50508681036040880152610985818961081d565b9b9a5050505050505050505050565b6001600160a01b0383168152606060208083018290528351838301819052600092916080918286019080830287018401888401875b83811015610a4957607f198a8403018552815160e06109e9858351610868565b8188015161ffff168589015260408083015190860152898201518a8601528882015115158986015260a08083015115159086015260c091820151918501819052610a35818601836107dd565b9688019694505050908501906001016109c9565b50508781036040890152610a5d8782610b11565b9a9950505050505050505050565b6001600160a01b0391909116815260200190565b60006020825261070b602083018461081d565b602080825260159082015274556e617574686f72697a65642063616c6c6261636b60581b604082015260600190565b61ffff9290921682526001600160a01b0316602082015260400190565b61ffff929092168252602082015260400190565b6000823560de19833603018112610b07578182fd5b9190910192915050565b90815260200190565b6000808335601e19843603018112610b30578283fd5b830160208101925035905067ffffffffffffffff811115610b5057600080fd5b602081023603831315610b6257600080fd5b925092905056fea26469706673582212209aab23a7c1b36322db4a05612c63c1dc2eb5950d70c612ea64a8dacd4e7decb864736f6c634300070600330000000000000000000000001344a36a1b56144c3bc62e7757377d288fde0369
Deployed Bytecode
0x60806040526004361061003f5760003560e01c806306fdde0314610044578063221c3b4c1461006f578063a5b77b6b14610091578063aa1a0cae146100a6575b600080fd5b34801561005057600080fd5b506100596100c6565b6040516100669190610a7f565b60405180910390f35b34801561007b57600080fd5b506100846100ff565b6040516100669190610a6b565b6100a461009f36600461067c565b610123565b005b3480156100b257600080fd5b506100a46100c13660046105f3565b610254565b6040518060400160405280601881526020017f4c6576657261676564204e546f6b656e2041646170746572000000000000000081525081565b7f0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde036981565b6001821461013057600080fd5b60028383600081811061013f57fe5b90506020028101906101519190610af2565b61015f9060208101906106f1565b600681111561016a57fe5b1461017457600080fd5b60008383600081811061018357fe5b90506020028101906101959190610af2565b6101a690604081019060200161078f565b826040516020016101b8929190610ade565b60408051601f1981840301815290829052635950d8e960e01b825291506001600160a01b037f0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde03691690635950d8e990349061021c903390899089908890600401610876565b6000604051808303818588803b15801561023557600080fd5b505af1158015610249573d6000803e3d6000fd5b505050505050505050565b336001600160a01b037f0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde03691614801561029457506001600160a01b03841630145b6102b95760405162461bcd60e51b81526004016102b090610a92565b60405180910390fd5b806102c35761055a565b60006102d18284018461073f565b60408051600180825281830190925291925060009190816020015b6102f4610560565b8152602001906001900390816102ec57905050905060068160008151811061031857fe5b602002602001015160000190600681111561032f57fe5b9081600681111561033c57fe5b90525081518151829060009061034e57fe5b60200260200101516020019061ffff16908161ffff168152505060008160008151811061037757fe5b6020026020010151606001818152505060008160008151811061039657fe5b602002602001015160800190151590811515815250506001816000815181106103bb57fe5b602002602001015160a00190151590811515815250508160200151600014156104b457815160405163fc1b134560e01b81526000916001600160a01b037f0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde0369169163fc1b13459161042f918a90600401610ac1565b60606040518083038186803b15801561044757600080fd5b505afa15801561045b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047f9190610712565b505090506000811361049057600080fd5b808260008151811061049e57fe5b60200260200101516040018181525050506104d7565b8160200151816000815181106104c657fe5b602002602001015160400181815250505b604051635950d8e960e01b81526001600160a01b037f0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde03691690635950d8e9906105259088908590600401610994565b600060405180830381600087803b15801561053f57600080fd5b505af1158015610553573d6000803e3d6000fd5b5050505050505b50505050565b6040805160e081019091528060008152602001600061ffff1681526020016000815260200160008152602001600015158152602001600015158152602001606081525090565b80356001600160a01b03811681146105bd57600080fd5b919050565b803580151581146105bd57600080fd5b8035600781106105bd57600080fd5b803561ffff811681146105bd57600080fd5b60008060008060608587031215610608578384fd5b610611856105a6565b935061061f602086016105a6565b9250604085013567ffffffffffffffff8082111561063b578384fd5b818701915087601f83011261064e578384fd5b81358181111561065c578485fd5b88602082850101111561066d578485fd5b95989497505060200194505050565b600080600060408486031215610690578283fd5b833567ffffffffffffffff808211156106a7578485fd5b818601915086601f8301126106ba578485fd5b8135818111156106c8578586fd5b87602080830285010111156106db578586fd5b6020928301989097509590910135949350505050565b600060208284031215610702578081fd5b61070b826105d2565b9392505050565b600080600060608486031215610726578283fd5b8351925060208401519150604084015190509250925092565b600060408284031215610750578081fd5b6040516040810181811067ffffffffffffffff8211171561076d57fe5b604052610779836105e1565b8152602083013560208201528091505092915050565b6000602082840312156107a0578081fd5b61070b826105e1565b81835260006001600160fb1b038311156107c1578081fd5b6020830280836020870137939093016020019283525090919050565b6000815180845260208085019450808401835b8381101561080c578151875295820195908201906001016107f0565b509495945050505050565b15159052565b60008151808452815b8181101561084257602081850181015186830182015201610826565b818111156108535782602083870101525b50601f01601f19169290920160200192915050565b6007811061087257fe5b9052565b6001600160a01b038516815260606020808301829052828201859052600091906080908185018782028601830189865b8a81101561097157888303607f190184528135368d900360de190181126108cb578889fd5b8c0160e06108e1856108dc846105d2565b610868565b61ffff6108ef8884016105e1565b16858801526040828101359086015288820135898601526109118883016105c2565b61091d89870182610817565b5060a061092b8184016105c2565b61093782880182610817565b505060c061094781840184610b1a565b9350828288015261095b83880185836107a9565b97890197965050509286019250506001016108a6565b50508681036040880152610985818961081d565b9b9a5050505050505050505050565b6001600160a01b0383168152606060208083018290528351838301819052600092916080918286019080830287018401888401875b83811015610a4957607f198a8403018552815160e06109e9858351610868565b8188015161ffff168589015260408083015190860152898201518a8601528882015115158986015260a08083015115159086015260c091820151918501819052610a35818601836107dd565b9688019694505050908501906001016109c9565b50508781036040890152610a5d8782610b11565b9a9950505050505050505050565b6001600160a01b0391909116815260200190565b60006020825261070b602083018461081d565b602080825260159082015274556e617574686f72697a65642063616c6c6261636b60581b604082015260600190565b61ffff9290921682526001600160a01b0316602082015260400190565b61ffff929092168252602082015260400190565b6000823560de19833603018112610b07578182fd5b9190910192915050565b90815260200190565b6000808335601e19843603018112610b30578283fd5b830160208101925035905067ffffffffffffffff811115610b5057600080fd5b602081023603831315610b6257600080fd5b925092905056fea26469706673582212209aab23a7c1b36322db4a05612c63c1dc2eb5950d70c612ea64a8dacd4e7decb864736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde0369
-----Decoded View---------------
Arg [0] : notional (address): 0x1344A36A1B56144C3Bc62E7757377D288fDE0369
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000001344a36a1b56144c3bc62e7757377d288fde0369
Net Worth in USD
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.