Source Code
Overview
S Balance
S Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
PositionsManager
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 89999 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IAaveV3Pool} from "./interfaces/IAaveV3Pool.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IAccountValuesLens} from "./interfaces/IAccountValuesLens.sol";
import {IOracleUSD} from "./interfaces/IOracleUSD.sol";
import {IConfigRegistry} from "./interfaces/IConfigRegistry.sol";
import {IIRM} from "./interfaces/IIRM.sol";
import {
ReentrancyGuardTransientUpgradeable
} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardTransientUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {PMStorage} from "./storage/PMStorage.sol";
import {RiskLib} from "./utils/RiskLib.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IPositionsManager} from "./interfaces/IPositionsManager.sol";
import {IFlash} from "./interfaces/IFlash.sol";
import {TransientSlot} from "@openzeppelin/contracts/utils/TransientSlot.sol";
contract PositionsManager is
PMStorage,
IPositionsManager,
Initializable,
ReentrancyGuardTransientUpgradeable,
UUPSUpgradeable
{
using SafeERC20 for IERC20;
using TransientSlot for *;
// Mirror of OpenZeppelin's transient reentrancy guard storage slot so that
// engines can temporarily lock PM's `nonReentrant` entrypoints across an
// external flash-style callback window.
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant _REENTRANCY_GUARD_STORAGE_PM =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
/// @custom:oz-upgrades-unsafe-allow constructor
/// Immutable addresses; fixed per implementation version
address public immutable FT;
constructor(address systemTokenFT_) {
FT = systemTokenFT_;
_disableInitializers();
}
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event AdminTransferred(address indexed prev, address indexed next);
event EngineSet(address indexed m, bool ok);
event Deposit(address indexed u, address indexed a, uint256 amt);
event Withdraw(address indexed u, address indexed a, uint256 amt);
event Borrow(address indexed u, address indexed a, uint256 amt);
event Repay(address indexed u, address indexed a, uint256 amt, bool full);
event Accrue(address indexed a, uint256 newIndex);
event DepositFor(
address indexed from, address indexed beneficiary, address indexed asset, uint256 amount
);
event RepayFor(
address indexed from,
address indexed borrower,
address indexed asset,
uint256 amount,
bool full
);
event ValuesLensSet(address indexed lens);
event BorrowPauseSet(address indexed asset, bool paused);
event DepositPauseSet(address indexed asset, bool paused);
event WithdrawPauseSet(address indexed asset, bool paused);
event MetaActionsSet(address indexed module);
event Skimmed(address indexed asset, uint256 delta, uint256 newCash);
// Settlement primitives (orderbook engines)
event HoldReserved(address indexed user, address indexed token, uint128 amt);
event HoldReleasedToAvail(address indexed user, address indexed token, uint128 amt);
event HoldReleased(address indexed user, address indexed token, uint128 amt);
event Credited(address indexed user, address indexed asset, uint128 amt);
event DebitedAvail(address indexed user, address indexed asset, uint128 amt);
modifier onlyAdmin() {
_onlyAdmin();
_;
}
modifier onlyEngine() {
_onlyEngine();
_;
}
function setValuesLens(address lens) external onlyAdmin {
if (lens == address(0)) revert ftPositionManagerLensZero();
valuesLens = IAccountValuesLens(lens);
emit ValuesLensSet(lens);
}
function setBorrowPaused(address asset, bool paused) external onlyAdmin {
borrowPaused[asset] = paused;
emit BorrowPauseSet(asset, paused);
}
function setDepositPaused(address asset, bool paused) external onlyAdmin {
depositPaused[asset] = paused;
emit DepositPauseSet(asset, paused);
}
function setWithdrawPaused(address asset, bool paused) external onlyAdmin {
withdrawPaused[asset] = paused;
emit WithdrawPauseSet(asset, paused);
}
function initialize(address _cfg, address _admin) external initializer {
__ReentrancyGuardTransient_init();
config = IConfigRegistry(_cfg);
admin = _admin;
emit AdminTransferred(address(0), admin);
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256(bytes("PositionsManager")),
keccak256(bytes("1")),
block.chainid,
address(this)
)
);
}
// Meta-actions router authorization
modifier onlyMetaActions() {
_onlyMetaActions();
_;
}
function _onlyAdmin() internal view {
if (msg.sender != admin) revert ftPositionManagerOnlyOwner();
}
function _onlyEngine() internal view {
if (!engines[msg.sender]) revert ftPositionManagerOnlyEngine();
}
function _onlyMetaActions() internal view {
if (msg.sender != metaActions) revert ftPositionManagerOnlyMetaActions();
}
function setMetaActions(address m) external onlyAdmin {
metaActions = m;
emit MetaActionsSet(m);
}
// UUPS upgrade authorization
function _authorizeUpgrade(address newImplementation) internal override onlyAdmin {}
/*//////////////////////////////////////////////////////////////
ADMIN CONFIGURATION
//////////////////////////////////////////////////////////////*/
event CapsSet(address indexed asset, uint256 supplyCap, uint256 borrowCap);
event AccountBorrowCapSet(address indexed user, address indexed asset, uint256 capUnits);
function setCaps(address asset, uint256 supplyCap_, uint256 borrowCap_) external onlyAdmin {
supplyCap[asset] = supplyCap_;
borrowCap[asset] = borrowCap_;
emit CapsSet(asset, supplyCap_, borrowCap_);
}
/// @notice Set nominal per-account borrow cap for a specific asset (token units). 0 disables.
function setAccountBorrowCap(address user, address asset, uint256 capUnits) external onlyAdmin {
accountBorrowCap[user][asset] = capUnits;
emit AccountBorrowCapSet(user, asset, capUnits);
}
function setAdmin(address _admin) external onlyAdmin {
if (_admin == address(0)) revert ftPositionManagerZeroAdmin();
emit AdminTransferred(admin, _admin);
admin = _admin;
}
function setEngine(address m, bool ok) external onlyAdmin {
if (m == address(0)) revert ftPositionManagerZeroAddress();
engines[m] = ok;
emit EngineSet(m, ok);
}
/// @notice Engine-only hook to toggle the same transient reentrancy guard
/// used by PM's `nonReentrant` modifier. Intended for external
/// engines that perform flash-style callbacks (e.g., RFQ) so that
/// user-facing PM entrypoints cannot be reentered during the callback.
function setEngineReentrancyLock(bool locked) external onlyEngine {
// If PM is already inside a `nonReentrant` context, do not allow
// external engines to override the guard state.
if (locked) {
if (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
_REENTRANCY_GUARD_STORAGE_PM.asBoolean().tstore(true);
} else {
_REENTRANCY_GUARD_STORAGE_PM.asBoolean().tstore(false);
}
}
// ===== Meta entry points (called by MetaActions) =====
function metaDeposit(
address user,
address asset,
uint256 amount
)
external
onlyMetaActions
nonReentrant
{
_deposit(user, asset, amount);
}
function metaWithdraw(
address user,
address asset,
uint256 amount
)
external
onlyMetaActions
nonReentrant
{
_withdraw(user, asset, amount);
_enforceHFInvariant(user);
}
function metaBorrow(
address user,
address asset,
uint256 amount
)
external
onlyMetaActions
nonReentrant
{
_borrow(user, asset, amount);
_enforceHFInvariant(user);
}
function metaRepay(
address user,
address asset,
uint256 amount
)
external
onlyMetaActions
nonReentrant
{
_repay(user, user, asset, amount);
}
/* ===================== Interest ===================== */
function _accrue(address asset) internal {
AssetState storage s = astate[asset];
uint256 t = block.timestamp;
if (s.lastAccrual == 0) {
s.lastAccrual = t;
if (s.borrowIndexWad == 0) s.borrowIndexWad = WAD;
// opportunistically realize external idle yield if configured
_harvestIdle(asset, false);
emit Accrue(asset, s.borrowIndexWad);
return;
}
if (t == s.lastAccrual) return;
// realize external idle yield before borrow interest progression
_harvestIdle(asset, false);
// Short-circuit if no outstanding borrows: skip IRM call and math
if (s.borrows == 0) {
if (s.borrowIndexWad == 0) s.borrowIndexWad = WAD;
s.lastAccrual = t;
emit Accrue(asset, s.borrowIndexWad);
return;
}
// Pull IRM and reserve factor, but do not gate accrual on `enabled`.
// Disabled blocks new actions; interest keeps accruing to avoid free rides.
IConfigRegistry.AssetCfg memory c = config.getAssetCfg(asset);
uint256 dt = t - s.lastAccrual;
uint256 denom = s.cash + s.borrows + s.idlePrincipal;
if (denom == 0) {
s.lastAccrual = t;
emit Accrue(asset, s.borrowIndexWad);
return;
}
// Utilization and borrow APR
uint256 utilWad = Math.mulDiv(s.borrows, WAD, denom);
uint256 aprWad = IIRM(c.irm).borrowAPR(asset, utilWad);
// Borrow index factor
uint256 interestWad = Math.mulDiv(aprWad, dt, 365 days);
uint256 bFactorWad = WAD + interestWad;
// interest in token units since last accrual (based on global borrows), round up so that
// global borrows never drift below the sum of all per-user principals due to truncation.
uint256 interestUnits = Math.mulDiv(s.borrows, interestWad, WAD, Math.Rounding.Ceil);
// reserve factor (bps) portion is protocol profit (token units)
uint256 reserveAdd = Math.mulDiv(interestUnits, c.reserveFactorBps, BPS);
// Update indexes (index progression keeps floor rounding for borrower fairness)
s.borrowIndexWad = Math.mulDiv(s.borrowIndexWad, bFactorWad, WAD);
// grow borrows by full interest (keeps utilization consistent)
s.borrows += interestUnits;
// accrue protocol reserves as withdrawable tokens
s.reserves += reserveAdd;
// Distribute net interest to suppliers via cumulative supply index
uint256 toSuppliers = interestUnits - reserveAdd;
uint256 ts = s.totalSupplied;
if (toSuppliers > 0) {
if (ts > 0) {
// deltaIndex = toSuppliers / totalSupplied, in WAD
uint256 deltaIndex = (toSuppliers * WAD) / ts;
s.supplyIndexWad += deltaIndex;
// track unclaimable supplier interest bucket (asset units)
s.supplierInterestAccrued += toSuppliers;
} else {
// No suppliers to distribute to; conservatively send to reserves
s.reserves += toSuppliers;
}
}
s.lastAccrual = t;
emit Accrue(asset, s.borrowIndexWad);
}
event IdleHarvested(
address indexed asset, uint256 yieldUnits, uint256 reservesUsed, uint256 newSupplyIndexWad
);
event IdleRebalanced(
address indexed asset,
uint256 deposited,
uint256 withdrawn,
uint256 newIdlePrincipal,
uint256 newCash
);
function rebalanceIdle(address asset) external onlyAdmin nonReentrant {
if (address(config) == address(0)) revert ftPositionManagerZeroAddress();
IConfigRegistry.IdleCfg memory icfg = config.getIdleCfg(asset);
if (!icfg.aaveEnabled) revert ftPositionManagerIdleNotEnabled();
if (icfg.aavePool == address(0)) revert ftPositionManagerIdlePoolZero();
if (icfg.aToken == address(0)) revert ftPositionManagerIdleATokenZero();
AssetState storage s = astate[asset];
uint256 cash = s.cash;
uint256 buffer = icfg.cashBuffer;
if (cash > buffer + icfg.minRebalance) {
uint256 excess = cash - buffer;
uint16 bpsCap = icfg.maxDepositBps == 0 ? uint16(BPS) : icfg.maxDepositBps;
uint256 capAmt = (excess * bpsCap) / BPS;
uint256 toDeposit = capAmt > excess ? excess : capAmt;
if (toDeposit == 0 || toDeposit < icfg.minRebalance) {
revert ftPositionManagerIdleMinRebalance();
}
IERC20(asset).approve(icfg.aavePool, 0);
IERC20(asset).approve(icfg.aavePool, toDeposit);
IAaveV3Pool(icfg.aavePool).supply(asset, toDeposit, address(this), 0);
IERC20(asset).approve(icfg.aavePool, 0);
s.cash = cash - toDeposit;
s.idlePrincipal += toDeposit;
emit IdleRebalanced(asset, toDeposit, 0, s.idlePrincipal, s.cash);
return;
}
if (buffer > cash && (buffer - cash) >= icfg.minRebalance) {
uint256 need = buffer - cash;
uint256 withdrawn = IAaveV3Pool(icfg.aavePool).withdraw(asset, need, address(this));
if (withdrawn == 0 || withdrawn < icfg.minRebalance) {
revert ftPositionManagerIdleMinRebalance();
}
s.cash = cash + withdrawn;
uint256 p = s.idlePrincipal;
s.idlePrincipal = p > withdrawn ? (p - withdrawn) : 0;
emit IdleRebalanced(asset, 0, withdrawn, s.idlePrincipal, s.cash);
return;
}
revert ftPositionManagerIdleNothingToRebalance();
}
function _pullFromIdleIfNeeded(
address asset,
uint256 minCash
)
internal
returns (uint256 pulled)
{
if (address(config) == address(0)) revert ftPositionManagerZeroAddress();
AssetState storage s = astate[asset];
if (s.cash >= minCash) return 0;
IConfigRegistry.IdleCfg memory icfg = config.getIdleCfg(asset);
if (!icfg.aaveEnabled || icfg.aavePool == address(0) || icfg.aToken == address(0)) {
return 0;
}
// realize positive yield (emits IdleHarvested when applicable)
{
IConfigRegistry.IdleCfg memory icfg2 = config.getIdleCfg(asset);
if (icfg2.aaveEnabled && icfg2.aToken != address(0)) {
_realizePositiveYield(asset, icfg2.aToken);
}
}
uint256 need = minCash - s.cash;
pulled = IAaveV3Pool(icfg.aavePool).withdraw(asset, need, address(this));
if (pulled > 0) {
s.cash += pulled;
uint256 p = s.idlePrincipal;
s.idlePrincipal = p > pulled ? (p - pulled) : 0;
emit IdleRebalanced(asset, 0, pulled, s.idlePrincipal, s.cash);
}
}
function _realizePositiveYield(address asset, address aToken) internal returns (bool) {
AssetState storage s = astate[asset];
uint256 u = IERC20(aToken).balanceOf(address(this));
uint256 p = s.idlePrincipal;
if (u <= p) return false;
uint256 delta = u - p;
IConfigRegistry.AssetCfg memory c = config.getAssetCfg(asset);
// Use mulDiv to avoid overflow on delta * reserveFactorBps
uint256 reserveAdd = Math.mulDiv(delta, c.reserveFactorBps, BPS);
if (reserveAdd > 0) s.reserves += reserveAdd;
uint256 toSuppliers = delta - reserveAdd;
if (toSuppliers > 0) {
uint256 ts = s.totalSupplied;
if (ts > 0) {
uint256 dIdx = (toSuppliers * WAD) / ts;
s.supplyIndexWad += dIdx;
s.supplierInterestAccrued += toSuppliers;
} else {
s.reserves += toSuppliers;
}
}
s.idlePrincipal = u;
emit IdleHarvested(asset, delta, 0, s.supplyIndexWad);
return true;
}
function _harvestIdle(address asset, bool strict) internal {
if (address(config) == address(0)) revert ftPositionManagerZeroAddress();
IConfigRegistry.IdleCfg memory icfg = config.getIdleCfg(asset);
if (!icfg.aaveEnabled) return;
if (icfg.aavePool == address(0) || icfg.aToken == address(0)) {
if (strict) {
if (icfg.aavePool == address(0)) revert ftPositionManagerIdlePoolZero();
if (icfg.aToken == address(0)) revert ftPositionManagerIdleATokenZero();
}
return;
}
AssetState storage s = astate[asset];
if (_realizePositiveYield(asset, icfg.aToken)) {
return;
} else {
uint256 u = IERC20(icfg.aToken).balanceOf(address(this));
uint256 p = s.idlePrincipal;
uint256 loss = p - u;
if (strict) {
if (s.reserves < loss) revert ftPositionManagerIdleLossExceedsReserves();
s.reserves -= loss;
s.idlePrincipal = u;
emit IdleHarvested(asset, 0, loss, s.supplyIndexWad);
} else {
return;
}
}
}
/// @notice Public/admin callable: realize idle yield now and reconcile potential losses using reserves.
function harvestIdle(address asset) external onlyAdmin nonReentrant {
_harvestIdle(asset, true);
}
/* ===================== User flows ===================== */
function _depositFrom(address from, address beneficiary, address asset, uint256 amt) internal {
// 1) bring interest up-to-date under pre-action util
_accrue(asset);
_syncFT(beneficiary, asset);
_syncSupplier(beneficiary, asset);
IConfigRegistry.AssetCfg memory c = config.getAssetCfg(asset);
if (!c.enabled) revert ftPositionManagerAssetDisabled();
if (depositPaused[asset]) revert ftPositionManagerDepositPaused();
// Pull funds first; credit the actual received amount to defend against fee-on-transfer tokens
uint256 balBefore = IERC20(asset).balanceOf(address(this));
IERC20(asset).safeTransferFrom(from, address(this), amt);
uint256 balAfter = IERC20(asset).balanceOf(address(this));
uint256 received = balAfter - balBefore; // underflow-safe given transfer succeeded
if (received == 0) revert ftPositionManagerAmountZero();
// supply cap check using actual received units
AssetState storage s = astate[asset];
uint256 newTotalSupplyUnits = (s.cash + s.borrows + s.idlePrincipal) + received;
uint256 cap = supplyCap[asset];
if (cap != 0 && newTotalSupplyUnits > cap) revert ftPositionManagerSupplyCap();
// Credit beneficiary with actual received amount
collateral[beneficiary][asset].avail += received;
s.cash += received;
s.totalSupplied += received;
_touchCollAsset(beneficiary, asset);
// Emit appropriate event with actual credited amount
if (from == beneficiary) {
emit Deposit(beneficiary, asset, received);
} else {
emit DepositFor(from, beneficiary, asset, received);
}
}
function _deposit(address user, address asset, uint256 amt) internal {
_depositFrom(user, user, asset, amt);
}
function deposit(address asset, uint256 amt) external nonReentrant {
if (amt == 0) revert ftPositionManagerAmountZero();
_deposit(msg.sender, asset, amt);
}
function depositFor(address beneficiary, address asset, uint256 amount) external nonReentrant {
if (amount == 0) revert ftPositionManagerAmountZero();
if (beneficiary == address(0)) revert ftPositionManagerZeroAddress();
_depositFrom(msg.sender, beneficiary, asset, amount);
}
function _withdraw(address user, address asset, uint256 amt) internal {
// Values lens is required for solvency checks
if (address(valuesLens) == address(0)) revert ftPositionManagerLensZero();
// 1) accrue first so HF check uses fresh debt/indices & pre-action util
_accrue(asset);
_syncBorrower(user, asset);
_syncFT(user, asset);
_syncSupplier(user, asset);
if (withdrawPaused[asset]) revert ftPositionManagerWithdrawPaused();
// Attempt on-demand idle pull if local cash is insufficient
AssetState storage s = astate[asset];
if (s.cash < amt) {
_pullFromIdleIfNeeded(asset, amt);
}
if (s.cash < amt) revert ftPositionManagerInsufficientLiquidity();
collateral[user][asset].avail -= amt;
s.cash -= amt;
s.totalSupplied -= amt;
IERC20(asset).safeTransfer(user, amt);
_touchCollAsset(user, asset);
emit Withdraw(user, asset, amt);
}
function withdraw(address asset, uint256 amt) external nonReentrant {
if (amt == 0) revert ftPositionManagerAmountZero();
_withdraw(msg.sender, asset, amt);
_enforceHFInvariant(msg.sender);
}
function _borrow(address user, address asset, uint256 amt) internal {
IConfigRegistry.AssetCfg memory c = config.getAssetCfg(asset);
if (!c.enabled) revert ftPositionManagerAssetDisabled();
if (borrowPaused[asset]) revert ftPositionManagerBorrowPaused();
_accrue(asset);
_syncBorrower(user, asset);
AssetState storage s = astate[asset];
// Attempt on-demand idle pull if local cash is insufficient
if (s.cash < amt) {
_pullFromIdleIfNeeded(asset, amt);
}
if (s.cash < amt) revert ftPositionManagerInsufficientLiquidity();
// enforce borrow cap
uint256 newBorrows = s.borrows + amt;
uint256 bcap = borrowCap[asset];
if (bcap != 0 && newBorrows > bcap) revert ftPositionManagerBorrowCap();
DebtData storage d = debt[user][asset];
// Enforce per-account nominal cap for this asset (token units)
uint256 acctCap = accountBorrowCap[user][asset];
if (acctCap > 0) {
uint256 projected = d.principal + amt;
if (projected > acctCap) revert ftPositionManagerAccountDebtCap();
}
if (d.principal == 0) d.indexAtOpenWad = s.borrowIndexWad;
d.principal += amt;
s.borrows += amt;
s.cash -= amt;
_touchDebtAsset(user, asset);
IERC20(asset).safeTransfer(user, amt);
emit Borrow(user, asset, amt);
}
function _enforceHFInvariant(address user) internal view {
(uint256 collUSD, uint256 debtUSD,) = valuesLens.accountValues(address(this), user);
if (RiskLib.hfBps(collUSD, debtUSD) < config.hfSafeBps()) {
revert ftPositionManagerHealthFactor();
}
}
function borrow(address asset, uint256 amt) external nonReentrant {
if (amt == 0) revert ftPositionManagerAmountZero();
_borrow(msg.sender, asset, amt);
_enforceHFInvariant(msg.sender);
}
/// @notice Borrow to a callback target, execute arbitrary logic (e.g., swap), then
/// credit any received `collateralAsset` to the caller and enforce final HF.
/// Optionally pulls an initial margin deposit from the caller before the flow.
function borrowAndDepositVia(
address borrowAsset,
uint256 borrowAmount,
address collateralAsset,
uint256 minCollateralAmount,
address callbackTarget,
bytes calldata callbackData
)
external
nonReentrant
{
if (borrowAmount == 0) revert ftPositionManagerAmountZero();
if (callbackTarget == address(0)) revert ftPositionManagerZeroAddress();
_borrow(msg.sender, borrowAsset, borrowAmount);
// Execute filler callback
IFlash(callbackTarget).onFlash(callbackData);
// After callback, credit any received collateral and check final HF
_depositFrom(msg.sender, msg.sender, collateralAsset, minCollateralAmount);
_enforceHFInvariant(msg.sender);
}
function _repay(address from, address user, address asset, uint256 amt) internal {
_accrue(asset);
_syncBorrower(user, asset);
DebtData storage d = debt[user][asset];
if (d.principal == 0) revert ftPositionManagerNoDebt();
// Pull funds to PM bucket; use actual received to remain robust to fee-on-transfer tokens
uint256 want = amt > d.principal ? d.principal : amt;
uint256 balBefore = IERC20(asset).balanceOf(address(this));
IERC20(asset).safeTransferFrom(from, address(this), want);
uint256 balAfter = IERC20(asset).balanceOf(address(this));
uint256 received = balAfter - balBefore; // underflow-safe if transfer succeeded
if (received == 0) {
// Nothing received; avoid altering debt state
revert ftPositionManagerAmountZero();
}
uint256 used = received > d.principal ? d.principal : received;
d.principal -= used;
AssetState storage s = astate[asset];
s.borrows -= used;
s.cash += received;
bool full = (d.principal == 0);
_touchDebtAsset(user, asset);
// Emit appropriate event
if (from == user) {
emit Repay(user, asset, used, full);
} else {
emit RepayFor(from, user, asset, used, full);
}
}
function repay(address asset, uint256 amt) external nonReentrant {
if (amt == 0) revert ftPositionManagerAmountZero();
_repay(msg.sender, msg.sender, asset, amt);
}
function repayFor(address borrower, address asset, uint256 amount) external nonReentrant {
if (borrower == address(0)) revert ftPositionManagerZeroAddress();
_repay(msg.sender, borrower, asset, amount);
}
/* ===================== Account valuation ===================== */
// admin can withdraw accrued reserves (protocol profit) when liquid
function withdrawReserves(address asset, address to) external onlyAdmin nonReentrant {
_accrue(asset); // keep economics consistent
AssetState storage s = astate[asset];
uint256 amount = s.reserves;
if (s.cash < amount) revert ftPositionManagerInsufficientCash();
// Effects
s.reserves = 0;
s.cash -= amount;
// Interactions
IERC20(asset).safeTransfer(to, amount);
}
/// @notice Reconcile `s.cash` to on-chain token balance for donated or direct-transferred tokens.
/// Credits to reserves (can be distributed via FT).
function skim(address asset) external onlyAdmin nonReentrant {
_accrue(asset);
uint256 bal = IERC20(asset).balanceOf(address(this));
AssetState storage s = astate[asset];
if (bal <= s.cash) return;
uint256 delta = bal - s.cash;
s.cash = bal;
s.reserves += delta;
emit Skimmed(asset, delta, s.cash);
}
/// @notice View your global balance for a token.
function getBalance(
address user,
address token
)
external
view
returns (uint256 avail, uint256 _hold)
{
Balance memory b = collateral[user][token];
return (b.avail, b.hold);
}
/* ===================== Views ===================== */
function userCollateralAssets(address user) external view returns (address[] memory) {
return _userCollAssets[user];
}
function userDebtAssets(address user) external view returns (address[] memory) {
return _userDebtAssets[user];
}
/// @notice Reserve `amt` of `token` for `user` on order placement.
/// (Moves avail -> hold; requires sufficient avail.)
function hold(address user, address token, uint128 amt) external onlyEngine nonReentrant {
_accrue(token);
_syncFT(user, token);
_syncSupplier(user, token);
Balance storage b = collateral[user][token];
b.avail -= amt; // underflow-safe (revert) if insufficient
b.hold += amt;
_touchCollAsset(user, token);
emit HoldReserved(user, token, amt);
}
/// @notice Release a reservation back to avail (on cancel/expire).
function releaseHoldToAvail(
address user,
address token,
uint128 amt
)
external
onlyEngine
nonReentrant
{
_accrue(token);
_syncFT(user, token);
_syncSupplier(user, token);
Balance storage b = collateral[user][token];
b.hold -= amt;
b.avail += amt;
_touchCollAsset(user, token);
emit HoldReleasedToAvail(user, token, amt);
}
/// @notice Consume `amt` of held `token` at settlement (maker/taker consumption).
/// (Reduces hold; counterparties are credited via credit()).
function releaseHold(address user, address token, uint128 amt)
external
onlyEngine
nonReentrant
{
_accrue(token);
_syncFT(user, token);
_syncSupplier(user, token);
Balance storage b = collateral[user][token];
b.hold -= amt;
astate[token].totalSupplied -= amt;
_touchCollAsset(user, token);
emit HoldReleased(user, token, amt);
}
/// @notice Credit `amt` of `token` to `user` available balance (post-settlement).
function credit(address user, address asset, uint128 amt) external onlyEngine nonReentrant {
_accrue(asset);
_syncFT(user, asset);
_syncSupplier(user, asset);
collateral[user][asset].avail += amt;
astate[asset].totalSupplied += amt;
_touchCollAsset(user, asset);
emit Credited(user, asset, amt);
}
/// @notice Debit `amt` from `user` available balance (fees, etc.).
function debitAvail(address user, address asset, uint128 amt) external onlyEngine nonReentrant {
_accrue(asset);
_syncFT(user, asset);
_syncSupplier(user, asset);
collateral[user][asset].avail -= amt;
astate[asset].totalSupplied -= amt;
_touchCollAsset(user, asset);
emit DebitedAvail(user, asset, amt);
}
event InterestSettledForFT(address indexed asset, uint256 out);
event InterestSettledWithFT(address indexed asset, uint256 out, uint256 ftIn);
function settleSupplyInterestWithFT(
address asset,
uint256 out,
uint256 ftIn
)
external
onlyAdmin
nonReentrant
{
_withdrawSupplyInterestForFT(asset);
_settleOutstandingFT(asset, out, ftIn);
}
function _settleOutstandingFT(address asset, uint256 out, uint256 ftIn) internal {
AssetState storage s = astate[asset];
if (out != s.pendingTotalInterestSettled) {
revert ftPositionManagerExceedsSupplierInterest();
}
if (!(out > 0 && ftIn > 0)) revert ftPositionManagerZeroAddress();
address ft = FT;
if (ft == address(0)) revert ftPositionManagerZeroAddress();
// Token flows
IERC20(ft).safeTransferFrom(msg.sender, address(this), ftIn);
astate[ft].cash += ftIn;
// Compute FT-per-interest delta (not stored), used for product index
uint256 deltaFtPerInterest = Math.mulDiv(ftIn, WAD, out);
// Also update the FT settlement product index: Σ(ΔSupplyIndex * ΔFtPerInterest)
uint256 prevSettledIdx = s.supplyIndexSettledWad;
uint256 newSettledIdx = s.pendingSupplyIndexSettledWad;
if (newSettledIdx > prevSettledIdx) {
uint256 deltaSupplyIdx = newSettledIdx - prevSettledIdx; // WAD
uint256 deltaProd = Math.mulDiv(deltaSupplyIdx, deltaFtPerInterest, WAD);
s.ftProductIndexWad += deltaProd;
}
s.supplyIndexSettledWad = s.pendingSupplyIndexSettledWad;
s.pendingTotalInterestSettled = 0;
s.lastSettle = block.timestamp;
emit InterestSettledWithFT(asset, out, ftIn);
}
function settleOutstandingFT(
address asset,
uint256 out,
uint256 ftIn
)
external
onlyAdmin
nonReentrant
{
_settleOutstandingFT(asset, out, ftIn);
}
function _withdrawSupplyInterestForFT(address asset) internal {
AssetState storage s = astate[asset];
uint256 out = s.supplierInterestAccrued;
if (s.pendingTotalInterestSettled > 0) revert ftPositionManagerExceedsSupplierInterest();
if (out == 0) revert ftPositionManagerNoSupplierInterest();
s.cash -= out;
IERC20(asset).safeTransfer(msg.sender, out);
s.supplierInterestAccrued -= out;
s.pendingTotalInterestSettled = out;
s.pendingSupplyIndexSettledWad = s.supplyIndexWad;
emit InterestSettledForFT(asset, out);
}
function withdrawSupplyInterestForFT(address asset) external onlyAdmin nonReentrant {
_withdrawSupplyInterestForFT(asset);
}
function _syncFT(address user, address asset) internal {
address ft = FT;
AssetState memory s = astate[asset];
InterestData storage iData = userSupplyIndexWad[user][asset];
// Product-index payout to ensure sum over epochs of (ΔS × ΔF)
uint256 principal = collateral[user][asset].avail + collateral[user][asset].hold;
if (principal == 0) {
iData.indexAtOpenWad = s.supplyIndexWad;
iData.userFTProductIndexWad = s.ftProductIndexWad;
iData.supplyIndexSettledAtOpenWad = s.supplyIndexSettledWad;
return;
}
uint256 curProd = s.ftProductIndexWad;
uint256 lastProd = iData.userFTProductIndexWad;
uint256 _ft = 0;
// Fence: only credit if user was present before the latest settled index fence
// Late joiners will have indexAtOpenWad == s.supplyIndexSettledWad at settlement time.
if (
principal > 0 && curProd > lastProd
&& iData.supplyIndexSettledAtOpenWad < s.supplyIndexSettledWad
) {
if (iData.indexAtOpenWad < s.supplyIndexSettledWad) {
uint256 deltaProd = curProd - lastProd;
_ft = Math.mulDiv(principal, deltaProd, WAD);
uint256 deltaSupplyIndex = s.supplyIndexSettledWad - iData.indexAtOpenWad;
uint256 deltaSupplyIndexSettled =
s.supplyIndexSettledWad - iData.supplyIndexSettledAtOpenWad;
if (deltaSupplyIndex < deltaSupplyIndexSettled) {
_ft = Math.mulDiv(_ft, deltaSupplyIndex, deltaSupplyIndexSettled);
}
}
iData.supplyIndexSettledAtOpenWad = s.supplyIndexSettledWad;
}
// Snapshot product index regardless to avoid re-paying
iData.userFTProductIndexWad = curProd;
// Advance supply index snapshot to post-settlement fence
iData.indexAtOpenWad = s.supplyIndexSettledWad;
if (_ft > 0) {
_syncSupplier(user, ft);
collateral[user][ft].avail += _ft;
astate[ft].totalSupplied += _ft;
_touchCollAsset(user, ft);
}
}
function _touchCollAsset(address user, address asset) internal {
Balance storage b = collateral[user][asset];
bool active = (b.avail + b.hold) > 0;
uint256 ix = _collIx[user][asset];
if (active && ix == 0) {
_userCollAssets[user].push(asset);
_collIx[user][asset] = _userCollAssets[user].length; // 1-based
} else if (!active && ix != 0) {
uint256 arrIx = ix - 1;
address[] storage arr = _userCollAssets[user];
uint256 last = arr.length - 1;
if (arrIx != last) {
address moved = arr[last];
arr[arrIx] = moved;
_collIx[user][moved] = arrIx + 1;
}
arr.pop();
_collIx[user][asset] = 0;
}
}
function _touchDebtAsset(address user, address asset) internal {
bool active = (debt[user][asset].principal > 0);
uint256 ix = _debtIx[user][asset];
if (active && ix == 0) {
_userDebtAssets[user].push(asset);
_debtIx[user][asset] = _userDebtAssets[user].length; // 1-based
} else if (!active && ix != 0) {
uint256 arrIx = ix - 1;
address[] storage arr = _userDebtAssets[user];
uint256 last = arr.length - 1;
if (arrIx != last) {
address moved = arr[last];
arr[arrIx] = moved;
_debtIx[user][moved] = arrIx + 1;
}
arr.pop();
_debtIx[user][asset] = 0;
}
}
function _syncSupplier(address user, address asset) internal {
Balance memory b = collateral[user][asset];
uint256 principal = b.avail + b.hold;
// Preview global supplier index up to the current timestamp
AssetState memory s = astate[asset];
uint256 idxNow = s.supplyIndexSettledWad;
InterestData storage idata = userSupplyIndexWad[user][asset];
uint256 idxUser = idata.indexAtOpenWad; // defaults to 0 for new users
if (idxUser == 0) {
// First sync: if principal > 0, accrue from baseline 0 up to idxNow;
// otherwise just snapshot and return.
if (principal == 0) {
idata.indexAtOpenWad = s.supplyIndexWad;
// Fence FT settlement for new joiners: snapshot product index only
idata.userFTProductIndexWad = s.ftProductIndexWad;
return;
}
idata.indexAtOpenWad = idxNow;
return;
}
if (idxNow > idxUser) {
// Advance user's snapshot to the latest index (interest units not stored)
idata.indexAtOpenWad = idxNow;
}
}
function _syncBorrower(address user, address asset) internal {
DebtData storage d = debt[user][asset];
if (d.principal == 0) return;
AssetState memory s = astate[asset];
uint256 idxNow = s.borrowIndexWad;
uint256 idxOpen = (d.indexAtOpenWad == 0) ? WAD : d.indexAtOpenWad;
if (idxNow == idxOpen) return;
// realize interest into principal
d.principal = Math.mulDiv(d.principal, idxNow, idxOpen);
d.indexAtOpenWad = idxNow;
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
interface IAaveV3Pool {
/// @notice Supply `amount` of `asset` on behalf of `onBehalfOf`.
/// @param asset underlying ERC20 asset
/// @param amount amount of underlying to supply
/// @param onBehalfOf address that receives the aTokens
/// @param referralCode referral code (0 if none)
function supply(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
)
external;
/// @notice Withdraw `amount` of `asset` to `to`. Returns actually withdrawn amount.
/// @param asset underlying ERC20 asset
/// @param amount amount of underlying to withdraw (type(uint256).max to withdraw all)
/// @param to destination address
function withdraw(address asset, uint256 amount, address to) external returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
interface IAccountValuesLens {
function accountValues(
address pm,
address user
)
external
view
returns (uint256 collUSD, uint256 debtUSD, uint256 collUSDNoLTV);
function previewBorrowIndexWad(
address pmAddr,
address asset
)
external
view
returns (uint256 idxNow);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
interface IOracleUSD {
function priceUSD(address asset) external view returns (uint256);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
interface IConfigRegistry {
struct AssetCfg {
address irm;
uint16 ltvBps; // Loan-to-Value in bps
uint16 reserveFactorBps; // Reserve Factor in bps
bool enabled;
}
// ========== Idle/Aave configuration ==========
struct IdleCfg {
// 2 full slots of 256-bit fields for tight packing; small fields grouped last.
uint256 cashBuffer; // keep at least this much underlying liquid in PM
uint256 minRebalance; // min amount to move on a rebalance to avoid dust churn
address aavePool; // Aave V3 Pool address
address aToken; // corresponding aToken for the underlying asset
uint16 maxDepositBps; // cap how much of on-hand cash can be deposited per rebalance (in bps of (cash - buffer))
bool aaveEnabled; // enable supply-only strategy on Aave for this asset
}
event OwnerChanged(address indexed o);
event GuardianChanged(address indexed g);
event AssetSet(address indexed asset, AssetCfg cfg);
event IdleCfgSet(address indexed asset, IdleCfg cfg);
event OracleSet(address indexed router);
event HFTargetSet(uint16 bps);
event HFSafeSet(uint16 bps);
event DelaySet(uint32 delaySec);
event LtvChangeProposed(address indexed asset, uint16 oldLtv, uint16 newLtv, uint64 eta);
event LtvChangeExecuted(address indexed asset, uint16 newLtv);
event OracleChangeProposed(address indexed next, uint64 eta);
event OracleChangeExecuted(address indexed next);
function getAssetCfg(address asset) external view returns (AssetCfg memory);
function getIdleCfg(address asset) external view returns (IdleCfg memory);
function oracleRouter() external view returns (address);
function hfTargetBps() external view returns (uint16);
function hfSafeBps() external view returns (uint16);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
interface IIRM {
/// @notice Return borrow APR (WAD, 1e18 = 100%) for `asset` at utilization `utilWad` (0..1e18)
function borrowAPR(address asset, uint256 utilWad) external view returns (uint256 aprWad);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/ReentrancyGuardTransient.sol)
pragma solidity ^0.8.24;
import {TransientSlot} from "@openzeppelin/contracts/utils/TransientSlot.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Variant of {ReentrancyGuard} that uses transient storage.
*
* NOTE: This variant only works on networks where EIP-1153 is available.
*
* _Available since v5.1._
*/
abstract contract ReentrancyGuardTransientUpgradeable is Initializable {
using TransientSlot for *;
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant REENTRANCY_GUARD_STORAGE =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function __ReentrancyGuardTransient_init() internal onlyInitializing {
}
function __ReentrancyGuardTransient_init_unchained() internal onlyInitializing {
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, REENTRANCY_GUARD_STORAGE.asBoolean().tload() will be false
if (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true);
}
function _nonReentrantAfter() private {
REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false);
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return REENTRANCY_GUARD_STORAGE.asBoolean().tload();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IConfigRegistry} from "../interfaces/IConfigRegistry.sol";
import {IAccountValuesLens} from "../interfaces/IAccountValuesLens.sol";
import {Constants} from "../utils/Constants.sol";
import {IPMViews} from "../interfaces/IPMViews.sol";
abstract contract PMStorage is IPMViews {
uint256 internal constant WAD = Constants.WAD;
uint256 internal constant BPS = Constants.BPS;
struct DebtData {
uint256 principal;
uint256 indexAtOpenWad;
}
struct InterestData {
uint256 indexAtOpenWad; // used to calculate supplyIndex delta
uint256 userFTProductIndexWad; // snapshot of per-asset FT product index (supplyIndex delta * ΔFtPerInterest)
uint256 supplyIndexSettledAtOpenWad;
}
struct AssetState {
uint256 borrowIndexWad;
uint256 lastAccrual;
uint256 cash;
uint256 borrows;
uint256 reserves;
// Supplier interest index (additive, WAD) and total supplied principal (token units)
uint256 supplyIndexWad;
uint256 totalSupplied;
// Supplier interest accrued
uint256 supplierInterestAccrued;
// Underlying principal invested into Aave (asset units)
uint256 idlePrincipal;
// FT settlement tracking
uint256 supplyIndexSettledWad; // last settled supply index (WAD)
uint256 lastSettle; // timestamp of last settlement
uint256 pendingSupplyIndexSettledWad; // interest withdrawn but not yet settled
uint256 pendingTotalInterestSettled; // amount pending settlement (asset units)
// Cumulative product index: Σ(ΔSupplyIndex × ΔFtPerInterest)
uint256 ftProductIndexWad;
}
// --- PositionsManager storage (prefix must match exact declaration order) ---
IConfigRegistry public config;
// Skip fields before collateral/debt only if order matches; we include full block necessary
address public admin;
mapping(address => bool) public engines; // PositionsManager, RFQ, ftLP, OrderBook, AMM, etc
// Core ledgers
// user => token => {avail,hold}
mapping(address => mapping(address => Balance)) public collateral;
mapping(address => mapping(address => DebtData)) public debt; // user->asset->debt
mapping(address => AssetState) public astate;
// Per-account active asset sets (separate for clarity & simpler netting)
mapping(address => address[]) internal _userCollAssets; // user -> assets with non-zero collateral
mapping(address => mapping(address => uint256)) internal _collIx; // user->asset->index+1 (0 = absent)
mapping(address => address[]) internal _userDebtAssets; // user -> assets with non-zero debt
mapping(address => mapping(address => uint256)) internal _debtIx; // user->asset->index+1 (0 = absent)
// Externalized account valuation lens (upgradeable)
IAccountValuesLens public valuesLens;
// Emergency per-asset borrow pause (deposits/withdraws still governed by asset enabled flag)
mapping(address => bool) public borrowPaused;
// Emergency per-asset deposit/withdraw pause (orthogonal to `enabled` and borrowPaused)
mapping(address => bool) public depositPaused;
mapping(address => bool) public withdrawPaused;
// ========== Supplier interest accounting (Aave-like) ==========
// Per-user last synchronized index for an asset
mapping(address => mapping(address => InterestData)) public userSupplyIndexWad; // user->asset->index
bytes32 public DOMAIN_SEPARATOR;
address public metaActions;
// Caps in token units (0 = no cap)
mapping(address => uint256) public supplyCap; // asset => max (cash + borrows)
mapping(address => uint256) public borrowCap; // asset => max borrows
// Per-account, per-asset nominal debt cap in token units (0 = no cap)
mapping(address => mapping(address => uint256)) public accountBorrowCap; // user => asset => cap
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {Constants} from "./Constants.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
library RiskLib {
// Computes health factor in basis points from collateral and debt (USD WAD).
// Returns max uint16 when debt is zero. Uses mulDiv to avoid intermediate overflow.
function hfBps(uint256 collUSD, uint256 debtUSD) internal pure returns (uint16) {
if (debtUSD == 0) return type(uint16).max;
uint256 res = Math.mulDiv(collUSD, Constants.BPS, debtUSD);
if (res > type(uint16).max) return type(uint16).max;
return uint16(res);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IPMViews} from "./IPMViews.sol";
interface IPositionsManager is IPMViews {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error ftPositionManagerOnlyOwner();
error ftPositionManagerOnlyMetaActions();
error ftPositionManagerOnlyEngine();
error ftPositionManagerLensZero();
error ftPositionManagerZeroAdmin();
error ftPositionManagerZeroAddress();
error ftPositionManagerAssetDisabled();
error ftPositionManagerSupplyCap();
error ftPositionManagerInsufficientLiquidity();
error ftPositionManagerHealthFactor();
error ftPositionManagerNoDebt();
error ftPositionManagerBorrowPaused();
error ftPositionManagerDepositPaused();
error ftPositionManagerWithdrawPaused();
error ftPositionManagerBorrowCap();
error ftPositionManagerAccountDebtCap();
error ftPositionManagerAmountZero();
error ftPositionManagerInsufficientCash();
error ftPositionManagerNoSupplierInterest();
error ftPositionManagerExceedsSupplierInterest();
error ftPositionManagerIdleNotEnabled();
error ftPositionManagerIdlePoolZero();
error ftPositionManagerIdleATokenZero();
error ftPositionManagerIdleLossExceedsReserves();
error ftPositionManagerIdleNothingToRebalance();
error ftPositionManagerIdleMinRebalance();
// ========= User actions =========
function deposit(address asset, uint256 amt) external;
function withdraw(address asset, uint256 amt) external;
function borrow(address asset, uint256 amt) external;
function repay(address asset, uint256 amt) external;
function metaDeposit(address user, address asset, uint256 amount) external;
function metaWithdraw(address user, address asset, uint256 amount) external;
function metaBorrow(address user, address asset, uint256 amount) external;
function metaRepay(address user, address asset, uint256 amount) external;
// ========= Views =========
function getBalance(
address user,
address token
)
external
view
returns (uint256 avail, uint256 hold);
function userCollateralAssets(address user) external view returns (address[] memory);
function userDebtAssets(address user) external view returns (address[] memory);
function setValuesLens(address lens) external;
function setAccountBorrowCap(address user, address asset, uint256 capUnits) external;
function settleSupplyInterestWithFT(
address asset,
uint256 expectedOutAsset,
uint256 ftAmountIn
)
external;
function rebalanceIdle(address asset) external;
function setCaps(address asset, uint256 supplyCap_, uint256 borrowCap_) external;
function harvestIdle(address asset) external;
function setDepositPaused(address asset, bool paused) external;
function setWithdrawPaused(address asset, bool paused) external;
function setBorrowPaused(address asset, bool paused) external;
function depositFor(address beneficiary, address asset, uint256 amount) external;
function repayFor(address borrower, address asset, uint256 amount) external;
/// @notice Borrow tokens to a callback target, run arbitrary logic (e.g., swap), then
/// credit any received `collateralAsset` to the caller and enforce final HF.
/// Optionally pulls an initial margin deposit from the caller before the flow.
/// @param borrowAsset The asset to borrow upfront.
/// @param borrowAmount The amount to borrow.
/// @param collateralAsset The asset expected to be deposited after the callback.
/// @param minCollateralAmount Minimum amount of `collateralAsset` that must be received by PM and credited.
/// @param callbackTarget The contract to receive the borrowed tokens and execute `callbackData`.
/// @param callbackData Calldata to execute on `callbackTarget`.
function borrowAndDepositVia(
address borrowAsset,
uint256 borrowAmount,
address collateralAsset,
uint256 minCollateralAmount,
address callbackTarget,
bytes calldata callbackData
)
external;
function debitAvail(address user, address asset, uint128 amt) external;
function credit(address user, address asset, uint128 amt) external;
function skim(address asset) external;
function withdrawReserves(address asset, address to) external;
function FT() external view returns (address);
/// @notice Engine-only hook to toggle the PositionsManager reentrancy guard.
/// Used by external engines that perform flash-style callbacks (e.g., RFQ)
/// to block reentrant user actions into PM during the callback window.
/// @param locked When true, subsequent `nonReentrant` PM entrypoints will revert
/// until unlocked (or transaction end, since the guard is transient).
function setEngineReentrancyLock(bool locked) external;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
interface IFlash {
function onFlash(bytes calldata data) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.
pragma solidity ^0.8.24;
/**
* @dev Library for reading and writing value-types to specific transient storage slots.
*
* Transient slots are often used to store temporary values that are removed after the current transaction.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* * Example reading and writing values using transient storage:
* ```solidity
* contract Lock {
* using TransientSlot for *;
*
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
*
* modifier locked() {
* require(!_LOCK_SLOT.asBoolean().tload());
*
* _LOCK_SLOT.asBoolean().tstore(true);
* _;
* _LOCK_SLOT.asBoolean().tstore(false);
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library TransientSlot {
/**
* @dev UDVT that represents a slot holding an address.
*/
type AddressSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a AddressSlot.
*/
function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
return AddressSlot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a bool.
*/
type BooleanSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a BooleanSlot.
*/
function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
return BooleanSlot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a bytes32.
*/
type Bytes32Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Bytes32Slot.
*/
function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
return Bytes32Slot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a uint256.
*/
type Uint256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Uint256Slot.
*/
function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
return Uint256Slot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a int256.
*/
type Int256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Int256Slot.
*/
function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
return Int256Slot.wrap(slot);
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(AddressSlot slot) internal view returns (address value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(AddressSlot slot, address value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(BooleanSlot slot) internal view returns (bool value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(BooleanSlot slot, bool value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Bytes32Slot slot, bytes32 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Uint256Slot slot) internal view returns (uint256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Uint256Slot slot, uint256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Int256Slot slot) internal view returns (int256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Int256Slot slot, int256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC1822.sol)
pragma solidity >=0.4.16;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
library Constants {
uint256 constant WAD = 1e18;
uint256 constant BPS = 1e4;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import {IConfigRegistry} from "./IConfigRegistry.sol";
import {IAccountValuesLens} from "./IAccountValuesLens.sol";
// Minimal view interface into PositionsManager used by the lens
interface IPMViews {
struct Balance {
uint256 avail;
uint256 hold;
}
function debt(
address user,
address asset
)
external
view
returns (uint256 principal, uint256 indexAtOpenWad);
function userSupplyIndexWad(
address user,
address asset
)
external
view
returns (uint256, uint256, uint256);
function config() external view returns (IConfigRegistry);
function engines(address m) external view returns (bool);
function valuesLens() external view returns (IAccountValuesLens);
function withdrawPaused(address asset) external view returns (bool);
function supplyCap(address asset) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function admin() external view returns (address);
function astate(address asset)
external
view
returns (
uint256 borrowIndexWad,
uint256 lastAccrual,
uint256 cash,
uint256 borrows,
uint256 reserves,
uint256 supplyIndexWad,
uint256 totalSupplied,
uint256 supplierInterestAccrued,
uint256 idlePrincipal,
uint256 supplyIndexSettledWad,
uint256 lastSettle,
uint256 pendingSupplyIndexSettledWad,
uint256 pendingTotalInterestSettled,
uint256 ftProductIndexWad
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)
pragma solidity >=0.4.16;
/**
* @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.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)
pragma solidity >=0.4.11;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/"
],
"optimizer": {
"enabled": true,
"runs": 89999
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"systemTokenFT_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"ftPositionManagerAccountDebtCap","type":"error"},{"inputs":[],"name":"ftPositionManagerAmountZero","type":"error"},{"inputs":[],"name":"ftPositionManagerAssetDisabled","type":"error"},{"inputs":[],"name":"ftPositionManagerBorrowCap","type":"error"},{"inputs":[],"name":"ftPositionManagerBorrowPaused","type":"error"},{"inputs":[],"name":"ftPositionManagerDepositPaused","type":"error"},{"inputs":[],"name":"ftPositionManagerExceedsSupplierInterest","type":"error"},{"inputs":[],"name":"ftPositionManagerHealthFactor","type":"error"},{"inputs":[],"name":"ftPositionManagerIdleATokenZero","type":"error"},{"inputs":[],"name":"ftPositionManagerIdleLossExceedsReserves","type":"error"},{"inputs":[],"name":"ftPositionManagerIdleMinRebalance","type":"error"},{"inputs":[],"name":"ftPositionManagerIdleNotEnabled","type":"error"},{"inputs":[],"name":"ftPositionManagerIdleNothingToRebalance","type":"error"},{"inputs":[],"name":"ftPositionManagerIdlePoolZero","type":"error"},{"inputs":[],"name":"ftPositionManagerInsufficientCash","type":"error"},{"inputs":[],"name":"ftPositionManagerInsufficientLiquidity","type":"error"},{"inputs":[],"name":"ftPositionManagerLensZero","type":"error"},{"inputs":[],"name":"ftPositionManagerNoDebt","type":"error"},{"inputs":[],"name":"ftPositionManagerNoSupplierInterest","type":"error"},{"inputs":[],"name":"ftPositionManagerOnlyEngine","type":"error"},{"inputs":[],"name":"ftPositionManagerOnlyMetaActions","type":"error"},{"inputs":[],"name":"ftPositionManagerOnlyOwner","type":"error"},{"inputs":[],"name":"ftPositionManagerSupplyCap","type":"error"},{"inputs":[],"name":"ftPositionManagerWithdrawPaused","type":"error"},{"inputs":[],"name":"ftPositionManagerZeroAddress","type":"error"},{"inputs":[],"name":"ftPositionManagerZeroAdmin","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"capUnits","type":"uint256"}],"name":"AccountBorrowCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"a","type":"address"},{"indexed":false,"internalType":"uint256","name":"newIndex","type":"uint256"}],"name":"Accrue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prev","type":"address"},{"indexed":true,"internalType":"address","name":"next","type":"address"}],"name":"AdminTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"address","name":"a","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bool","name":"paused","type":"bool"}],"name":"BorrowPauseSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"supplyCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"borrowCap","type":"uint256"}],"name":"CapsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint128","name":"amt","type":"uint128"}],"name":"Credited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint128","name":"amt","type":"uint128"}],"name":"DebitedAvail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"address","name":"a","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bool","name":"paused","type":"bool"}],"name":"DepositPauseSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"m","type":"address"},{"indexed":false,"internalType":"bool","name":"ok","type":"bool"}],"name":"EngineSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint128","name":"amt","type":"uint128"}],"name":"HoldReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint128","name":"amt","type":"uint128"}],"name":"HoldReleasedToAvail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint128","name":"amt","type":"uint128"}],"name":"HoldReserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"yieldUnits","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservesUsed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newSupplyIndexWad","type":"uint256"}],"name":"IdleHarvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"deposited","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newIdlePrincipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCash","type":"uint256"}],"name":"IdleRebalanced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"out","type":"uint256"}],"name":"InterestSettledForFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ftIn","type":"uint256"}],"name":"InterestSettledWithFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"MetaActionsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"address","name":"a","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"},{"indexed":false,"internalType":"bool","name":"full","type":"bool"}],"name":"Repay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"full","type":"bool"}],"name":"RepayFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"delta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCash","type":"uint256"}],"name":"Skimmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lens","type":"address"}],"name":"ValuesLensSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"u","type":"address"},{"indexed":true,"internalType":"address","name":"a","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bool","name":"paused","type":"bool"}],"name":"WithdrawPauseSet","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"accountBorrowCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"astate","outputs":[{"internalType":"uint256","name":"borrowIndexWad","type":"uint256"},{"internalType":"uint256","name":"lastAccrual","type":"uint256"},{"internalType":"uint256","name":"cash","type":"uint256"},{"internalType":"uint256","name":"borrows","type":"uint256"},{"internalType":"uint256","name":"reserves","type":"uint256"},{"internalType":"uint256","name":"supplyIndexWad","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"supplierInterestAccrued","type":"uint256"},{"internalType":"uint256","name":"idlePrincipal","type":"uint256"},{"internalType":"uint256","name":"supplyIndexSettledWad","type":"uint256"},{"internalType":"uint256","name":"lastSettle","type":"uint256"},{"internalType":"uint256","name":"pendingSupplyIndexSettledWad","type":"uint256"},{"internalType":"uint256","name":"pendingTotalInterestSettled","type":"uint256"},{"internalType":"uint256","name":"ftProductIndexWad","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"borrowAsset","type":"address"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"address","name":"collateralAsset","type":"address"},{"internalType":"uint256","name":"minCollateralAmount","type":"uint256"},{"internalType":"address","name":"callbackTarget","type":"address"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"name":"borrowAndDepositVia","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"collateral","outputs":[{"internalType":"uint256","name":"avail","type":"uint256"},{"internalType":"uint256","name":"hold","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"contract IConfigRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint128","name":"amt","type":"uint128"}],"name":"credit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint128","name":"amt","type":"uint128"}],"name":"debitAvail","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"debt","outputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"indexAtOpenWad","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"depositPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"engines","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"avail","type":"uint256"},{"internalType":"uint256","name":"_hold","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"harvestIdle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint128","name":"amt","type":"uint128"}],"name":"hold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_cfg","type":"address"},{"internalType":"address","name":"_admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"metaActions","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"metaBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"metaDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"metaRepay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"metaWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"rebalanceIdle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint128","name":"amt","type":"uint128"}],"name":"releaseHold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint128","name":"amt","type":"uint128"}],"name":"releaseHoldToAvail","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repayFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"capUnits","type":"uint256"}],"name":"setAccountBorrowCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"paused","type":"bool"}],"name":"setBorrowPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"supplyCap_","type":"uint256"},{"internalType":"uint256","name":"borrowCap_","type":"uint256"}],"name":"setCaps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"paused","type":"bool"}],"name":"setDepositPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"m","type":"address"},{"internalType":"bool","name":"ok","type":"bool"}],"name":"setEngine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"locked","type":"bool"}],"name":"setEngineReentrancyLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"m","type":"address"}],"name":"setMetaActions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"lens","type":"address"}],"name":"setValuesLens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"paused","type":"bool"}],"name":"setWithdrawPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"out","type":"uint256"},{"internalType":"uint256","name":"ftIn","type":"uint256"}],"name":"settleOutstandingFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"out","type":"uint256"},{"internalType":"uint256","name":"ftIn","type":"uint256"}],"name":"settleSupplyInterestWithFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"skim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supplyCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userCollateralAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userDebtAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userSupplyIndexWad","outputs":[{"internalType":"uint256","name":"indexAtOpenWad","type":"uint256"},{"internalType":"uint256","name":"userFTProductIndexWad","type":"uint256"},{"internalType":"uint256","name":"supplyIndexSettledAtOpenWad","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"valuesLens","outputs":[{"internalType":"contract IAccountValuesLens","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"withdrawPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawReserves","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"withdrawSupplyInterestForFT","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60c03461012457601f615ef138819003918201601f19168301916001600160401b038311848410176101285780849260209460405283398101031261012457516001600160a01b0381168103610124573060805260a0525f516020615ed15f395f51905f525460ff8160401c16610115576002600160401b03196001600160401b038216016100bf575b604051615d94908161013d82396080518181816113eb015261151c015260a051818181611da00152818161391701526143a60152f35b6001600160401b0319166001600160401b039081175f516020615ed15f395f51905f52556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a15f610089565b63f92ee8a960e01b5f5260045ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffdfe6080806040526004361015610012575f80fd5b5f905f3560e01c90816305d79c14146122e357508063079166e51461224057806307e4e81b146121ab57806308e331741461217d57806310a2f514146120df57806319a7e38714611fed57806322867d7814611fb85780632850e9e214611f855780632cca5ce314611edb57806331a42e1b14611e0357806333fcd8e314611de15780633644e51514611dc45780633dbf51ab14611d745780633ec2199314611d0657806340ccf25614611cbc578063466fe6b514611c1957806347e7ef2414611be4578063485cc955146118605780634a34a55d146118165780634b8a3529146117d95780634f1ef286146114935780635259e0b11461146357806352d1902d146113c45780635c044766146113125780635c6fe1301461124c578063649fa701146111d35780636c3a420a1461112e578063704b6c021461106257806374c3767e14610fdb57806379502c5514610fa95780637a0f2fcb14610f815780637b030b3314610efc57806381a1e35e14610ec9578063910849a514610d9f578063976ce49514610d62578063ac75db2414610d31578063ad3cb1cc14610c9d578063b3db428b14610c35578063b6606d1c14610b87578063bb6fd53f146109b8578063bc25cf7714610986578063be1fa06e146108cf578063bf09f27414610885578063cb20844314610840578063cc218ece146107dc578063d449300d14610778578063d4fac45d146106ff578063d76a6779146106b5578063db84aa5914610683578063dc2693f21461055c578063dcd989fd14610460578063dd2a0ac11461042e578063ea86795c14610405578063efeec38c14610389578063f3fef3a3146102fb578063f6f6f72c146102c75763f851a44014610291575f80fd5b346102c457806003193601126102c457602073ffffffffffffffffffffffffffffffffffffffff60015416604051908152f35b80fd5b50346102c457806003193601126102c457602073ffffffffffffffffffffffffffffffffffffffff600a5416604051908152f35b50346102c45760406003193601126102c457610315612324565b60243590610321612f7b565b8115610361579061033291336145d5565b61033b33613327565b807f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d80f35b6004837ffebfd77f000000000000000000000000000000000000000000000000000000008152fd5b50346102c45773ffffffffffffffffffffffffffffffffffffffff7f6806c6169898920521cc6099da39b1c3207743aa68299fb40eb9cc655f645f3560406103d036612489565b9490916103db612ee9565b1693848652601160205281838720558486526012602052808387205582519182526020820152a280f35b50346102c45761033b610417366123c8565b91610420612f32565b610428612f7b565b8061475a565b50346102c45760206003193601126102c45761033b61044b612324565b610453612ee9565b61045b612f7b565b614aa6565b50346102c457602073ffffffffffffffffffffffffffffffffffffffff7f4bcdbeb6d8dffebcc63f0e8cd053fc2b529f1f64846c87dad98b5d84420464986104a73661241c565b949193906104b36134a0565b6104bb612f7b565b6104c4816134df565b6104ce8186613915565b6104d88186613be8565b61052d8183871696878a526003865260408a208583165f5286526fffffffffffffffffffffffffffffffff60405f20991698600181016105198b82546125a1565b90556105268a82546125db565b9055613e8f565b6040519586521693a3807f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d80f35b50346102c45760206fffffffffffffffffffffffffffffffff7f64999df6b539f19d9a33e826d657da3208b3dbc70f145a5fc9d5a6cc70aab60761059f3661241c565b6105ad9592959491946134a0565b6105b5612f7b565b6105be856134df565b6105c88587613915565b6105d28587613be8565b1661065673ffffffffffffffffffffffffffffffffffffffff861694858852600384526040882073ffffffffffffffffffffffffffffffffffffffff82165f52845260405f206106238482546125db565b905573ffffffffffffffffffffffffffffffffffffffff81169687895260058552600660408a20016105268582546125db565b604051908152a3807f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d80f35b50346102c45760206003193601126102c45761033b6106a0612324565b6106a8612ee9565b6106b0612f7b565b6127e1565b50346102c45760206003193601126102c45760ff604060209273ffffffffffffffffffffffffffffffffffffffff6106eb612324565b168152600b84522054166040519015158152f35b50346102c45760406003193601126102c45773ffffffffffffffffffffffffffffffffffffffff6040610730612324565b928261073a612347565b9416815260036020522091165f526020526040805f206020825161075d816124c0565b60018354938483520154918291015282519182526020820152f35b50346102c45760406003193601126102c45773ffffffffffffffffffffffffffffffffffffffff60406107a9612324565b92826107b3612347565b9416815260046020522091165f526020526040805f206001815491015482519182526020820152f35b50346102c45760406003193601126102c45773ffffffffffffffffffffffffffffffffffffffff604061080d612324565b9282610817612347565b9416815260036020522091165f526020526040805f206001815491015482519182526020820152f35b50346102c45760206003193601126102c457604060209173ffffffffffffffffffffffffffffffffffffffff610874612324565b168152601283522054604051908152f35b50346102c45760206003193601126102c45760ff604060209273ffffffffffffffffffffffffffffffffffffffff6108bb612324565b168152600284522054166040519015158152f35b50346102c45760206003193601126102c45773ffffffffffffffffffffffffffffffffffffffff6108fe612324565b610906612ee9565b16801561095e57807fffffffffffffffffffffffff0000000000000000000000000000000000000000600a541617600a557f9f0301fa2208131f7c9f8468d1fbc66952f7eb7b402d7d3aff64c268f38e18b98280a280f35b6004827f284e23a5000000000000000000000000000000000000000000000000000000008152fd5b50346102c45760206003193601126102c45761033b6109a3612324565b6109ab612ee9565b6109b3612f7b565b6125e8565b5034610b335760c0600319360112610b33576109d2612324565b6024356044359173ffffffffffffffffffffffffffffffffffffffff83168303610b33576084359073ffffffffffffffffffffffffffffffffffffffff8216809203610b335760a4359067ffffffffffffffff8211610b335736602383011215610b335781600401359367ffffffffffffffff8511610b33573660248685010111610b3357610a5f612f7b565b8015610b5f578315610b3757610a759133613032565b813b15610b33575f91602483604486947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f604051998a98899788957fffcb8632000000000000000000000000000000000000000000000000000000008752602060048801528282880152018686013785858286010152011681010301925af18015610b2857610b11575b506103329060643590333361475a565b610b1e9192505f90612526565b5f90610332610b01565b6040513d5f823e3d90fd5b5f80fd5b7f5fbe2e88000000000000000000000000000000000000000000000000000000005f5260045ffd5b7ffebfd77f000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b33576040600319360112610b3357610ba0612324565b7f98739cd7055b60cff3bd6bf23dda95ec1a79de66ab4498d7e7c58b35e3868258602073ffffffffffffffffffffffffffffffffffffffff610be061236a565b93610be9612ee9565b1692835f52600b8252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b6040519015158152a2005b34610b3357610c43366123c8565b90610c4c612f7b565b8115610b5f5773ffffffffffffffffffffffffffffffffffffffff831615610b3757610c78923361475a565b5f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610b33575f600319360112610b33576040805190610cbc8183612526565b6005825260208201917f352e302e3000000000000000000000000000000000000000000000000000000083527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8351948593602085525180918160208701528686015e5f85828601015201168101030190f35b34610b33576020600319360112610b3357610c78610d4d612324565b610d55612ee9565b610d5d612f7b565b6144a9565b34610b3357610d70366123c8565b90610d79612f7b565b73ffffffffffffffffffffffffffffffffffffffff831615610b3757610c7892336140a7565b34610b33577f2e8095a3840d90965eacca5a6466aec26c1c238b6685b01446bb4f320ac933f86020610dd03661241c565b610dde9492949391936134a0565b610de6612f7b565b610def846134df565b610df98486613915565b610e038486613be8565b610e9d73ffffffffffffffffffffffffffffffffffffffff861694855f526003845260405f2073ffffffffffffffffffffffffffffffffffffffff82165f52845260016fffffffffffffffffffffffffffffffff60405f2094169301610e6a8482546125a1565b905573ffffffffffffffffffffffffffffffffffffffff811696875f5260058552600660405f20016105268582546125a1565b604051908152a35f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610b3357610c78610ef7610edd366123c8565b90610ee9939293612f32565b610ef1612f7b565b836145d5565b613327565b34610b33576040600319360112610b3357610f15612324565b73ffffffffffffffffffffffffffffffffffffffff610f32612347565b91165f52600e60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052606060405f20805490600260018201549101549060405192835260208301526040820152f35b34610b3357610c78610f92366123c8565b91610f9b612f32565b610fa3612f7b565b806140a7565b34610b33575f600319360112610b3357602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611009612324565b611011612ee9565b16807fffffffffffffffffffffffff000000000000000000000000000000000000000060105416176010557f5226c2129eacbc36446bd868e02ddc36344062a0b8dbdd02835138e4e2d37faa5f80a2005b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611090612324565b611098612ee9565b168015611106577fffffffffffffffffffffffff00000000000000000000000000000000000000006001548273ffffffffffffffffffffffffffffffffffffffff82167ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec65f80a31617600155005b7faf0a4134000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff61115c612324565b165f52600860205260405f206040519081602082549182815201915f5260205f20905f5b8181106111a7576111a38561119781870382612526565b60405191829182612379565b0390f35b825473ffffffffffffffffffffffffffffffffffffffff16845260209093019260019283019201611180565b34610b335773ffffffffffffffffffffffffffffffffffffffff807f49a1b412397bd44f92ba2bc3e644cb3bd76f37060688b0ced2263c5e7a10dd39602061121a366123c8565b9591611227959195612ee9565b1693845f526013835260405f208282165f5283528560405f20556040519586521693a3005b34610b335760206fffffffffffffffffffffffffffffffff7f0d40bd549532c28d6905ada91d6a00498b4583c1dcf33f30c0dc6afd0fd4e4ba61128e3661241c565b61129c9592959491946134a0565b6112a4612f7b565b6112ad856134df565b6112b78587613915565b6112c18587613be8565b16610e9d73ffffffffffffffffffffffffffffffffffffffff861694855f526003845260405f2073ffffffffffffffffffffffffffffffffffffffff82165f52845260405f20610e6a8482546125a1565b34610b33576040600319360112610b335761132b612324565b73ffffffffffffffffffffffffffffffffffffffff611348612347565b91611351612ee9565b611359612f7b565b611362816134df565b1690815f52600560205260405f20906004820192600284549301805484811061139c5784611395915f610c7898556125a1565b905561456e565b7f9d764d6c000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b33575f600319360112610b335773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016300361143b5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b7fe07c8dba000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b3357610c7861147436612489565b9161147d612ee9565b611485612f7b565b61148e816144a9565b614350565b6040600319360112610b33576114a7612324565b6024359067ffffffffffffffff8211610b335736602383011215610b33578160040135906114d482612567565b916114e26040519384612526565b80835260208301933660248383010111610b3357815f9260246020930187378401015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016803014908115611797575b5061143b57611554612ee9565b73ffffffffffffffffffffffffffffffffffffffff8116926040517f52d1902d000000000000000000000000000000000000000000000000000000008152602081600481885afa5f9181611763575b506115d457847f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8692036117385750823b1561170d57807fffffffffffffffffffffffff00000000000000000000000000000000000000007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a28251156116db575f80916116d1945190845af43d156116d3573d916116b583612567565b926116c36040519485612526565b83523d5f602085013e615cfb565b005b606091615cfb565b505050346116e557005b7fb398979f000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7faa1d49a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9091506020813d60201161178f575b8161177f60209383612526565b81010312610b33575190866115a3565b3d9150611772565b905073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141584611547565b34610b33576040600319360112610b33576117f2612324565b6024356117fd612f7b565b8015610b5f5761180d9133613032565b610c7833613327565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611844612324565b165f52600c602052602060ff60405f2054166040519015158152f35b34610b33576040600319360112610b3357611879612324565b611881612347565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549160ff8360401c16159267ffffffffffffffff811680159081611bdc575b6001149081611bd2575b159081611bc9575b50611ba1578360017fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008316177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055611b4c575b507ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549160ff8360401c1615611b245773ffffffffffffffffffffffffffffffffffffffff8092167fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f5516807fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001555f7ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec68180a36040916010602084516119f88682612526565b828152017f506f736974696f6e734d616e6167657200000000000000000000000000000000815220600160208551611a308782612526565b828152017f310000000000000000000000000000000000000000000000000000000000000081522084519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f84528683015260608201524660808201523060a082015260a08152611aa760c082612526565b519020600f55611ab357005b7fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2917fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff602092167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00555160018152a1005b7fd7e6bcf8000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005583611926565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b905015856118d3565b303b1591506118cb565b8591506118c1565b34610b33576040600319360112610b3357611bfd612324565b602435611c08612f7b565b8015610b5f57610c7891333361475a565b34610b33576040600319360112610b3357611c32612324565b7fe8e062fa20ded751d71cc7e16b5a24d1a6b1dd71eddf4de1a8010ce93b33cbb3602073ffffffffffffffffffffffffffffffffffffffff611c7261236a565b93611c7b612ee9565b1692835f52600d8252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611cea612324565b165f52600d602052602060ff60405f2054166040519015158152f35b34610b33576040600319360112610b3357611d1f612324565b73ffffffffffffffffffffffffffffffffffffffff611d3c612347565b91165f52601360205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b34610b33575f600319360112610b3357602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b34610b33575f600319360112610b33576020600f54604051908152f35b34610b3357610c78611df236612489565b91611dfb612ee9565b61148e612f7b565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611e31612324565b165f5260056020526101c060405f2080549060018101549060028101546003820154600483015460058401546006850154600786015490600887015492600988015494600a89015496600b8a015498600d600c8c01549b01549b60206040519e8f908152015260408d015260608c015260808b015260a08a015260c089015260e08801526101008701526101208601526101408501526101608401526101808301526101a0820152f35b34610b33576040600319360112610b3357611ef4612324565b73ffffffffffffffffffffffffffffffffffffffff611f1161236a565b91611f1a612ee9565b16908115610b375760207fb4d4597270bf234ac93311fc2d72c364d07f3225345f1e9ea730818fd201debc91835f5260028252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b34610b33575f600319360112610b3357602073ffffffffffffffffffffffffffffffffffffffff60105416604051908152f35b34610b33576040600319360112610b3357611fd1612324565b602435611fdc612f7b565b8015610b5f57610c789133336140a7565b34610b3357602073ffffffffffffffffffffffffffffffffffffffff7f2630763406eaad6cdd32cc078c92164f7c25c2fc52db1a0e7838af2d315ff57a6120333661241c565b9491939061203f6134a0565b612047612f7b565b612050816134df565b61205a8186613915565b6120648186613be8565b6120b18183871696875f526003865260405f208583165f52865260016fffffffffffffffffffffffffffffffff60405f209a16996120a38b82546125a1565b8155016105268a82546125db565b6040519586521693a35f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610b33576020600319360112610b33576004358015158103610b33576121046134a0565b15610c78577f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c6121555760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b3357610c78610ef7612191366123c8565b9061219d939293612f32565b6121a5612f7b565b83613032565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff6121d9612324565b165f52600660205260405f206040519081602082549182815201915f5260205f20905f5b818110612214576111a38561119781870382612526565b825473ffffffffffffffffffffffffffffffffffffffff168452602090930192600192830192016121fd565b34610b33576040600319360112610b3357612259612324565b7f58dd7f4077ec3722270636a9381ab77a346c24cf2d0c1853c3bf16d5d4c158a4602073ffffffffffffffffffffffffffffffffffffffff61229961236a565b936122a2612ee9565b1692835f52600c8252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b34610b33576020600319360112610b335760209073ffffffffffffffffffffffffffffffffffffffff612314612324565b165f526011825260405f20548152f35b6004359073ffffffffffffffffffffffffffffffffffffffff82168203610b3357565b6024359073ffffffffffffffffffffffffffffffffffffffff82168203610b3357565b602435908115158203610b3357565b60206040818301928281528451809452019201905f5b81811061239c5750505090565b825173ffffffffffffffffffffffffffffffffffffffff1684526020938401939092019160010161238f565b6003196060910112610b335760043573ffffffffffffffffffffffffffffffffffffffff81168103610b33579060243573ffffffffffffffffffffffffffffffffffffffff81168103610b33579060443590565b6003196060910112610b335760043573ffffffffffffffffffffffffffffffffffffffff81168103610b33579060243573ffffffffffffffffffffffffffffffffffffffff81168103610b3357906044356fffffffffffffffffffffffffffffffff81168103610b335790565b6003196060910112610b335760043573ffffffffffffffffffffffffffffffffffffffff81168103610b3357906024359060443590565b6040810190811067ffffffffffffffff8211176124dc57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6101c0810190811067ffffffffffffffff8211176124dc57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176124dc57604052565b67ffffffffffffffff81116124dc57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b919082039182116125ae57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b919082018092116125ae57565b73ffffffffffffffffffffffffffffffffffffffff90612607816134df565b166040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481855afa908115610b28575f916126bc575b50815f52600560205260405f2060028101805492838111156126b5576004604093826126987f49cf9aded2ad8e7065fe6c416c8f2eed2d5515ab396ffcd96cc9d12f23c5256797826125a1565b9455016126a68382546125db565b905582519182526020820152a2565b5050505050565b90506020813d6020116126e6575b816126d760209383612526565b81010312610b3357515f61264b565b3d91506126ca565b519073ffffffffffffffffffffffffffffffffffffffff82168203610b3357565b519061ffff82168203610b3357565b51908115158203610b3357565b908160c0910312610b33576040519060c0820182811067ffffffffffffffff8211176124dc576127a29160a0916040528051845260208101516020850152612775604082016126ee565b6040850152612786606082016126ee565b60608501526127976080820161270f565b60808501520161271e565b60a082015290565b81156127b4570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b905f9073ffffffffffffffffffffffffffffffffffffffff5f54168015610b37576040517f31ddaa1f00000000000000000000000000000000000000000000000000000000815260c08160248173ffffffffffffffffffffffffffffffffffffffff8916958660048301525afa908115610b28575f91612eba575b5060a081015115612e92576040810173ffffffffffffffffffffffffffffffffffffffff81511615612e6a5773ffffffffffffffffffffffffffffffffffffffff60608301511615612e4257825f52600560205260405f20906002820192835491815160208301926128cf8451836125db565b8511612ab7575083811180612aa3575b61290b576004897f40bb205e000000000000000000000000000000000000000000000000000000008152fd5b9860209173ffffffffffffffffffffffffffffffffffffffff6129358661299c999a9c9b9d6125a1565b91511690896040518099819582947f69328dec00000000000000000000000000000000000000000000000000000000845230916004850191604091949373ffffffffffffffffffffffffffffffffffffffff91826060860197168552602085015216910152565b03925af1938415612a98578694612a64575b508315908115612a59575b50612a3157916008608094926129f1837f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e098966125db565b80945501908154818082115f14612a2757612a0b916125a1565b80925b55604051938452602084015260408301526060820152a2565b5050838092612a0e565b6004857f3470d577000000000000000000000000000000000000000000000000000000008152fd5b90505183105f6129b9565b9093506020813d602011612a90575b81612a8060209383612526565b81010312610b335751925f6129ae565b3d9150612a73565b6040513d88823e3d90fd5b50612aae84826125a1565b835111156128df565b91929799506080612acf61ffff92869b98999b6125a1565b9201511680612e39575061ffff6127105b168082029082820414821517156125ae57612710900481811115612e315750955b8615908115612e26575b50612dfe5773ffffffffffffffffffffffffffffffffffffffff815116604051907f095ea7b300000000000000000000000000000000000000000000000000000000825260048201525f60248201526020816044815f8c5af18015610b2857612dc7575b5080516040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018790526020816044815f8c5af18015610b2857612d90575b5073ffffffffffffffffffffffffffffffffffffffff815116803b15610b33575f80916084604051809481937f617ba0370000000000000000000000000000000000000000000000000000000083528d60048401528c60248401523060448401528160648401525af18015610b2857612d67575b5073ffffffffffffffffffffffffffffffffffffffff905116604051907f095ea7b30000000000000000000000000000000000000000000000000000000082526004820152836024820152602081604481878b5af18015612d5c57612ce9575b5091600860809492612cd9877f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e098966125a1565b8094550190612a0b8483546125db565b6020813d602011612d54575b81612d0260209383612526565b81010312612d505760809492612cd9877f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e0989694612d4160089561271e565b50949650975050929450612ca5565b8380fd5b3d9150612cf5565b6040513d86823e3d90fd5b612d749194505f90612526565b5f9273ffffffffffffffffffffffffffffffffffffffff612c45565b6020813d602011612dbf575b81612da960209383612526565b81010312610b3357612dba9061271e565b612bd1565b3d9150612d9c565b6020813d602011612df6575b81612de060209383612526565b81010312610b3357612df19061271e565b612b6f565b3d9150612dd3565b7f3470d577000000000000000000000000000000000000000000000000000000005f5260045ffd5b90505186105f612b0b565b905095612b01565b61ffff90612ae0565b7fb65ce21e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f59f8cd44000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9f3808e3000000000000000000000000000000000000000000000000000000005f5260045ffd5b612edc915060c03d60c011612ee2575b612ed48183612526565b81019061272b565b5f61285c565b503d612eca565b73ffffffffffffffffffffffffffffffffffffffff600154163303612f0a57565b7fb544a4e8000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff601054163303612f5357565b7f83a8284e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c6121555760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d565b90816080910312610b3357604051906080820182811067ffffffffffffffff8211176124dc5761302a91606091604052613000816126ee565b845261300e6020820161270f565b602085015261301f6040820161270f565b60408501520161271e565b606082015290565b73ffffffffffffffffffffffffffffffffffffffff5f5416926040517ffb20974f00000000000000000000000000000000000000000000000000000000815260808160248173ffffffffffffffffffffffffffffffffffffffff8816988960048301525afa8015610b28576060915f916132f8575b500151156132d057835f52600b60205260ff60405f2054166132a8576130cc836134df565b6130d68383614ee7565b835f52600560205260405f20926002840182815410613298575b8281541061327057600385016131078482546125db565b875f52601260205260405f20548015159182613266575b505061323e5773ffffffffffffffffffffffffffffffffffffffff851695865f52600460205260405f20885f5260205260405f2090875f52601360205260405f20895f5260205260405f2054806131f3575b5085946131de948694846131b660209a6131d8967f312a5e5e1079f5dda4e95dbbd0b908b291fd5b992ef22073643ab691572c5b529d98549081156131e7575b506125db565b90556131c38682546125db565b90556131d08582546125a1565b90558261534b565b8761456e565b604051908152a3565b5460018501555f6131b0565b6132048784959698979994546125db565b11613216575f96949593929196613170565b7f48c6b2c2000000000000000000000000000000000000000000000000000000005f5260045ffd5b7ffad3a252000000000000000000000000000000000000000000000000000000005f5260045ffd5b1190505f8061311e565b7f34e4d368000000000000000000000000000000000000000000000000000000005f5260045ffd5b6132a28383615022565b506130f0565b7fbf64d2e7000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f6c3d13c1000000000000000000000000000000000000000000000000000000005f5260045ffd5b61331a915060803d608011613320575b6133128183612526565b810190612fc7565b5f6130a7565b503d613308565b606073ffffffffffffffffffffffffffffffffffffffff604481600a54169360405194859384927f390f61d20000000000000000000000000000000000000000000000000000000084523060048501521660248301525afa8015610b28575f5f91613464575b6133979250615541565b6004602073ffffffffffffffffffffffffffffffffffffffff5f5416604051928380927fcee3d4110000000000000000000000000000000000000000000000000000000082525afa908115610b28575f91613425575b5061ffff8091169116106133fd57565b7f90f4a458000000000000000000000000000000000000000000000000000000005f5260045ffd5b90506020813d60201161345c575b8161344060209383612526565b81010312610b335761ffff613455819261270f565b91506133ed565b3d9150613433565b50506060813d606011613498575b8161347f60609383612526565b81010312610b335780602061339792519101519061338d565b3d9150613472565b335f52600260205260ff60405f205416156134b757565b7fd13a8703000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff811690815f52600560205260405f2060018101918254156138c357825442146138bd5761352081614d1c565b6003820180549182156138705790602491608073ffffffffffffffffffffffffffffffffffffffff5f5416604051948580927ffb20974f0000000000000000000000000000000000000000000000000000000082528b60048301525afa928315610b28575f9361384f575b506135978654426125a1565b906135b46135a98660028901546125db565b6008880154906125db565b80156138175761363d92916135cb60209288615570565b9073ffffffffffffffffffffffffffffffffffffffff875116906040518096819482937f63679793000000000000000000000000000000000000000000000000000000008452600484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03915afa8015610b28575f906137e3575b6136589250615645565b80670de0b6b3a7640000019283670de0b6b3a7640000116125ae57846136b86136b061ffff6136a486670de0b6b3a76400006136996136bf9960409d6156ee565b9187091515906125db565b98899501511684615791565b9588546156ee565b87556125db565b90556136dd60048401916136d48184546125db565b938484556125a1565b6006840154918115938415613724575b50505050506020907f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769242905554604051908152a2565b939592949385156137aa575050670de0b6b3a7640000810294818604670de0b6b3a76400001417156125ae5761377d6020947f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b85770983776966127aa565b61378c600585019182546125db565b905561379d600784019182546125db565b90555b9281925f806136ed565b7f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b85770983776965060209550916137dc91926125db565b90556137a0565b506020823d60201161380f575b816137fd60209383612526565b81010312610b3357613658915161364e565b3d91506137f0565b5050505050506020907f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769242905554604051908152a2565b61386991935060803d608011613320576133128183612526565b915f61358b565b505050807f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769260209254156138ad575b42905554604051908152a2565b670de0b6b3a764000082556138a0565b50505050565b906138fb6020927f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769442905582541561390557614d1c565b54604051908152a2565b670de0b6b3a76400008355614d1c565b7f00000000000000000000000000000000000000000000000000000000000000009073ffffffffffffffffffffffffffffffffffffffff83165f52600560205260405f206040519361396685612509565b815485526001820154602086015260028201546040860152600382015460608601526004820154608086015260058201549160a08601928352600681015460c0870152600781015460e087015260088101546101008701526101a0600d6009830154926101208901938452600a8101546101408a0152600b8101546101608a0152600c8101546101808a01520154960195865273ffffffffffffffffffffffffffffffffffffffff841695865f52600e60205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f52602052613aa560405f2093885f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f205490895f52600360205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052600160405f200154906125db565b938415613bd25750516001830180545f9581841180613bc4575b613b54575b50505551905580613ad55750505050565b613b4b93613ae38484613be8565b5f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f20613b198282546125db565b905573ffffffffffffffffffffffffffffffffffffffff83165f526005602052610526600660405f20019182546125db565b5f8080806138bd565b85549185518310613b71575b505050825160028501555f80613ac4565b613b9392975090613b85613b8b92866125a1565b906156ee565b9584516125a1565b613ba384516002870154906125a1565b90818110613bb2575b80613b60565b613bbc92966158be565b935f80613bac565b506002860154855111613abf565b5183555160018301555160029091015550505050565b73ffffffffffffffffffffffffffffffffffffffff16805f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f52602052613c4f602060405f20604051613c3b816124c0565b6001825492838352015492839101526125db565b73ffffffffffffffffffffffffffffffffffffffff83165f52600560205260405f209260405190613c7f82612509565b845482526001850154602083015260028501546040830152600385015460608301526004850154608083015260058501549360a08301948552600686015460c0840152600786015460e084015260088601546101008401526101a0600d60098801549788610120870152600a810154610140870152600b810154610160870152600c810154610180870152015493019283525f52600e60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20928354928315613d56575050508211613d53575050565b55565b9091925015613d6457505055565b600192935051835551910155565b8054821015613d87575f5260205f2001905f90565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b80548015613e0c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190613de98282613d72565b73ffffffffffffffffffffffffffffffffffffffff82549160031b1b1916905555565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b90815491680100000000000000008310156124dc5782613e61916001613e8d95018155613d72565b90919073ffffffffffffffffffffffffffffffffffffffff8084549260031b9316831b921b1916179055565b565b73ffffffffffffffffffffffffffffffffffffffff16805f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f52602052613ee160405f2060018154910154906125db565b15801590825f52600760205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f2054918061409f575b15613f7257505090815f526006602052613f368160405f20613e39565b815f52600660205260405f2054915f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f2055565b80614096575b613f82575b505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908082116125ae57825f52600660205260405f20908154927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84019384116125ae5783613ffb94820361402a575b505050613db4565b5f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f526020525f6040812055565b613e619173ffffffffffffffffffffffffffffffffffffffff6140506140619387613d72565b90549060031b1c1692839186613d72565b845f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20555f8080613ff3565b50801515613f78565b508115613f19565b92906140b2836134df565b6140bc8382614ee7565b73ffffffffffffffffffffffffffffffffffffffff811692835f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f2092835490811561432857818111156143205750945b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8316966020826024818b5afa918215610b28575f926142ea575b5061417d9030848a61597b565b604051907f70a082310000000000000000000000000000000000000000000000000000000082523060048301526020826024818b5afa8015610b28575f906142b6575b6141ca92506125a1565b938415610b5f5773ffffffffffffffffffffffffffffffffffffffff92816142389254968781115f146142ab5761420188806125a1565b8255895f52600560205261422e600260405f20600381016142238c82546125a1565b9055019182546125db565b905554159461534b565b1691838303614276576040805191825291151560208201527f32b9f192f046502437b65280a1ff8a435327a7bb3986b85db4a5e61b44e5d3b39250a3565b6040805191825291151560208201527ffe1b46ad82b670225ffdad07a6c5d6c091daed088a1c049d9e4a3dc82124e1379190a4565b6142018180996125a1565b506020823d6020116142e2575b816142d060209383612526565b81010312610b33576141ca91516141c0565b3d91506142c3565b9091506020813d602011614318575b8161430660209383612526565b81010312610b3357519061417d614170565b3d91506142f9565b905094614115565b7f41c2aada000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff1691825f52600560205260405f2091600c830191825482036144815781151580614478575b15610b375773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016938415610b37575f6040947f16c76d81a47c737c0d3daa00dfb6dce401133e61c8e82d5fd65b599ddc7ecc90966143ff8530338461597b565b825260056020526002868320016144178582546125db565b90556144238585615570565b600984018054600b8601549281841161444e575b50505555600a4291015582519182526020820152a2565b61445b61446092856125a1565b6156ee565b61446f600d87019182546125db565b90555f80614437565b5080151561438a565b7fcedf65e4000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff16805f52600560205260405f2060078101908154600c820191825461448157811561454657816020937fbd37e746d35a5ef50049f706ec75c287091538b68733b1dd25add1162aa373ad95600284016145188482546125a1565b905561452583338a61456e565b6145308382546125a1565b905555600b6005820154910155604051908152a2565b7fa6613090000000000000000000000000000000000000000000000000000000005f5260045ffd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082015273ffffffffffffffffffffffffffffffffffffffff929092166024830152604480830193909352918152613e8d916145d0606483612526565b6159e2565b919073ffffffffffffffffffffffffffffffffffffffff600a541615614732576145fe816134df565b6146088184614ee7565b6146128184613915565b61461c8184613be8565b73ffffffffffffffffffffffffffffffffffffffff811692835f52600d60205260ff60405f20541661470a57835f52600560205260405f20926002840193818554106146fa575b81855410613270577f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb938360066131de9373ffffffffffffffffffffffffffffffffffffffff6020971698895f526003885260405f208b5f52885260405f206146cd8882546125a1565b90556146da8782546125a1565b9055016146e88582546125a1565b90556146f584828a61456e565b613e8f565b6147048285615022565b50614663565b7f1d6f8dcd000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f284e23a5000000000000000000000000000000000000000000000000000000005f5260045ffd5b90614764836134df565b61476e8382613915565b6147788382613be8565b73ffffffffffffffffffffffffffffffffffffffff5f5416936040517ffb20974f00000000000000000000000000000000000000000000000000000000815260808160248173ffffffffffffffffffffffffffffffffffffffff8916998a60048301525afa8015610b28576060915f91614a87575b500151156132d057845f52600c60205260ff60405f205416614a5f57604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481895afa918215610b28575f92614a29575b5061485a9030858861597b565b604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481895afa8015610b28575f906149f5575b6148a792506125a1565b918215610b5f57845f52600560205260405f2060028101946148e6856148e16148d689546003870154906125db565b6008860154906125db565b6125db565b875f52601160205260405f205480151591826149eb575b50506149c35783600661495f9373ffffffffffffffffffffffffffffffffffffffff80971698895f52600360205260405f208b5f5260205260405f206149448a82546125db565b90556149518982546125db565b9055016105268782546125db565b16828103614995575060207f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f6291604051908152a3565b9060207f9b97b64e9cc6e815f094532deb9581a5b7daa7de9eecaf344c66d6e707b0b41891604051908152a4565b7f1e306e25000000000000000000000000000000000000000000000000000000005f5260045ffd5b1190505f806148fd565b506020823d602011614a21575b81614a0f60209383612526565b81010312610b33576148a7915161489d565b3d9150614a02565b9091506020813d602011614a57575b81614a4560209383612526565b81010312610b3357519061485a61484d565b3d9150614a38565b7fb48990ce000000000000000000000000000000000000000000000000000000005f5260045ffd5b614aa0915060803d608011613320576133128183612526565b5f6147ed565b73ffffffffffffffffffffffffffffffffffffffff5f5416908115610b37576040517f31ddaa1f00000000000000000000000000000000000000000000000000000000815260c08160248173ffffffffffffffffffffffffffffffffffffffff8616968760048301525afa908115610b28575f91614cfd575b5060a081015115613f7d5773ffffffffffffffffffffffffffffffffffffffff60408201511615808015614cdb575b614cb25750825f526005602052614b85606060405f2092019273ffffffffffffffffffffffffffffffffffffffff84511690615a69565b15614b8f57505050565b602073ffffffffffffffffffffffffffffffffffffffff6024935116604051938480927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa918215610b28575f92614c7e575b506008810191614bfc8184546125a1565b906004830192835491838310614c56577f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e095606095614c3d866005966125a1565b9055550154604051915f835260208301526040820152a2565b7f5f890b07000000000000000000000000000000000000000000000000000000005f5260045ffd5b9091506020813d602011614caa575b81614c9a60209383612526565b81010312610b335751905f614beb565b3d9150614c8d565b91509150612e6a576060015173ffffffffffffffffffffffffffffffffffffffff1615612e4257565b5073ffffffffffffffffffffffffffffffffffffffff60608301511615614b4e565b614d16915060c03d60c011612ee257612ed48183612526565b5f614b1f565b73ffffffffffffffffffffffffffffffffffffffff5f54168015610b3757604051907f31ddaa1f00000000000000000000000000000000000000000000000000000000825260c08260248173ffffffffffffffffffffffffffffffffffffffff8716948560048301525afa918215610b28575f92614ec6575b5060a082015115613f7d5773ffffffffffffffffffffffffffffffffffffffff604083015116158015614ea4575b613f7d575f526005602052614df8606060405f2092019273ffffffffffffffffffffffffffffffffffffffff84511690615a69565b15614e01575050565b602073ffffffffffffffffffffffffffffffffffffffff6024935116604051938480927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa918215610b28575f92614e6f575b50906008614e6c9201546125a1565b50565b91506020823d602011614e9c575b81614e8a60209383612526565b81010312610b33579051906008614e5d565b3d9150614e7d565b5073ffffffffffffffffffffffffffffffffffffffff60608301511615614dc3565b614ee091925060c03d60c011612ee257612ed48183612526565b905f614d95565b73ffffffffffffffffffffffffffffffffffffffff165f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f20908154908115613f7d5773ffffffffffffffffffffffffffffffffffffffff165f52600560205260405f2091604051614f6081612509565b6101a0600d85549586845260018101546020850152600281015460408501526003810154606085015260048101546080850152600581015460a0850152600681015460c0850152600781015460e085015260088101546101008501526009810154610120850152600a810154610140850152600b810154610160850152600c81015461018085015201549101526001810191825480155f1461501d5750670de0b6b3a76400005b8085146126b55784615018926158be565b905555565b615007565b91909173ffffffffffffffffffffffffffffffffffffffff5f54168015610b375773ffffffffffffffffffffffffffffffffffffffff821691825f52600560205260405f20906002820192868454101561534157604051907f31ddaa1f00000000000000000000000000000000000000000000000000000000825285600483015260c082602481845afa918215610b28575f92615320575b5060a08201511580156152fe575b80156152dc575b6152d1579060c060249392604051948580927f31ddaa1f0000000000000000000000000000000000000000000000000000000082528a60048301525afa978815610b2857604061515873ffffffffffffffffffffffffffffffffffffffff926151c09b6020975f916152b2575b5060a08101511515806152a3575b61528c575b508854906125a1565b92015116905f604051809a819582947f69328dec00000000000000000000000000000000000000000000000000000000845230916004850191604091949373ffffffffffffffffffffffffffffffffffffffff91826060860197168552602085015216910152565b03925af1948515610b28575f95615258575b5084806151df5750505050565b826008608093615211847f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e097546125db565b809355018054838082115f1461524e5761522a916125a1565b80915b55604051925f8452602084015260408301526060820152a25f8080806138bd565b50505f809161522d565b9094506020813d602011615284575b8161527460209383612526565b81010312610b335751935f6151d2565b3d9150615267565b84606061529c9201511687615a69565b505f61514f565b5084606082015116151561514a565b6152cb915060c03d60c011612ee257612ed48183612526565b5f61513c565b505f96505050505050565b5073ffffffffffffffffffffffffffffffffffffffff606083015116156150cf565b5073ffffffffffffffffffffffffffffffffffffffff604083015116156150c8565b61533a91925060c03d60c011612ee257612ed48183612526565b905f6150ba565b505f955050505050565b73ffffffffffffffffffffffffffffffffffffffff16805f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f205415801590825f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f20549180615539575b1561541f57505090815f5260086020526153e38160405f20613e39565b815f52600860205260405f2054915f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f2055565b80615530575b61542e57505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908082116125ae57825f52600860205260405f20908154927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84019384116125ae57836154a69482036154d557505050613db4565b5f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f526020525f6040812055565b613e619173ffffffffffffffffffffffffffffffffffffffff6140506154fb9387613d72565b845f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20555f8080613ff3565b50801515615425565b5081156153c6565b9080156155685761555191615822565b61ffff81116155615761ffff1690565b5061ffff90565b505061ffff90565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff670de0b6b3a7640000820991670de0b6b3a7640000820291828085109403938085039414615636578382111561561e57670de0b6b3a7640000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b509061564292506127aa565b90565b9190915f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84820990848102928380841093039280840393146156df57826301e1338011156156cd57507f98f5be4dd1e14769fbd6666224dc1eb80dd2e0a3d2c8b328f57e76b7ae10395793946301e13380910990828211900360f91b910360071c170290565b634e487b71905260116020526024601cfd5b5050506301e133809192500490565b9190915f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848209908481029283808410930392808403931461577e5782670de0b6b3a764000011156156cd57507faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699394670de0b6b3a7640000910990828211900360ee1b910360121c170290565b505050670de0b6b3a76400009192500490565b9190915f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8482099084810292838084109303928084039314615815578261271011156156cd57507fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e919394612710910990828211900360fc1b910360041c170290565b5050506127109192500490565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612710820991612710820291828085109403938085039414615636578382111561561e57612710829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b90917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff838309928083029283808610950394808603951461596e57848311156159565790829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b50509061564292506127aa565b90919273ffffffffffffffffffffffffffffffffffffffff613e8d9481604051957f23b872dd0000000000000000000000000000000000000000000000000000000060208801521660248601521660448401526064830152606482526145d0608483612526565b905f602091828151910182855af115610b28575f513d615a60575073ffffffffffffffffffffffffffffffffffffffff81163b155b615a1e5750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b60011415615a17565b73ffffffffffffffffffffffffffffffffffffffff80911691825f526005602052602060405f20916024604051809581937f70a08231000000000000000000000000000000000000000000000000000000008352306004840152165afa918215610b28575f92615cc7575b506008810191825480821115615cbe57615aee90826125a1565b926024608073ffffffffffffffffffffffffffffffffffffffff5f5416604051928380927ffb20974f0000000000000000000000000000000000000000000000000000000082528a60048301525afa908115610b285761ffff6040615b6e93615b62935f91615c9f575b5001511686615791565b80615c89575b856125a1565b80158015615bb9575b50505560050154604080519283525f60208401528201527f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e090606090a2600190565b939094926006820154928315155f14615c4957670de0b6b3a7640000870295878704670de0b6b3a76400001417156125ae577f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e096615c1b6005956060986127aa565b615c298686019182546125db565b9055615c3a600785019182546125db565b90555b92509294819450615b77565b60609550600593507f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e096615c82600485019182546125db565b9055615c3d565b60048501615c988282546125db565b9055615b68565b615cb8915060803d608011613320576133128183612526565b5f615b58565b50505050505f90565b9091506020813d602011615cf3575b81615ce360209383612526565b81010312610b335751905f615ad4565b3d9150615cd6565b90615d385750805115615d1057602081519101fd5b7fd6bda275000000000000000000000000000000000000000000000000000000005f5260045ffd5b81511580615d8b575b615d49575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b50803b15615d4156f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00000000000000000000000000c9315bb243baaeef1fcd9358730ba07596d1d531
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f905f3560e01c90816305d79c14146122e357508063079166e51461224057806307e4e81b146121ab57806308e331741461217d57806310a2f514146120df57806319a7e38714611fed57806322867d7814611fb85780632850e9e214611f855780632cca5ce314611edb57806331a42e1b14611e0357806333fcd8e314611de15780633644e51514611dc45780633dbf51ab14611d745780633ec2199314611d0657806340ccf25614611cbc578063466fe6b514611c1957806347e7ef2414611be4578063485cc955146118605780634a34a55d146118165780634b8a3529146117d95780634f1ef286146114935780635259e0b11461146357806352d1902d146113c45780635c044766146113125780635c6fe1301461124c578063649fa701146111d35780636c3a420a1461112e578063704b6c021461106257806374c3767e14610fdb57806379502c5514610fa95780637a0f2fcb14610f815780637b030b3314610efc57806381a1e35e14610ec9578063910849a514610d9f578063976ce49514610d62578063ac75db2414610d31578063ad3cb1cc14610c9d578063b3db428b14610c35578063b6606d1c14610b87578063bb6fd53f146109b8578063bc25cf7714610986578063be1fa06e146108cf578063bf09f27414610885578063cb20844314610840578063cc218ece146107dc578063d449300d14610778578063d4fac45d146106ff578063d76a6779146106b5578063db84aa5914610683578063dc2693f21461055c578063dcd989fd14610460578063dd2a0ac11461042e578063ea86795c14610405578063efeec38c14610389578063f3fef3a3146102fb578063f6f6f72c146102c75763f851a44014610291575f80fd5b346102c457806003193601126102c457602073ffffffffffffffffffffffffffffffffffffffff60015416604051908152f35b80fd5b50346102c457806003193601126102c457602073ffffffffffffffffffffffffffffffffffffffff600a5416604051908152f35b50346102c45760406003193601126102c457610315612324565b60243590610321612f7b565b8115610361579061033291336145d5565b61033b33613327565b807f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d80f35b6004837ffebfd77f000000000000000000000000000000000000000000000000000000008152fd5b50346102c45773ffffffffffffffffffffffffffffffffffffffff7f6806c6169898920521cc6099da39b1c3207743aa68299fb40eb9cc655f645f3560406103d036612489565b9490916103db612ee9565b1693848652601160205281838720558486526012602052808387205582519182526020820152a280f35b50346102c45761033b610417366123c8565b91610420612f32565b610428612f7b565b8061475a565b50346102c45760206003193601126102c45761033b61044b612324565b610453612ee9565b61045b612f7b565b614aa6565b50346102c457602073ffffffffffffffffffffffffffffffffffffffff7f4bcdbeb6d8dffebcc63f0e8cd053fc2b529f1f64846c87dad98b5d84420464986104a73661241c565b949193906104b36134a0565b6104bb612f7b565b6104c4816134df565b6104ce8186613915565b6104d88186613be8565b61052d8183871696878a526003865260408a208583165f5286526fffffffffffffffffffffffffffffffff60405f20991698600181016105198b82546125a1565b90556105268a82546125db565b9055613e8f565b6040519586521693a3807f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d80f35b50346102c45760206fffffffffffffffffffffffffffffffff7f64999df6b539f19d9a33e826d657da3208b3dbc70f145a5fc9d5a6cc70aab60761059f3661241c565b6105ad9592959491946134a0565b6105b5612f7b565b6105be856134df565b6105c88587613915565b6105d28587613be8565b1661065673ffffffffffffffffffffffffffffffffffffffff861694858852600384526040882073ffffffffffffffffffffffffffffffffffffffff82165f52845260405f206106238482546125db565b905573ffffffffffffffffffffffffffffffffffffffff81169687895260058552600660408a20016105268582546125db565b604051908152a3807f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d80f35b50346102c45760206003193601126102c45761033b6106a0612324565b6106a8612ee9565b6106b0612f7b565b6127e1565b50346102c45760206003193601126102c45760ff604060209273ffffffffffffffffffffffffffffffffffffffff6106eb612324565b168152600b84522054166040519015158152f35b50346102c45760406003193601126102c45773ffffffffffffffffffffffffffffffffffffffff6040610730612324565b928261073a612347565b9416815260036020522091165f526020526040805f206020825161075d816124c0565b60018354938483520154918291015282519182526020820152f35b50346102c45760406003193601126102c45773ffffffffffffffffffffffffffffffffffffffff60406107a9612324565b92826107b3612347565b9416815260046020522091165f526020526040805f206001815491015482519182526020820152f35b50346102c45760406003193601126102c45773ffffffffffffffffffffffffffffffffffffffff604061080d612324565b9282610817612347565b9416815260036020522091165f526020526040805f206001815491015482519182526020820152f35b50346102c45760206003193601126102c457604060209173ffffffffffffffffffffffffffffffffffffffff610874612324565b168152601283522054604051908152f35b50346102c45760206003193601126102c45760ff604060209273ffffffffffffffffffffffffffffffffffffffff6108bb612324565b168152600284522054166040519015158152f35b50346102c45760206003193601126102c45773ffffffffffffffffffffffffffffffffffffffff6108fe612324565b610906612ee9565b16801561095e57807fffffffffffffffffffffffff0000000000000000000000000000000000000000600a541617600a557f9f0301fa2208131f7c9f8468d1fbc66952f7eb7b402d7d3aff64c268f38e18b98280a280f35b6004827f284e23a5000000000000000000000000000000000000000000000000000000008152fd5b50346102c45760206003193601126102c45761033b6109a3612324565b6109ab612ee9565b6109b3612f7b565b6125e8565b5034610b335760c0600319360112610b33576109d2612324565b6024356044359173ffffffffffffffffffffffffffffffffffffffff83168303610b33576084359073ffffffffffffffffffffffffffffffffffffffff8216809203610b335760a4359067ffffffffffffffff8211610b335736602383011215610b335781600401359367ffffffffffffffff8511610b33573660248685010111610b3357610a5f612f7b565b8015610b5f578315610b3757610a759133613032565b813b15610b33575f91602483604486947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f604051998a98899788957fffcb8632000000000000000000000000000000000000000000000000000000008752602060048801528282880152018686013785858286010152011681010301925af18015610b2857610b11575b506103329060643590333361475a565b610b1e9192505f90612526565b5f90610332610b01565b6040513d5f823e3d90fd5b5f80fd5b7f5fbe2e88000000000000000000000000000000000000000000000000000000005f5260045ffd5b7ffebfd77f000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b33576040600319360112610b3357610ba0612324565b7f98739cd7055b60cff3bd6bf23dda95ec1a79de66ab4498d7e7c58b35e3868258602073ffffffffffffffffffffffffffffffffffffffff610be061236a565b93610be9612ee9565b1692835f52600b8252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b6040519015158152a2005b34610b3357610c43366123c8565b90610c4c612f7b565b8115610b5f5773ffffffffffffffffffffffffffffffffffffffff831615610b3757610c78923361475a565b5f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610b33575f600319360112610b33576040805190610cbc8183612526565b6005825260208201917f352e302e3000000000000000000000000000000000000000000000000000000083527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8351948593602085525180918160208701528686015e5f85828601015201168101030190f35b34610b33576020600319360112610b3357610c78610d4d612324565b610d55612ee9565b610d5d612f7b565b6144a9565b34610b3357610d70366123c8565b90610d79612f7b565b73ffffffffffffffffffffffffffffffffffffffff831615610b3757610c7892336140a7565b34610b33577f2e8095a3840d90965eacca5a6466aec26c1c238b6685b01446bb4f320ac933f86020610dd03661241c565b610dde9492949391936134a0565b610de6612f7b565b610def846134df565b610df98486613915565b610e038486613be8565b610e9d73ffffffffffffffffffffffffffffffffffffffff861694855f526003845260405f2073ffffffffffffffffffffffffffffffffffffffff82165f52845260016fffffffffffffffffffffffffffffffff60405f2094169301610e6a8482546125a1565b905573ffffffffffffffffffffffffffffffffffffffff811696875f5260058552600660405f20016105268582546125a1565b604051908152a35f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610b3357610c78610ef7610edd366123c8565b90610ee9939293612f32565b610ef1612f7b565b836145d5565b613327565b34610b33576040600319360112610b3357610f15612324565b73ffffffffffffffffffffffffffffffffffffffff610f32612347565b91165f52600e60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052606060405f20805490600260018201549101549060405192835260208301526040820152f35b34610b3357610c78610f92366123c8565b91610f9b612f32565b610fa3612f7b565b806140a7565b34610b33575f600319360112610b3357602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611009612324565b611011612ee9565b16807fffffffffffffffffffffffff000000000000000000000000000000000000000060105416176010557f5226c2129eacbc36446bd868e02ddc36344062a0b8dbdd02835138e4e2d37faa5f80a2005b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611090612324565b611098612ee9565b168015611106577fffffffffffffffffffffffff00000000000000000000000000000000000000006001548273ffffffffffffffffffffffffffffffffffffffff82167ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec65f80a31617600155005b7faf0a4134000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff61115c612324565b165f52600860205260405f206040519081602082549182815201915f5260205f20905f5b8181106111a7576111a38561119781870382612526565b60405191829182612379565b0390f35b825473ffffffffffffffffffffffffffffffffffffffff16845260209093019260019283019201611180565b34610b335773ffffffffffffffffffffffffffffffffffffffff807f49a1b412397bd44f92ba2bc3e644cb3bd76f37060688b0ced2263c5e7a10dd39602061121a366123c8565b9591611227959195612ee9565b1693845f526013835260405f208282165f5283528560405f20556040519586521693a3005b34610b335760206fffffffffffffffffffffffffffffffff7f0d40bd549532c28d6905ada91d6a00498b4583c1dcf33f30c0dc6afd0fd4e4ba61128e3661241c565b61129c9592959491946134a0565b6112a4612f7b565b6112ad856134df565b6112b78587613915565b6112c18587613be8565b16610e9d73ffffffffffffffffffffffffffffffffffffffff861694855f526003845260405f2073ffffffffffffffffffffffffffffffffffffffff82165f52845260405f20610e6a8482546125a1565b34610b33576040600319360112610b335761132b612324565b73ffffffffffffffffffffffffffffffffffffffff611348612347565b91611351612ee9565b611359612f7b565b611362816134df565b1690815f52600560205260405f20906004820192600284549301805484811061139c5784611395915f610c7898556125a1565b905561456e565b7f9d764d6c000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b33575f600319360112610b335773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ddad28dee14fb08817a405078421e7eaaf86a85616300361143b5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b7fe07c8dba000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b3357610c7861147436612489565b9161147d612ee9565b611485612f7b565b61148e816144a9565b614350565b6040600319360112610b33576114a7612324565b6024359067ffffffffffffffff8211610b335736602383011215610b33578160040135906114d482612567565b916114e26040519384612526565b80835260208301933660248383010111610b3357815f9260246020930187378401015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ddad28dee14fb08817a405078421e7eaaf86a85616803014908115611797575b5061143b57611554612ee9565b73ffffffffffffffffffffffffffffffffffffffff8116926040517f52d1902d000000000000000000000000000000000000000000000000000000008152602081600481885afa5f9181611763575b506115d457847f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8692036117385750823b1561170d57807fffffffffffffffffffffffff00000000000000000000000000000000000000007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a28251156116db575f80916116d1945190845af43d156116d3573d916116b583612567565b926116c36040519485612526565b83523d5f602085013e615cfb565b005b606091615cfb565b505050346116e557005b7fb398979f000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4c9c8ce3000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7faa1d49a4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9091506020813d60201161178f575b8161177f60209383612526565b81010312610b33575190866115a3565b3d9150611772565b905073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141584611547565b34610b33576040600319360112610b33576117f2612324565b6024356117fd612f7b565b8015610b5f5761180d9133613032565b610c7833613327565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611844612324565b165f52600c602052602060ff60405f2054166040519015158152f35b34610b33576040600319360112610b3357611879612324565b611881612347565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549160ff8360401c16159267ffffffffffffffff811680159081611bdc575b6001149081611bd2575b159081611bc9575b50611ba1578360017fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008316177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055611b4c575b507ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549160ff8360401c1615611b245773ffffffffffffffffffffffffffffffffffffffff8092167fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f5516807fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001555f7ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec68180a36040916010602084516119f88682612526565b828152017f506f736974696f6e734d616e6167657200000000000000000000000000000000815220600160208551611a308782612526565b828152017f310000000000000000000000000000000000000000000000000000000000000081522084519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f84528683015260608201524660808201523060a082015260a08152611aa760c082612526565b519020600f55611ab357005b7fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2917fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff602092167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00555160018152a1005b7fd7e6bcf8000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005583611926565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b905015856118d3565b303b1591506118cb565b8591506118c1565b34610b33576040600319360112610b3357611bfd612324565b602435611c08612f7b565b8015610b5f57610c7891333361475a565b34610b33576040600319360112610b3357611c32612324565b7fe8e062fa20ded751d71cc7e16b5a24d1a6b1dd71eddf4de1a8010ce93b33cbb3602073ffffffffffffffffffffffffffffffffffffffff611c7261236a565b93611c7b612ee9565b1692835f52600d8252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611cea612324565b165f52600d602052602060ff60405f2054166040519015158152f35b34610b33576040600319360112610b3357611d1f612324565b73ffffffffffffffffffffffffffffffffffffffff611d3c612347565b91165f52601360205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b34610b33575f600319360112610b3357602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c9315bb243baaeef1fcd9358730ba07596d1d531168152f35b34610b33575f600319360112610b33576020600f54604051908152f35b34610b3357610c78611df236612489565b91611dfb612ee9565b61148e612f7b565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff611e31612324565b165f5260056020526101c060405f2080549060018101549060028101546003820154600483015460058401546006850154600786015490600887015492600988015494600a89015496600b8a015498600d600c8c01549b01549b60206040519e8f908152015260408d015260608c015260808b015260a08a015260c089015260e08801526101008701526101208601526101408501526101608401526101808301526101a0820152f35b34610b33576040600319360112610b3357611ef4612324565b73ffffffffffffffffffffffffffffffffffffffff611f1161236a565b91611f1a612ee9565b16908115610b375760207fb4d4597270bf234ac93311fc2d72c364d07f3225345f1e9ea730818fd201debc91835f5260028252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b34610b33575f600319360112610b3357602073ffffffffffffffffffffffffffffffffffffffff60105416604051908152f35b34610b33576040600319360112610b3357611fd1612324565b602435611fdc612f7b565b8015610b5f57610c789133336140a7565b34610b3357602073ffffffffffffffffffffffffffffffffffffffff7f2630763406eaad6cdd32cc078c92164f7c25c2fc52db1a0e7838af2d315ff57a6120333661241c565b9491939061203f6134a0565b612047612f7b565b612050816134df565b61205a8186613915565b6120648186613be8565b6120b18183871696875f526003865260405f208583165f52865260016fffffffffffffffffffffffffffffffff60405f209a16996120a38b82546125a1565b8155016105268a82546125db565b6040519586521693a35f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610b33576020600319360112610b33576004358015158103610b33576121046134a0565b15610c78577f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c6121555760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b34610b3357610c78610ef7612191366123c8565b9061219d939293612f32565b6121a5612f7b565b83613032565b34610b33576020600319360112610b335773ffffffffffffffffffffffffffffffffffffffff6121d9612324565b165f52600660205260405f206040519081602082549182815201915f5260205f20905f5b818110612214576111a38561119781870382612526565b825473ffffffffffffffffffffffffffffffffffffffff168452602090930192600192830192016121fd565b34610b33576040600319360112610b3357612259612324565b7f58dd7f4077ec3722270636a9381ab77a346c24cf2d0c1853c3bf16d5d4c158a4602073ffffffffffffffffffffffffffffffffffffffff61229961236a565b936122a2612ee9565b1692835f52600c8252610c2a8160405f209060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b34610b33576020600319360112610b335760209073ffffffffffffffffffffffffffffffffffffffff612314612324565b165f526011825260405f20548152f35b6004359073ffffffffffffffffffffffffffffffffffffffff82168203610b3357565b6024359073ffffffffffffffffffffffffffffffffffffffff82168203610b3357565b602435908115158203610b3357565b60206040818301928281528451809452019201905f5b81811061239c5750505090565b825173ffffffffffffffffffffffffffffffffffffffff1684526020938401939092019160010161238f565b6003196060910112610b335760043573ffffffffffffffffffffffffffffffffffffffff81168103610b33579060243573ffffffffffffffffffffffffffffffffffffffff81168103610b33579060443590565b6003196060910112610b335760043573ffffffffffffffffffffffffffffffffffffffff81168103610b33579060243573ffffffffffffffffffffffffffffffffffffffff81168103610b3357906044356fffffffffffffffffffffffffffffffff81168103610b335790565b6003196060910112610b335760043573ffffffffffffffffffffffffffffffffffffffff81168103610b3357906024359060443590565b6040810190811067ffffffffffffffff8211176124dc57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6101c0810190811067ffffffffffffffff8211176124dc57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176124dc57604052565b67ffffffffffffffff81116124dc57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b919082039182116125ae57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b919082018092116125ae57565b73ffffffffffffffffffffffffffffffffffffffff90612607816134df565b166040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152602081602481855afa908115610b28575f916126bc575b50815f52600560205260405f2060028101805492838111156126b5576004604093826126987f49cf9aded2ad8e7065fe6c416c8f2eed2d5515ab396ffcd96cc9d12f23c5256797826125a1565b9455016126a68382546125db565b905582519182526020820152a2565b5050505050565b90506020813d6020116126e6575b816126d760209383612526565b81010312610b3357515f61264b565b3d91506126ca565b519073ffffffffffffffffffffffffffffffffffffffff82168203610b3357565b519061ffff82168203610b3357565b51908115158203610b3357565b908160c0910312610b33576040519060c0820182811067ffffffffffffffff8211176124dc576127a29160a0916040528051845260208101516020850152612775604082016126ee565b6040850152612786606082016126ee565b60608501526127976080820161270f565b60808501520161271e565b60a082015290565b81156127b4570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b905f9073ffffffffffffffffffffffffffffffffffffffff5f54168015610b37576040517f31ddaa1f00000000000000000000000000000000000000000000000000000000815260c08160248173ffffffffffffffffffffffffffffffffffffffff8916958660048301525afa908115610b28575f91612eba575b5060a081015115612e92576040810173ffffffffffffffffffffffffffffffffffffffff81511615612e6a5773ffffffffffffffffffffffffffffffffffffffff60608301511615612e4257825f52600560205260405f20906002820192835491815160208301926128cf8451836125db565b8511612ab7575083811180612aa3575b61290b576004897f40bb205e000000000000000000000000000000000000000000000000000000008152fd5b9860209173ffffffffffffffffffffffffffffffffffffffff6129358661299c999a9c9b9d6125a1565b91511690896040518099819582947f69328dec00000000000000000000000000000000000000000000000000000000845230916004850191604091949373ffffffffffffffffffffffffffffffffffffffff91826060860197168552602085015216910152565b03925af1938415612a98578694612a64575b508315908115612a59575b50612a3157916008608094926129f1837f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e098966125db565b80945501908154818082115f14612a2757612a0b916125a1565b80925b55604051938452602084015260408301526060820152a2565b5050838092612a0e565b6004857f3470d577000000000000000000000000000000000000000000000000000000008152fd5b90505183105f6129b9565b9093506020813d602011612a90575b81612a8060209383612526565b81010312610b335751925f6129ae565b3d9150612a73565b6040513d88823e3d90fd5b50612aae84826125a1565b835111156128df565b91929799506080612acf61ffff92869b98999b6125a1565b9201511680612e39575061ffff6127105b168082029082820414821517156125ae57612710900481811115612e315750955b8615908115612e26575b50612dfe5773ffffffffffffffffffffffffffffffffffffffff815116604051907f095ea7b300000000000000000000000000000000000000000000000000000000825260048201525f60248201526020816044815f8c5af18015610b2857612dc7575b5080516040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018790526020816044815f8c5af18015610b2857612d90575b5073ffffffffffffffffffffffffffffffffffffffff815116803b15610b33575f80916084604051809481937f617ba0370000000000000000000000000000000000000000000000000000000083528d60048401528c60248401523060448401528160648401525af18015610b2857612d67575b5073ffffffffffffffffffffffffffffffffffffffff905116604051907f095ea7b30000000000000000000000000000000000000000000000000000000082526004820152836024820152602081604481878b5af18015612d5c57612ce9575b5091600860809492612cd9877f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e098966125a1565b8094550190612a0b8483546125db565b6020813d602011612d54575b81612d0260209383612526565b81010312612d505760809492612cd9877f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e0989694612d4160089561271e565b50949650975050929450612ca5565b8380fd5b3d9150612cf5565b6040513d86823e3d90fd5b612d749194505f90612526565b5f9273ffffffffffffffffffffffffffffffffffffffff612c45565b6020813d602011612dbf575b81612da960209383612526565b81010312610b3357612dba9061271e565b612bd1565b3d9150612d9c565b6020813d602011612df6575b81612de060209383612526565b81010312610b3357612df19061271e565b612b6f565b3d9150612dd3565b7f3470d577000000000000000000000000000000000000000000000000000000005f5260045ffd5b90505186105f612b0b565b905095612b01565b61ffff90612ae0565b7fb65ce21e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f59f8cd44000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9f3808e3000000000000000000000000000000000000000000000000000000005f5260045ffd5b612edc915060c03d60c011612ee2575b612ed48183612526565b81019061272b565b5f61285c565b503d612eca565b73ffffffffffffffffffffffffffffffffffffffff600154163303612f0a57565b7fb544a4e8000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff601054163303612f5357565b7f83a8284e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c6121555760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d565b90816080910312610b3357604051906080820182811067ffffffffffffffff8211176124dc5761302a91606091604052613000816126ee565b845261300e6020820161270f565b602085015261301f6040820161270f565b60408501520161271e565b606082015290565b73ffffffffffffffffffffffffffffffffffffffff5f5416926040517ffb20974f00000000000000000000000000000000000000000000000000000000815260808160248173ffffffffffffffffffffffffffffffffffffffff8816988960048301525afa8015610b28576060915f916132f8575b500151156132d057835f52600b60205260ff60405f2054166132a8576130cc836134df565b6130d68383614ee7565b835f52600560205260405f20926002840182815410613298575b8281541061327057600385016131078482546125db565b875f52601260205260405f20548015159182613266575b505061323e5773ffffffffffffffffffffffffffffffffffffffff851695865f52600460205260405f20885f5260205260405f2090875f52601360205260405f20895f5260205260405f2054806131f3575b5085946131de948694846131b660209a6131d8967f312a5e5e1079f5dda4e95dbbd0b908b291fd5b992ef22073643ab691572c5b529d98549081156131e7575b506125db565b90556131c38682546125db565b90556131d08582546125a1565b90558261534b565b8761456e565b604051908152a3565b5460018501555f6131b0565b6132048784959698979994546125db565b11613216575f96949593929196613170565b7f48c6b2c2000000000000000000000000000000000000000000000000000000005f5260045ffd5b7ffad3a252000000000000000000000000000000000000000000000000000000005f5260045ffd5b1190505f8061311e565b7f34e4d368000000000000000000000000000000000000000000000000000000005f5260045ffd5b6132a28383615022565b506130f0565b7fbf64d2e7000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f6c3d13c1000000000000000000000000000000000000000000000000000000005f5260045ffd5b61331a915060803d608011613320575b6133128183612526565b810190612fc7565b5f6130a7565b503d613308565b606073ffffffffffffffffffffffffffffffffffffffff604481600a54169360405194859384927f390f61d20000000000000000000000000000000000000000000000000000000084523060048501521660248301525afa8015610b28575f5f91613464575b6133979250615541565b6004602073ffffffffffffffffffffffffffffffffffffffff5f5416604051928380927fcee3d4110000000000000000000000000000000000000000000000000000000082525afa908115610b28575f91613425575b5061ffff8091169116106133fd57565b7f90f4a458000000000000000000000000000000000000000000000000000000005f5260045ffd5b90506020813d60201161345c575b8161344060209383612526565b81010312610b335761ffff613455819261270f565b91506133ed565b3d9150613433565b50506060813d606011613498575b8161347f60609383612526565b81010312610b335780602061339792519101519061338d565b3d9150613472565b335f52600260205260ff60405f205416156134b757565b7fd13a8703000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff811690815f52600560205260405f2060018101918254156138c357825442146138bd5761352081614d1c565b6003820180549182156138705790602491608073ffffffffffffffffffffffffffffffffffffffff5f5416604051948580927ffb20974f0000000000000000000000000000000000000000000000000000000082528b60048301525afa928315610b28575f9361384f575b506135978654426125a1565b906135b46135a98660028901546125db565b6008880154906125db565b80156138175761363d92916135cb60209288615570565b9073ffffffffffffffffffffffffffffffffffffffff875116906040518096819482937f63679793000000000000000000000000000000000000000000000000000000008452600484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03915afa8015610b28575f906137e3575b6136589250615645565b80670de0b6b3a7640000019283670de0b6b3a7640000116125ae57846136b86136b061ffff6136a486670de0b6b3a76400006136996136bf9960409d6156ee565b9187091515906125db565b98899501511684615791565b9588546156ee565b87556125db565b90556136dd60048401916136d48184546125db565b938484556125a1565b6006840154918115938415613724575b50505050506020907f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769242905554604051908152a2565b939592949385156137aa575050670de0b6b3a7640000810294818604670de0b6b3a76400001417156125ae5761377d6020947f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b85770983776966127aa565b61378c600585019182546125db565b905561379d600784019182546125db565b90555b9281925f806136ed565b7f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b85770983776965060209550916137dc91926125db565b90556137a0565b506020823d60201161380f575b816137fd60209383612526565b81010312610b3357613658915161364e565b3d91506137f0565b5050505050506020907f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769242905554604051908152a2565b61386991935060803d608011613320576133128183612526565b915f61358b565b505050807f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769260209254156138ad575b42905554604051908152a2565b670de0b6b3a764000082556138a0565b50505050565b906138fb6020927f9a65b5c5cdb30037df3368f844350f18c08099259c8c402a4781b857709837769442905582541561390557614d1c565b54604051908152a2565b670de0b6b3a76400008355614d1c565b7f000000000000000000000000c9315bb243baaeef1fcd9358730ba07596d1d5319073ffffffffffffffffffffffffffffffffffffffff83165f52600560205260405f206040519361396685612509565b815485526001820154602086015260028201546040860152600382015460608601526004820154608086015260058201549160a08601928352600681015460c0870152600781015460e087015260088101546101008701526101a0600d6009830154926101208901938452600a8101546101408a0152600b8101546101608a0152600c8101546101808a01520154960195865273ffffffffffffffffffffffffffffffffffffffff841695865f52600e60205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f52602052613aa560405f2093885f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f205490895f52600360205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052600160405f200154906125db565b938415613bd25750516001830180545f9581841180613bc4575b613b54575b50505551905580613ad55750505050565b613b4b93613ae38484613be8565b5f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f20613b198282546125db565b905573ffffffffffffffffffffffffffffffffffffffff83165f526005602052610526600660405f20019182546125db565b5f8080806138bd565b85549185518310613b71575b505050825160028501555f80613ac4565b613b9392975090613b85613b8b92866125a1565b906156ee565b9584516125a1565b613ba384516002870154906125a1565b90818110613bb2575b80613b60565b613bbc92966158be565b935f80613bac565b506002860154855111613abf565b5183555160018301555160029091015550505050565b73ffffffffffffffffffffffffffffffffffffffff16805f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f52602052613c4f602060405f20604051613c3b816124c0565b6001825492838352015492839101526125db565b73ffffffffffffffffffffffffffffffffffffffff83165f52600560205260405f209260405190613c7f82612509565b845482526001850154602083015260028501546040830152600385015460608301526004850154608083015260058501549360a08301948552600686015460c0840152600786015460e084015260088601546101008401526101a0600d60098801549788610120870152600a810154610140870152600b810154610160870152600c810154610180870152015493019283525f52600e60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20928354928315613d56575050508211613d53575050565b55565b9091925015613d6457505055565b600192935051835551910155565b8054821015613d87575f5260205f2001905f90565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b80548015613e0c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190613de98282613d72565b73ffffffffffffffffffffffffffffffffffffffff82549160031b1b1916905555565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b90815491680100000000000000008310156124dc5782613e61916001613e8d95018155613d72565b90919073ffffffffffffffffffffffffffffffffffffffff8084549260031b9316831b921b1916179055565b565b73ffffffffffffffffffffffffffffffffffffffff16805f52600360205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f52602052613ee160405f2060018154910154906125db565b15801590825f52600760205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f2054918061409f575b15613f7257505090815f526006602052613f368160405f20613e39565b815f52600660205260405f2054915f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f2055565b80614096575b613f82575b505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908082116125ae57825f52600660205260405f20908154927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84019384116125ae5783613ffb94820361402a575b505050613db4565b5f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f526020525f6040812055565b613e619173ffffffffffffffffffffffffffffffffffffffff6140506140619387613d72565b90549060031b1c1692839186613d72565b845f52600760205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20555f8080613ff3565b50801515613f78565b508115613f19565b92906140b2836134df565b6140bc8382614ee7565b73ffffffffffffffffffffffffffffffffffffffff811692835f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f2092835490811561432857818111156143205750945b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8316966020826024818b5afa918215610b28575f926142ea575b5061417d9030848a61597b565b604051907f70a082310000000000000000000000000000000000000000000000000000000082523060048301526020826024818b5afa8015610b28575f906142b6575b6141ca92506125a1565b938415610b5f5773ffffffffffffffffffffffffffffffffffffffff92816142389254968781115f146142ab5761420188806125a1565b8255895f52600560205261422e600260405f20600381016142238c82546125a1565b9055019182546125db565b905554159461534b565b1691838303614276576040805191825291151560208201527f32b9f192f046502437b65280a1ff8a435327a7bb3986b85db4a5e61b44e5d3b39250a3565b6040805191825291151560208201527ffe1b46ad82b670225ffdad07a6c5d6c091daed088a1c049d9e4a3dc82124e1379190a4565b6142018180996125a1565b506020823d6020116142e2575b816142d060209383612526565b81010312610b33576141ca91516141c0565b3d91506142c3565b9091506020813d602011614318575b8161430660209383612526565b81010312610b3357519061417d614170565b3d91506142f9565b905094614115565b7f41c2aada000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff1691825f52600560205260405f2091600c830191825482036144815781151580614478575b15610b375773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c9315bb243baaeef1fcd9358730ba07596d1d53116938415610b37575f6040947f16c76d81a47c737c0d3daa00dfb6dce401133e61c8e82d5fd65b599ddc7ecc90966143ff8530338461597b565b825260056020526002868320016144178582546125db565b90556144238585615570565b600984018054600b8601549281841161444e575b50505555600a4291015582519182526020820152a2565b61445b61446092856125a1565b6156ee565b61446f600d87019182546125db565b90555f80614437565b5080151561438a565b7fcedf65e4000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff16805f52600560205260405f2060078101908154600c820191825461448157811561454657816020937fbd37e746d35a5ef50049f706ec75c287091538b68733b1dd25add1162aa373ad95600284016145188482546125a1565b905561452583338a61456e565b6145308382546125a1565b905555600b6005820154910155604051908152a2565b7fa6613090000000000000000000000000000000000000000000000000000000005f5260045ffd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082015273ffffffffffffffffffffffffffffffffffffffff929092166024830152604480830193909352918152613e8d916145d0606483612526565b6159e2565b919073ffffffffffffffffffffffffffffffffffffffff600a541615614732576145fe816134df565b6146088184614ee7565b6146128184613915565b61461c8184613be8565b73ffffffffffffffffffffffffffffffffffffffff811692835f52600d60205260ff60405f20541661470a57835f52600560205260405f20926002840193818554106146fa575b81855410613270577f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb938360066131de9373ffffffffffffffffffffffffffffffffffffffff6020971698895f526003885260405f208b5f52885260405f206146cd8882546125a1565b90556146da8782546125a1565b9055016146e88582546125a1565b90556146f584828a61456e565b613e8f565b6147048285615022565b50614663565b7f1d6f8dcd000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f284e23a5000000000000000000000000000000000000000000000000000000005f5260045ffd5b90614764836134df565b61476e8382613915565b6147788382613be8565b73ffffffffffffffffffffffffffffffffffffffff5f5416936040517ffb20974f00000000000000000000000000000000000000000000000000000000815260808160248173ffffffffffffffffffffffffffffffffffffffff8916998a60048301525afa8015610b28576060915f91614a87575b500151156132d057845f52600c60205260ff60405f205416614a5f57604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481895afa918215610b28575f92614a29575b5061485a9030858861597b565b604051907f70a08231000000000000000000000000000000000000000000000000000000008252306004830152602082602481895afa8015610b28575f906149f5575b6148a792506125a1565b918215610b5f57845f52600560205260405f2060028101946148e6856148e16148d689546003870154906125db565b6008860154906125db565b6125db565b875f52601160205260405f205480151591826149eb575b50506149c35783600661495f9373ffffffffffffffffffffffffffffffffffffffff80971698895f52600360205260405f208b5f5260205260405f206149448a82546125db565b90556149518982546125db565b9055016105268782546125db565b16828103614995575060207f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f6291604051908152a3565b9060207f9b97b64e9cc6e815f094532deb9581a5b7daa7de9eecaf344c66d6e707b0b41891604051908152a4565b7f1e306e25000000000000000000000000000000000000000000000000000000005f5260045ffd5b1190505f806148fd565b506020823d602011614a21575b81614a0f60209383612526565b81010312610b33576148a7915161489d565b3d9150614a02565b9091506020813d602011614a57575b81614a4560209383612526565b81010312610b3357519061485a61484d565b3d9150614a38565b7fb48990ce000000000000000000000000000000000000000000000000000000005f5260045ffd5b614aa0915060803d608011613320576133128183612526565b5f6147ed565b73ffffffffffffffffffffffffffffffffffffffff5f5416908115610b37576040517f31ddaa1f00000000000000000000000000000000000000000000000000000000815260c08160248173ffffffffffffffffffffffffffffffffffffffff8616968760048301525afa908115610b28575f91614cfd575b5060a081015115613f7d5773ffffffffffffffffffffffffffffffffffffffff60408201511615808015614cdb575b614cb25750825f526005602052614b85606060405f2092019273ffffffffffffffffffffffffffffffffffffffff84511690615a69565b15614b8f57505050565b602073ffffffffffffffffffffffffffffffffffffffff6024935116604051938480927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa918215610b28575f92614c7e575b506008810191614bfc8184546125a1565b906004830192835491838310614c56577f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e095606095614c3d866005966125a1565b9055550154604051915f835260208301526040820152a2565b7f5f890b07000000000000000000000000000000000000000000000000000000005f5260045ffd5b9091506020813d602011614caa575b81614c9a60209383612526565b81010312610b335751905f614beb565b3d9150614c8d565b91509150612e6a576060015173ffffffffffffffffffffffffffffffffffffffff1615612e4257565b5073ffffffffffffffffffffffffffffffffffffffff60608301511615614b4e565b614d16915060c03d60c011612ee257612ed48183612526565b5f614b1f565b73ffffffffffffffffffffffffffffffffffffffff5f54168015610b3757604051907f31ddaa1f00000000000000000000000000000000000000000000000000000000825260c08260248173ffffffffffffffffffffffffffffffffffffffff8716948560048301525afa918215610b28575f92614ec6575b5060a082015115613f7d5773ffffffffffffffffffffffffffffffffffffffff604083015116158015614ea4575b613f7d575f526005602052614df8606060405f2092019273ffffffffffffffffffffffffffffffffffffffff84511690615a69565b15614e01575050565b602073ffffffffffffffffffffffffffffffffffffffff6024935116604051938480927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa918215610b28575f92614e6f575b50906008614e6c9201546125a1565b50565b91506020823d602011614e9c575b81614e8a60209383612526565b81010312610b33579051906008614e5d565b3d9150614e7d565b5073ffffffffffffffffffffffffffffffffffffffff60608301511615614dc3565b614ee091925060c03d60c011612ee257612ed48183612526565b905f614d95565b73ffffffffffffffffffffffffffffffffffffffff165f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f5260205260405f20908154908115613f7d5773ffffffffffffffffffffffffffffffffffffffff165f52600560205260405f2091604051614f6081612509565b6101a0600d85549586845260018101546020850152600281015460408501526003810154606085015260048101546080850152600581015460a0850152600681015460c0850152600781015460e085015260088101546101008501526009810154610120850152600a810154610140850152600b810154610160850152600c81015461018085015201549101526001810191825480155f1461501d5750670de0b6b3a76400005b8085146126b55784615018926158be565b905555565b615007565b91909173ffffffffffffffffffffffffffffffffffffffff5f54168015610b375773ffffffffffffffffffffffffffffffffffffffff821691825f52600560205260405f20906002820192868454101561534157604051907f31ddaa1f00000000000000000000000000000000000000000000000000000000825285600483015260c082602481845afa918215610b28575f92615320575b5060a08201511580156152fe575b80156152dc575b6152d1579060c060249392604051948580927f31ddaa1f0000000000000000000000000000000000000000000000000000000082528a60048301525afa978815610b2857604061515873ffffffffffffffffffffffffffffffffffffffff926151c09b6020975f916152b2575b5060a08101511515806152a3575b61528c575b508854906125a1565b92015116905f604051809a819582947f69328dec00000000000000000000000000000000000000000000000000000000845230916004850191604091949373ffffffffffffffffffffffffffffffffffffffff91826060860197168552602085015216910152565b03925af1948515610b28575f95615258575b5084806151df5750505050565b826008608093615211847f3f6c2d888e3655f127387ddbb51a311acc15f36a8d5535bd05b5b9556aaa29e097546125db565b809355018054838082115f1461524e5761522a916125a1565b80915b55604051925f8452602084015260408301526060820152a25f8080806138bd565b50505f809161522d565b9094506020813d602011615284575b8161527460209383612526565b81010312610b335751935f6151d2565b3d9150615267565b84606061529c9201511687615a69565b505f61514f565b5084606082015116151561514a565b6152cb915060c03d60c011612ee257612ed48183612526565b5f61513c565b505f96505050505050565b5073ffffffffffffffffffffffffffffffffffffffff606083015116156150cf565b5073ffffffffffffffffffffffffffffffffffffffff604083015116156150c8565b61533a91925060c03d60c011612ee257612ed48183612526565b905f6150ba565b505f955050505050565b73ffffffffffffffffffffffffffffffffffffffff16805f52600460205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f205415801590825f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f20549180615539575b1561541f57505090815f5260086020526153e38160405f20613e39565b815f52600860205260405f2054915f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f2055565b80615530575b61542e57505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908082116125ae57825f52600860205260405f20908154927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84019384116125ae57836154a69482036154d557505050613db4565b5f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f526020525f6040812055565b613e619173ffffffffffffffffffffffffffffffffffffffff6140506154fb9387613d72565b845f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f20555f8080613ff3565b50801515615425565b5081156153c6565b9080156155685761555191615822565b61ffff81116155615761ffff1690565b5061ffff90565b505061ffff90565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff670de0b6b3a7640000820991670de0b6b3a7640000820291828085109403938085039414615636578382111561561e57670de0b6b3a7640000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b509061564292506127aa565b90565b9190915f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84820990848102928380841093039280840393146156df57826301e1338011156156cd57507f98f5be4dd1e14769fbd6666224dc1eb80dd2e0a3d2c8b328f57e76b7ae10395793946301e13380910990828211900360f91b910360071c170290565b634e487b71905260116020526024601cfd5b5050506301e133809192500490565b9190915f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848209908481029283808410930392808403931461577e5782670de0b6b3a764000011156156cd57507faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699394670de0b6b3a7640000910990828211900360ee1b910360121c170290565b505050670de0b6b3a76400009192500490565b9190915f907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8482099084810292838084109303928084039314615815578261271011156156cd57507fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e919394612710910990828211900360fc1b910360041c170290565b5050506127109192500490565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612710820991612710820291828085109403938085039414615636578382111561561e57612710829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b90917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff838309928083029283808610950394808603951461596e57848311156159565790829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b50509061564292506127aa565b90919273ffffffffffffffffffffffffffffffffffffffff613e8d9481604051957f23b872dd0000000000000000000000000000000000000000000000000000000060208801521660248601521660448401526064830152606482526145d0608483612526565b905f602091828151910182855af115610b28575f513d615a60575073ffffffffffffffffffffffffffffffffffffffff81163b155b615a1e5750565b73ffffffffffffffffffffffffffffffffffffffff907f5274afe7000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b60011415615a17565b73ffffffffffffffffffffffffffffffffffffffff80911691825f526005602052602060405f20916024604051809581937f70a08231000000000000000000000000000000000000000000000000000000008352306004840152165afa918215610b28575f92615cc7575b506008810191825480821115615cbe57615aee90826125a1565b926024608073ffffffffffffffffffffffffffffffffffffffff5f5416604051928380927ffb20974f0000000000000000000000000000000000000000000000000000000082528a60048301525afa908115610b285761ffff6040615b6e93615b62935f91615c9f575b5001511686615791565b80615c89575b856125a1565b80158015615bb9575b50505560050154604080519283525f60208401528201527f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e090606090a2600190565b939094926006820154928315155f14615c4957670de0b6b3a7640000870295878704670de0b6b3a76400001417156125ae577f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e096615c1b6005956060986127aa565b615c298686019182546125db565b9055615c3a600785019182546125db565b90555b92509294819450615b77565b60609550600593507f3da554118f5a2adbe66b8089472fbb7e6b6c86598448e01b2482b01bb8c569e096615c82600485019182546125db565b9055615c3d565b60048501615c988282546125db565b9055615b68565b615cb8915060803d608011613320576133128183612526565b5f615b58565b50505050505f90565b9091506020813d602011615cf3575b81615ce360209383612526565b81010312610b335751905f615ad4565b3d9150615cd6565b90615d385750805115615d1057602081519101fd5b7fd6bda275000000000000000000000000000000000000000000000000000000005f5260045ffd5b81511580615d8b575b615d49575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b50803b15615d4156
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c9315bb243baaeef1fcd9358730ba07596d1d531
-----Decoded View---------------
Arg [0] : systemTokenFT_ (address): 0xC9315Bb243bAAeEF1Fcd9358730ba07596d1d531
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c9315bb243baaeef1fcd9358730ba07596d1d531
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.