Overview
ETH Balance
ETH Value
$0.00Latest 25 from a total of 31 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Add Liquidity | 24759707 | 160 days ago | IN | 0.00002811 ETH | 0.00000005 | ||||
| Add Liquidity | 24530670 | 162 days ago | IN | 0.00002358 ETH | 0.00000082 | ||||
| Remove Liquidity | 24417652 | 164 days ago | IN | 0 ETH | 0.00000005 | ||||
| Add Liquidity | 24417597 | 164 days ago | IN | 0.00003142 ETH | 0.00000005 | ||||
| Add Liquidity | 24417580 | 164 days ago | IN | 0.00003142 ETH | 0.00000005 | ||||
| Add Liquidity | 24362040 | 164 days ago | IN | 0.00001824 ETH | 0.00000008 | ||||
| Add Liquidity | 24239789 | 166 days ago | IN | 0.00000324 ETH | 0.00000005 | ||||
| Add Liquidity | 24163379 | 166 days ago | IN | 0.00010754 ETH | 0.00000005 | ||||
| Add Liquidity | 23761673 | 171 days ago | IN | 0.00000903 ETH | 0.00000005 | ||||
| Remove Liquidity | 23578371 | 173 days ago | IN | 0 ETH | 0.00000005 | ||||
| Add Liquidity | 23578330 | 173 days ago | IN | 0.00000926 ETH | 0.00000005 | ||||
| Remove Liquidity | 23434855 | 175 days ago | IN | 0 ETH | 0.00000004 | ||||
| Remove Liquidity | 23434832 | 175 days ago | IN | 0 ETH | 0.00000004 | ||||
| Add Liquidity | 23147153 | 178 days ago | IN | 0.0000079 ETH | 0.00000006 | ||||
| Remove Liquidity | 23064996 | 179 days ago | IN | 0 ETH | 0.00000005 | ||||
| Remove Liquidity | 23064969 | 179 days ago | IN | 0 ETH | 0.00000005 | ||||
| Add Liquidity | 23064883 | 179 days ago | IN | 0.00001925 ETH | 0.00000005 | ||||
| Add Liquidity | 22948728 | 181 days ago | IN | 0.00001421 ETH | 0.00000005 | ||||
| Add Liquidity | 22683676 | 184 days ago | IN | 0.00001159 ETH | 0.00000005 | ||||
| Add Liquidity | 21510746 | 197 days ago | IN | 0.00000029 ETH | 0.00000054 | ||||
| Remove Liquidity | 21492795 | 197 days ago | IN | 0 ETH | 0.00000006 | ||||
| Add Liquidity | 21311781 | 199 days ago | IN | 0.00001467 ETH | 0.00000006 | ||||
| Add Liquidity | 20363267 | 210 days ago | IN | 0.00002876 ETH | 0.00000004 | ||||
| Add Liquidity | 19589544 | 219 days ago | IN | 0.0000606 ETH | 0.00000095 | ||||
| Add Liquidity | 18796944 | 229 days ago | IN | 1.27555134 ETH | 0.00000004 |
Latest 25 internal transactions (View All)
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 24759707 | 160 days ago | 0.00002811 ETH | ||||
| 24759707 | 160 days ago | 0 ETH | ||||
| 24759525 | 160 days ago | 0.00003362 ETH | ||||
| 24759525 | 160 days ago | 0.00003362 ETH | ||||
| 24530716 | 162 days ago | 0.00002246 ETH | ||||
| 24530716 | 162 days ago | 0.00002246 ETH | ||||
| 24530670 | 162 days ago | 0.00002358 ETH | ||||
| 24417597 | 164 days ago | 0.00003142 ETH | ||||
| 24417597 | 164 days ago | 0 ETH | ||||
| 24417580 | 164 days ago | 0.00003142 ETH | ||||
| 24417580 | 164 days ago | 0 ETH | ||||
| 24417438 | 164 days ago | 0.00006557 ETH | ||||
| 24417438 | 164 days ago | 0.00006557 ETH | ||||
| 24362175 | 164 days ago | 0.00000803 ETH | ||||
| 24362175 | 164 days ago | 0.00000803 ETH | ||||
| 24362040 | 164 days ago | 0.00001824 ETH | ||||
| 24239847 | 166 days ago | 0.00000316 ETH | ||||
| 24239847 | 166 days ago | 0.00000316 ETH | ||||
| 24239832 | 166 days ago | 0.00000316 ETH | ||||
| 24239832 | 166 days ago | 0.00000316 ETH | ||||
| 24239789 | 166 days ago | 0.00000324 ETH | ||||
| 24163379 | 166 days ago | 0.00010753 ETH | ||||
| 24163379 | 166 days ago | 0 ETH | ||||
| 24163280 | 166 days ago | 0.00002 ETH | ||||
| 24163280 | 166 days ago | 0.00002 ETH |
Cross-Chain Transactions
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
// V4 core
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {Currency, CurrencyLibrary} from "v4-core/types/Currency.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {IHooks} from "v4-core/interfaces/IPoolManager.sol";
import {SafeCast} from "v4-core/libraries/SafeCast.sol";
// Solmate
import {Owned} from "solmate/src/auth/Owned.sol";
// Local
import {BaseFees} from "./base/BaseFees.sol";
import {BasePoolManager} from "./base/BasePoolManager.sol";
import {PoolStatus} from "./types/PoolStatus.sol";
import {PoolStatusLibrary} from "./types/PoolStatusLibrary.sol";
import {CurrencyExtLibrary} from "./libraries/CurrencyExtLibrary.sol";
import {CurrencyPoolLibrary} from "./libraries/CurrencyPoolLibrary.sol";
import {UQ112x112} from "./libraries/UQ112x112.sol";
import {TimeLibrary} from "./libraries/TimeLibrary.sol";
import {LiquidityLevel} from "./libraries/LiquidityLevel.sol";
import {PerLibrary} from "./libraries/PerLibrary.sol";
import {FeeLibrary} from "./libraries/FeeLibrary.sol";
import {MarginParams, MarginParamsVo} from "./types/MarginParams.sol";
import {ReleaseParams} from "./types/ReleaseParams.sol";
import {BalanceStatus} from "./types/BalanceStatus.sol";
import {AddLiquidityParams, RemoveLiquidityParams} from "./types/LiquidityParams.sol";
import {IPairPoolManager} from "./interfaces/IPairPoolManager.sol";
import {IPoolStatusManager} from "./interfaces/IPoolStatusManager.sol";
import {ILendingPoolManager} from "./interfaces/ILendingPoolManager.sol";
import {IMarginFees} from "./interfaces/IMarginFees.sol";
import {IMarginLiquidity} from "./interfaces/IMarginLiquidity.sol";
import {IMirrorTokenManager} from "./interfaces/IMirrorTokenManager.sol";
contract PairPoolManager is IPairPoolManager, BaseFees, BasePoolManager {
using UQ112x112 for *;
using SafeCast for uint256;
using TimeLibrary for uint32;
using LiquidityLevel for uint8;
using FeeLibrary for uint24;
using PerLibrary for uint256;
using CurrencyLibrary for Currency;
using CurrencyExtLibrary for Currency;
using CurrencyPoolLibrary for Currency;
using PoolStatusLibrary for PoolStatus;
error InsufficientLiquidityMinted();
error InsufficientLiquidityBurnt();
error InsufficientOutputReceived();
error InsufficientValue();
error NotPositionManager();
error NotAllowed();
error StatusManagerAlreadySet();
error HookAlreadySet();
error LowFeePoolOnlyOneLevel();
event Initialize(
PoolId indexed id,
Currency indexed currency0,
Currency indexed currency1,
uint24 fee,
int24 tickSpacing,
IHooks hooks
);
event Mint(
PoolId indexed poolId,
address indexed source,
address indexed sender,
uint256 liquidity,
uint256 amount0,
uint256 amount1,
uint8 level
);
event Burn(
PoolId indexed poolId, address indexed sender, uint256 liquidity, uint256 amount0, uint256 amount1, uint8 level
);
event Release(
PoolId indexed poolId,
Currency indexed borrowCurrency,
uint256 debtAmount,
uint256 repayAmount,
uint256 burnAmount,
uint256 rawBorrowAmount
);
event Swap(
PoolId indexed poolId,
address indexed sender,
uint256 amount0,
uint256 amount1,
uint24 fee,
bool zeroForOne,
uint256 feeAmount
);
IMirrorTokenManager public immutable mirrorTokenManager;
ILendingPoolManager public immutable lendingPoolManager;
IMarginLiquidity public immutable marginLiquidity;
IHooks public hooks;
IPoolStatusManager public statusManager;
mapping(address => bool) public positionManagers;
constructor(
address initialOwner,
IPoolManager _manager,
IMirrorTokenManager _mirrorTokenManager,
ILendingPoolManager _lendingPoolManager,
IMarginLiquidity _marginLiquidity
) BasePoolManager(initialOwner, _manager) {
mirrorTokenManager = _mirrorTokenManager;
lendingPoolManager = _lendingPoolManager;
marginLiquidity = _marginLiquidity;
poolManager.setOperator(address(lendingPoolManager), true);
mirrorTokenManager.setOperator(address(lendingPoolManager), true);
}
function marginFees() public view returns (IMarginFees) {
return statusManager.marginFees();
}
modifier onlyPosition() {
if (!(positionManagers[msg.sender])) revert NotPositionManager();
_;
}
modifier onlyFees() {
require(msg.sender == address(marginFees()), "UNAUTHORIZED");
_;
}
modifier onlyHooks() {
require(msg.sender == address(hooks), "UNAUTHORIZED");
_;
}
modifier onlyLendingPool() {
require(msg.sender == address(lendingPoolManager), "UNAUTHORIZED");
_;
}
function getStatus(PoolId poolId) external view returns (PoolStatus memory _status) {
_status = statusManager.getStatus(poolId);
}
function getReserves(PoolId poolId) external view returns (uint256 _reserve0, uint256 _reserve1) {
PoolStatus memory status = statusManager.getStatus(poolId);
(_reserve0, _reserve1) = status.getReserves();
}
function getAmountIn(PoolId poolId, bool zeroForOne, uint256 amountOut) external view returns (uint256 amountIn) {
PoolStatus memory status = statusManager.getStatus(poolId);
(amountIn,,) = statusManager.getAmountIn(status, zeroForOne, amountOut);
}
function getAmountOut(PoolId poolId, bool zeroForOne, uint256 amountIn) external view returns (uint256 amountOut) {
PoolStatus memory status = statusManager.getStatus(poolId);
(amountOut,,) = statusManager.getAmountOut(status, zeroForOne, amountIn);
}
// ******************** HOOK CALL ********************
function initialize(PoolKey calldata key) external onlyHooks {
statusManager.initialize(key);
emit Initialize(key.toId(), key.currency0, key.currency1, key.fee, key.tickSpacing, key.hooks);
}
function swap(address sender, PoolKey calldata key, IPoolManager.SwapParams calldata params)
external
onlyHooks
returns (
Currency specified,
Currency unspecified,
uint256 specifiedAmount,
uint256 unspecifiedAmount,
uint24 swapFee
)
{
PoolId poolId = key.toId();
PoolStatus memory _status = statusManager.getStatus(poolId);
bool exactInput = params.amountSpecified < 0;
(specified, unspecified) =
(params.zeroForOne == exactInput) ? (key.currency0, key.currency1) : (key.currency1, key.currency0);
specifiedAmount = exactInput ? uint256(-params.amountSpecified) : uint256(params.amountSpecified);
uint256 feeAmount;
if (exactInput) {
(unspecifiedAmount, swapFee, feeAmount) =
statusManager.getAmountOut(_status, params.zeroForOne, specifiedAmount);
poolManager.approve(address(hooks), unspecified.toId(), unspecifiedAmount);
} else {
(unspecifiedAmount, swapFee, feeAmount) =
statusManager.getAmountIn(_status, params.zeroForOne, specifiedAmount);
poolManager.approve(address(hooks), specified.toId(), specifiedAmount);
}
if (feeAmount > 0) {
Currency feeCurrency = params.zeroForOne ? key.currency0 : key.currency1;
feeAmount = statusManager.updateSwapProtocolFees(feeCurrency, feeAmount);
emit Fees(poolId, feeCurrency, sender, uint8(FeeType.SWAP), feeAmount);
}
(uint256 amount0, uint256 amount1) = (params.zeroForOne == exactInput)
? (specifiedAmount, unspecifiedAmount)
: (unspecifiedAmount, specifiedAmount);
emit Swap(poolId, sender, amount0, amount1, swapFee, params.zeroForOne, feeAmount);
}
// ******************** SELF CALL ********************
/// @inheritdoc IPairPoolManager
function addLiquidity(AddLiquidityParams calldata params)
external
payable
ensure(params.deadline)
returns (uint256 liquidity)
{
PoolStatus memory status = statusManager.setBalances(msg.sender, params.poolId);
if (params.level > LiquidityLevel.RETAIN_BOTH && status.key.fee < 3000) revert LowFeePoolOnlyOneLevel();
if (status.key.currency0.isAddressZero() && params.amount0 != msg.value) revert InsufficientValue();
uint256 uPoolId = marginLiquidity.getPoolId(params.poolId);
uint256 _totalSupply = marginLiquidity.balanceOf(address(this), uPoolId);
uint256 amount0In;
uint256 amount1In;
(liquidity, amount0In, amount1In) =
status.computeLiquidity(_totalSupply, params.amount0, params.amount1, params.amount0Min, params.amount1Min);
if (params.amount0 > amount0In && status.key.currency0.isAddressZero()) {
status.key.currency0.transfer(msg.sender, params.amount0 - amount0In);
}
if (liquidity == 0) revert InsufficientLiquidityMinted();
marginLiquidity.addLiquidity(msg.sender, uPoolId, params.level, liquidity);
poolManager.unlock(abi.encodeCall(this.handleAddLiquidity, (msg.sender, status.key, amount0In, amount1In)));
statusManager.update(params.poolId);
emit Mint(params.poolId, params.source, msg.sender, liquidity, amount0In, amount1In, params.level);
}
/// @dev Handle liquidity addition by taking tokens from the sender and claiming ERC6909 to the hook address
function handleAddLiquidity(address sender, PoolKey calldata key, uint256 amount0, uint256 amount1)
external
selfOnly
{
key.currency0.settle(poolManager, sender, amount0, false);
key.currency0.take(poolManager, address(this), amount0, true);
key.currency1.settle(poolManager, sender, amount1, false);
key.currency1.take(poolManager, address(this), amount1, true);
}
/// @inheritdoc IPairPoolManager
function removeLiquidity(RemoveLiquidityParams memory params)
external
ensure(params.deadline)
returns (uint256 amount0, uint256 amount1)
{
PoolStatus memory status = statusManager.setBalances(msg.sender, params.poolId);
uint256 uPoolId = marginLiquidity.getPoolId(params.poolId);
{
(uint256 _reserve0, uint256 _reserve1) = status.getReserves();
(uint256 _totalSupply, uint256 retainSupply0, uint256 retainSupply1) = marginLiquidity.getSupplies(uPoolId);
params.liquidity = marginLiquidity.removeLiquidity(msg.sender, uPoolId, params.level, params.liquidity);
uint256 maxReserve0 = status.realReserve0;
uint256 maxReserve1 = status.realReserve1;
amount0 = Math.mulDiv(params.liquidity, _reserve0, _totalSupply);
amount1 = Math.mulDiv(params.liquidity, _reserve1, _totalSupply);
// currency0 enable margin,can claim interest1
if (params.level.zeroForMargin()) {
uint256 retainAmount1 = Math.mulDiv(retainSupply1, _reserve1, _totalSupply);
if (maxReserve1 > retainAmount1) {
maxReserve1 -= retainAmount1;
} else {
maxReserve1 = 0;
}
}
// currency1 enable margin,can claim interest0
if (params.level.oneForMargin()) {
uint256 retainAmount0 = Math.mulDiv(retainSupply0, _reserve0, _totalSupply);
if (maxReserve0 > retainAmount0) {
maxReserve0 -= retainAmount0;
} else {
maxReserve0 = 0;
}
}
require(amount0 <= maxReserve0 && amount1 <= maxReserve1, "NOT_ENOUGH_RESERVE");
if (amount0 == 0 || amount1 == 0) revert InsufficientLiquidityBurnt();
if (
params.amount0Min > 0 && amount0 < params.amount0Min
|| params.amount1Min > 0 && amount1 < params.amount1Min
) {
revert InsufficientOutputReceived();
}
}
poolManager.unlock(abi.encodeCall(this.handleRemoveLiquidity, (msg.sender, status.key, amount0, amount1)));
statusManager.update(params.poolId);
emit Burn(params.poolId, msg.sender, params.liquidity, amount0, amount1, params.level);
}
function handleRemoveLiquidity(address sender, PoolKey calldata key, uint256 amount0, uint256 amount1)
external
selfOnly
{
// burn 6909s
poolManager.burn(address(this), key.currency0.toId(), amount0);
poolManager.burn(address(this), key.currency1.toId(), amount1);
// transfer token to liquidity from address
key.currency0.take(poolManager, sender, amount0, false);
key.currency1.take(poolManager, sender, amount1, false);
}
// ******************** OWNER CALL ********************
function setHooks(IHooks _hooks) external onlyOwner {
if (address(hooks) != address(0)) revert HookAlreadySet();
hooks = _hooks;
}
function setStatusManager(IPoolStatusManager _poolStatusManager) external onlyOwner {
if (address(statusManager) != address(0)) revert StatusManagerAlreadySet();
statusManager = _poolStatusManager;
}
function addPositionManager(address _marginPositionManager) external onlyOwner {
positionManagers[_marginPositionManager] = true;
}
function removePositionManager(address _marginPositionManager) external onlyOwner {
delete positionManagers[_marginPositionManager];
}
// ******************** MARGIN FUNCTIONS ********************
function setBalances(address sender, PoolId poolId) external onlyPosition returns (PoolStatus memory _status) {
_status = statusManager.setBalances(sender, poolId);
}
function margin(address sender, PoolStatus memory status, MarginParamsVo memory paramsVo)
external
payable
onlyPosition
returns (MarginParamsVo memory)
{
bytes memory result =
poolManager.unlock(abi.encodeCall(this.handleMargin, (msg.sender, sender, status, paramsVo)));
(paramsVo.params.marginAmount, paramsVo.marginTotal, paramsVo.params.borrowAmount) =
abi.decode(result, (uint256, uint256, uint256));
return paramsVo;
}
function handleMargin(
address _positionManager,
address sender,
PoolStatus memory status,
MarginParamsVo calldata paramsVo
) external selfOnly returns (uint256 marginAmount, uint256 marginWithoutFee, uint256 borrowAmount) {
MarginParams memory params = paramsVo.params;
(Currency borrowCurrency, Currency marginCurrency) = params.marginForOne
? (status.key.currency0, status.key.currency1)
: (status.key.currency1, status.key.currency0);
uint256 marginFeeAmount;
// transfer marginAmount to lendingPoolManager
marginCurrency.settle(poolManager, sender, params.marginAmount, false);
marginCurrency.take(poolManager, address(this), params.marginAmount, true);
if (params.leverage > 0) {
(uint256 marginReserve0, uint256 marginReserve1, uint256 incrementMaxMirror0, uint256 incrementMaxMirror1) =
marginLiquidity.getMarginReserves(address(this), params.poolId, status);
uint256 marginReserves = params.marginForOne ? marginReserve1 : marginReserve0;
uint256 incrementMaxMirror = params.marginForOne ? incrementMaxMirror0 : incrementMaxMirror1;
uint256 marginTotal = params.marginAmount * params.leverage;
require(marginReserves >= marginTotal, "MARGIN_NOT_ENOUGH");
(borrowAmount,,) = statusManager.getAmountIn(status, params.marginForOne, marginTotal);
require(incrementMaxMirror >= borrowAmount, "MIRROR_TOO_MUCH");
uint24 _marginFeeRate = status.marginFee == 0 ? statusManager.marginFees().marginFee() : status.marginFee;
(marginWithoutFee, marginFeeAmount) = _marginFeeRate.deduct(marginTotal);
// transfer marginTotal to lendingPoolManager
marginWithoutFee =
lendingPoolManager.realIn(sender, _positionManager, params.poolId, marginCurrency, marginWithoutFee);
} else {
{
uint256 borrowMaxAmount = status.getAmountOut(!params.marginForOne, params.marginAmount);
uint256 flowMaxAmount = (params.marginForOne ? status.realReserve0 : status.realReserve1) * 20 / 100;
borrowMaxAmount = borrowMaxAmount.mulMillionDiv(paramsVo.minMarginLevel);
borrowMaxAmount = Math.min(borrowMaxAmount, flowMaxAmount);
if (params.borrowAmount > 0) {
borrowAmount = Math.min(borrowMaxAmount, params.borrowAmount);
} else {
borrowAmount = borrowMaxAmount;
}
(uint256 flowReserve0, uint256 flowReserve1) =
marginLiquidity.getFlowReserves(address(this), params.poolId, status);
uint256 borrowReserves = (params.marginForOne ? flowReserve0 : flowReserve1);
require(borrowReserves >= borrowAmount, "MIRROR_TOO_MUCH");
}
if (borrowAmount > 0) {
// transfer borrowAmount to user
borrowCurrency.settle(poolManager, address(this), borrowAmount, true);
borrowCurrency.take(poolManager, sender, borrowAmount, false);
}
marginWithoutFee = 0;
}
if (marginFeeAmount > 0) {
uint256 feeAmount = statusManager.updateMarginProtocolFees(marginCurrency, marginFeeAmount);
emit Fees(params.poolId, marginCurrency, sender, uint8(FeeType.MARGIN), feeAmount);
}
marginAmount =
lendingPoolManager.realIn(sender, _positionManager, params.poolId, marginCurrency, params.marginAmount);
// mint mirror token
mirrorTokenManager.mint(borrowCurrency.toTokenId(params.poolId), borrowAmount);
(uint256 mirrorBalance0, uint256 mirrorBalance1) = borrowCurrency == status.key.currency0
? (borrowAmount + status.mirrorReserve0, uint256(status.mirrorReserve1))
: (uint256(status.mirrorReserve0), borrowAmount + status.mirrorReserve1);
if (mirrorBalance0 > 0) {
lendingPoolManager.mirrorInRealOut(params.poolId, status, status.key.currency0, mirrorBalance0);
}
if (mirrorBalance1 > 0) {
lendingPoolManager.mirrorInRealOut(params.poolId, status, status.key.currency1, mirrorBalance1);
}
statusManager.update(params.poolId);
}
function _releaseToPool(
ReleaseParams calldata params,
PoolStatus memory status,
Currency borrowCurrency,
uint256 repayAmount
) internal {
uint256 borrowTokenId = borrowCurrency.toTokenId(params.poolId);
// burn mirror token
(uint256 pairAmount, uint256 lendingAmount) =
mirrorTokenManager.burn(address(lendingPoolManager), borrowTokenId, params.debtAmount);
uint256 burnAmount = pairAmount + lendingAmount;
int256 diff = repayAmount.toInt256() - params.debtAmount.toInt256();
if (diff != 0) {
int256 interest0;
int256 interest1;
int256 lendingInterest;
uint256 diffUint = diff > 0 ? uint256(diff) : uint256(-diff);
(uint256 interestReserve0, uint256 interestReserve1) =
marginLiquidity.getInterestReserves(address(this), params.poolId, status);
uint256 pairReserve = params.marginForOne ? interestReserve0 : interestReserve1;
uint256 lendingReserve = params.marginForOne ? status.lendingReserve0() : status.lendingReserve1();
uint256 lendingDiff = Math.mulDiv(diffUint, lendingReserve, pairReserve + lendingReserve);
uint256 pairDiff = diffUint - lendingDiff;
if (diff > 0) {
if (params.marginForOne) {
interest0 = pairDiff.toInt256();
} else {
interest1 = pairDiff.toInt256();
}
lendingInterest = lendingDiff.toInt256();
} else {
if (params.marginForOne) {
interest0 = -(pairDiff.toInt256());
} else {
interest1 = -(pairDiff.toInt256());
}
lendingInterest = -(lendingDiff.toInt256());
}
if (interest0 != 0 || interest1 != 0) {
marginLiquidity.changeLiquidity(
params.poolId, status.reserve0(), status.reserve1(), interest0, interest1
);
}
if (lendingInterest != 0) {
lendingPoolManager.updateInterests(borrowTokenId, lendingInterest);
lendingInterest += lendingAmount.toInt256();
if (lendingInterest > 0) {
poolManager.transfer(address(lendingPoolManager), borrowCurrency.toId(), uint256(lendingInterest));
} else {
uint256 moveAmount = uint256(-lendingInterest);
if (moveAmount > 0) {
moveAmount = Math.min(moveAmount, lendingReserve);
uint256 lendingRealReserve =
params.marginForOne ? status.lendingRealReserve0 : status.lendingRealReserve1;
if (lendingRealReserve >= moveAmount) {
poolManager.transferFrom(
address(lendingPoolManager), address(this), borrowCurrency.toId(), moveAmount
);
moveAmount = 0;
} else {
poolManager.transferFrom(
address(lendingPoolManager), address(this), borrowCurrency.toId(), lendingRealReserve
);
moveAmount -= lendingRealReserve;
}
if (moveAmount > 0) {
mirrorTokenManager.transferFrom(
address(lendingPoolManager),
address(this),
borrowCurrency.toTokenId(status.key),
moveAmount
);
}
}
}
}
} else {
poolManager.transfer(address(lendingPoolManager), borrowCurrency.toId(), lendingAmount);
}
emit Release(params.poolId, borrowCurrency, params.debtAmount, repayAmount, burnAmount, params.rawBorrowAmount);
}
function release(address sender, PoolStatus memory status, ReleaseParams memory params)
external
payable
onlyPosition
returns (uint256)
{
bytes memory result = poolManager.unlock(abi.encodeCall(this.handleRelease, (sender, status, params)));
return abi.decode(result, (uint256));
}
function handleRelease(address sender, PoolStatus memory status, ReleaseParams calldata params)
external
selfOnly
returns (uint256)
{
(Currency borrowCurrency, Currency marginCurrency) = params.marginForOne
? (status.key.currency0, status.key.currency1)
: (status.key.currency1, status.key.currency0);
// take repayAmount borrowCurrency from the pool
uint256 repayAmount = params.repayAmount;
if (params.releaseAmount > 0) {
if (repayAmount == 0) {
// when liquidated
repayAmount = status.getAmountOut(!params.marginForOne, params.releaseAmount);
}
// release margin
lendingPoolManager.reserveOut(
sender, params.payer, params.poolId, status, marginCurrency, params.releaseAmount + 1
);
} else if (repayAmount > 0) {
// repay borrow
borrowCurrency.settle(poolManager, params.payer, repayAmount, false);
borrowCurrency.take(poolManager, address(this), repayAmount, true);
}
_releaseToPool(params, status, borrowCurrency, repayAmount);
statusManager.update(params.poolId);
return repayAmount;
}
// ******************** EXTERNAL FUNCTIONS ********************
function mirrorInRealOut(PoolId poolId, PoolStatus memory status, Currency currency, uint256 amount)
external
onlyLendingPool
returns (bool success)
{
uint256 id = currency.toId();
uint256 balance = poolManager.balanceOf(address(this), id);
if (balance > amount) {
(,, uint256 incrementMaxMirror0, uint256 incrementMaxMirror1) =
marginLiquidity.getMarginReserves(address(this), poolId, status);
uint256 incrementMaxMirror = status.key.currency0 == currency ? incrementMaxMirror0 : incrementMaxMirror1;
if (incrementMaxMirror >= amount) {
poolManager.transfer(msg.sender, id, amount);
mirrorTokenManager.transferFrom(msg.sender, address(this), currency.toTokenId(poolId), amount);
success = true;
}
}
}
function swapMirror(address recipient, PoolId poolId, bool zeroForOne, uint256 amountIn, uint256 amountOutMin)
external
payable
returns (uint256 amountOut)
{
address sender = msg.sender;
PoolStatus memory status = statusManager.setBalances(sender, poolId);
uint256 feeAmount;
(amountOut,, feeAmount) = statusManager.getAmountOut(status, zeroForOne, amountIn);
uint256 mirrorOut = zeroForOne ? status.mirrorReserve1 : status.mirrorReserve0;
require(amountOut <= mirrorOut, "NOT_ENOUGH_RESERVE");
if (amountOutMin > 0 && amountOut < amountOutMin) revert InsufficientOutputReceived();
(Currency inputCurrency, Currency outputCurrency) =
zeroForOne ? (status.key.currency0, status.key.currency1) : (status.key.currency1, status.key.currency0);
uint256 sendValue = inputCurrency.checkAmount(amountIn);
if (sendValue > 0) {
amountIn = sendValue;
if (msg.value > sendValue) {
transferNative(sender, msg.value - sendValue);
}
}
poolManager.unlock(abi.encodeCall(this.handleSwapMirror, (sender, inputCurrency, amountIn)));
lendingPoolManager.mirrorIn(sender, recipient, poolId, outputCurrency, amountOut);
if (feeAmount > 0) {
feeAmount = statusManager.updateSwapProtocolFees(inputCurrency, feeAmount);
emit Fees(poolId, inputCurrency, sender, uint8(FeeType.SWAP), feeAmount);
}
statusManager.update(poolId);
}
function handleSwapMirror(address sender, Currency currency, uint256 amount) external selfOnly {
currency.settle(poolManager, sender, amount, false);
currency.take(poolManager, address(this), amount, true);
}
/// @inheritdoc IPairPoolManager
function collectProtocolFees(address recipient, Currency currency, uint256 amount)
external
onlyFees
returns (uint256)
{
bytes memory result = poolManager.unlock(abi.encodeCall(this.handleCollectFees, (recipient, currency, amount)));
return abi.decode(result, (uint256));
}
function handleCollectFees(address recipient, Currency currency, uint256 amount)
external
selfOnly
returns (uint256 amountCollected)
{
amountCollected = statusManager.collectProtocolFees(currency, amount);
currency.settle(poolManager, address(this), amountCollected, true);
currency.take(poolManager, recipient, amountCollected, false);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return 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.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev 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 {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 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 prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, 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 {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
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^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// 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^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice 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) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @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 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @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: MIT
pragma solidity ^0.8.0;
import {Currency} from "./Currency.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {PoolIdLibrary} from "./PoolId.sol";
using PoolIdLibrary for PoolKey global;
/// @notice Returns the key for identifying a pool
struct PoolKey {
/// @notice The lower currency of the pool, sorted numerically
Currency currency0;
/// @notice The higher currency of the pool, sorted numerically
Currency currency1;
/// @notice The pool LP fee, capped at 1_000_000. If the highest bit is 1, the pool has a dynamic fee and must be exactly equal to 0x800000
uint24 fee;
/// @notice Ticks that involve positions must be a multiple of tick spacing
int24 tickSpacing;
/// @notice The hooks of the pool
IHooks hooks;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "./PoolKey.sol";
type PoolId is bytes32;
/// @notice Library for computing the ID of a pool
library PoolIdLibrary {
/// @notice Returns value equal to keccak256(abi.encode(poolKey))
function toId(PoolKey memory poolKey) internal pure returns (PoolId poolId) {
assembly ("memory-safe") {
// 0xa0 represents the total size of the poolKey struct (5 slots of 32 bytes)
poolId := keccak256(poolKey, 0xa0)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20Minimal} from "../interfaces/external/IERC20Minimal.sol";
import {CustomRevert} from "../libraries/CustomRevert.sol";
type Currency is address;
using {greaterThan as >, lessThan as <, greaterThanOrEqualTo as >=, equals as ==} for Currency global;
using CurrencyLibrary for Currency global;
function equals(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) == Currency.unwrap(other);
}
function greaterThan(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) > Currency.unwrap(other);
}
function lessThan(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) < Currency.unwrap(other);
}
function greaterThanOrEqualTo(Currency currency, Currency other) pure returns (bool) {
return Currency.unwrap(currency) >= Currency.unwrap(other);
}
/// @title CurrencyLibrary
/// @dev This library allows for transferring and holding native tokens and ERC20 tokens
library CurrencyLibrary {
/// @notice Additional context for ERC-7751 wrapped error when a native transfer fails
error NativeTransferFailed();
/// @notice Additional context for ERC-7751 wrapped error when an ERC20 transfer fails
error ERC20TransferFailed();
/// @notice A constant to represent the native currency
Currency public constant ADDRESS_ZERO = Currency.wrap(address(0));
function transfer(Currency currency, address to, uint256 amount) internal {
// altered from https://github.com/transmissions11/solmate/blob/44a9963d4c78111f77caa0e65d677b8b46d6f2e6/src/utils/SafeTransferLib.sol
// modified custom error selectors
bool success;
if (currency.isAddressZero()) {
assembly ("memory-safe") {
// Transfer the ETH and revert if it fails.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
// revert with NativeTransferFailed, containing the bubbled up error as an argument
if (!success) {
CustomRevert.bubbleUpAndRevertWith(to, bytes4(0), NativeTransferFailed.selector);
}
} else {
assembly ("memory-safe") {
// Get a pointer to some free memory.
let fmp := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(fmp, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(fmp, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.
success :=
and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), currency, 0, fmp, 68, 0, 32)
)
// Now clean the memory we used
mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
}
// revert with ERC20TransferFailed, containing the bubbled up error as an argument
if (!success) {
CustomRevert.bubbleUpAndRevertWith(
Currency.unwrap(currency), IERC20Minimal.transfer.selector, ERC20TransferFailed.selector
);
}
}
}
function balanceOfSelf(Currency currency) internal view returns (uint256) {
if (currency.isAddressZero()) {
return address(this).balance;
} else {
return IERC20Minimal(Currency.unwrap(currency)).balanceOf(address(this));
}
}
function balanceOf(Currency currency, address owner) internal view returns (uint256) {
if (currency.isAddressZero()) {
return owner.balance;
} else {
return IERC20Minimal(Currency.unwrap(currency)).balanceOf(owner);
}
}
function isAddressZero(Currency currency) internal pure returns (bool) {
return Currency.unwrap(currency) == Currency.unwrap(ADDRESS_ZERO);
}
function toId(Currency currency) internal pure returns (uint256) {
return uint160(Currency.unwrap(currency));
}
// If the upper 12 bytes are non-zero, they will be zero-ed out
// Therefore, fromId() and toId() are not inverses of each other
function fromId(uint256 id) internal pure returns (Currency) {
return Currency.wrap(address(uint160(id)));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Currency} from "../types/Currency.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "./IHooks.sol";
import {IERC6909Claims} from "./external/IERC6909Claims.sol";
import {IProtocolFees} from "./IProtocolFees.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {PoolId} from "../types/PoolId.sol";
import {IExtsload} from "./IExtsload.sol";
import {IExttload} from "./IExttload.sol";
/// @notice Interface for the PoolManager
interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload {
/// @notice Thrown when a currency is not netted out after the contract is unlocked
error CurrencyNotSettled();
/// @notice Thrown when trying to interact with a non-initialized pool
error PoolNotInitialized();
/// @notice Thrown when unlock is called, but the contract is already unlocked
error AlreadyUnlocked();
/// @notice Thrown when a function is called that requires the contract to be unlocked, but it is not
error ManagerLocked();
/// @notice Pools are limited to type(int16).max tickSpacing in #initialize, to prevent overflow
error TickSpacingTooLarge(int24 tickSpacing);
/// @notice Pools must have a positive non-zero tickSpacing passed to #initialize
error TickSpacingTooSmall(int24 tickSpacing);
/// @notice PoolKey must have currencies where address(currency0) < address(currency1)
error CurrenciesOutOfOrderOrEqual(address currency0, address currency1);
/// @notice Thrown when a call to updateDynamicLPFee is made by an address that is not the hook,
/// or on a pool that does not have a dynamic swap fee.
error UnauthorizedDynamicLPFeeUpdate();
/// @notice Thrown when trying to swap amount of 0
error SwapAmountCannotBeZero();
///@notice Thrown when native currency is passed to a non native settlement
error NonzeroNativeValue();
/// @notice Thrown when `clear` is called with an amount that is not exactly equal to the open currency delta.
error MustClearExactPositiveDelta();
/// @notice Emitted when a new pool is initialized
/// @param id The abi encoded hash of the pool key struct for the new pool
/// @param currency0 The first currency of the pool by address sort order
/// @param currency1 The second currency of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param hooks The hooks contract address for the pool, or address(0) if none
/// @param sqrtPriceX96 The price of the pool on initialization
/// @param tick The initial tick of the pool corresponding to the initialized price
event Initialize(
PoolId indexed id,
Currency indexed currency0,
Currency indexed currency1,
uint24 fee,
int24 tickSpacing,
IHooks hooks,
uint160 sqrtPriceX96,
int24 tick
);
/// @notice Emitted when a liquidity position is modified
/// @param id The abi encoded hash of the pool key struct for the pool that was modified
/// @param sender The address that modified the pool
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param liquidityDelta The amount of liquidity that was added or removed
/// @param salt The extra data to make positions unique
event ModifyLiquidity(
PoolId indexed id, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt
);
/// @notice Emitted for swaps between currency0 and currency1
/// @param id The abi encoded hash of the pool key struct for the pool that was modified
/// @param sender The address that initiated the swap call, and that received the callback
/// @param amount0 The delta of the currency0 balance of the pool
/// @param amount1 The delta of the currency1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of the price of the pool after the swap
/// @param fee The swap fee in hundredths of a bip
event Swap(
PoolId indexed id,
address indexed sender,
int128 amount0,
int128 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick,
uint24 fee
);
/// @notice Emitted for donations
/// @param id The abi encoded hash of the pool key struct for the pool that was donated to
/// @param sender The address that initiated the donate call
/// @param amount0 The amount donated in currency0
/// @param amount1 The amount donated in currency1
event Donate(PoolId indexed id, address indexed sender, uint256 amount0, uint256 amount1);
/// @notice All interactions on the contract that account deltas require unlocking. A caller that calls `unlock` must implement
/// `IUnlockCallback(msg.sender).unlockCallback(data)`, where they interact with the remaining functions on this contract.
/// @dev The only functions callable without an unlocking are `initialize` and `updateDynamicLPFee`
/// @param data Any data to pass to the callback, via `IUnlockCallback(msg.sender).unlockCallback(data)`
/// @return The data returned by the call to `IUnlockCallback(msg.sender).unlockCallback(data)`
function unlock(bytes calldata data) external returns (bytes memory);
/// @notice Initialize the state for a given pool ID
/// @dev A swap fee totaling MAX_SWAP_FEE (100%) makes exact output swaps impossible since the input is entirely consumed by the fee
/// @param key The pool key for the pool to initialize
/// @param sqrtPriceX96 The initial square root price
/// @return tick The initial tick of the pool
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external returns (int24 tick);
struct ModifyLiquidityParams {
// the lower and upper tick of the position
int24 tickLower;
int24 tickUpper;
// how to modify the liquidity
int256 liquidityDelta;
// a value to set if you want unique liquidity positions at the same range
bytes32 salt;
}
/// @notice Modify the liquidity for the given pool
/// @dev Poke by calling with a zero liquidityDelta
/// @param key The pool to modify liquidity in
/// @param params The parameters for modifying the liquidity
/// @param hookData The data to pass through to the add/removeLiquidity hooks
/// @return callerDelta The balance delta of the caller of modifyLiquidity. This is the total of both principal, fee deltas, and hook deltas if applicable
/// @return feesAccrued The balance delta of the fees generated in the liquidity range. Returned for informational purposes
function modifyLiquidity(PoolKey memory key, ModifyLiquidityParams memory params, bytes calldata hookData)
external
returns (BalanceDelta callerDelta, BalanceDelta feesAccrued);
struct SwapParams {
/// Whether to swap token0 for token1 or vice versa
bool zeroForOne;
/// The desired input amount if negative (exactIn), or the desired output amount if positive (exactOut)
int256 amountSpecified;
/// The sqrt price at which, if reached, the swap will stop executing
uint160 sqrtPriceLimitX96;
}
/// @notice Swap against the given pool
/// @param key The pool to swap in
/// @param params The parameters for swapping
/// @param hookData The data to pass through to the swap hooks
/// @return swapDelta The balance delta of the address swapping
/// @dev Swapping on low liquidity pools may cause unexpected swap amounts when liquidity available is less than amountSpecified.
/// Additionally note that if interacting with hooks that have the BEFORE_SWAP_RETURNS_DELTA_FLAG or AFTER_SWAP_RETURNS_DELTA_FLAG
/// the hook may alter the swap input/output. Integrators should perform checks on the returned swapDelta.
function swap(PoolKey memory key, SwapParams memory params, bytes calldata hookData)
external
returns (BalanceDelta swapDelta);
/// @notice Donate the given currency amounts to the in-range liquidity providers of a pool
/// @dev Calls to donate can be frontrun adding just-in-time liquidity, with the aim of receiving a portion donated funds.
/// Donors should keep this in mind when designing donation mechanisms.
/// @dev This function donates to in-range LPs at slot0.tick. In certain edge-cases of the swap algorithm, the `sqrtPrice` of
/// a pool can be at the lower boundary of tick `n`, but the `slot0.tick` of the pool is already `n - 1`. In this case a call to
/// `donate` would donate to tick `n - 1` (slot0.tick) not tick `n` (getTickAtSqrtPrice(slot0.sqrtPriceX96)).
/// Read the comments in `Pool.swap()` for more information about this.
/// @param key The key of the pool to donate to
/// @param amount0 The amount of currency0 to donate
/// @param amount1 The amount of currency1 to donate
/// @param hookData The data to pass through to the donate hooks
/// @return BalanceDelta The delta of the caller after the donate
function donate(PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
external
returns (BalanceDelta);
/// @notice Writes the current ERC20 balance of the specified currency to transient storage
/// This is used to checkpoint balances for the manager and derive deltas for the caller.
/// @dev This MUST be called before any ERC20 tokens are sent into the contract, but can be skipped
/// for native tokens because the amount to settle is determined by the sent value.
/// However, if an ERC20 token has been synced and not settled, and the caller instead wants to settle
/// native funds, this function can be called with the native currency to then be able to settle the native currency
function sync(Currency currency) external;
/// @notice Called by the user to net out some value owed to the user
/// @dev Will revert if the requested amount is not available, consider using `mint` instead
/// @dev Can also be used as a mechanism for free flash loans
/// @param currency The currency to withdraw from the pool manager
/// @param to The address to withdraw to
/// @param amount The amount of currency to withdraw
function take(Currency currency, address to, uint256 amount) external;
/// @notice Called by the user to pay what is owed
/// @return paid The amount of currency settled
function settle() external payable returns (uint256 paid);
/// @notice Called by the user to pay on behalf of another address
/// @param recipient The address to credit for the payment
/// @return paid The amount of currency settled
function settleFor(address recipient) external payable returns (uint256 paid);
/// @notice WARNING - Any currency that is cleared, will be non-retrievable, and locked in the contract permanently.
/// A call to clear will zero out a positive balance WITHOUT a corresponding transfer.
/// @dev This could be used to clear a balance that is considered dust.
/// Additionally, the amount must be the exact positive balance. This is to enforce that the caller is aware of the amount being cleared.
function clear(Currency currency, uint256 amount) external;
/// @notice Called by the user to move value into ERC6909 balance
/// @param to The address to mint the tokens to
/// @param id The currency address to mint to ERC6909s, as a uint256
/// @param amount The amount of currency to mint
/// @dev The id is converted to a uint160 to correspond to a currency address
/// If the upper 12 bytes are not 0, they will be 0-ed out
function mint(address to, uint256 id, uint256 amount) external;
/// @notice Called by the user to move value from ERC6909 balance
/// @param from The address to burn the tokens from
/// @param id The currency address to burn from ERC6909s, as a uint256
/// @param amount The amount of currency to burn
/// @dev The id is converted to a uint160 to correspond to a currency address
/// If the upper 12 bytes are not 0, they will be 0-ed out
function burn(address from, uint256 id, uint256 amount) external;
/// @notice Updates the pools lp fees for the a pool that has enabled dynamic lp fees.
/// @dev A swap fee totaling MAX_SWAP_FEE (100%) makes exact output swaps impossible since the input is entirely consumed by the fee
/// @param key The key of the pool to update dynamic LP fees for
/// @param newDynamicLPFee The new dynamic pool LP fee
function updateDynamicLPFee(PoolKey memory key, uint24 newDynamicLPFee) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {CustomRevert} from "./CustomRevert.sol";
/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
using CustomRevert for bytes4;
error SafeCastOverflow();
/// @notice Cast a uint256 to a uint160, revert on overflow
/// @param x The uint256 to be downcasted
/// @return y The downcasted integer, now type uint160
function toUint160(uint256 x) internal pure returns (uint160 y) {
y = uint160(x);
if (y != x) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a uint128, revert on overflow
/// @param x The uint256 to be downcasted
/// @return y The downcasted integer, now type uint128
function toUint128(uint256 x) internal pure returns (uint128 y) {
y = uint128(x);
if (x != y) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a int128 to a uint128, revert on overflow or underflow
/// @param x The int128 to be casted
/// @return y The casted integer, now type uint128
function toUint128(int128 x) internal pure returns (uint128 y) {
if (x < 0) SafeCastOverflow.selector.revertWith();
y = uint128(x);
}
/// @notice Cast a int256 to a int128, revert on overflow or underflow
/// @param x The int256 to be downcasted
/// @return y The downcasted integer, now type int128
function toInt128(int256 x) internal pure returns (int128 y) {
y = int128(x);
if (y != x) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a int256, revert on overflow
/// @param x The uint256 to be casted
/// @return y The casted integer, now type int256
function toInt256(uint256 x) internal pure returns (int256 y) {
y = int256(x);
if (y < 0) SafeCastOverflow.selector.revertWith();
}
/// @notice Cast a uint256 to a int128, revert on overflow
/// @param x The uint256 to be downcasted
/// @return The downcasted integer, now type int128
function toInt128(uint256 x) internal pure returns (int128) {
if (x >= 1 << 127) SafeCastOverflow.selector.revertWith();
return int128(int256(x));
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Simple single owner authorization mixin.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol)
abstract contract Owned {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OwnershipTransferred(address indexed user, address indexed newOwner);
/*//////////////////////////////////////////////////////////////
OWNERSHIP STORAGE
//////////////////////////////////////////////////////////////*/
address public owner;
modifier onlyOwner() virtual {
require(msg.sender == owner, "UNAUTHORIZED");
_;
}
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(address _owner) {
owner = _owner;
emit OwnershipTransferred(address(0), _owner);
}
/*//////////////////////////////////////////////////////////////
OWNERSHIP LOGIC
//////////////////////////////////////////////////////////////*/
function transferOwnership(address newOwner) public virtual onlyOwner {
owner = newOwner;
emit OwnershipTransferred(msg.sender, newOwner);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {PoolId} from "v4-core/types/PoolId.sol";
import {Currency, CurrencyLibrary} from "v4-core/types/Currency.sol";
abstract contract BaseFees {
event Fees(PoolId indexed poolId, Currency indexed currency, address indexed sender, uint8 feeType, uint256 fee);
enum FeeType {
SWAP,
MARGIN,
INTERESTS
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
// V4 core
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {SafeCallback} from "v4-periphery/src/base/SafeCallback.sol";
// Solmate
import {Owned} from "solmate/src/auth/Owned.sol";
abstract contract BasePoolManager is SafeCallback, Owned {
error NotSelf();
error LockFailure();
/// @dev Only this address may call this function
modifier selfOnly() {
if (msg.sender != address(this)) revert NotSelf();
_;
}
function transferNative(address to, uint256 amount) internal {
(bool success,) = to.call{value: amount}("");
require(success, "TRANSFER_FAILED");
}
modifier ensure(uint256 deadline) {
require(deadline >= block.timestamp, "EXPIRED");
_;
}
constructor(address initialOwner, IPoolManager _poolManager) Owned(initialOwner) SafeCallback(_poolManager) {}
function _unlockCallback(bytes calldata data) internal virtual override returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).call(data);
if (success) return returnData;
if (returnData.length == 0) revert LockFailure();
// if the call failed, bubble up the reason
assembly ("memory-safe") {
revert(add(returnData, 32), mload(returnData))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {Currency} from "v4-core/types/Currency.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {UQ112x112} from "../libraries/UQ112x112.sol";
import {FeeLibrary} from "../libraries/FeeLibrary.sol";
/// @notice Returns the status of a hook.
struct PoolStatus {
/// @notice The block timestamp of the last update of the pool.
uint32 blockTimestampLast;
/// @notice The real reserve of the first currency in the pool.(x)
uint112 realReserve0;
/// @notice The real reserve of the second currency in the pool.(y)
uint112 realReserve1;
/// @notice The mirror reserve of the first currency in the pool.(x')
uint112 mirrorReserve0;
/// @notice The mirror reserve of the second currency in the pool.(y')
uint112 mirrorReserve1;
/// @notice The margin fee of the pool.
uint24 marginFee;
/// @notice The real reserve of the first currency in the lending pool.
uint112 lendingRealReserve0;
/// @notice The real reserve of the second currency in the lending pool.
uint112 lendingRealReserve1;
/// @notice The mirror reserve of the first currency in the lending pool.
uint112 lendingMirrorReserve0;
/// @notice The mirror reserve of the second currency in the lending pool.
uint112 lendingMirrorReserve1;
/// @notice The truncated reserve of the first currency in the lending pool.
uint112 truncatedReserve0;
/// @notice The truncated reserve of the second currency in the lending pool.
uint112 truncatedReserve1;
/// @notice The cumulative borrow rate of the first currency in the pool.
uint256 rate0CumulativeLast;
/// @notice The cumulative borrow rate of the second currency in the pool.
uint256 rate1CumulativeLast;
/// @notice The the key for identifying a pool
PoolKey key;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {Currency} from "v4-core/types/Currency.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {UQ112x112} from "../libraries/UQ112x112.sol";
import {PerLibrary} from "../libraries/PerLibrary.sol";
import {FeeLibrary} from "../libraries/FeeLibrary.sol";
import {PoolStatus} from "./PoolStatus.sol";
library PoolStatusLibrary {
using UQ112x112 for *;
using FeeLibrary for uint24;
function reserve0(PoolStatus memory status) internal pure returns (uint112) {
return status.realReserve0 + status.mirrorReserve0;
}
function reserve1(PoolStatus memory status) internal pure returns (uint112) {
return status.realReserve1 + status.mirrorReserve1;
}
function lendingReserve0(PoolStatus memory status) internal pure returns (uint112) {
return status.lendingRealReserve0 + status.lendingMirrorReserve0;
}
function lendingReserve1(PoolStatus memory status) internal pure returns (uint112) {
return status.lendingRealReserve1 + status.lendingMirrorReserve1;
}
function totalRealReserve0(PoolStatus memory status) internal pure returns (uint112) {
return status.realReserve0 + status.lendingRealReserve0;
}
function totalRealReserve1(PoolStatus memory status) internal pure returns (uint112) {
return status.realReserve1 + status.lendingRealReserve1;
}
function totalMirrorReserve0(PoolStatus memory status) internal pure returns (uint112) {
return status.mirrorReserve0 + status.lendingMirrorReserve0;
}
function totalMirrorReserve1(PoolStatus memory status) internal pure returns (uint112) {
return status.mirrorReserve1 + status.lendingMirrorReserve1;
}
function totalMirrorReserves(PoolStatus memory status) internal pure returns (uint112) {
return totalMirrorReserve0(status) + totalMirrorReserve1(status);
}
function getReserves(PoolStatus memory status) internal pure returns (uint256 _reserve0, uint256 _reserve1) {
_reserve0 = reserve0(status);
_reserve1 = reserve1(status);
}
function getPrice0X112(PoolStatus memory status) internal pure returns (uint224) {
return reserve1(status).encode().div(reserve0(status));
}
function getPrice1X112(PoolStatus memory status) internal pure returns (uint224) {
return reserve0(status).encode().div(reserve1(status));
}
function computeLiquidity(
PoolStatus memory status,
uint256 totalSupply,
uint256 amount0,
uint256 amount1,
uint256 amount0Min,
uint256 amount1Min
) internal pure returns (uint256 liquidity, uint256 amount0In, uint256 amount1In) {
(uint256 _reserve0, uint256 _reserve1) = getReserves(status);
if (_reserve0 > 0 && _reserve1 > 0) {
uint256 amount1Exactly = Math.mulDiv(amount0, _reserve1, _reserve0);
if (amount1Exactly <= amount1) {
require(amount1Exactly >= amount1Min, "INSUFFICIENT_AMOUNT1");
amount1In = amount1Exactly;
amount0In = amount0;
} else {
uint256 amount0Exactly = Math.mulDiv(amount1, _reserve0, _reserve1);
require(amount0Exactly >= amount0Min && amount0 >= amount0Exactly, "INSUFFICIENT_AMOUNT0");
amount0In = amount0Exactly;
amount1In = amount1;
}
liquidity =
Math.min(Math.mulDiv(amount0In, totalSupply, _reserve0), Math.mulDiv(amount1In, totalSupply, _reserve1));
} else {
liquidity = Math.sqrt(amount0 * amount1);
amount0In = amount0;
amount1In = amount1;
}
}
function getAmountOut(PoolStatus memory status, bool zeroForOne, uint256 amountIn)
internal
pure
returns (uint256 amountOut)
{
(uint256 reserveIn, uint256 reserveOut) =
zeroForOne ? (reserve0(status), reserve1(status)) : (reserve1(status), reserve0(status));
uint256 amountInWithoutFee = status.key.fee.deductFrom(amountIn);
uint256 numerator = amountInWithoutFee * reserveOut;
uint256 denominator = reserveIn + amountInWithoutFee;
amountOut = numerator / denominator;
}
function getAmountIn(PoolStatus memory status, bool zeroForOne, uint256 amountOut)
internal
pure
returns (uint256 amountIn)
{
(uint256 reserveIn, uint256 reserveOut) =
zeroForOne ? (reserve0(status), reserve1(status)) : (reserve1(status), reserve0(status));
uint256 numerator = reserveIn * amountOut;
uint256 denominator = (reserveOut - amountOut);
uint256 amountInWithoutFee = (numerator / denominator) + 1;
amountIn = status.key.fee.attachFrom(amountInWithoutFee);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Currency} from "v4-core/types/Currency.sol";
import {IERC20} from "../external/openzeppelin-contracts/IERC20.sol";
import {SafeERC20} from "../external/openzeppelin-contracts/SafeERC20.sol";
library CurrencyExtLibrary {
using SafeERC20 for IERC20;
error InsufficientValue();
function approve(Currency currency, address spender, uint256 amount) internal returns (bool success) {
if (!currency.isAddressZero()) {
IERC20 token = IERC20(Currency.unwrap(currency));
token.forceApprove(spender, amount);
}
success = true;
}
function checkAmount(Currency currency, uint256 amount) internal returns (uint256 sendValue) {
if (currency.isAddressZero()) {
if (msg.value < amount) revert InsufficientValue();
sendValue = amount;
}
}
function transfer(Currency currency, address payer, address recipient, uint256 amount)
internal
returns (bool success)
{
if (currency.isAddressZero()) {
(success,) = recipient.call{value: amount}("");
} else {
IERC20 token = IERC20(Currency.unwrap(currency));
if (payer != address(this)) {
token.safeTransferFrom(payer, recipient, amount);
} else {
token.safeTransfer(recipient, amount);
}
success = true;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Currency} from "v4-core/types/Currency.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "v4-core/types/PoolId.sol";
import {CurrencyExtLibrary} from "./CurrencyExtLibrary.sol";
import {IERC20} from "../external/openzeppelin-contracts/IERC20.sol";
import {SafeERC20} from "../external/openzeppelin-contracts/SafeERC20.sol";
library CurrencyPoolLibrary {
using PoolIdLibrary for PoolId;
using SafeERC20 for IERC20;
using CurrencyExtLibrary for Currency;
error InsufficientValue();
/// @notice Settle (pay) a currency to the PoolManager
/// @param currency Currency to settle
/// @param manager IPoolManager to settle to
/// @param payer Address of the payer, the token sender
/// @param amount Amount to send
/// @param burn If true, burn the ERC-6909 token, otherwise ERC20-transfer to the PoolManager
function settle(Currency currency, IPoolManager manager, address payer, uint256 amount, bool burn) internal {
// for native currencies or burns, calling sync is not required
// short circuit for ERC-6909 burns to support ERC-6909-wrapped native tokens
if (burn) {
manager.burn(payer, currency.toId(), amount);
} else if (currency.isAddressZero()) {
manager.settle{value: amount}();
} else {
manager.sync(currency);
IERC20 token = IERC20(Currency.unwrap(currency));
if (payer != address(this)) {
token.safeTransferFrom(payer, address(manager), amount);
} else {
token.safeTransfer(address(manager), amount);
}
manager.settle();
}
}
/// @notice Take (receive) a currency from the PoolManager
/// @param currency Currency to take
/// @param manager IPoolManager to take from
/// @param recipient Address of the recipient, the token receiver
/// @param amount Amount to receive
/// @param claims If true, mint the ERC-6909 token, otherwise ERC20-transfer from the PoolManager to recipient
function take(Currency currency, IPoolManager manager, address recipient, uint256 amount, bool claims) internal {
claims ? manager.mint(recipient, currency.toId(), amount) : manager.take(currency, recipient, amount);
}
function toTokenId(Currency currency, PoolId poolId) internal pure returns (uint256) {
return uint256(keccak256(abi.encode(currency, poolId)));
}
function toTokenId(Currency currency, PoolKey memory key) internal pure returns (uint256) {
return toTokenId(currency, key.toId());
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
library UQ112x112 {
error Overflow();
uint224 constant Q112 = 2 ** 112;
/// @notice Cast a uint256 to a uint112, revert on overflow or underflow
/// @param x The uint256 to be casted
/// @return y The casted integer, now type uint112
function toUint112(uint256 x) internal pure returns (uint112 y) {
y = uint112(x);
if (x != y) revert Overflow();
}
/// @notice Cast a uint256 to a uint224, revert on overflow or underflow
/// @param x The uint256 to be casted
/// @return y The casted integer, now type uint224
function toUint224(uint256 x) internal pure returns (uint224 y) {
y = uint224(x);
if (x != y) revert Overflow();
}
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// decode UQ112x112 as a uint112
function decode(uint224 x) internal pure returns (uint112 z) {
z = uint112(x / Q112); // never overflows
}
function encode256(uint256 y) internal pure returns (uint256 z) {
z = y * Q112;
}
function decode256(uint256 x) internal pure returns (uint256 z) {
z = x / Q112;
}
function add(uint112 x, uint256 y) internal pure returns (uint112 z) {
z = x + toUint112(y);
}
// subtract
function sub(uint112 x, uint256 y) internal pure returns (uint112 z) {
z = x - toUint112(y);
}
function mul(uint112 x, uint256 y) internal pure returns (uint224 z) {
z = toUint224(x) * toUint224(y);
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function div(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / toUint224(y);
}
function scaleDown(uint112 x, uint256 scaler, uint256 denominator) internal pure returns (uint112 z) {
z = toUint112(Math.mulDiv(x, denominator - scaler, denominator));
}
function growRatioX112(uint256 ratio, uint256 numerator, uint256 denominator)
internal
pure
returns (uint256 result)
{
result = ratio;
if (numerator > 0 && denominator > 0) result += Math.mulDiv(Q112, numerator, denominator);
}
function reduceRatioX112(uint256 ratio, uint256 numerator, uint256 denominator)
internal
pure
returns (uint256 result)
{
result = ratio;
if (numerator > 0 && denominator > 0) {
uint256 cut = Math.mulDiv(Q112, numerator, denominator, Math.Rounding.Ceil);
if (result > cut) {
result -= cut;
} else {
result = 0;
}
}
}
function mulRatioX112(uint256 input, uint256 ratioX112) internal pure returns (uint256 result) {
result = Math.mulDiv(input, ratioX112, Q112);
}
function divRatioX112(uint256 input, uint256 ratioX112) internal pure returns (uint256 result) {
result = Math.mulDiv(input, Q112, ratioX112);
}
function increaseInterestCeil(uint128 current, uint256 rateCumulativeOld, uint256 rateCumulativeLast)
internal
pure
returns (uint128 result)
{
result = toUint112(Math.mulDiv(current, rateCumulativeLast, rateCumulativeOld, Math.Rounding.Ceil));
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
library TimeLibrary {
function getTimeElapsed(uint32 blockTimestampLast) internal view returns (uint256 timeElapsed) {
uint32 blockTS = uint32(block.timestamp % 2 ** 32);
if (blockTimestampLast <= blockTS) {
timeElapsed = uint256(blockTS - blockTimestampLast);
} else {
timeElapsed = uint256(2 ** 32 - blockTimestampLast + blockTS);
}
}
function getTimeElapsedMicrosecond(uint32 blockTimestampLast) internal view returns (uint256 timeElapsed) {
uint32 blockTS = uint32(block.timestamp % 2 ** 32);
if (blockTimestampLast <= blockTS) {
timeElapsed = uint256(blockTS - blockTimestampLast) * (10 ** 6);
} else {
timeElapsed = uint256(2 ** 32 - blockTimestampLast + blockTS) * (10 ** 6);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library LiquidityLevel {
uint256 constant LP_FLAG = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0;
uint8 constant RETAIN_BOTH = 1;
uint8 constant BORROW_TOKEN0 = 2;
uint8 constant BORROW_TOKEN1 = 3;
uint8 constant BORROW_BOTH = 4;
error LevelError();
function validate(uint8 level) internal pure returns (bool valid) {
valid = level >= RETAIN_BOTH && level <= BORROW_BOTH;
if (!valid) revert LevelError();
}
function zeroForMargin(uint8 level) internal pure returns (bool value) {
value = level == BORROW_TOKEN1 || level == BORROW_BOTH;
}
function oneForMargin(uint8 level) internal pure returns (bool value) {
value = level == BORROW_TOKEN0 || level == BORROW_BOTH;
}
function getPoolId(uint256 id) internal pure returns (uint256 poolId) {
poolId = id & LP_FLAG;
}
function getLevelId(uint8 level, uint256 id) internal pure returns (uint256 levelId) {
if (validate(level)) {
levelId = (id & LP_FLAG) + level;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
library PerLibrary {
uint256 public constant ONE_MILLION = 10 ** 6;
uint256 public constant ONE_TRILLION = 10 ** 12;
uint256 public constant TRILLION_YEAR_SECONDS = ONE_TRILLION * 365 * 24 * 3600;
function mulMillion(uint256 x) internal pure returns (uint256 y) {
y = x * ONE_MILLION;
}
function divMillion(uint256 x) internal pure returns (uint256 y) {
y = x / ONE_MILLION;
}
function mulMillionDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = Math.mulDiv(x, ONE_MILLION, y);
}
function mulDivMillion(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = Math.mulDiv(x, y, ONE_MILLION);
}
function upperMillion(uint256 x, uint256 per) internal pure returns (uint256 z) {
z = Math.mulDiv(x, ONE_MILLION + per, ONE_MILLION);
}
function lowerMillion(uint256 x, uint256 per) internal pure returns (uint256 z) {
if (per >= ONE_MILLION) {
return z;
}
z = Math.mulDiv(x, ONE_MILLION - per, ONE_MILLION);
}
function isWithinTolerance(uint256 a, uint256 b, uint256 t) internal pure returns (bool) {
return a >= b ? (a - b) <= t : (b - a) <= t;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {PerLibrary} from "./PerLibrary.sol";
library FeeLibrary {
function deductFrom(uint24 fee, uint256 amount) internal pure returns (uint256 amountWithoutFee) {
uint256 ratio = PerLibrary.ONE_MILLION - fee;
amountWithoutFee = Math.mulDiv(amount, ratio, PerLibrary.ONE_MILLION);
}
function deduct(uint24 fee, uint256 amount) internal pure returns (uint256 amountWithoutFee, uint256 feeAmount) {
amountWithoutFee = deductFrom(fee, amount);
feeAmount = amount - amountWithoutFee;
}
function attachFrom(uint24 fee, uint256 amount) internal pure returns (uint256 amountWithFee) {
uint256 ratio = PerLibrary.ONE_MILLION - fee;
amountWithFee = Math.mulDiv(amount, PerLibrary.ONE_MILLION, ratio);
}
function attach(uint24 fee, uint256 amount) internal pure returns (uint256 amountWithFee, uint256 feeAmount) {
amountWithFee = attachFrom(fee, amount);
feeAmount = amountWithFee - amount;
}
function part(uint24 fee, uint256 amount) internal pure returns (uint256 feeAmount) {
feeAmount = Math.mulDiv(amount, uint256(fee), PerLibrary.ONE_MILLION);
}
function bound(uint24 fee, uint256 amount) internal pure returns (uint256 lower, uint256 upper) {
lower = deductFrom(fee, amount);
upper = attachFrom(fee, amount);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {PoolId} from "v4-core/types/PoolId.sol";
import {Currency, CurrencyLibrary} from "v4-core/types/Currency.sol";
/// @notice MarginParams is a struct that contains all the parameters needed to open a margin position.
struct MarginParams {
/// @notice The poolId of the pool.
PoolId poolId;
/// @notice true: currency1 is marginToken, false: currency0 is marginToken
bool marginForOne;
/// @notice Leverage factor of the margin position.
uint24 leverage;
/// @notice The amount of margin
uint256 marginAmount;
/// @notice The borrow amount of the margin position.When the parameter is passed in, it is 0.
uint256 borrowAmount;
/// @notice The maximum borrow amount of the margin position.
uint256 borrowMaxAmount;
/// @notice The address of recipient
address recipient;
/// @notice Deadline for the transaction
uint256 deadline;
}
struct MarginParamsVo {
MarginParams params;
/// @notice The total amount of margin,equals to marginAmount * leverage * (1-marginFee).
uint256 marginTotal;
/// @notice Min margin level.
uint24 minMarginLevel;
/// @notice Min margin level.
Currency marginCurrency;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {PoolId} from "v4-core/types/PoolId.sol";
/// @notice ReleaseParams is a struct that contains all the parameters needed to release margin position.
struct ReleaseParams {
/// @notice The poolId of the pool.
PoolId poolId;
/// @notice true: currency1 is marginToken, false: currency0 is marginToken
bool marginForOne;
/// @notice Payment address.
address payer;
/// @notice Debt amount.
uint256 debtAmount;
/// @notice Repay amount.
uint256 repayAmount;
/// @notice Release amount.
uint256 releaseAmount;
/// @notice The raw amount of borrowed tokens.
uint256 rawBorrowAmount;
/// @notice Deadline for the transaction
uint256 deadline;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
/// @notice Returns the balances of a pool.
struct BalanceStatus {
/// @notice The balance of token0 in the pool.
uint256 balance0;
/// @notice The balance of token1 in the pool.
uint256 balance1;
/// @notice The mirror balance of token0 in the pool.
uint256 mirrorBalance0;
/// @notice The mirror balance of token1 in the pool.
uint256 mirrorBalance1;
/// @notice The total balance of token0 in the lending pool.
uint256 lendingBalance0;
/// @notice The total balance of token1 in the lending pool.
uint256 lendingBalance1;
/// @notice The mirror balance of token0 in the lending pool.
uint256 lendingMirrorBalance0;
/// @notice The mirror balance of token1 in the lending pool.
uint256 lendingMirrorBalance1;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Currency} from "v4-core/types/Currency.sol";
import {PoolId} from "v4-core/types/PoolId.sol";
/// @notice Liquidity parameters for addLiquidity
struct AddLiquidityParams {
/// @notice The id of the pool
PoolId poolId;
/// @notice The token0 amount to add
uint256 amount0;
/// @notice The token1 amount to add
uint256 amount1;
/// @notice The token0 min amount to get
uint256 amount0Min;
/// @notice The token1 min amount to get
uint256 amount1Min;
/// @notice LP level 1: x*y, 2: (x+x')*y, 3: x*(y+y'), 4: (x+x')*(y+y')
uint8 level;
/// @notice The address of source
address source;
/// @notice Deadline for the transaction
uint256 deadline;
}
/// @notice Liquidity parameters for removeLiquidity
struct RemoveLiquidityParams {
/// @notice The id of the pool
PoolId poolId;
/// @notice LP level
uint8 level;
/// @notice LP amount to remove
uint256 liquidity;
/// @notice The token0 min amount to get
uint256 amount0Min;
/// @notice The token1 min amount to get
uint256 amount1Min;
/// @notice Deadline for the transaction
uint256 deadline;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {Currency} from "v4-core/types/Currency.sol";
import {PoolId} from "v4-core/types/PoolId.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {BeforeSwapDelta, toBeforeSwapDelta} from "v4-core/types/BeforeSwapDelta.sol";
import {AddLiquidityParams, RemoveLiquidityParams} from "../types/LiquidityParams.sol";
import {ReleaseParams} from "../types/ReleaseParams.sol";
import {PoolStatus} from "../types/PoolStatus.sol";
import {IPairMarginManager} from "./IPairMarginManager.sol";
import {IMarginFees} from "./IMarginFees.sol";
import {IMarginLiquidity} from "./IMarginLiquidity.sol";
import {ILendingPoolManager} from "./ILendingPoolManager.sol";
import {IPoolStatusManager} from "./IPoolStatusManager.sol";
interface IPairPoolManager is IPairMarginManager {
function hooks() external view returns (IHooks hook);
function positionManagers(address _positionManager) external view returns (bool);
function lendingPoolManager() external view returns (ILendingPoolManager);
function statusManager() external view returns (IPoolStatusManager);
/// @notice Get current IMarginFees
function marginFees() external view returns (IMarginFees);
/// @notice Get current IMarginLiquidity
function marginLiquidity() external view returns (IMarginLiquidity);
/// @notice Get status of a pool
/// @param poolId The poolId of the pool to query
/// @return status The current status of the pool
function getStatus(PoolId poolId) external view returns (PoolStatus memory);
/// @notice Get the reserves of a pool
/// @param poolId The poolId of the pool to query
/// @return _reserve0 The reserve of the first token in the pool
/// @return _reserve1 The reserve of the second token in the pool
function getReserves(PoolId poolId) external view returns (uint256 _reserve0, uint256 _reserve1);
/// @notice Given an output amount of an asset and pair reserve, returns a required input amount of the other asset
/// @param poolId The poolId of the pool to query
/// @param zeroForOne If true, the input asset is the first token of the pair, otherwise it is the second token
/// @param amountOut an output amount
/// @return amountIn a required input amount
function getAmountIn(PoolId poolId, bool zeroForOne, uint256 amountOut) external view returns (uint256 amountIn);
/// @notice Given an input amount of an asset and pair reserve, returns the expected output amount of the other asset
/// @param poolId The poolId of the pool to query
/// @param zeroForOne If true, the input asset is the first token of the pair, otherwise it is the second token
/// @param amountIn a input amount
/// @return amountOut an output amount
function getAmountOut(PoolId poolId, bool zeroForOne, uint256 amountIn) external view returns (uint256 amountOut);
// ******************** HOOK CALL ********************
function initialize(PoolKey calldata key) external;
function swap(address sender, PoolKey calldata key, IPoolManager.SwapParams calldata params)
external
returns (
Currency specified,
Currency unspecified,
uint256 specifiedAmount,
uint256 unspecifiedAmount,
uint24 swapFee
);
// ******************** USER CALL ********************
/// @notice Add liquidity to a pool
/// @param params The parameters for the add liquidity hook
/// @return liquidity The amount of liquidity minted
function addLiquidity(AddLiquidityParams calldata params) external payable returns (uint256 liquidity);
/// @notice Remove liquidity from a pool
/// @param params The parameters for the remove liquidity hook
/// @return amount0 The amount of token0 repaid
/// @return amount1 The amount of token1 repaid
function removeLiquidity(RemoveLiquidityParams calldata params)
external
returns (uint256 amount0, uint256 amount1);
// ******************** EXTERNAL FUNCTIONS ********************
function mirrorInRealOut(PoolId poolId, PoolStatus memory status, Currency currency, uint256 amount)
external
returns (bool success);
function swapMirror(address recipient, PoolId poolId, bool zeroForOne, uint256 amountIn, uint256 amountOutMin)
external
payable
returns (uint256 amountOut);
/// @notice Collects the protocol fees for a given recipient and currency, returning the amount collected
/// @dev This will revert if the contract is unlocked
/// @param recipient The address to receive the protocol fees
/// @param currency The currency to withdraw
/// @param amount The amount of currency to withdraw
/// @return amountCollected The amount of currency successfully withdrawn
function collectProtocolFees(address recipient, Currency currency, uint256 amount) external returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import {PoolId} from "v4-core/types/PoolId.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {Currency, CurrencyLibrary} from "v4-core/types/Currency.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {IStatusBase} from "./IStatusBase.sol";
import {IMarginFees} from "./IMarginFees.sol";
import {BalanceStatus} from "../types/BalanceStatus.sol";
import {PoolStatus} from "../types/PoolStatus.sol";
import {GlobalStatus} from "../types/GlobalStatus.sol";
interface IPoolStatusManager is IStatusBase {
function hooks() external view returns (IHooks hook);
/// @notice Get current IMarginFees
function marginFees() external view returns (IMarginFees hook);
function initialize(PoolKey calldata key) external;
function getGlobalStatus(PoolId poolId) external view returns (GlobalStatus memory _status);
function getStatus(PoolId poolId) external view returns (PoolStatus memory _status);
function getAmountOut(PoolStatus memory status, bool zeroForOne, uint256 amountIn)
external
view
returns (uint256 amountOut, uint24 fee, uint256 feeAmount);
function getAmountIn(PoolStatus memory status, bool zeroForOne, uint256 amountOut)
external
view
returns (uint256 amountIn, uint24 fee, uint256 feeAmount);
function protocolFeesAccrued(Currency currency) external view returns (uint256);
function setBalances(address sender, PoolId poolId) external returns (PoolStatus memory _status);
function update(PoolId poolId) external;
function updateSwapProtocolFees(Currency currency, uint256 amount) external returns (uint256 restAmount);
function updateMarginProtocolFees(Currency currency, uint256 amount) external returns (uint256 restAmount);
function collectProtocolFees(Currency currency, uint256 amount) external returns (uint256 amountCollected);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
import {Currency} from "v4-core/types/Currency.sol";
import {PoolId} from "v4-core/types/PoolId.sol";
// Local
import {IERC6909Accrues} from "../interfaces/external/IERC6909Accrues.sol";
import {PoolStatus} from "../types/PoolStatus.sol";
interface ILendingPoolManager is IERC6909Accrues {
// ******************** EXTERNAL CALL ********************
function getGrownRatioX112(uint256 id, uint256 growAmount) external view returns (uint256 accruesRatioX112Grown);
function computeRealAmount(PoolId poolId, Currency currency, uint256 originalAmount)
external
view
returns (uint256 amount);
// ******************** POOL CALL ********************
function updateInterests(uint256 id, int256 interest) external;
function updateProtocolInterests(address caller, PoolId poolId, Currency currency, uint256 interest)
external
returns (uint256 originalAmount);
function sync(PoolId poolId, PoolStatus memory status) external;
function mirrorIn(address caller, address receiver, PoolId poolId, Currency currency, uint256 amount)
external
returns (uint256 originalAmount);
function mirrorInRealOut(PoolId poolId, PoolStatus memory status, Currency currency, uint256 amount)
external
returns (uint256 exchangeAmount);
function realIn(address caller, address recipient, PoolId poolId, Currency currency, uint256 amount)
external
returns (uint256 originalAmount);
function reserveOut(
address caller,
address payer,
PoolId poolId,
PoolStatus memory status,
Currency currency,
uint256 amount
) external;
// ******************** USER CALL ********************
function deposit(address sender, address recipient, PoolId poolId, Currency currency, uint256 amount)
external
payable
returns (uint256 originalAmount);
function deposit(address recipient, PoolId poolId, Currency currency, uint256 amount)
external
payable
returns (uint256 originalAmount);
function withdraw(address recipient, PoolId poolId, Currency currency, uint256 amount)
external
returns (uint256 originalAmount);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Currency} from "v4-core/types/Currency.sol";
import {PoolId} from "v4-core/types/PoolId.sol";
import {MarginParams} from "../types/MarginParams.sol";
import {ReleaseParams} from "../types/ReleaseParams.sol";
import {PoolStatus} from "../types/PoolStatus.sol";
import {IMarginLiquidity} from "./IMarginLiquidity.sol";
interface IMarginFees {
/// @notice Get the address of the fee receiver
/// @return feeTo The address of the fee receiver
function feeTo() external view returns (address);
function marginFee() external view returns (uint24);
/// @notice Get the dynamic swap fee from the status of pool
/// @param status The status of the pool
/// @param zeroForOne if true amountIn is currency0,else amountIn is currency1
/// @param amountIn The amount swap in
/// @param amountOut The amount swap out
/// @return _fee The dynamic fee of swap transaction
function dynamicFee(PoolStatus memory status, bool zeroForOne, uint256 amountIn, uint256 amountOut)
external
view
returns (uint24 _fee);
/// @notice Get the dynamic liquidity fee from the status of pool
/// @param _poolManager The address of pool manager
/// @param poolId The pool id
/// @param zeroForOne if true amountIn is currency0,else amountIn is currency1
/// @param amountIn The amount swap in
/// @param amountOut The amount swap out
/// @return _fee The dynamic fee of swap transaction
/// @return _marginFee The fee of margin transaction
function getPoolFees(address _poolManager, PoolId poolId, bool zeroForOne, uint256 amountIn, uint256 amountOut)
external
view
returns (uint24 _fee, uint24 _marginFee);
/// @notice Get the borrow rate from the reserves
/// @param realReserve The real reserve of the pool
/// @param mirrorReserve The mirror reserve of the pool
/// @return The borrow rate
function getBorrowRateByReserves(uint256 realReserve, uint256 mirrorReserve) external view returns (uint256);
/// @notice Get the last cumulative multiplication of rate
/// @param interestReserve0 The interest reserve of the first currency
/// @param interestReserve1 The interest reserve of the second currency
/// @param status The status of the pairPool
/// @return rate0CumulativeLast The currency0 last cumulative multiplication of rate
/// @return rate1CumulativeLast The currency1 last cumulative multiplication of rate
function getBorrowRateCumulativeLast(uint256 interestReserve0, uint256 interestReserve1, PoolStatus memory status)
external
view
returns (uint256 rate0CumulativeLast, uint256 rate1CumulativeLast);
/// @notice Get the last cumulative multiplication of rate
/// @param pairPoolManager The address of pairPoolManager
/// @param poolId The pool id
/// @param marginForOne true: currency1 is marginToken, false: currency0 is marginToken
/// @return The last cumulative multiplication of rate
function getBorrowRateCumulativeLast(address pairPoolManager, PoolId poolId, bool marginForOne)
external
view
returns (uint256);
/// @notice Get the current borrow rate
/// @param pairPoolManager The address of pairPoolManager
/// @param status The status of the pool
/// @param marginForOne true: currency1 is marginToken, false: currency0 is marginToken
/// @return The current borrow rate
function getBorrowRate(address pairPoolManager, PoolStatus memory status, bool marginForOne)
external
view
returns (uint256);
/// @notice Get the current borrow rate
/// @param pairPoolManager The address of pairPoolManager
/// @param poolId The pool id
/// @param marginForOne true: currency1 is marginToken, false: currency0 is marginToken
/// @return The current borrow rate
function getBorrowRate(address pairPoolManager, PoolId poolId, bool marginForOne) external view returns (uint256);
/// @notice Get the protocol part of the totalFee
/// @param totalFee Total fee amount
/// @return feeAmount The protocol part fee amount
function getProtocolSwapFeeAmount(uint256 totalFee) external view returns (uint256 feeAmount);
function getProtocolMarginFeeAmount(uint256 totalFee) external view returns (uint256 feeAmount);
function getProtocolInterestFeeAmount(uint256 totalFee) external view returns (uint256 feeAmount);
/// @notice Collects the protocol fees for a given recipient and currency, returning the amount collected
/// @param poolManager The address of pool manager
/// @param recipient The address to receive the protocol fees
/// @param currency The currency to withdraw
/// @param amount The amount of currency to withdraw
/// @return amountCollected The amount of currency successfully withdrawn
function collectProtocolFees(address poolManager, address recipient, Currency currency, uint256 amount)
external
returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
import {PoolId} from "v4-core/types/PoolId.sol";
import {IERC6909} from "../interfaces/external/IERC6909.sol";
import {PoolStatus} from "../types/PoolStatus.sol";
interface IMarginLiquidity is IERC6909 {
function addLiquidity(address sender, uint256 id, uint8 level, uint256 amount) external;
function removeLiquidity(address sender, uint256 id, uint8 level, uint256 amount) external returns (uint256);
function changeLiquidity(PoolId poolId, uint256 _reserve0, uint256 _reserve1, int256 interest0, int256 interest1)
external
returns (uint256 liquidity);
function addInterests(PoolId poolId, uint256 _reserve0, uint256 _reserve1, uint256 interest0, uint256 interest1)
external
returns (uint256 liquidity);
function getMaxSliding() external view returns (uint24);
function getPoolId(PoolId poolId) external pure returns (uint256 uPoolId);
function getSupplies(uint256 uPoolId)
external
view
returns (uint256 totalSupply, uint256 retainSupply0, uint256 retainSupply1);
/// Get the supplies of pool status
/// @param poolManager The address of pool manager
/// @param poolId The pool id
/// @return totalSupply The total supply
/// @return retainSupply0 The level1+level3 supply(can't mirror x)
/// @return retainSupply1 The level1+level2 supply(can't mirror y)
function getPoolSupplies(address poolManager, PoolId poolId)
external
view
returns (uint256 totalSupply, uint256 retainSupply0, uint256 retainSupply1);
/// Get the reserves can claim interests
/// @param pairPoolManager The address of pool manager
/// @param poolId The pool Id
/// @param status The status of pool
/// @return reserve0 The reserve can claim interest0
/// @return reserve1 The reserve can claim interest1
function getInterestReserves(address pairPoolManager, PoolId poolId, PoolStatus memory status)
external
view
returns (uint256 reserve0, uint256 reserve1);
function getFlowReserves(address pairPoolManager, PoolId poolId, PoolStatus memory status)
external
view
returns (uint256 reserve0, uint256 reserve1);
function getMarginReserves(address pairPoolManager, PoolId poolId, PoolStatus memory status)
external
view
returns (
uint256 marginReserve0,
uint256 marginReserve1,
uint256 incrementMaxMirror0,
uint256 incrementMaxMirror1
);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
import {IERC6909} from "../interfaces/external/IERC6909.sol";
interface IMirrorTokenManager is IERC6909 {
function mint(uint256 id, uint256 amount) external;
function mintInStatus(address receiver, uint256 id, uint256 amount) external;
function burn(uint256 id, uint256 amount) external;
function burn(address lendingPool, uint256 id, uint256 amount)
external
returns (uint256 pairAmount, uint256 lendingAmount);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {IPoolManager} from "./IPoolManager.sol";
import {BeforeSwapDelta} from "../types/BeforeSwapDelta.sol";
/// @notice V4 decides whether to invoke specific hooks by inspecting the least significant bits
/// of the address that the hooks contract is deployed to.
/// For example, a hooks contract deployed to address: 0x0000000000000000000000000000000000002400
/// has the lowest bits '10 0100 0000 0000' which would cause the 'before initialize' and 'after add liquidity' hooks to be used.
/// See the Hooks library for the full spec.
/// @dev Should only be callable by the v4 PoolManager.
interface IHooks {
/// @notice The hook called before the state of a pool is initialized
/// @param sender The initial msg.sender for the initialize call
/// @param key The key for the pool being initialized
/// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96
/// @return bytes4 The function selector for the hook
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4);
/// @notice The hook called after the state of a pool is initialized
/// @param sender The initial msg.sender for the initialize call
/// @param key The key for the pool being initialized
/// @param sqrtPriceX96 The sqrt(price) of the pool as a Q64.96
/// @param tick The current tick after the state of a pool is initialized
/// @return bytes4 The function selector for the hook
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
external
returns (bytes4);
/// @notice The hook called before liquidity is added
/// @param sender The initial msg.sender for the add liquidity call
/// @param key The key for the pool
/// @param params The parameters for adding liquidity
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeAddLiquidity(
address sender,
PoolKey calldata key,
IPoolManager.ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after liquidity is added
/// @param sender The initial msg.sender for the add liquidity call
/// @param key The key for the pool
/// @param params The parameters for adding liquidity
/// @param delta The caller's balance delta after adding liquidity; the sum of principal delta, fees accrued, and hook delta
/// @param feesAccrued The fees accrued since the last time fees were collected from this position
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterAddLiquidity(
address sender,
PoolKey calldata key,
IPoolManager.ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external returns (bytes4, BalanceDelta);
/// @notice The hook called before liquidity is removed
/// @param sender The initial msg.sender for the remove liquidity call
/// @param key The key for the pool
/// @param params The parameters for removing liquidity
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeRemoveLiquidity(
address sender,
PoolKey calldata key,
IPoolManager.ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after liquidity is removed
/// @param sender The initial msg.sender for the remove liquidity call
/// @param key The key for the pool
/// @param params The parameters for removing liquidity
/// @param delta The caller's balance delta after removing liquidity; the sum of principal delta, fees accrued, and hook delta
/// @param feesAccrued The fees accrued since the last time fees were collected from this position
/// @param hookData Arbitrary data handed into the PoolManager by the liquidity provider to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BalanceDelta The hook's delta in token0 and token1. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterRemoveLiquidity(
address sender,
PoolKey calldata key,
IPoolManager.ModifyLiquidityParams calldata params,
BalanceDelta delta,
BalanceDelta feesAccrued,
bytes calldata hookData
) external returns (bytes4, BalanceDelta);
/// @notice The hook called before a swap
/// @param sender The initial msg.sender for the swap call
/// @param key The key for the pool
/// @param params The parameters for the swap
/// @param hookData Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return BeforeSwapDelta The hook's delta in specified and unspecified currencies. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
/// @return uint24 Optionally override the lp fee, only used if three conditions are met: 1. the Pool has a dynamic fee, 2. the value's 2nd highest bit is set (23rd bit, 0x400000), and 3. the value is less than or equal to the maximum fee (1 million)
function beforeSwap(
address sender,
PoolKey calldata key,
IPoolManager.SwapParams calldata params,
bytes calldata hookData
) external returns (bytes4, BeforeSwapDelta, uint24);
/// @notice The hook called after a swap
/// @param sender The initial msg.sender for the swap call
/// @param key The key for the pool
/// @param params The parameters for the swap
/// @param delta The amount owed to the caller (positive) or owed to the pool (negative)
/// @param hookData Arbitrary data handed into the PoolManager by the swapper to be be passed on to the hook
/// @return bytes4 The function selector for the hook
/// @return int128 The hook's delta in unspecified currency. Positive: the hook is owed/took currency, negative: the hook owes/sent currency
function afterSwap(
address sender,
PoolKey calldata key,
IPoolManager.SwapParams calldata params,
BalanceDelta delta,
bytes calldata hookData
) external returns (bytes4, int128);
/// @notice The hook called before donate
/// @param sender The initial msg.sender for the donate call
/// @param key The key for the pool
/// @param amount0 The amount of token0 being donated
/// @param amount1 The amount of token1 being donated
/// @param hookData Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function beforeDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external returns (bytes4);
/// @notice The hook called after donate
/// @param sender The initial msg.sender for the donate call
/// @param key The key for the pool
/// @param amount0 The amount of token0 being donated
/// @param amount1 The amount of token1 being donated
/// @param hookData Arbitrary data handed into the PoolManager by the donor to be be passed on to the hook
/// @return bytes4 The function selector for the hook
function afterDonate(
address sender,
PoolKey calldata key,
uint256 amount0,
uint256 amount1,
bytes calldata hookData
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Minimal ERC20 interface for Uniswap
/// @notice Contains a subset of the full ERC20 interface that is used in Uniswap V3
interface IERC20Minimal {
/// @notice Returns an account's balance in the token
/// @param account The account for which to look up the number of tokens it has, i.e. its balance
/// @return The number of tokens held by the account
function balanceOf(address account) external view returns (uint256);
/// @notice Transfers the amount of token from the `msg.sender` to the recipient
/// @param recipient The account that will receive the amount transferred
/// @param amount The number of tokens to send from the sender to the recipient
/// @return Returns true for a successful transfer, false for an unsuccessful transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/// @notice Returns the current allowance given to a spender by an owner
/// @param owner The account of the token owner
/// @param spender The account of the token spender
/// @return The current allowance granted by `owner` to `spender`
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
/// @param spender The account which will be allowed to spend a given amount of the owners tokens
/// @param amount The amount of tokens allowed to be used by `spender`
/// @return Returns true for a successful approval, false for unsuccessful
function approve(address spender, uint256 amount) external returns (bool);
/// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
/// @param sender The account from which the transfer will be initiated
/// @param recipient The recipient of the transfer
/// @param amount The amount of the transfer
/// @return Returns true for a successful transfer, false for unsuccessful
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
/// @param from The account from which the tokens were sent, i.e. the balance decreased
/// @param to The account to which the tokens were sent, i.e. the balance increased
/// @param value The amount of tokens that were transferred
event Transfer(address indexed from, address indexed to, uint256 value);
/// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
/// @param owner The account that approved spending of its tokens
/// @param spender The account for which the spending allowance was modified
/// @param value The new allowance from the owner to the spender
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
/// @dev ERC-7751 error for wrapping bubbled up reverts
error WrappedError(address target, bytes4 selector, bytes reason, bytes details);
/// @dev Reverts with the selector of a custom error in the scratch space
function revertWith(bytes4 selector) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
revert(0, 0x04)
}
}
/// @dev Reverts with a custom error with an address argument in the scratch space
function revertWith(bytes4 selector, address addr) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with an int24 argument in the scratch space
function revertWith(bytes4 selector, int24 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, signextend(2, value))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with a uint160 argument in the scratch space
function revertWith(bytes4 selector, uint160 value) internal pure {
assembly ("memory-safe") {
mstore(0, selector)
mstore(0x04, and(value, 0xffffffffffffffffffffffffffffffffffffffff))
revert(0, 0x24)
}
}
/// @dev Reverts with a custom error with two int24 arguments
function revertWith(bytes4 selector, int24 value1, int24 value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), signextend(2, value1))
mstore(add(fmp, 0x24), signextend(2, value2))
revert(fmp, 0x44)
}
}
/// @dev Reverts with a custom error with two uint160 arguments
function revertWith(bytes4 selector, uint160 value1, uint160 value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
revert(fmp, 0x44)
}
}
/// @dev Reverts with a custom error with two address arguments
function revertWith(bytes4 selector, address value1, address value2) internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(fmp, selector)
mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
revert(fmp, 0x44)
}
}
/// @notice bubble up the revert message returned by a call and revert with a wrapped ERC-7751 error
/// @dev this method can be vulnerable to revert data bombs
function bubbleUpAndRevertWith(
address revertingContract,
bytes4 revertingFunctionSelector,
bytes4 additionalContext
) internal pure {
bytes4 wrappedErrorSelector = WrappedError.selector;
assembly ("memory-safe") {
// Ensure the size of the revert data is a multiple of 32 bytes
let encodedDataSize := mul(div(add(returndatasize(), 31), 32), 32)
let fmp := mload(0x40)
// Encode wrapped error selector, address, function selector, offset, additional context, size, revert reason
mstore(fmp, wrappedErrorSelector)
mstore(add(fmp, 0x04), and(revertingContract, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(
add(fmp, 0x24),
and(revertingFunctionSelector, 0xffffffff00000000000000000000000000000000000000000000000000000000)
)
// offset revert reason
mstore(add(fmp, 0x44), 0x80)
// offset additional context
mstore(add(fmp, 0x64), add(0xa0, encodedDataSize))
// size revert reason
mstore(add(fmp, 0x84), returndatasize())
// revert reason
returndatacopy(add(fmp, 0xa4), 0, returndatasize())
// size additional context
mstore(add(fmp, add(0xa4, encodedDataSize)), 0x04)
// additional context
mstore(
add(fmp, add(0xc4, encodedDataSize)),
and(additionalContext, 0xffffffff00000000000000000000000000000000000000000000000000000000)
)
revert(fmp, add(0xe4, encodedDataSize))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for claims over a contract balance, wrapped as a ERC6909
interface IERC6909Claims {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OperatorSet(address indexed owner, address indexed operator, bool approved);
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
event Transfer(address caller, address indexed from, address indexed to, uint256 indexed id, uint256 amount);
/*//////////////////////////////////////////////////////////////
FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Owner balance of an id.
/// @param owner The address of the owner.
/// @param id The id of the token.
/// @return amount The balance of the token.
function balanceOf(address owner, uint256 id) external view returns (uint256 amount);
/// @notice Spender allowance of an id.
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @return amount The allowance of the token.
function allowance(address owner, address spender, uint256 id) external view returns (uint256 amount);
/// @notice Checks if a spender is approved by an owner as an operator
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @return approved The approval status.
function isOperator(address owner, address spender) external view returns (bool approved);
/// @notice Transfers an amount of an id from the caller to a receiver.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Transfers an amount of an id from a sender to a receiver.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Approves an amount of an id to a spender.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
/// @notice Sets or removes an operator for the caller.
/// @param operator The address of the operator.
/// @param approved The approval status.
/// @return bool True, always
function setOperator(address operator, bool approved) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Currency} from "../types/Currency.sol";
import {PoolId} from "../types/PoolId.sol";
import {PoolKey} from "../types/PoolKey.sol";
/// @notice Interface for all protocol-fee related functions in the pool manager
interface IProtocolFees {
/// @notice Thrown when protocol fee is set too high
error ProtocolFeeTooLarge(uint24 fee);
/// @notice Thrown when collectProtocolFees or setProtocolFee is not called by the controller.
error InvalidCaller();
/// @notice Thrown when collectProtocolFees is attempted on a token that is synced.
error ProtocolFeeCurrencySynced();
/// @notice Emitted when the protocol fee controller address is updated in setProtocolFeeController.
event ProtocolFeeControllerUpdated(address indexed protocolFeeController);
/// @notice Emitted when the protocol fee is updated for a pool.
event ProtocolFeeUpdated(PoolId indexed id, uint24 protocolFee);
/// @notice Given a currency address, returns the protocol fees accrued in that currency
/// @param currency The currency to check
/// @return amount The amount of protocol fees accrued in the currency
function protocolFeesAccrued(Currency currency) external view returns (uint256 amount);
/// @notice Sets the protocol fee for the given pool
/// @param key The key of the pool to set a protocol fee for
/// @param newProtocolFee The fee to set
function setProtocolFee(PoolKey memory key, uint24 newProtocolFee) external;
/// @notice Sets the protocol fee controller
/// @param controller The new protocol fee controller
function setProtocolFeeController(address controller) external;
/// @notice Collects the protocol fees for a given recipient and currency, returning the amount collected
/// @dev This will revert if the contract is unlocked
/// @param recipient The address to receive the protocol fees
/// @param currency The currency to withdraw
/// @param amount The amount of currency to withdraw
/// @return amountCollected The amount of currency successfully withdrawn
function collectProtocolFees(address recipient, Currency currency, uint256 amount)
external
returns (uint256 amountCollected);
/// @notice Returns the current protocol fee controller address
/// @return address The current protocol fee controller address
function protocolFeeController() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {SafeCast} from "../libraries/SafeCast.sol";
/// @dev Two `int128` values packed into a single `int256` where the upper 128 bits represent the amount0
/// and the lower 128 bits represent the amount1.
type BalanceDelta is int256;
using {add as +, sub as -, eq as ==, neq as !=} for BalanceDelta global;
using BalanceDeltaLibrary for BalanceDelta global;
using SafeCast for int256;
function toBalanceDelta(int128 _amount0, int128 _amount1) pure returns (BalanceDelta balanceDelta) {
assembly ("memory-safe") {
balanceDelta := or(shl(128, _amount0), and(sub(shl(128, 1), 1), _amount1))
}
}
function add(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
int256 res0;
int256 res1;
assembly ("memory-safe") {
let a0 := sar(128, a)
let a1 := signextend(15, a)
let b0 := sar(128, b)
let b1 := signextend(15, b)
res0 := add(a0, b0)
res1 := add(a1, b1)
}
return toBalanceDelta(res0.toInt128(), res1.toInt128());
}
function sub(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
int256 res0;
int256 res1;
assembly ("memory-safe") {
let a0 := sar(128, a)
let a1 := signextend(15, a)
let b0 := sar(128, b)
let b1 := signextend(15, b)
res0 := sub(a0, b0)
res1 := sub(a1, b1)
}
return toBalanceDelta(res0.toInt128(), res1.toInt128());
}
function eq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
return BalanceDelta.unwrap(a) == BalanceDelta.unwrap(b);
}
function neq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
return BalanceDelta.unwrap(a) != BalanceDelta.unwrap(b);
}
/// @notice Library for getting the amount0 and amount1 deltas from the BalanceDelta type
library BalanceDeltaLibrary {
/// @notice A BalanceDelta of 0
BalanceDelta public constant ZERO_DELTA = BalanceDelta.wrap(0);
function amount0(BalanceDelta balanceDelta) internal pure returns (int128 _amount0) {
assembly ("memory-safe") {
_amount0 := sar(128, balanceDelta)
}
}
function amount1(BalanceDelta balanceDelta) internal pure returns (int128 _amount1) {
assembly ("memory-safe") {
_amount1 := signextend(15, balanceDelta)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for functions to access any storage slot in a contract
interface IExtsload {
/// @notice Called by external contracts to access granular pool state
/// @param slot Key of slot to sload
/// @return value The value of the slot as bytes32
function extsload(bytes32 slot) external view returns (bytes32 value);
/// @notice Called by external contracts to access granular pool state
/// @param startSlot Key of slot to start sloading from
/// @param nSlots Number of slots to load into return value
/// @return values List of loaded values.
function extsload(bytes32 startSlot, uint256 nSlots) external view returns (bytes32[] memory values);
/// @notice Called by external contracts to access sparse pool state
/// @param slots List of slots to SLOAD from.
/// @return values List of loaded values.
function extsload(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice Interface for functions to access any transient storage slot in a contract
interface IExttload {
/// @notice Called by external contracts to access transient storage of the contract
/// @param slot Key of slot to tload
/// @return value The value of the slot as bytes32
function exttload(bytes32 slot) external view returns (bytes32 value);
/// @notice Called by external contracts to access sparse transient pool state
/// @param slots List of slots to tload
/// @return values List of loaded values
function exttload(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IUnlockCallback} from "@uniswap/v4-core/src/interfaces/callback/IUnlockCallback.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {ImmutableState} from "./ImmutableState.sol";
/// @title Safe Callback
/// @notice A contract that only allows the Uniswap v4 PoolManager to call the unlockCallback
abstract contract SafeCallback is ImmutableState, IUnlockCallback {
/// @notice Thrown when calling unlockCallback where the caller is not PoolManager
error NotPoolManager();
constructor(IPoolManager _poolManager) ImmutableState(_poolManager) {}
/// @notice Only allow calls from the PoolManager contract
modifier onlyPoolManager() {
if (msg.sender != address(poolManager)) revert NotPoolManager();
_;
}
/// @inheritdoc IUnlockCallback
/// @dev We force the onlyPoolManager modifier by exposing a virtual function after the onlyPoolManager check.
function unlockCallback(bytes calldata data) external onlyPoolManager returns (bytes memory) {
return _unlockCallback(data);
}
/// @dev to be implemented by the child contract, to safely guarantee the logic is only executed by the PoolManager
function _unlockCallback(bytes calldata data) internal virtual returns (bytes memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.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 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
pragma solidity ^0.8.0;
// Return type of the beforeSwap hook.
// Upper 128 bits is the delta in specified tokens. Lower 128 bits is delta in unspecified tokens (to match the afterSwap hook)
type BeforeSwapDelta is int256;
// Creates a BeforeSwapDelta from specified and unspecified
function toBeforeSwapDelta(int128 deltaSpecified, int128 deltaUnspecified)
pure
returns (BeforeSwapDelta beforeSwapDelta)
{
assembly ("memory-safe") {
beforeSwapDelta := or(shl(128, deltaSpecified), and(sub(shl(128, 1), 1), deltaUnspecified))
}
}
/// @notice Library for getting the specified and unspecified deltas from the BeforeSwapDelta type
library BeforeSwapDeltaLibrary {
/// @notice A BeforeSwapDelta of 0
BeforeSwapDelta public constant ZERO_DELTA = BeforeSwapDelta.wrap(0);
/// extracts int128 from the upper 128 bits of the BeforeSwapDelta
/// returned by beforeSwap
function getSpecifiedDelta(BeforeSwapDelta delta) internal pure returns (int128 deltaSpecified) {
assembly ("memory-safe") {
deltaSpecified := sar(128, delta)
}
}
/// extracts int128 from the lower 128 bits of the BeforeSwapDelta
/// returned by beforeSwap and afterSwap
function getUnspecifiedDelta(BeforeSwapDelta delta) internal pure returns (int128 deltaUnspecified) {
assembly ("memory-safe") {
deltaUnspecified := signextend(15, delta)
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
import {Currency} from "v4-core/types/Currency.sol";
import {PoolId} from "v4-core/types/PoolId.sol";
import {MarginParamsVo} from "../types/MarginParams.sol";
import {ReleaseParams} from "../types/ReleaseParams.sol";
import {PoolStatus} from "../types/PoolStatus.sol";
import {IMarginFees} from "../interfaces/IMarginFees.sol";
import {IMarginLiquidity} from "../interfaces/IMarginLiquidity.sol";
import {ILendingPoolManager} from "../interfaces/ILendingPoolManager.sol";
import {IPoolStatusManager} from "../interfaces/IPoolStatusManager.sol";
interface IPairMarginManager {
function lendingPoolManager() external view returns (ILendingPoolManager);
function statusManager() external view returns (IPoolStatusManager);
/// @notice Get current IMarginFees
function marginFees() external view returns (IMarginFees);
/// @notice Get current IMarginLiquidity
function marginLiquidity() external view returns (IMarginLiquidity);
/// @notice Get status of a pool
/// @param poolId The poolId of the pool to query
/// @return status The current status of the pool
function getStatus(PoolId poolId) external view returns (PoolStatus memory);
/// @notice Get the reserves of a pool
/// @param poolId The poolId of the pool to query
/// @return _reserve0 The reserve of the first token in the pool
/// @return _reserve1 The reserve of the second token in the pool
function getReserves(PoolId poolId) external view returns (uint256 _reserve0, uint256 _reserve1);
/// @notice Given an output amount of an asset and pair reserve, returns a required input amount of the other asset
/// @param poolId The poolId of the pool to query
/// @param zeroForOne If true, the input asset is the first token of the pair, otherwise it is the second token
/// @param amountOut an output amount
/// @return amountIn a required input amount
function getAmountIn(PoolId poolId, bool zeroForOne, uint256 amountOut) external view returns (uint256 amountIn);
/// @notice Given an input amount of an asset and pair reserve, returns the expected output amount of the other asset
/// @param poolId The poolId of the pool to query
/// @param zeroForOne If true, the input asset is the first token of the pair, otherwise it is the second token
/// @param amountIn a input amount
/// @return amountOut an output amount
function getAmountOut(PoolId poolId, bool zeroForOne, uint256 amountIn) external view returns (uint256 amountOut);
// ******************** MARGIN FUNCTIONS ********************
function setBalances(address sender, PoolId poolId) external returns (PoolStatus memory _status);
/// @notice Margin
/// @param sender The address of sender
/// @param status The status for the pool
/// @param paramsVo The parameters for the margin hook
/// @return The updated parameters for the margin hook
function margin(address sender, PoolStatus memory status, MarginParamsVo memory paramsVo)
external
payable
returns (MarginParamsVo memory);
/// @notice Release
/// @param sender The address of sender
/// @param status The status for the pool
/// @param params The parameters for the release hook
/// @return The amount of tokens repaid
function release(address sender, PoolStatus memory status, ReleaseParams memory params)
external
payable
returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;
interface IStatusBase {
function pairPoolManager() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {PoolStatus} from "./PoolStatus.sol";
import {LendingStatus} from "./LendingStatus.sol";
/// @notice Returns the status of global.
struct GlobalStatus {
/// @notice The status of pair pool.
PoolStatus pairPoolStatus;
/// @notice The status of lending pool.
LendingStatus lendingStatus;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC6909} from "./IERC6909.sol";
/// @notice Interface for accrues over a contract balance, wrapped as a ERC6909
interface IERC6909Accrues is IERC6909 {
function accruesRatioX112Of(uint256 id) external view returns (uint256);
function totalSupply(uint256 id) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for accrues over a contract balance, wrapped as a ERC6909
interface IERC6909 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OperatorSet(address indexed owner, address indexed operator, bool approved);
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
event Transfer(address caller, address indexed from, address indexed to, uint256 indexed id, uint256 amount);
/*//////////////////////////////////////////////////////////////
FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Owner balance of an id.
/// @param owner The address of the owner.
/// @param id The id of the token.
/// @return amount The balance of the token.
function balanceOf(address owner, uint256 id) external view returns (uint256 amount);
/// @notice Spender allowance of an id.
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @return amount The allowance of the token.
function allowance(address owner, address spender, uint256 id) external view returns (uint256 amount);
/// @notice Checks if a spender is approved by an owner as an operator
/// @param owner The address of the owner.
/// @param spender The address of the spender.
/// @return approved The approval status.
function isOperator(address owner, address spender) external view returns (bool approved);
/// @notice Transfers an amount of an id from the caller to a receiver.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Transfers an amount of an id from a sender to a receiver.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always, unless the function reverts
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
/// @notice Approves an amount of an id to a spender.
/// @param spender The address of the spender.
/// @param id The id of the token.
/// @param amount The amount of the token.
/// @return bool True, always
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
/// @notice Sets or removes an operator for the caller.
/// @param operator The address of the operator.
/// @param approved The approval status.
/// @return bool True, always
function setOperator(address operator, bool approved) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @notice Interface for the callback executed when an address unlocks the pool manager
interface IUnlockCallback {
/// @notice Called by the pool manager on `msg.sender` when the manager is unlocked
/// @param data The data that was passed to the call to unlock
/// @return Any data that you want to be returned from the unlock call
function unlockCallback(bytes calldata data) external returns (bytes memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IImmutableState} from "../interfaces/IImmutableState.sol";
/// @title Immutable State
/// @notice A collection of immutable state variables, commonly used across multiple contracts
contract ImmutableState is IImmutableState {
/// @inheritdoc IImmutableState
IPoolManager public immutable poolManager;
constructor(IPoolManager _poolManager) {
poolManager = _poolManager;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
/// @notice Returns the status of a lending pool.
struct LendingStatus {
/// @notice The accrues ratio of the first currency in the pool.(x)
uint256 accruesRatio0X112;
/// @notice The accrues ratio of the second currency in the pool.(y)
uint256 accruesRatio1X112;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
/// @title Interface for ImmutableState
interface IImmutableState {
/// @notice The Uniswap v4 PoolManager contract
function poolManager() external view returns (IPoolManager);
}{
"remappings": [
"@ensdomains/=lib/v4-periphery/lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"@openzeppelin/contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/contracts/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"ds-test/=lib/v4-periphery/lib/v4-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/forge-gas-snapshot/src/",
"forge-std/=lib/forge-std/src/",
"hardhat/=lib/v4-periphery/lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"permit2/=lib/v4-periphery/lib/permit2/",
"solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"v4-core/=lib/v4-periphery/lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"contract IPoolManager","name":"_manager","type":"address"},{"internalType":"contract IMirrorTokenManager","name":"_mirrorTokenManager","type":"address"},{"internalType":"contract ILendingPoolManager","name":"_lendingPoolManager","type":"address"},{"internalType":"contract IMarginLiquidity","name":"_marginLiquidity","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"HookAlreadySet","type":"error"},{"inputs":[],"name":"InsufficientLiquidityBurnt","type":"error"},{"inputs":[],"name":"InsufficientLiquidityMinted","type":"error"},{"inputs":[],"name":"InsufficientOutputReceived","type":"error"},{"inputs":[],"name":"InsufficientValue","type":"error"},{"inputs":[],"name":"InsufficientValue","type":"error"},{"inputs":[],"name":"LockFailure","type":"error"},{"inputs":[],"name":"LowFeePoolOnlyOneLevel","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotAllowed","type":"error"},{"inputs":[],"name":"NotPoolManager","type":"error"},{"inputs":[],"name":"NotPositionManager","type":"error"},{"inputs":[],"name":"NotSelf","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"StatusManagerAlreadySet","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"PoolId","name":"poolId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"level","type":"uint8"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"PoolId","name":"poolId","type":"bytes32"},{"indexed":true,"internalType":"Currency","name":"currency","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint8","name":"feeType","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Fees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"PoolId","name":"id","type":"bytes32"},{"indexed":true,"internalType":"Currency","name":"currency0","type":"address"},{"indexed":true,"internalType":"Currency","name":"currency1","type":"address"},{"indexed":false,"internalType":"uint24","name":"fee","type":"uint24"},{"indexed":false,"internalType":"int24","name":"tickSpacing","type":"int24"},{"indexed":false,"internalType":"contract IHooks","name":"hooks","type":"address"}],"name":"Initialize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"PoolId","name":"poolId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"source","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"level","type":"uint8"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"PoolId","name":"poolId","type":"bytes32"},{"indexed":true,"internalType":"Currency","name":"borrowCurrency","type":"address"},{"indexed":false,"internalType":"uint256","name":"debtAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"burnAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rawBorrowAmount","type":"uint256"}],"name":"Release","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"PoolId","name":"poolId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint24","name":"fee","type":"uint24"},{"indexed":false,"internalType":"bool","name":"zeroForOne","type":"bool"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"Swap","type":"event"},{"inputs":[{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint8","name":"level","type":"uint8"},{"internalType":"address","name":"source","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct AddLiquidityParams","name":"params","type":"tuple"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_marginPositionManager","type":"address"}],"name":"addPositionManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"Currency","name":"currency","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"collectProtocolFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"getAmountIn","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"PoolId","name":"poolId","type":"bytes32"}],"name":"getReserves","outputs":[{"internalType":"uint256","name":"_reserve0","type":"uint256"},{"internalType":"uint256","name":"_reserve1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"PoolId","name":"poolId","type":"bytes32"}],"name":"getStatus","outputs":[{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"_status","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"handleAddLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"Currency","name":"currency","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"handleCollectFees","outputs":[{"internalType":"uint256","name":"amountCollected","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_positionManager","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"status","type":"tuple"},{"components":[{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"marginForOne","type":"bool"},{"internalType":"uint24","name":"leverage","type":"uint24"},{"internalType":"uint256","name":"marginAmount","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"borrowMaxAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct MarginParams","name":"params","type":"tuple"},{"internalType":"uint256","name":"marginTotal","type":"uint256"},{"internalType":"uint24","name":"minMarginLevel","type":"uint24"},{"internalType":"Currency","name":"marginCurrency","type":"address"}],"internalType":"struct MarginParamsVo","name":"paramsVo","type":"tuple"}],"name":"handleMargin","outputs":[{"internalType":"uint256","name":"marginAmount","type":"uint256"},{"internalType":"uint256","name":"marginWithoutFee","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"status","type":"tuple"},{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"marginForOne","type":"bool"},{"internalType":"address","name":"payer","type":"address"},{"internalType":"uint256","name":"debtAmount","type":"uint256"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"uint256","name":"releaseAmount","type":"uint256"},{"internalType":"uint256","name":"rawBorrowAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ReleaseParams","name":"params","type":"tuple"}],"name":"handleRelease","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"handleRemoveLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"Currency","name":"currency","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"handleSwapMirror","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"hooks","outputs":[{"internalType":"contract IHooks","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lendingPoolManager","outputs":[{"internalType":"contract ILendingPoolManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"status","type":"tuple"},{"components":[{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"marginForOne","type":"bool"},{"internalType":"uint24","name":"leverage","type":"uint24"},{"internalType":"uint256","name":"marginAmount","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"borrowMaxAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct MarginParams","name":"params","type":"tuple"},{"internalType":"uint256","name":"marginTotal","type":"uint256"},{"internalType":"uint24","name":"minMarginLevel","type":"uint24"},{"internalType":"Currency","name":"marginCurrency","type":"address"}],"internalType":"struct MarginParamsVo","name":"paramsVo","type":"tuple"}],"name":"margin","outputs":[{"components":[{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"marginForOne","type":"bool"},{"internalType":"uint24","name":"leverage","type":"uint24"},{"internalType":"uint256","name":"marginAmount","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"borrowMaxAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct MarginParams","name":"params","type":"tuple"},{"internalType":"uint256","name":"marginTotal","type":"uint256"},{"internalType":"uint24","name":"minMarginLevel","type":"uint24"},{"internalType":"Currency","name":"marginCurrency","type":"address"}],"internalType":"struct MarginParamsVo","name":"","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"marginFees","outputs":[{"internalType":"contract IMarginFees","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marginLiquidity","outputs":[{"internalType":"contract IMarginLiquidity","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"status","type":"tuple"},{"internalType":"Currency","name":"currency","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mirrorInRealOut","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mirrorTokenManager","outputs":[{"internalType":"contract IMirrorTokenManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolManager","outputs":[{"internalType":"contract IPoolManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"positionManagers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"status","type":"tuple"},{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"marginForOne","type":"bool"},{"internalType":"address","name":"payer","type":"address"},{"internalType":"uint256","name":"debtAmount","type":"uint256"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"uint256","name":"releaseAmount","type":"uint256"},{"internalType":"uint256","name":"rawBorrowAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ReleaseParams","name":"params","type":"tuple"}],"name":"release","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"uint8","name":"level","type":"uint8"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct RemoveLiquidityParams","name":"params","type":"tuple"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marginPositionManager","type":"address"}],"name":"removePositionManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"PoolId","name":"poolId","type":"bytes32"}],"name":"setBalances","outputs":[{"components":[{"internalType":"uint32","name":"blockTimestampLast","type":"uint32"},{"internalType":"uint112","name":"realReserve0","type":"uint112"},{"internalType":"uint112","name":"realReserve1","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"mirrorReserve1","type":"uint112"},{"internalType":"uint24","name":"marginFee","type":"uint24"},{"internalType":"uint112","name":"lendingRealReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingRealReserve1","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve0","type":"uint112"},{"internalType":"uint112","name":"lendingMirrorReserve1","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve0","type":"uint112"},{"internalType":"uint112","name":"truncatedReserve1","type":"uint112"},{"internalType":"uint256","name":"rate0CumulativeLast","type":"uint256"},{"internalType":"uint256","name":"rate1CumulativeLast","type":"uint256"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"}],"internalType":"struct PoolStatus","name":"_status","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IHooks","name":"_hooks","type":"address"}],"name":"setHooks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPoolStatusManager","name":"_poolStatusManager","type":"address"}],"name":"setStatusManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"statusManager","outputs":[{"internalType":"contract IPoolStatusManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"Currency","name":"currency0","type":"address"},{"internalType":"Currency","name":"currency1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"contract IHooks","name":"hooks","type":"address"}],"internalType":"struct PoolKey","name":"key","type":"tuple"},{"components":[{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"int256","name":"amountSpecified","type":"int256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct IPoolManager.SwapParams","name":"params","type":"tuple"}],"name":"swap","outputs":[{"internalType":"Currency","name":"specified","type":"address"},{"internalType":"Currency","name":"unspecified","type":"address"},{"internalType":"uint256","name":"specifiedAmount","type":"uint256"},{"internalType":"uint256","name":"unspecifiedAmount","type":"uint256"},{"internalType":"uint24","name":"swapFee","type":"uint24"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"PoolId","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"}],"name":"swapMirror","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"unlockCallback","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
61010080604052346102ed5760a081615a60803803809161002082856102f1565b8339810103126102ed5780516001600160a01b03811691908290036102ed576020810151916001600160a01b0383168084036102ed576040830151916001600160a01b03831683036102ed576060840151946001600160a01b038616948587036102ed5760800151926001600160a01b03841684036102ed576020956044945f936080528460018060a01b03198554161784556040519889978896867f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a360a05260c05260e05263558a729760e01b84526004840152600160248401525af180156102c5576102d0575b5060a05160c05160405163558a729760e01b81526001600160a01b0391821660048201526001602482015291602091839160449183915f91165af180156102c557610296575b60405161571f908161034182396080518181816104cd01528181610a8f01528181610e5501528181610f86015281816114f601528181611895015281816118c50152818161216e0152818161219a0152818161235b015281816126ac01528181612d65015281816132580152818161337101528181613497015281816136ec015281816137ba0152818161388701528181613a7201528181613b5e01528181613efb015281816141d401526142d9015260a0518181816101b5015281816110dc01528181611b580152612f77015260c051818181610af101528181610f3001528181611aac01528181611b2101528181611cca01528181611d7301528181612e6401528181612f3a015261390c015260e0518181816102c8015281816107c401528181610ffb0152818161192201528181612103015281816124f8015261301d0152f35b6102b79060203d6020116102be575b6102af81836102f1565b810190610328565b505f610152565b503d6102a5565b6040513d5f823e3d90fd5b6102e89060203d6020116102be576102af81836102f1565b61010c565b5f80fd5b601f909101601f19168101906001600160401b0382119082101761031457604052565b634e487b7160e01b5f52604160045260245ffd5b908160209103126102ed575180151581036102ed579056fe60a06040526004361015610011575f80fd5b5f6080525f3560e01c80630776e76e146142a357806309d1b44814613d2557806312bd6d9e14613cbb57806313ac42a714613c8f578063244195d314613b3c5780632bc5fd8514613aa65780633594e7c214613a525780635be39ae8146139c25780635de28ae01461393b5780635e6263eb146138f557806364d2756f1461381b5780636b4067fe14612de85780638072e28b14612b675780638161b87414612afb5780638461d8671461243e5780638a05a2e6146123e75780638da5cb5b146123bc57806391dd73461461230a578063a4a9e9881461226f578063afb427b614611648578063b447325914611578578063bb4dab6d14611389578063bfb9f86b146111d5578063c3edb7ff14610eef578063cd7033c414610ec5578063d8d232a214610e84578063dc4c90d314610e3e578063e2f0ab0114610de4578063e86cb2be14610dba578063ee7a3dc6146108e8578063f2fde38b14610867578063fb63daa1146107f3578063fb6b0e67146107ad578063fea9d06a146101ea5763ffcd9d161461019e575f80fd5b346101e4576080513660031901126101e4576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b60805180fd5b346101e45760c03660031901126101e45760405160c0810167ffffffffffffffff81118282101761079557604052600435815260243560ff811681036101e4576020820190815260408201906044358252606083019060643582526080840192608435845261026360a4358060a0880152421115614d36565b6002548551604051632bc5fd8560e01b81523360048201526024810191909152608051909161026091839160449183916001600160a01b03165af19081156105b05760805191610766575b50855160405163db620f4f60e01b815260048101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169590946020866024818a5afa9586156105b05760805196610732575b506001600160701b0361031e846154f0565b16966001600160701b03610331856154d1565b169760405163d5ffe20960e01b8152886004820152606081602481865afa9889156105b05760805193608051926080519b6106ee575b508951895160405163fd32826f60e01b8152336004820152602481019490945260ff90911660448401526064830152909392919060209085908180608481015b0391608051905af19283156105b057608051936106b4575b61044094508389526001600160701b03602089015116926103ef82826001600160701b0360408d0151169761542c565b9c6103fc83828d5161542c565b9c60ff8d5116600381149081156106a9575b50610676575b505060ff8b51166002811490811561066b575b5061063f575b5050508911159081610634575b50614ef6565b8615801561062c575b610619575190811515918261060f575b5081156105f2575b506105df5761049f6101c0869201516104918660405194859363244195d360e01b60208601523360248601614d89565b03601f1981018352826145d9565b604051906348c8949160e01b825281806104bf6080519360048301614859565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b0576105bd575b506002548551906001600160a01b0316803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057610597575b50935193519051604080519283526020830185905282810184905260ff90911660608301529333917fc2be77b0137decbf54134864ee86b9011325f158d6c136bbd73e45dbb383cbe790608090a382519182526020820152f35b6080516105a3916145d9565b6080516101e4578561053d565b6040513d608051823e3d90fd5b6105da903d80608051833e6105d281836145d9565b810190614cb8565b6104fa565b63f262b62160e01b608051526004608051fd5b51801515915081610605575b5087610461565b90508410876105fe565b8710915088610459565b637435645360e11b608051526004608051fd5b508515610449565b90508711158a61043a565b6106489261542c565b808211156106615761065991614d7c565b8b808061042d565b5050608051610659565b60049150148f610427565b61068491849197939761542c565b8082111561069e5761069591614d7c565b935b8e80610414565b505060805193610697565b60049150145f61040e565b92506020843d6020116106e6575b816106cf602093836145d9565b810103126106e2576104409351926103bf565b5f80fd5b3d91506106c2565b61071c919b506103a7955060209294935060603d60601161072b575b61071481836145d9565b810190614d1b565b9b919593949093909250610367565b503d61070a565b9095506020813d60201161075e575b8161074e602093836145d9565b810103126106e25751948861030c565b3d9150610741565b61078891506102603d811161078e575b61078081836145d9565b81019061494d565b866102ae565b503d610776565b634e487b7160e01b6080515260416004526024608051fd5b346101e4576080513660031901126101e4576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101e45760203660031901126101e45761080c61432c565b61082260018060a01b03608051541633146148da565b600154906001600160a01b038216610854576001600160a01b03166001600160a01b0319919091161760015560805180f35b635f7c8ab560e11b608051526004608051fd5b346101e45760203660031901126101e45761088061432c565b6080515490610899336001600160a01b038416146148da565b60018060a01b031680916bffffffffffffffffffffffff60a01b161760805155337f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0608051608051a360805180f35b60a03660031901126101e4576108fc61432c565b604435906024359082151583036101e457600254604051632bc5fd8560e01b8152336004820152602481018490529360843592606435928392906102609088906001600160a01b03168180604481010391608051905af19687156105b05760805197610d99575b5060025460405163206a728560e21b8152979060609089906001600160a01b031681806109958a888860048501614b40565b03915afa9586156105b057608051988997610d60575b508215610d49576109ce6001600160701b03806080850151165b168a1115614ef6565b8015159081610d3f575b506105df576101c09115610d2257015180516020909101516001600160a01b03918216939116915b6080516001600160a01b038516958615610d00575b5080610c92575b50604051631aca73e160e11b60208201523360248201526001600160a01b03851660448201526064810192909252610a6182608481015b03601f1981018452836145d9565b604051916348c8949160e01b83528280610a816080519360048301614859565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19081156105b0576020928892610c78575b50610ae3896040519586948594636aa0852360e01b86523360048701614e6a565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b057610c49575b5082610b8c575b50506002546001600160a01b03169050803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057610b73575b602082604051908152f35b608051610b7f916145d9565b6080516101e45781610b68565b60025460405163096b565360e11b81526001600160a01b0392831660048201526024810194909452608051602092859260449284929091165af19182156105b05760805192610c15575b50604080515f81526020810193909352339284917f43473e5e46598b12a9d6961219fd5cf4e66ec4f6653d7206553a25c454687c8e91a4828080610b25565b9091506020813d602011610c41575b81610c31602093836145d9565b810103126106e257519084610bd6565b3d9150610c24565b6020813d602011610c70575b81610c62602093836145d9565b810103126106e25751610b1e565b3d9150610c55565b610c8d903d80608051833e6105d281836145d9565b610ac2565b8092509180341115610a1c5760805190819081908190610cb29034614d7c565b335af1610cbd615269565b5015610cc95788610a1c565b60405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606490fd5b8091503410610d0f5789610a15565b63044044a560e21b608051526004608051fd5b0151602081015190516001600160a01b0391821693911691610a00565b90508810896109d8565b6109ce6001600160701b03806060850151166109c5565b909650610d8691985060603d606011610d92575b610d7e81836145d9565b810190614b1e565b989190509795896109ab565b503d610d74565b610db39197506102603d811161078e5761078081836145d9565b9587610963565b346101e4576080513660031901126101e4576002546040516001600160a01b039091168152602090f35b346101e45760203660031901126101e457610dfd61432c565b610e1360018060a01b03608051541633146148da565b608080516001600160a01b039290921690915260036020525160408120805460ff1916600117905580f35b346101e4576080513660031901126101e4576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101e45760203660031901126101e4576001600160a01b03610ea561432c565b16608051526003602052602060ff60406080512054166040519015158152f35b346101e4576080513660031901126101e4576001546040516001600160a01b039091168152602090f35b346101e4576102c03660031901126101e457600435610f0d3661466f565b61028435916001600160a01b03831691908284036101e4576102a43591610f5e337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146148da565b608051604051627eeac760e11b81523060048201526024810186905290946001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929091602081604481875afa80156105b0578691608051916111a0575b5011610fd7575b6020866040519015158152f35b604051630ead1e7d60e01b815260808180610ff785893060048501614dce565b03817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa80156105b0578387936080519360805193611166575b506101c00151516001600160a01b03160361115f57505b101561105f575b80610fca565b6040516304ade6db60e11b815233600482015260248101919091526044810184905260805190945060209185916064918391905af19081156105b0576110ce946020946110b193611144575b506152dd565b604051637f4c824d60e11b81529384928392303360048601614ecc565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b057611117575b506020600182808080611059565b6111389060203d60201161113d575b61113081836145d9565b810190614b62565b611109565b503d611126565b61115a90863d881161113d5761113081836145d9565b6110ab565b9050611052565b90925061118c91935060803d608011611199575b61118481836145d9565b810190614e35565b949250905092918b61103b565b503d61117a565b9150506020813d6020116111cd575b816111bc602093836145d9565b810103126106e25785905189610fc3565b3d91506111af565b346101e457366003190160a081126101e4576001546111fe906001600160a01b031633146148da565b6002546001600160a01b0316803b156101e45760405163bfb9f86b60e01b8152916001600160a01b0361122f61432c565b1660048401526001600160a01b03611245614342565b16602484015260443562ffffff811693908481036101e45784604483015260805150606435908160020b938483036101e457606484018590526084356001600160a01b038116969094908786036101e4578760848301528160a48160805193608051905af180156105b057611370575b5060a0136101e457604051946112ca866145a0565b6004356001600160a01b038116969095908787036101e457868152602435906001600160a01b03821682036101e457602081019190915260408101849052606081810195909552608081019590955260a090942094507f3fd553db44f207b1f41348cfc4d251860814af9eadc470e8e7895e4d120511f49361134a614899565b9260805150506040519788526020880152604087015260018060a01b031694a460805180f35b60805161137c916145d9565b6080516101e457876112b5565b6103803660031901126101e45761139e61432c565b6113a73661466f565b610100366102831901126101e4576040516113c181614583565b6102843581526102a43580151581036101e457602082019081526102c4356001600160a01b03811681036101e45760408301908152606083016102e4358152608084019161030435835260a085019361032435855260c086019561034435875260e08101976103643589523360805152600360205260ff604060805120541615611565576040516335a033ff60e11b60208201526001600160a01b03909a1660248b01526114739060448b01906143ea565b516102a48901525115156102c4880152516001600160a01b03166102e487015251610304860152516103248501525161034484015251610364830152516103848083019190915281526114c86103a4826145d9565b604051906348c8949160e01b825281806114e86080519360048301614859565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19081156105b05760805191611549575b50602081519181808201938492010103126106e25760209051604051908152f35b61155f91503d80608051833e6105d281836145d9565b81611528565b63041fb8cb60e31b608051526004608051fd5b346101e45761158636614530565b6002546040516302ef145760e51b815260048101949094529192916001600160a01b031661026083602481845afa9384156105b0576115e99460609460805191611629575b50604051637987bed160e11b81529586948593849360048501614b40565b03915afa80156105b05760209160805191611608575b50604051908152f35b611621915060603d606011610d9257610d7e81836145d9565b5050826115ff565b61164291506102603d811161078e5761078081836145d9565b866115cb565b346101e4576104003660031901126101e45761166261432c565b61166a614342565b906102603660431901126101e45760405190611685826145bc565b60443563ffffffff811681036101e45782526064356001600160701b03811681036101e45760208301526084356001600160701b03811681036101e457604083015260a4356001600160701b03811681036101e457606083015260c4356001600160701b03811681036101e457608083015260e43562ffffff811681036101e45760a0830152610104356001600160701b03811681036101e45760c0830152610124356001600160701b03811681036101e45760e0830152610144356001600160701b03811681036101e457610100830152610164356001600160701b03811681036101e457610120830152610184356001600160701b03811681036101e4576101408301526101a4356001600160701b03811681036101e4576101608301526101c4356101808301526101e4356101a08301526117c5366102046145fb565b6101c0830152366102a3190161016081126101e45730330361225c57610100136101e4576040516117f581614583565b6102a43581526102c43580151581036101e45760208201526102e43562ffffff811681036101e45760408201526103043560608201526103243560808201526103443560a0820152610364356001600160a01b03811681036101e45760c08201526103843560e082015260208101511561223c576101c083015180516020909101516001600160a01b039081169491165b60805160608401516118ba90887f000000000000000000000000000000000000000000000000000000000000000089614f37565b6118ea6060850151307f000000000000000000000000000000000000000000000000000000000000000089615117565b604084015162ffffff1615612044575061191e60808385516040519384928392630ead1e7d60e01b84523060048501614dce565b03817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156105b057608051918291829182919061201f575b50602087015115801594906120175750925b1561200f5750945b611995606086015162ffffff60408801511690614e57565b809210611fd65760018060a01b03600254166119d0606084602089015115156040519384928392637987bed160e11b84528b60048501614b40565b0381855afa80156105b0576119f29160805191611fb5575b5080981015614df7565b60a0850151839062ffffff1680611fa65750506020600491604051928380926313ac42a760e01b82525afa9081156105b05760049160209160805191611f79575b5060405163b67df1c360e01b815292839182906001600160a01b03165afa80156105b057839160805191611f35575b50611a7791611a709161550f565b8093614d7c565b916020828a611a9e8951948c60405196879586956372a6b5df60e01b875260048701614e6a565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19081156105b05760805191611f03575b50975b82611e38575b855160608701516040516372a6b5df60e01b815299602095508a948594611b1394919060048701614e6a565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19485156105b05760805195611e04575b5082517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690611b8b90836152dd565b90803b156101e45760405191630d9778e560e11b835260048301528560248301528160448160805193608051905af180156105b057611deb575b506101c0820151516001600160a01b03918216911603611dbf57611bf66001600160701b0360608301511684614c8f565b906001600160701b03608082015116915b80611d2c575b5081611c87575b50506002549051906001600160a01b0316803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057611c6e575b5060609260405192835260208301526040820152f35b608051611c7a916145d9565b6080516101e45783611c58565b6020908351611cbc60018060a01b03846101c085015101511694604051958694859463c3edb7ff60e01b865260048601614e9c565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b057611cfd575b80611c14565b611d1e9060203d602011611d25575b611d1681836145d9565b810190614b7a565b5084611cf7565b503d611d0c565b83516101c08301515160405163c3edb7ff60e01b81529260209284928392611d659290916001600160a01b031690889060048601614e9c565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b05715611c0d57611db89060203d602011611d2557611d1681836145d9565b5086611c0d565b6001600160701b0360608201511690611de56001600160701b0360808301511685614c8f565b91611c07565b608051611df7916145d9565b6080516101e45786611bc5565b9094506020813d602011611e30575b81611e20602093836145d9565b810103126106e257519386611b53565b3d9150611e13565b60025460405163236668f160e11b81526001600160a01b038a811660048301526024820195909552608051909460209286926044928492165af180156105b05760805190611ed0575b865160408051600181526020818101949094529295506001600160a01b0384811693908c1692917f43473e5e46598b12a9d6961219fd5cf4e66ec4f6653d7206553a25c454687c8e91a4611ae7565b506020833d602011611efb575b81611eea602093836145d9565b810103126106e25760209251611e81565b3d9150611edd565b90506020813d602011611f2d575b81611f1e602093836145d9565b810103126106e2575189611ade565b3d9150611f11565b9150506020813d602011611f71575b81611f51602093836145d9565b810103126101e457611a7083611f69611a7793614929565b915091611a62565b3d9150611f44565b611f999150823d8411611f9f575b611f9181836145d9565b810190614b89565b8b611a33565b503d611f87565b611a77925090611a709161550f565b611fce915060603d606011610d9257610d7e81836145d9565b50508b6119e8565b60405162461bcd60e51b815260206004820152601160248201527009a82a48e929cbe9c9ea8be8a9c9eaa8e9607b1b6044820152606490fd5b90509461197d565b905092611975565b9250505061203c915060803d6080116111995761118481836145d9565b90918a611963565b612059602085015115606086015190856151dd565b602085015115612229576001600160701b036020850151165b6001600160701b03818116601402908116036122115760646001600160701b0391821660140282160416906103c4359062ffffff8216908183036101e4576120ba925061530d565b908082101561220a57505b6080850151801561220357808210156121fc57505b945b6120ff604085875182519384928392630352520960e61b84523060048501614dce565b03817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa80156105b0576080516121589289928291906121cb575b506020890151156121c457505b1015614df7565b85612167575b60805197611ae1565b61219386307f0000000000000000000000000000000000000000000000000000000000000000866150b2565b6121bf86897f000000000000000000000000000000000000000000000000000000000000000086615165565b61215e565b9050612151565b90506121ef915060403d6040116121f5575b6121e781836145d9565b810190614db8565b8c612144565b503d6121dd565b90506120da565b50946120dc565b90506120c5565b634e487b7160e01b6080515260116004526024608051fd5b6001600160701b03604085015116612072565b6101c0830151602081015190516001600160a01b03908116949116611886565b6314e1dbf760e11b608051526004608051fd5b346101e45760203660031901126101e4576002546040516302ef145760e51b815260048035908201529061026090829060249082906001600160a01b03165afa80156105b057604091608051916122eb575b506001600160701b036122de816122d7846154f0565b16926154d1565b1682519182526020820152f35b61230491506102603d811161078e5761078081836145d9565b826122c1565b346101e45760203660031901126101e45760043567ffffffffffffffff81116101e457366023820112156101e45780600401359067ffffffffffffffff82116101e45736602483830101116101e4577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036123a9576123a59160246123999201615298565b60405191829182614859565b0390f35b63570c108560e11b608051526004608051fd5b346101e4576080513660031901126101e457608051546040516001600160a01b039091168152602090f35b346101e45760203660031901126101e45761240061432c565b61241660018060a01b03608051541633146148da565b608080516001600160a01b039290921690915260036020525160408120805460ff1916905580f35b6101003660031901126101e4576124594260e4351015614d36565b600254604051632bc5fd8560e01b8152336004808301919091523560248201819052608051919290916102609184916044918391906001600160a01b03165af19182156105b05760805192612ada575b50600160ff6124b6614d6c565b161180612ac1575b612aae576101c082018051519092906001600160a01b03161580612aa2575b610d0f5760405163db620f4f60e01b815260048101839052917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316602084602481845afa9384156105b05760805194612a6e575b50604051627eeac760e11b81523060048201526024810185905294602086604481855afa9586156105b05760805196612a3a575b506044359560243595906001600160701b036125938161258c896154f0565b16976154d1565b169786151580612a31575b15612a0e576125ae878a8a61542c565b908082116129995750608435811061295d576125d990986125d289985b848a61542c565b928a61542c565b8082101561295657505b955b85811180612943575b6127ee575b5085156127db57612602614d6c565b833b156101e45760405163c97a1c3f60e01b8152608051336004830152602482019390935260ff9091166044820152606481018790529283908180608481010391608051905af19182156105b05784926127bd575b5061267e9051610491876040519485936303bb73b760e11b60208601523360248601614d89565b604051906348c8949160e01b8252818061269e6080519360048301614859565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b0576127a3575b506002546001600160a01b0316803b156101e45760405190638b14724560e01b82528260048301528160248160805193608051905af180156105b05761278a575b5060c4356001600160a01b03811691908281036101e4576020957fdca088c2fe7922b62f9f0baee7a00b0de372311b1be3abea418c21f93dbc4a6d915061275f614d6c565b60408051888152602081019790975286019190915260ff1660608501523393608090a4604051908152f35b608051612796916145d9565b6080516101e4578461271a565b6127b8903d80608051833e6105d281836145d9565b6126d9565b6127cc919250608051906145d9565b6080516101e457829086612657565b633489be7560e21b608051526004608051fd5b8251516001600160a01b031690612806908790614d7c565b9080612886575060805190819081908190335af115612826575b876125f3565b601f19601f3d0116604051906390bfb86560e01b82523360048301526080516024830152608060448301528060a00160648301523d60848301523d60805160a484013e808201600460a482015260c4633d2cec6f60e21b91015260e40190fd5b906040519063a9059cbb60e01b825233600483015260248201526020608051604483608051865af13d15601f3d116001608051511416171690608051815260805160208201526040608051910152156128df5750612820565b601f19601f3d0116604051916390bfb86560e01b8352600483015263a9059cbb60e01b6024830152608060448301528060a00160648301523d60848301523d60805160a484013e808201600460a482015260c4633c9fd93960e21b91015260e40190fd5b508251516001600160a01b0316156125ee565b90506125e3565b60405162461bcd60e51b8152602060048201526014602482015273494e53554646494349454e545f414d4f554e543160601b6044820152606490fd5b969890506129a8818a8961542c565b9060643582101580612a04575b156129c8576125d26125d992989a6125cb565b60405162461bcd60e51b81526020600482015260146024820152730494e53554646494349454e545f414d4f554e54360641b6044820152606490fd5b50818910156129b5565b87612a2893989950819750612a239250614e57565b61552c565b948694966125e5565b5088151561259e565b9095506020813d602011612a66575b81612a56602093836145d9565b810103126106e25751948661256d565b3d9150612a49565b9093506020813d602011612a9a575b81612a8a602093836145d9565b810103126106e257519285612539565b3d9150612a7d565b503460243514156124dd565b6348adeb2160e11b608051526004608051fd5b50610bb862ffffff60406101c0850151015116106124be565b612af49192506102603d811161078e5761078081836145d9565b90826124a9565b346101e4576104916114c8612b0f366144f6565b909390612b2d6001600160a01b03612b25614ba8565b1633146148da565b6040516364d2756f60e01b60208201526001600160a01b039384166024820152949092166044850152606484019190915282906084820190565b6103e03660031901126101e457612b7c61432c565b612b853661466f565b3661028319019061016082126101e45761010060405192612ba584614553565b126101e457604051612bb681614583565b6102843581526102a43580151581036101e45760208201526102c43562ffffff811681036101e45760408201526102e43560608201526103043560808201526103243560a0820152610344356001600160a01b03811681036101e45760c08201526103643560e082015282526103843560208301908152906103a43562ffffff811681036101e45760408401526103c4356001600160a01b03811681036101e4576060840152604051612c6881614553565b604051612c7481614583565b6080518152608051602082015260805160408201526080516060820152608051608082015260805160a082015260805160c082015260805160e082015281526080516020820152608051604082015260606080519101523360805152600360205260ff604060805120541615611565576040516357da13db60e11b60208201523360248201526001600160a01b039094166044850152612d189060648501906143ea565b612d266102c48401836147ce565b6104048352612d37610424846145d9565b604051926348c8949160e01b84528380612d576080519360048301614859565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af180156105b057612db06060916101609560805191612dcc575b5060208082518301019101614d1b565b91938551926080840152520152612dca60405180926147ce565bf35b612de291503d80608051833e6105d281836145d9565b86612da0565b346101e4576103803660031901126101e457612e0261432c565b612e0b3661466f565b610100366102831901126101e45730330361225c57612e28614aea565b156137f9576101c081015180516020909101516001600160a01b0390811693911691905b61030435936103243580156137ab578515613790575b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031691612e956148af565b6001830180931161221157833b156101e457604051630bbc0f5760e01b81526001600160a01b03958616600482015294166024850152610284356044850152612ee160648501866143ea565b6001600160a01b03166102c48401526102e483015260805190829061030490829084905af180156105b057613777575b505b6102843591612f2283826152dd565b60408051637a94c56560e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301819052602483018590526102e43560448401819052967f000000000000000000000000000000000000000000000000000000000000000090921695939092919082806064810103816080518a5af19182156105b0576080519060805193613753575b5082612fcc91614c8f565b956080518a1261351057608051881261351057878a038a8113600116612211578a89146136a7576080519661305692918891908c908381131561369857809a5b60408051633a43e9f760e01b8152977f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031694899182918c903060048501614dce565b0381865afa80156105b0576130c88d6130c2996130cf936080519160805191613677575b50613083614aea565b1561367057505b613092614aea565b1561364a576001600160701b036130b88d826101008160c08401511692015116906154b1565b169a8b8092614c8f565b9161542c565b809d614d7c565b91608051125f146135f6576130e2614aea565b156135d75750608051811261351057925b6080518b12613510578d9a935b80158015906135ce575b61353c575b505050816131a1575b505050505050506080905f805160206156ca83398151915292935b60408051968752602087018990528601526103443560608601526001600160a01b031693a36002546001600160a01b0316803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057610b7357602082604051908152f35b909192939495809998503b156101e45760405190636cf95b2960e01b82526004820152816024820152608051816044816080518d5af180156105b057613523575b50608051851261351057848101948512906080511390801582169115161761221157889160805185135f146132c85750506040516304ade6db60e11b81526001600160a01b0396871660048201529584166024870152505060448401529091906020828060648101038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19081156105b05785935f805160206156ca833981519152936080936132a9575b505b9392819289808080613118565b6132c19060203d60201161113d5761113081836145d9565b508861329a565b9092969195936132d790614afa565b90816132fc575b505050505f805160206156ca8339815191529293509060809161329c565b9295509091808210156135085750935b84613315614aea565b156134f4576001600160701b038060c0890151165b169080821061345c575050604051637f4c824d60e11b81529460209086908190613363906001600160a01b038916308860048601614ecc565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19485156105b057889561343f575b50608051915b826133b3575b806132de565b6133ed95506133cd60a06101c060209699015120866152dd565b604051637f4c824d60e11b81529687948593849390309060048601614ecc565b0391608051905af19081156105b05785935f805160206156ca83398151915293608093613420575b8594829394506133ad565b6134389060203d60201161113d5761113081836145d9565b5088613415565b6134579060203d60201161113d5761113081836145d9565b6133a1565b604051637f4c824d60e11b815296509060208780613489846001600160a01b038b16308a60048601614ecc565b038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19182156105b0578a976134d1936134d7575b50614d7c565b916133a7565b6134ef9060203d60201161113d5761113081836145d9565b6134cb565b6001600160701b038060e08901511661332a565b90509361330c565b6393dafdf160e01b608051526004608051fd5b60805161352f916145d9565b6080516101e4578b6131e2565b613545886154f0565b9b61354f896154d1565b906040519d8e9163ed4ed80b60e01b835260048301526001600160701b031690602401526001600160701b031660448d015260648c015260848b01528960805191815a9360a492602095f19889156105b0578c996135af575b808061310f565b6135c79060203d602011611d2557611d1681836145d9565b508d6135a8565b5081151561310a565b93506080518112156130f3576393dafdf160e01b608051526004608051fd5b6135fe614aea565b15613631575060805181126135105761361690614afa565b925b6080518b126135105761362b8e9b614afa565b93613100565b935060805181126135105761364590614afa565b613618565b6001600160701b0361366b8d826101208160e08401511692015116906154b1565b6130b8565b905061308a565b9050613692915060403d6040116121f5576121e781836145d9565b5f61307a565b6136a181614afa565b9a61300c565b50506040516304ade6db60e11b81526001600160a01b039384166004820152928416602484015250604482015291506020828060648101038160805160018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af19081156105b05785935f805160206156ca83398151915293608093613734575b50613133565b61374c9060203d60201161113d5761113081836145d9565b508861372e565b612fcc9350613771915060403d6040116121f5576121e781836145d9565b92612fc1565b608051613783916145d9565b6080516101e45783612f11565b94506137a58561379e614aea565b15856151dd565b94612e62565b5050508215612f13576137f4837f00000000000000000000000000000000000000000000000000000000000000006137ec826137e56148af565b8388614f37565b309085615117565b612f13565b6101c0810151602081015190516001600160a01b039081169391169190612e4c565b346101e457613829366144f6565b909130330361225c5760025460405163ba65fb1560e01b81526001600160a01b0385811660048301526024820194909452608051909360209285926044928492165af19182156105b057608051926138c0575b50816138b8916020947f0000000000000000000000000000000000000000000000000000000000000000906138b3843084846150b2565b615165565b604051908152f35b9091506020813d6020116138ed575b816138dc602093836145d9565b810103126106e2575190602061387c565b3d91506138cf565b346101e4576080513660031901126101e4576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346101e45760203660031901126101e457613954614bfb565b506002546040516302ef145760e51b815260048035908201529061026090829060249082906001600160a01b03165afa80156105b05761026091608051916139a5575b50612dca60405180926143ea565b6139bc9150823d811161078e5761078081836145d9565b82613997565b346101e4576139d036614530565b6002546040516302ef145760e51b815260048101949094529192916001600160a01b031661026083602481845afa9384156105b0576115e99460609460805191613a33575b5060405163206a728560e21b81529586948593849360048501614b40565b613a4c91506102603d811161078e5761078081836145d9565b86613a15565b346101e457613a60366144f6565b9030330361225c57613aa092613a99837f0000000000000000000000000000000000000000000000000000000000000000928385614f37565b3091615117565b60805180f35b346101e45760403660031901126101e457613abf61432c565b613ac7614bfb565b503360805152600360205260ff60406080512054161561156557600254604051632bc5fd8560e01b81526001600160a01b039283166004820152602480359082015260805190926102609284926044928492165af180156105b05761026091608051916139a55750612dca60405180926143ea565b346106e257613b4a3661436c565b919290303303613c80576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081811695909291613b8d826148c6565b16863b156106e257604051637a94c56560e11b81523060048201526024810191909152604481018390525f81606481838b5af18015613c7557613c61575b5060208101956001600160a01b03613be2886148c6565b16813b156101e457604051637a94c56560e11b81526080805130600484015260248301939093526044820189905251909283916064918391905af180156105b057613c44575b5094613c3f6138b39285856138b3613aa09a6148c6565b6148c6565b608051919691613c53916145d9565b6080516101e4579486613c28565b5f613c6b916145d9565b5f60805286613bcb565b6040513d5f823e3d90fd5b6314e1dbf760e11b5f5260045ffd5b346106e2575f3660031901126106e2576020613ca9614ba8565b6040516001600160a01b039091168152f35b346106e25760203660031901126106e2576004356001600160a01b038116908190036106e257613cf560018060a01b035f541633146148da565b6002546001600160a01b038116613d16576001600160a01b03191617600255005b630d43628160e31b5f5260045ffd5b346106e2576101203660031901126106e257613d3f61432c565b60a03660231901126106e25760603660c31901126106e2576001546001600160a01b0316613d6e3382146148da565b604051613d7a816145a0565b6024356001600160a01b03811681036106e25781526044356001600160a01b03811681036106e257602082015260643562ffffff811681036106e25760408201526084358060020b81036106e257606082015260a435906001600160a01b03821682036106e257608081019190915260a090206002546040516302ef145760e51b81526004810183905291906001600160a01b031661026083602481845afa928315613c75575f93614282575b5060e4355f81129384613e38614adb565b15150361425e57613e47614899565b95613e50614883565b925b861561425857613e6190614afa565b935b8615614150575050606083613ea49260018060a01b036002541690613e86614adb565b60405163206a728560e21b8152958694859384939060048501614b40565b03915afa938415613c75575f945f925f91614129575b5060015460405163426a849360e01b81526001600160a01b03918216600482015290851660248201526044810187905292969092602081806064810103815f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af18015613c755761410a575b505b82613fde575b60a080997f9eb28ec873feb86f8f76c2d80034e39d1f684febd8b002b9798e739ab5644a9b92613f66614adb565b151503613fd157869462ffffff899a5b613f7e614adb565b9b604051988952602089015216998a6040880152151560608701526080860152600180831b031693a360405194600180881b03168552600180871b03166020850152604084015260608301526080820152f35b879462ffffff889a613f76565b5f92613fe8614adb565b84146140f7576020614038613ffb614899565b925b60025460405163096b565360e11b81526001600160a01b03868116600483015260248201939093529788939190921691839182906044820190565b03925af1938415613c75575f946140c2575b50604080515f81526020810186905260a09b7f9eb28ec873feb86f8f76c2d80034e39d1f684febd8b002b9798e739ab5644a9b948d94919390926001600160a01b0380861693169188917f43473e5e46598b12a9d6961219fd5cf4e66ec4f6653d7206553a25c454687c8e9190a49250995050613f38565b9093506020813d6020116140ef575b816140de602093836145d9565b810103126106e257519260a061404a565b3d91506140d1565b6020614038614104614883565b92613ffd565b6141229060203d60201161113d5761113081836145d9565b5089613f30565b91955050614146915060603d606011610d9257610d7e81836145d9565b9194909189613eba565b8460609161418194614163989498614adb565b604051637987bed160e11b8152968794859384939060048501614b40565b03915afa958615613c75575f965f935f9161422e575b5060405163426a849360e01b81526001600160a01b039788166004820152968916602488015260448701869052929695602081806064810103815f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af18015613c755761420f575b50613f32565b6142279060203d60201161113d5761113081836145d9565b5089614209565b6020985086945061424e915060603d606011610d9257610d7e81836145d9565b9198909450614197565b93613e63565b614266614883565b9561426f614899565b6001600160a01b03978816971692613e52565b61429c9193506102603d811161078e5761078081836145d9565b9185613e27565b346106e2576142b13661436c565b919290303303613c80576143208360208661430f6142d161432a996148c6565b956142ff81897f0000000000000000000000000000000000000000000000000000000000000000809a614f37565b308761430a856148c6565b615117565b01938361431b866148c6565b614f37565b61430a30926148c6565b005b600435906001600160a01b03821682036106e257565b602435906001600160a01b03821682036106e257565b35906001600160a01b03821682036106e257565b906101006003198301126106e2576004356001600160a01b03811681036106e25760a0909260231901126106e25760249060c4359060e43590565b80516001600160a01b03908116835260208083015182169084015260408083015162ffffff169084015260608083015160020b9084015260809182015116910152565b906101c0806144f49363ffffffff81511684526001600160701b0360208201511660208501526001600160701b0360408201511660408501526001600160701b0360608201511660608501526001600160701b03608082015116608085015262ffffff60a08201511660a08501526001600160701b0360c08201511660c08501526001600160701b0360e08201511660e08501526001600160701b03610100820151166101008501526001600160701b03610120820151166101208501526001600160701b03610140820151166101408501526001600160701b03610160820151166101608501526101808101516101808501526101a08101516101a085015201519101906143a7565b565b60609060031901126106e2576004356001600160a01b03811681036106e257906024356001600160a01b03811681036106e2579060443590565b60609060031901126106e2576004359060243580151581036106e2579060443590565b6080810190811067ffffffffffffffff82111761456f57604052565b634e487b7160e01b5f52604160045260245ffd5b610100810190811067ffffffffffffffff82111761456f57604052565b60a0810190811067ffffffffffffffff82111761456f57604052565b6101e0810190811067ffffffffffffffff82111761456f57604052565b90601f8019910116810190811067ffffffffffffffff82111761456f57604052565b91908260a09103126106e257604051614613816145a0565b809261461e81614358565b825261462c60208201614358565b6020830152604081013562ffffff811681036106e25760408301526060810135908160020b82036106e257608061466a918193606086015201614358565b910152565b906102606023198301126106e257604051614689816145bc565b809260243563ffffffff811681036106e25782526044356001600160701b03811681036106e25760208301526064356001600160701b03811681036106e25760408301526084356001600160701b03811681036106e257606083015260a4356001600160701b03811681036106e257608083015260c43562ffffff811681036106e25760a083015260e4356001600160701b03811681036106e25760c0830152610104356001600160701b03811681036106e25760e0830152610124356001600160701b03811681036106e257610100830152610144356001600160701b03811681036106e257610120830152610164356001600160701b03811681036106e257610140830152610184356001600160701b03811681036106e2576101c09161466a916101608501526101a4356101808501526101c4356101a08501526101e46145fb565b6101409060e081518051855260208101511515602086015262ffffff6040820151166040860152606081015160608601526080810151608086015260a081015160a086015260018060a01b0360c08201511660c0860152015160e0840152602081015161010084015262ffffff604082015116610120840152606060018060a01b0391015116910152565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b6044356001600160a01b03811681036106e25790565b6024356001600160a01b03811681036106e25790565b6102c4356001600160a01b03811681036106e25790565b356001600160a01b03811681036106e25790565b156148e157565b60405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606490fd5b51906001600160701b03821682036106e257565b519062ffffff821682036106e257565b51906001600160a01b03821682036106e257565b8091039061026082126106e25760405191614967836145bc565b81519063ffffffff821682036106e25760a091845261498860208401614915565b602085015261499960408401614915565b60408501526149aa60608401614915565b60608501526149bb60808401614915565b60808501526149cb828401614929565b828501526149db60c08401614915565b60c08501526149ec60e08401614915565b60e08501526149fe6101008401614915565b610100850152614a116101208401614915565b610120850152614a246101408401614915565b610140850152614a376101608401614915565b6101608501526101808301516101808501526101a08301516101a08501526101bf1901126106e25760405190614a6c826145a0565b614a796101c08201614939565b8252614a886101e08201614939565b6020830152614a9a6102008201614929565b6040830152610220810151908160020b82036106e257606083019190915261024001516001600160a01b03811681036106e25760808201526101c082015290565b60c43580151581036106e25790565b6102a43580151581036106e25790565b600160ff1b8114614b0a575f0390565b634e487b7160e01b5f52601160045260245ffd5b908160609103126106e2578051916040614b3a60208401614929565b92015190565b61028091949392614b56826102a08101976143ea565b15156102608201520152565b908160209103126106e2575180151581036106e25790565b908160209103126106e2575190565b908160209103126106e257516001600160a01b03811681036106e25790565b6002546040516313ac42a760e01b815290602090829060049082906001600160a01b03165afa908115613c75575f91614bdf575090565b614bf8915060203d602011611f9f57611f9181836145d9565b90565b60405190614c08826145bc565b815f81525f60208201525f60408201525f60608201525f60808201525f60a08201525f60c08201525f60e08201525f6101008201525f6101208201525f6101408201525f6101608201525f6101808201525f6101a08201526101c060405191614c70836145a0565b5f83525f60208401525f60408401525f60608401525f60808401520152565b91908201809211614b0a57565b67ffffffffffffffff811161456f57601f01601f191660200190565b6020818303126106e25780519067ffffffffffffffff82116106e2570181601f820112156106e257805190614cec82614c9c565b92614cfa60405194856145d9565b828452602083830101116106e257815f9260208093018386015e8301015290565b908160609103126106e2578051916040602083015192015190565b15614d3d57565b60405162461bcd60e51b81526020600482015260076024820152661156141254915160ca1b6044820152606490fd5b60a43560ff811681036106e25790565b91908203918211614b0a57565b6001600160a01b039091168152610100810194939260e092614daf9060208401906143a7565b60c08201520152565b91908260409103126106e2576020825192015190565b6001600160a01b03909116815260208101919091526102a0810192916144f491604001906143ea565b15614dfe57565b60405162461bcd60e51b815260206004820152600f60248201526e09a92a4a49ea4bea89e9ebe9aaa869608b1b6044820152606490fd5b91908260809103126106e2578151916020810151916060604083015192015190565b81810292918115918404141715614b0a57565b6001600160a01b0391821681529181166020830152604082019290925291166060820152608081019190915260a00190565b90949392614eb96102a0936102c0840197845260208401906143ea565b6001600160a01b03166102808201520152565b6001600160a01b039182168152911660208201526040810191909152606081019190915260800190565b15614efd57565b60405162461bcd60e51b81526020600482015260126024820152714e4f545f454e4f5547485f5245534552564560701b6044820152606490fd5b6001600160a01b0316929183614f945750604051630476982d60e21b81529250602091839160049183916001600160a01b03165af18015613c7557614f795750565b614f919060203d602011611d2557611d1681836145d9565b50565b916001600160a01b0390911690813b156106e257604051632961046560e21b815260048101859052925a935f816024818388819af18015613c7557615097575b509293849360209392916001600160a01b03909116903082146150595761502992604051926323b872dd60e01b8785015260248401528460448401526064830152606482526150246084836145d9565b615671565b600460405180958193630476982d60e21b83525af190811561504d5750614f795750565b604051903d90823e3d90fd5b60405163a9059cbb60e01b868201526001600160a01b038516602482015260448101939093526150929291506150248260648101610a53565b615029565b602093929194505f6150a8916145d9565b5f93909192614fd4565b9192906001600160a01b0316803b156106e257604051637a94c56560e11b81526001600160a01b03948516600482015293909216602484015260448301525f908290818381606481015b03925af18015613c755761510d5750565b5f6144f4916145d9565b9192906001600160a01b0316803b156106e257604051630ab714fb60e11b81526001600160a01b03948516600482015293909216602484015260448301525f908290818381606481016150fc565b91906001600160a01b0316803b156106e257604051630b0d9c0960e01b81526001600160a01b03938416600482015291909216602482015260448101929092525f908290606490829084905af18015613c755761510d5750565b81156151c9570490565b634e487b7160e01b5f52601260045260245ffd5b61523290614bf893925f14615238576001600160701b0361522b81615223615204856154f0565b9662ffffff60406101c0615217896154d1565b985b015101511661550f565b931683614e57565b9316614c8f565b906151bf565b6001600160701b0361522b81615223615250856154d1565b9662ffffff60406101c0615263896154f0565b98615219565b3d15615293573d9061527a82614c9c565b9161528860405193846145d9565b82523d5f602084013e565b606090565b5f9182918160405192839283378101838152039082305af1906152b9615269565b916144f457508051156152ce57602081519101fd5b6314815f4760e31b5f5260045ffd5b604080516001600160a01b03909216602083019081528282019390935281526153076060826145d9565b51902090565b90620f42408202905f19620f424084099282808510940393808503941461539d578382111561538e57620f4240829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b63227bc15360e01b5f5260045ffd5b5090614bf892506151bf565b9190915f838202915f198582099183808410930392808403931461541e5782620f4240111561540f57507fde8f6cefed634549b62c77574f722e1ac57e23f24d8fd5cb790fb65668c261399394620f4240910990828211900360fa1b910360061c170290565b63227bc15360e01b8152600490fd5b505050620f42409192500490565b9091828202915f19848209938380861095039480860395146154a4578483111561538e57829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b505090614bf892506151bf565b906001600160701b03809116911601906001600160701b038211614b0a57565b614bf8906001600160701b0360808160408401511692015116906154b1565b614bf8906001600160701b0360608160208401511692015116906154b1565b62ffffff16620f424003620f42408111614b0a57614bf8916153a9565b801561566c576155fa6001825f908460801c80615660575b508060401c80615653575b508060201c80615646575b508060101c80615639575b508060081c8061562c575b508060041c8061561f575b508060021c80615612575b50821c61560b575b811c1b61559b81846151bf565b0160011c6155a981846151bf565b0160011c6155b781846151bf565b0160011c6155c581846151bf565b0160011c6155d381846151bf565b0160011c6155e181846151bf565b0160011c6155ef81846151bf565b0160011c80926151bf565b80821015615606575090565b905090565b810161558e565b600291509101905f615586565b600491509101905f61557b565b600891509101905f615570565b601091509101905f615565565b602091509101905f61555a565b604091509101905f61554f565b9150506080905f615544565b505f90565b905f602091828151910182855af115613c75575f513d6156c057506001600160a01b0381163b155b6156a05750565b635274afe760e01b5f9081526001600160a01b0391909116600452602490fd5b6001141561569956fe1d9d1025f06575cd23c8334c2f057422670381e5e2513b4a4bd6ecc63f649d4fa26469706673582212207ac8cec8c3f7a138721c41bf0e8d69d64d6e9f72d25e4f6cb2b27fdabda202db64736f6c634300081a00330000000000000000000000004945b4d356edc02caab24d2407e87962696426730000000000000000000000001f984000000000000000000000000000000000040000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb350000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b
Deployed Bytecode
0x60a06040526004361015610011575f80fd5b5f6080525f3560e01c80630776e76e146142a357806309d1b44814613d2557806312bd6d9e14613cbb57806313ac42a714613c8f578063244195d314613b3c5780632bc5fd8514613aa65780633594e7c214613a525780635be39ae8146139c25780635de28ae01461393b5780635e6263eb146138f557806364d2756f1461381b5780636b4067fe14612de85780638072e28b14612b675780638161b87414612afb5780638461d8671461243e5780638a05a2e6146123e75780638da5cb5b146123bc57806391dd73461461230a578063a4a9e9881461226f578063afb427b614611648578063b447325914611578578063bb4dab6d14611389578063bfb9f86b146111d5578063c3edb7ff14610eef578063cd7033c414610ec5578063d8d232a214610e84578063dc4c90d314610e3e578063e2f0ab0114610de4578063e86cb2be14610dba578063ee7a3dc6146108e8578063f2fde38b14610867578063fb63daa1146107f3578063fb6b0e67146107ad578063fea9d06a146101ea5763ffcd9d161461019e575f80fd5b346101e4576080513660031901126101e4576040517f0000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac6001600160a01b03168152602090f35b60805180fd5b346101e45760c03660031901126101e45760405160c0810167ffffffffffffffff81118282101761079557604052600435815260243560ff811681036101e4576020820190815260408201906044358252606083019060643582526080840192608435845261026360a4358060a0880152421115614d36565b6002548551604051632bc5fd8560e01b81523360048201526024810191909152608051909161026091839160449183916001600160a01b03165af19081156105b05760805191610766575b50855160405163db620f4f60e01b815260048101919091527f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b03169590946020866024818a5afa9586156105b05760805196610732575b506001600160701b0361031e846154f0565b16966001600160701b03610331856154d1565b169760405163d5ffe20960e01b8152886004820152606081602481865afa9889156105b05760805193608051926080519b6106ee575b508951895160405163fd32826f60e01b8152336004820152602481019490945260ff90911660448401526064830152909392919060209085908180608481015b0391608051905af19283156105b057608051936106b4575b61044094508389526001600160701b03602089015116926103ef82826001600160701b0360408d0151169761542c565b9c6103fc83828d5161542c565b9c60ff8d5116600381149081156106a9575b50610676575b505060ff8b51166002811490811561066b575b5061063f575b5050508911159081610634575b50614ef6565b8615801561062c575b610619575190811515918261060f575b5081156105f2575b506105df5761049f6101c0869201516104918660405194859363244195d360e01b60208601523360248601614d89565b03601f1981018352826145d9565b604051906348c8949160e01b825281806104bf6080519360048301614859565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af180156105b0576105bd575b506002548551906001600160a01b0316803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057610597575b50935193519051604080519283526020830185905282810184905260ff90911660608301529333917fc2be77b0137decbf54134864ee86b9011325f158d6c136bbd73e45dbb383cbe790608090a382519182526020820152f35b6080516105a3916145d9565b6080516101e4578561053d565b6040513d608051823e3d90fd5b6105da903d80608051833e6105d281836145d9565b810190614cb8565b6104fa565b63f262b62160e01b608051526004608051fd5b51801515915081610605575b5087610461565b90508410876105fe565b8710915088610459565b637435645360e11b608051526004608051fd5b508515610449565b90508711158a61043a565b6106489261542c565b808211156106615761065991614d7c565b8b808061042d565b5050608051610659565b60049150148f610427565b61068491849197939761542c565b8082111561069e5761069591614d7c565b935b8e80610414565b505060805193610697565b60049150145f61040e565b92506020843d6020116106e6575b816106cf602093836145d9565b810103126106e2576104409351926103bf565b5f80fd5b3d91506106c2565b61071c919b506103a7955060209294935060603d60601161072b575b61071481836145d9565b810190614d1b565b9b919593949093909250610367565b503d61070a565b9095506020813d60201161075e575b8161074e602093836145d9565b810103126106e25751948861030c565b3d9150610741565b61078891506102603d811161078e575b61078081836145d9565b81019061494d565b866102ae565b503d610776565b634e487b7160e01b6080515260416004526024608051fd5b346101e4576080513660031901126101e4576040517f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b03168152602090f35b346101e45760203660031901126101e45761080c61432c565b61082260018060a01b03608051541633146148da565b600154906001600160a01b038216610854576001600160a01b03166001600160a01b0319919091161760015560805180f35b635f7c8ab560e11b608051526004608051fd5b346101e45760203660031901126101e45761088061432c565b6080515490610899336001600160a01b038416146148da565b60018060a01b031680916bffffffffffffffffffffffff60a01b161760805155337f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0608051608051a360805180f35b60a03660031901126101e4576108fc61432c565b604435906024359082151583036101e457600254604051632bc5fd8560e01b8152336004820152602481018490529360843592606435928392906102609088906001600160a01b03168180604481010391608051905af19687156105b05760805197610d99575b5060025460405163206a728560e21b8152979060609089906001600160a01b031681806109958a888860048501614b40565b03915afa9586156105b057608051988997610d60575b508215610d49576109ce6001600160701b03806080850151165b168a1115614ef6565b8015159081610d3f575b506105df576101c09115610d2257015180516020909101516001600160a01b03918216939116915b6080516001600160a01b038516958615610d00575b5080610c92575b50604051631aca73e160e11b60208201523360248201526001600160a01b03851660448201526064810192909252610a6182608481015b03601f1981018452836145d9565b604051916348c8949160e01b83528280610a816080519360048301614859565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af19081156105b0576020928892610c78575b50610ae3896040519586948594636aa0852360e01b86523360048701614e6a565b038160805160018060a01b037f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35165af180156105b057610c49575b5082610b8c575b50506002546001600160a01b03169050803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057610b73575b602082604051908152f35b608051610b7f916145d9565b6080516101e45781610b68565b60025460405163096b565360e11b81526001600160a01b0392831660048201526024810194909452608051602092859260449284929091165af19182156105b05760805192610c15575b50604080515f81526020810193909352339284917f43473e5e46598b12a9d6961219fd5cf4e66ec4f6653d7206553a25c454687c8e91a4828080610b25565b9091506020813d602011610c41575b81610c31602093836145d9565b810103126106e257519084610bd6565b3d9150610c24565b6020813d602011610c70575b81610c62602093836145d9565b810103126106e25751610b1e565b3d9150610c55565b610c8d903d80608051833e6105d281836145d9565b610ac2565b8092509180341115610a1c5760805190819081908190610cb29034614d7c565b335af1610cbd615269565b5015610cc95788610a1c565b60405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606490fd5b8091503410610d0f5789610a15565b63044044a560e21b608051526004608051fd5b0151602081015190516001600160a01b0391821693911691610a00565b90508810896109d8565b6109ce6001600160701b03806060850151166109c5565b909650610d8691985060603d606011610d92575b610d7e81836145d9565b810190614b1e565b989190509795896109ab565b503d610d74565b610db39197506102603d811161078e5761078081836145d9565b9587610963565b346101e4576080513660031901126101e4576002546040516001600160a01b039091168152602090f35b346101e45760203660031901126101e457610dfd61432c565b610e1360018060a01b03608051541633146148da565b608080516001600160a01b039290921690915260036020525160408120805460ff1916600117905580f35b346101e4576080513660031901126101e4576040517f0000000000000000000000001f984000000000000000000000000000000000046001600160a01b03168152602090f35b346101e45760203660031901126101e4576001600160a01b03610ea561432c565b16608051526003602052602060ff60406080512054166040519015158152f35b346101e4576080513660031901126101e4576001546040516001600160a01b039091168152602090f35b346101e4576102c03660031901126101e457600435610f0d3661466f565b61028435916001600160a01b03831691908284036101e4576102a43591610f5e337f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb356001600160a01b0316146148da565b608051604051627eeac760e11b81523060048201526024810186905290946001600160a01b037f0000000000000000000000001f9840000000000000000000000000000000000416929091602081604481875afa80156105b0578691608051916111a0575b5011610fd7575b6020866040519015158152f35b604051630ead1e7d60e01b815260808180610ff785893060048501614dce565b03817f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b03165afa80156105b0578387936080519360805193611166575b506101c00151516001600160a01b03160361115f57505b101561105f575b80610fca565b6040516304ade6db60e11b815233600482015260248101919091526044810184905260805190945060209185916064918391905af19081156105b0576110ce946020946110b193611144575b506152dd565b604051637f4c824d60e11b81529384928392303360048601614ecc565b038160805160018060a01b037f0000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac165af180156105b057611117575b506020600182808080611059565b6111389060203d60201161113d575b61113081836145d9565b810190614b62565b611109565b503d611126565b61115a90863d881161113d5761113081836145d9565b6110ab565b9050611052565b90925061118c91935060803d608011611199575b61118481836145d9565b810190614e35565b949250905092918b61103b565b503d61117a565b9150506020813d6020116111cd575b816111bc602093836145d9565b810103126106e25785905189610fc3565b3d91506111af565b346101e457366003190160a081126101e4576001546111fe906001600160a01b031633146148da565b6002546001600160a01b0316803b156101e45760405163bfb9f86b60e01b8152916001600160a01b0361122f61432c565b1660048401526001600160a01b03611245614342565b16602484015260443562ffffff811693908481036101e45784604483015260805150606435908160020b938483036101e457606484018590526084356001600160a01b038116969094908786036101e4578760848301528160a48160805193608051905af180156105b057611370575b5060a0136101e457604051946112ca866145a0565b6004356001600160a01b038116969095908787036101e457868152602435906001600160a01b03821682036101e457602081019190915260408101849052606081810195909552608081019590955260a090942094507f3fd553db44f207b1f41348cfc4d251860814af9eadc470e8e7895e4d120511f49361134a614899565b9260805150506040519788526020880152604087015260018060a01b031694a460805180f35b60805161137c916145d9565b6080516101e457876112b5565b6103803660031901126101e45761139e61432c565b6113a73661466f565b610100366102831901126101e4576040516113c181614583565b6102843581526102a43580151581036101e457602082019081526102c4356001600160a01b03811681036101e45760408301908152606083016102e4358152608084019161030435835260a085019361032435855260c086019561034435875260e08101976103643589523360805152600360205260ff604060805120541615611565576040516335a033ff60e11b60208201526001600160a01b03909a1660248b01526114739060448b01906143ea565b516102a48901525115156102c4880152516001600160a01b03166102e487015251610304860152516103248501525161034484015251610364830152516103848083019190915281526114c86103a4826145d9565b604051906348c8949160e01b825281806114e86080519360048301614859565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af19081156105b05760805191611549575b50602081519181808201938492010103126106e25760209051604051908152f35b61155f91503d80608051833e6105d281836145d9565b81611528565b63041fb8cb60e31b608051526004608051fd5b346101e45761158636614530565b6002546040516302ef145760e51b815260048101949094529192916001600160a01b031661026083602481845afa9384156105b0576115e99460609460805191611629575b50604051637987bed160e11b81529586948593849360048501614b40565b03915afa80156105b05760209160805191611608575b50604051908152f35b611621915060603d606011610d9257610d7e81836145d9565b5050826115ff565b61164291506102603d811161078e5761078081836145d9565b866115cb565b346101e4576104003660031901126101e45761166261432c565b61166a614342565b906102603660431901126101e45760405190611685826145bc565b60443563ffffffff811681036101e45782526064356001600160701b03811681036101e45760208301526084356001600160701b03811681036101e457604083015260a4356001600160701b03811681036101e457606083015260c4356001600160701b03811681036101e457608083015260e43562ffffff811681036101e45760a0830152610104356001600160701b03811681036101e45760c0830152610124356001600160701b03811681036101e45760e0830152610144356001600160701b03811681036101e457610100830152610164356001600160701b03811681036101e457610120830152610184356001600160701b03811681036101e4576101408301526101a4356001600160701b03811681036101e4576101608301526101c4356101808301526101e4356101a08301526117c5366102046145fb565b6101c0830152366102a3190161016081126101e45730330361225c57610100136101e4576040516117f581614583565b6102a43581526102c43580151581036101e45760208201526102e43562ffffff811681036101e45760408201526103043560608201526103243560808201526103443560a0820152610364356001600160a01b03811681036101e45760c08201526103843560e082015260208101511561223c576101c083015180516020909101516001600160a01b039081169491165b60805160608401516118ba90887f0000000000000000000000001f9840000000000000000000000000000000000489614f37565b6118ea6060850151307f0000000000000000000000001f9840000000000000000000000000000000000489615117565b604084015162ffffff1615612044575061191e60808385516040519384928392630ead1e7d60e01b84523060048501614dce565b03817f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b03165afa9081156105b057608051918291829182919061201f575b50602087015115801594906120175750925b1561200f5750945b611995606086015162ffffff60408801511690614e57565b809210611fd65760018060a01b03600254166119d0606084602089015115156040519384928392637987bed160e11b84528b60048501614b40565b0381855afa80156105b0576119f29160805191611fb5575b5080981015614df7565b60a0850151839062ffffff1680611fa65750506020600491604051928380926313ac42a760e01b82525afa9081156105b05760049160209160805191611f79575b5060405163b67df1c360e01b815292839182906001600160a01b03165afa80156105b057839160805191611f35575b50611a7791611a709161550f565b8093614d7c565b916020828a611a9e8951948c60405196879586956372a6b5df60e01b875260048701614e6a565b038160805160018060a01b037f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35165af19081156105b05760805191611f03575b50975b82611e38575b855160608701516040516372a6b5df60e01b815299602095508a948594611b1394919060048701614e6a565b038160805160018060a01b037f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35165af19485156105b05760805195611e04575b5082517f0000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac6001600160a01b031690611b8b90836152dd565b90803b156101e45760405191630d9778e560e11b835260048301528560248301528160448160805193608051905af180156105b057611deb575b506101c0820151516001600160a01b03918216911603611dbf57611bf66001600160701b0360608301511684614c8f565b906001600160701b03608082015116915b80611d2c575b5081611c87575b50506002549051906001600160a01b0316803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057611c6e575b5060609260405192835260208301526040820152f35b608051611c7a916145d9565b6080516101e45783611c58565b6020908351611cbc60018060a01b03846101c085015101511694604051958694859463c3edb7ff60e01b865260048601614e9c565b038160805160018060a01b037f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35165af180156105b057611cfd575b80611c14565b611d1e9060203d602011611d25575b611d1681836145d9565b810190614b7a565b5084611cf7565b503d611d0c565b83516101c08301515160405163c3edb7ff60e01b81529260209284928392611d659290916001600160a01b031690889060048601614e9c565b038160805160018060a01b037f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35165af180156105b05715611c0d57611db89060203d602011611d2557611d1681836145d9565b5086611c0d565b6001600160701b0360608201511690611de56001600160701b0360808301511685614c8f565b91611c07565b608051611df7916145d9565b6080516101e45786611bc5565b9094506020813d602011611e30575b81611e20602093836145d9565b810103126106e257519386611b53565b3d9150611e13565b60025460405163236668f160e11b81526001600160a01b038a811660048301526024820195909552608051909460209286926044928492165af180156105b05760805190611ed0575b865160408051600181526020818101949094529295506001600160a01b0384811693908c1692917f43473e5e46598b12a9d6961219fd5cf4e66ec4f6653d7206553a25c454687c8e91a4611ae7565b506020833d602011611efb575b81611eea602093836145d9565b810103126106e25760209251611e81565b3d9150611edd565b90506020813d602011611f2d575b81611f1e602093836145d9565b810103126106e2575189611ade565b3d9150611f11565b9150506020813d602011611f71575b81611f51602093836145d9565b810103126101e457611a7083611f69611a7793614929565b915091611a62565b3d9150611f44565b611f999150823d8411611f9f575b611f9181836145d9565b810190614b89565b8b611a33565b503d611f87565b611a77925090611a709161550f565b611fce915060603d606011610d9257610d7e81836145d9565b50508b6119e8565b60405162461bcd60e51b815260206004820152601160248201527009a82a48e929cbe9c9ea8be8a9c9eaa8e9607b1b6044820152606490fd5b90509461197d565b905092611975565b9250505061203c915060803d6080116111995761118481836145d9565b90918a611963565b612059602085015115606086015190856151dd565b602085015115612229576001600160701b036020850151165b6001600160701b03818116601402908116036122115760646001600160701b0391821660140282160416906103c4359062ffffff8216908183036101e4576120ba925061530d565b908082101561220a57505b6080850151801561220357808210156121fc57505b945b6120ff604085875182519384928392630352520960e61b84523060048501614dce565b03817f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b03165afa80156105b0576080516121589289928291906121cb575b506020890151156121c457505b1015614df7565b85612167575b60805197611ae1565b61219386307f0000000000000000000000001f98400000000000000000000000000000000004866150b2565b6121bf86897f0000000000000000000000001f9840000000000000000000000000000000000486615165565b61215e565b9050612151565b90506121ef915060403d6040116121f5575b6121e781836145d9565b810190614db8565b8c612144565b503d6121dd565b90506120da565b50946120dc565b90506120c5565b634e487b7160e01b6080515260116004526024608051fd5b6001600160701b03604085015116612072565b6101c0830151602081015190516001600160a01b03908116949116611886565b6314e1dbf760e11b608051526004608051fd5b346101e45760203660031901126101e4576002546040516302ef145760e51b815260048035908201529061026090829060249082906001600160a01b03165afa80156105b057604091608051916122eb575b506001600160701b036122de816122d7846154f0565b16926154d1565b1682519182526020820152f35b61230491506102603d811161078e5761078081836145d9565b826122c1565b346101e45760203660031901126101e45760043567ffffffffffffffff81116101e457366023820112156101e45780600401359067ffffffffffffffff82116101e45736602483830101116101e4577f0000000000000000000000001f984000000000000000000000000000000000046001600160a01b031633036123a9576123a59160246123999201615298565b60405191829182614859565b0390f35b63570c108560e11b608051526004608051fd5b346101e4576080513660031901126101e457608051546040516001600160a01b039091168152602090f35b346101e45760203660031901126101e45761240061432c565b61241660018060a01b03608051541633146148da565b608080516001600160a01b039290921690915260036020525160408120805460ff1916905580f35b6101003660031901126101e4576124594260e4351015614d36565b600254604051632bc5fd8560e01b8152336004808301919091523560248201819052608051919290916102609184916044918391906001600160a01b03165af19182156105b05760805192612ada575b50600160ff6124b6614d6c565b161180612ac1575b612aae576101c082018051519092906001600160a01b03161580612aa2575b610d0f5760405163db620f4f60e01b815260048101839052917f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b0316602084602481845afa9384156105b05760805194612a6e575b50604051627eeac760e11b81523060048201526024810185905294602086604481855afa9586156105b05760805196612a3a575b506044359560243595906001600160701b036125938161258c896154f0565b16976154d1565b169786151580612a31575b15612a0e576125ae878a8a61542c565b908082116129995750608435811061295d576125d990986125d289985b848a61542c565b928a61542c565b8082101561295657505b955b85811180612943575b6127ee575b5085156127db57612602614d6c565b833b156101e45760405163c97a1c3f60e01b8152608051336004830152602482019390935260ff9091166044820152606481018790529283908180608481010391608051905af19182156105b05784926127bd575b5061267e9051610491876040519485936303bb73b760e11b60208601523360248601614d89565b604051906348c8949160e01b8252818061269e6080519360048301614859565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af180156105b0576127a3575b506002546001600160a01b0316803b156101e45760405190638b14724560e01b82528260048301528160248160805193608051905af180156105b05761278a575b5060c4356001600160a01b03811691908281036101e4576020957fdca088c2fe7922b62f9f0baee7a00b0de372311b1be3abea418c21f93dbc4a6d915061275f614d6c565b60408051888152602081019790975286019190915260ff1660608501523393608090a4604051908152f35b608051612796916145d9565b6080516101e4578461271a565b6127b8903d80608051833e6105d281836145d9565b6126d9565b6127cc919250608051906145d9565b6080516101e457829086612657565b633489be7560e21b608051526004608051fd5b8251516001600160a01b031690612806908790614d7c565b9080612886575060805190819081908190335af115612826575b876125f3565b601f19601f3d0116604051906390bfb86560e01b82523360048301526080516024830152608060448301528060a00160648301523d60848301523d60805160a484013e808201600460a482015260c4633d2cec6f60e21b91015260e40190fd5b906040519063a9059cbb60e01b825233600483015260248201526020608051604483608051865af13d15601f3d116001608051511416171690608051815260805160208201526040608051910152156128df5750612820565b601f19601f3d0116604051916390bfb86560e01b8352600483015263a9059cbb60e01b6024830152608060448301528060a00160648301523d60848301523d60805160a484013e808201600460a482015260c4633c9fd93960e21b91015260e40190fd5b508251516001600160a01b0316156125ee565b90506125e3565b60405162461bcd60e51b8152602060048201526014602482015273494e53554646494349454e545f414d4f554e543160601b6044820152606490fd5b969890506129a8818a8961542c565b9060643582101580612a04575b156129c8576125d26125d992989a6125cb565b60405162461bcd60e51b81526020600482015260146024820152730494e53554646494349454e545f414d4f554e54360641b6044820152606490fd5b50818910156129b5565b87612a2893989950819750612a239250614e57565b61552c565b948694966125e5565b5088151561259e565b9095506020813d602011612a66575b81612a56602093836145d9565b810103126106e25751948661256d565b3d9150612a49565b9093506020813d602011612a9a575b81612a8a602093836145d9565b810103126106e257519285612539565b3d9150612a7d565b503460243514156124dd565b6348adeb2160e11b608051526004608051fd5b50610bb862ffffff60406101c0850151015116106124be565b612af49192506102603d811161078e5761078081836145d9565b90826124a9565b346101e4576104916114c8612b0f366144f6565b909390612b2d6001600160a01b03612b25614ba8565b1633146148da565b6040516364d2756f60e01b60208201526001600160a01b039384166024820152949092166044850152606484019190915282906084820190565b6103e03660031901126101e457612b7c61432c565b612b853661466f565b3661028319019061016082126101e45761010060405192612ba584614553565b126101e457604051612bb681614583565b6102843581526102a43580151581036101e45760208201526102c43562ffffff811681036101e45760408201526102e43560608201526103043560808201526103243560a0820152610344356001600160a01b03811681036101e45760c08201526103643560e082015282526103843560208301908152906103a43562ffffff811681036101e45760408401526103c4356001600160a01b03811681036101e4576060840152604051612c6881614553565b604051612c7481614583565b6080518152608051602082015260805160408201526080516060820152608051608082015260805160a082015260805160c082015260805160e082015281526080516020820152608051604082015260606080519101523360805152600360205260ff604060805120541615611565576040516357da13db60e11b60208201523360248201526001600160a01b039094166044850152612d189060648501906143ea565b612d266102c48401836147ce565b6104048352612d37610424846145d9565b604051926348c8949160e01b84528380612d576080519360048301614859565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af180156105b057612db06060916101609560805191612dcc575b5060208082518301019101614d1b565b91938551926080840152520152612dca60405180926147ce565bf35b612de291503d80608051833e6105d281836145d9565b86612da0565b346101e4576103803660031901126101e457612e0261432c565b612e0b3661466f565b610100366102831901126101e45730330361225c57612e28614aea565b156137f9576101c081015180516020909101516001600160a01b0390811693911691905b61030435936103243580156137ab578515613790575b7f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb356001600160a01b031691612e956148af565b6001830180931161221157833b156101e457604051630bbc0f5760e01b81526001600160a01b03958616600482015294166024850152610284356044850152612ee160648501866143ea565b6001600160a01b03166102c48401526102e483015260805190829061030490829084905af180156105b057613777575b505b6102843591612f2283826152dd565b60408051637a94c56560e11b81526001600160a01b037f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35811660048301819052602483018590526102e43560448401819052967f0000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac90921695939092919082806064810103816080518a5af19182156105b0576080519060805193613753575b5082612fcc91614c8f565b956080518a1261351057608051881261351057878a038a8113600116612211578a89146136a7576080519661305692918891908c908381131561369857809a5b60408051633a43e9f760e01b8152977f0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b6001600160a01b031694899182918c903060048501614dce565b0381865afa80156105b0576130c88d6130c2996130cf936080519160805191613677575b50613083614aea565b1561367057505b613092614aea565b1561364a576001600160701b036130b88d826101008160c08401511692015116906154b1565b169a8b8092614c8f565b9161542c565b809d614d7c565b91608051125f146135f6576130e2614aea565b156135d75750608051811261351057925b6080518b12613510578d9a935b80158015906135ce575b61353c575b505050816131a1575b505050505050506080905f805160206156ca83398151915292935b60408051968752602087018990528601526103443560608601526001600160a01b031693a36002546001600160a01b0316803b156101e45760405191638b14724560e01b835260048301528160248160805193608051905af180156105b057610b7357602082604051908152f35b909192939495809998503b156101e45760405190636cf95b2960e01b82526004820152816024820152608051816044816080518d5af180156105b057613523575b50608051851261351057848101948512906080511390801582169115161761221157889160805185135f146132c85750506040516304ade6db60e11b81526001600160a01b0396871660048201529584166024870152505060448401529091906020828060648101038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af19081156105b05785935f805160206156ca833981519152936080936132a9575b505b9392819289808080613118565b6132c19060203d60201161113d5761113081836145d9565b508861329a565b9092969195936132d790614afa565b90816132fc575b505050505f805160206156ca8339815191529293509060809161329c565b9295509091808210156135085750935b84613315614aea565b156134f4576001600160701b038060c0890151165b169080821061345c575050604051637f4c824d60e11b81529460209086908190613363906001600160a01b038916308860048601614ecc565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af19485156105b057889561343f575b50608051915b826133b3575b806132de565b6133ed95506133cd60a06101c060209699015120866152dd565b604051637f4c824d60e11b81529687948593849390309060048601614ecc565b0391608051905af19081156105b05785935f805160206156ca83398151915293608093613420575b8594829394506133ad565b6134389060203d60201161113d5761113081836145d9565b5088613415565b6134579060203d60201161113d5761113081836145d9565b6133a1565b604051637f4c824d60e11b815296509060208780613489846001600160a01b038b16308a60048601614ecc565b038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af19182156105b0578a976134d1936134d7575b50614d7c565b916133a7565b6134ef9060203d60201161113d5761113081836145d9565b6134cb565b6001600160701b038060e08901511661332a565b90509361330c565b6393dafdf160e01b608051526004608051fd5b60805161352f916145d9565b6080516101e4578b6131e2565b613545886154f0565b9b61354f896154d1565b906040519d8e9163ed4ed80b60e01b835260048301526001600160701b031690602401526001600160701b031660448d015260648c015260848b01528960805191815a9360a492602095f19889156105b0578c996135af575b808061310f565b6135c79060203d602011611d2557611d1681836145d9565b508d6135a8565b5081151561310a565b93506080518112156130f3576393dafdf160e01b608051526004608051fd5b6135fe614aea565b15613631575060805181126135105761361690614afa565b925b6080518b126135105761362b8e9b614afa565b93613100565b935060805181126135105761364590614afa565b613618565b6001600160701b0361366b8d826101208160e08401511692015116906154b1565b6130b8565b905061308a565b9050613692915060403d6040116121f5576121e781836145d9565b5f61307a565b6136a181614afa565b9a61300c565b50506040516304ade6db60e11b81526001600160a01b039384166004820152928416602484015250604482015291506020828060648101038160805160018060a01b037f0000000000000000000000001f98400000000000000000000000000000000004165af19081156105b05785935f805160206156ca83398151915293608093613734575b50613133565b61374c9060203d60201161113d5761113081836145d9565b508861372e565b612fcc9350613771915060403d6040116121f5576121e781836145d9565b92612fc1565b608051613783916145d9565b6080516101e45783612f11565b94506137a58561379e614aea565b15856151dd565b94612e62565b5050508215612f13576137f4837f0000000000000000000000001f984000000000000000000000000000000000046137ec826137e56148af565b8388614f37565b309085615117565b612f13565b6101c0810151602081015190516001600160a01b039081169391169190612e4c565b346101e457613829366144f6565b909130330361225c5760025460405163ba65fb1560e01b81526001600160a01b0385811660048301526024820194909452608051909360209285926044928492165af19182156105b057608051926138c0575b50816138b8916020947f0000000000000000000000001f98400000000000000000000000000000000004906138b3843084846150b2565b615165565b604051908152f35b9091506020813d6020116138ed575b816138dc602093836145d9565b810103126106e2575190602061387c565b3d91506138cf565b346101e4576080513660031901126101e4576040517f00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb356001600160a01b03168152602090f35b346101e45760203660031901126101e457613954614bfb565b506002546040516302ef145760e51b815260048035908201529061026090829060249082906001600160a01b03165afa80156105b05761026091608051916139a5575b50612dca60405180926143ea565b6139bc9150823d811161078e5761078081836145d9565b82613997565b346101e4576139d036614530565b6002546040516302ef145760e51b815260048101949094529192916001600160a01b031661026083602481845afa9384156105b0576115e99460609460805191613a33575b5060405163206a728560e21b81529586948593849360048501614b40565b613a4c91506102603d811161078e5761078081836145d9565b86613a15565b346101e457613a60366144f6565b9030330361225c57613aa092613a99837f0000000000000000000000001f98400000000000000000000000000000000004928385614f37565b3091615117565b60805180f35b346101e45760403660031901126101e457613abf61432c565b613ac7614bfb565b503360805152600360205260ff60406080512054161561156557600254604051632bc5fd8560e01b81526001600160a01b039283166004820152602480359082015260805190926102609284926044928492165af180156105b05761026091608051916139a55750612dca60405180926143ea565b346106e257613b4a3661436c565b919290303303613c80576001600160a01b037f0000000000000000000000001f9840000000000000000000000000000000000481811695909291613b8d826148c6565b16863b156106e257604051637a94c56560e11b81523060048201526024810191909152604481018390525f81606481838b5af18015613c7557613c61575b5060208101956001600160a01b03613be2886148c6565b16813b156101e457604051637a94c56560e11b81526080805130600484015260248301939093526044820189905251909283916064918391905af180156105b057613c44575b5094613c3f6138b39285856138b3613aa09a6148c6565b6148c6565b608051919691613c53916145d9565b6080516101e4579486613c28565b5f613c6b916145d9565b5f60805286613bcb565b6040513d5f823e3d90fd5b6314e1dbf760e11b5f5260045ffd5b346106e2575f3660031901126106e2576020613ca9614ba8565b6040516001600160a01b039091168152f35b346106e25760203660031901126106e2576004356001600160a01b038116908190036106e257613cf560018060a01b035f541633146148da565b6002546001600160a01b038116613d16576001600160a01b03191617600255005b630d43628160e31b5f5260045ffd5b346106e2576101203660031901126106e257613d3f61432c565b60a03660231901126106e25760603660c31901126106e2576001546001600160a01b0316613d6e3382146148da565b604051613d7a816145a0565b6024356001600160a01b03811681036106e25781526044356001600160a01b03811681036106e257602082015260643562ffffff811681036106e25760408201526084358060020b81036106e257606082015260a435906001600160a01b03821682036106e257608081019190915260a090206002546040516302ef145760e51b81526004810183905291906001600160a01b031661026083602481845afa928315613c75575f93614282575b5060e4355f81129384613e38614adb565b15150361425e57613e47614899565b95613e50614883565b925b861561425857613e6190614afa565b935b8615614150575050606083613ea49260018060a01b036002541690613e86614adb565b60405163206a728560e21b8152958694859384939060048501614b40565b03915afa938415613c75575f945f925f91614129575b5060015460405163426a849360e01b81526001600160a01b03918216600482015290851660248201526044810187905292969092602081806064810103815f7f0000000000000000000000001f984000000000000000000000000000000000046001600160a01b03165af18015613c755761410a575b505b82613fde575b60a080997f9eb28ec873feb86f8f76c2d80034e39d1f684febd8b002b9798e739ab5644a9b92613f66614adb565b151503613fd157869462ffffff899a5b613f7e614adb565b9b604051988952602089015216998a6040880152151560608701526080860152600180831b031693a360405194600180881b03168552600180871b03166020850152604084015260608301526080820152f35b879462ffffff889a613f76565b5f92613fe8614adb565b84146140f7576020614038613ffb614899565b925b60025460405163096b565360e11b81526001600160a01b03868116600483015260248201939093529788939190921691839182906044820190565b03925af1938415613c75575f946140c2575b50604080515f81526020810186905260a09b7f9eb28ec873feb86f8f76c2d80034e39d1f684febd8b002b9798e739ab5644a9b948d94919390926001600160a01b0380861693169188917f43473e5e46598b12a9d6961219fd5cf4e66ec4f6653d7206553a25c454687c8e9190a49250995050613f38565b9093506020813d6020116140ef575b816140de602093836145d9565b810103126106e257519260a061404a565b3d91506140d1565b6020614038614104614883565b92613ffd565b6141229060203d60201161113d5761113081836145d9565b5089613f30565b91955050614146915060603d606011610d9257610d7e81836145d9565b9194909189613eba565b8460609161418194614163989498614adb565b604051637987bed160e11b8152968794859384939060048501614b40565b03915afa958615613c75575f965f935f9161422e575b5060405163426a849360e01b81526001600160a01b039788166004820152968916602488015260448701869052929695602081806064810103815f7f0000000000000000000000001f984000000000000000000000000000000000046001600160a01b03165af18015613c755761420f575b50613f32565b6142279060203d60201161113d5761113081836145d9565b5089614209565b6020985086945061424e915060603d606011610d9257610d7e81836145d9565b9198909450614197565b93613e63565b614266614883565b9561426f614899565b6001600160a01b03978816971692613e52565b61429c9193506102603d811161078e5761078081836145d9565b9185613e27565b346106e2576142b13661436c565b919290303303613c80576143208360208661430f6142d161432a996148c6565b956142ff81897f0000000000000000000000001f98400000000000000000000000000000000004809a614f37565b308761430a856148c6565b615117565b01938361431b866148c6565b614f37565b61430a30926148c6565b005b600435906001600160a01b03821682036106e257565b602435906001600160a01b03821682036106e257565b35906001600160a01b03821682036106e257565b906101006003198301126106e2576004356001600160a01b03811681036106e25760a0909260231901126106e25760249060c4359060e43590565b80516001600160a01b03908116835260208083015182169084015260408083015162ffffff169084015260608083015160020b9084015260809182015116910152565b906101c0806144f49363ffffffff81511684526001600160701b0360208201511660208501526001600160701b0360408201511660408501526001600160701b0360608201511660608501526001600160701b03608082015116608085015262ffffff60a08201511660a08501526001600160701b0360c08201511660c08501526001600160701b0360e08201511660e08501526001600160701b03610100820151166101008501526001600160701b03610120820151166101208501526001600160701b03610140820151166101408501526001600160701b03610160820151166101608501526101808101516101808501526101a08101516101a085015201519101906143a7565b565b60609060031901126106e2576004356001600160a01b03811681036106e257906024356001600160a01b03811681036106e2579060443590565b60609060031901126106e2576004359060243580151581036106e2579060443590565b6080810190811067ffffffffffffffff82111761456f57604052565b634e487b7160e01b5f52604160045260245ffd5b610100810190811067ffffffffffffffff82111761456f57604052565b60a0810190811067ffffffffffffffff82111761456f57604052565b6101e0810190811067ffffffffffffffff82111761456f57604052565b90601f8019910116810190811067ffffffffffffffff82111761456f57604052565b91908260a09103126106e257604051614613816145a0565b809261461e81614358565b825261462c60208201614358565b6020830152604081013562ffffff811681036106e25760408301526060810135908160020b82036106e257608061466a918193606086015201614358565b910152565b906102606023198301126106e257604051614689816145bc565b809260243563ffffffff811681036106e25782526044356001600160701b03811681036106e25760208301526064356001600160701b03811681036106e25760408301526084356001600160701b03811681036106e257606083015260a4356001600160701b03811681036106e257608083015260c43562ffffff811681036106e25760a083015260e4356001600160701b03811681036106e25760c0830152610104356001600160701b03811681036106e25760e0830152610124356001600160701b03811681036106e257610100830152610144356001600160701b03811681036106e257610120830152610164356001600160701b03811681036106e257610140830152610184356001600160701b03811681036106e2576101c09161466a916101608501526101a4356101808501526101c4356101a08501526101e46145fb565b6101409060e081518051855260208101511515602086015262ffffff6040820151166040860152606081015160608601526080810151608086015260a081015160a086015260018060a01b0360c08201511660c0860152015160e0840152602081015161010084015262ffffff604082015116610120840152606060018060a01b0391015116910152565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b6044356001600160a01b03811681036106e25790565b6024356001600160a01b03811681036106e25790565b6102c4356001600160a01b03811681036106e25790565b356001600160a01b03811681036106e25790565b156148e157565b60405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606490fd5b51906001600160701b03821682036106e257565b519062ffffff821682036106e257565b51906001600160a01b03821682036106e257565b8091039061026082126106e25760405191614967836145bc565b81519063ffffffff821682036106e25760a091845261498860208401614915565b602085015261499960408401614915565b60408501526149aa60608401614915565b60608501526149bb60808401614915565b60808501526149cb828401614929565b828501526149db60c08401614915565b60c08501526149ec60e08401614915565b60e08501526149fe6101008401614915565b610100850152614a116101208401614915565b610120850152614a246101408401614915565b610140850152614a376101608401614915565b6101608501526101808301516101808501526101a08301516101a08501526101bf1901126106e25760405190614a6c826145a0565b614a796101c08201614939565b8252614a886101e08201614939565b6020830152614a9a6102008201614929565b6040830152610220810151908160020b82036106e257606083019190915261024001516001600160a01b03811681036106e25760808201526101c082015290565b60c43580151581036106e25790565b6102a43580151581036106e25790565b600160ff1b8114614b0a575f0390565b634e487b7160e01b5f52601160045260245ffd5b908160609103126106e2578051916040614b3a60208401614929565b92015190565b61028091949392614b56826102a08101976143ea565b15156102608201520152565b908160209103126106e2575180151581036106e25790565b908160209103126106e2575190565b908160209103126106e257516001600160a01b03811681036106e25790565b6002546040516313ac42a760e01b815290602090829060049082906001600160a01b03165afa908115613c75575f91614bdf575090565b614bf8915060203d602011611f9f57611f9181836145d9565b90565b60405190614c08826145bc565b815f81525f60208201525f60408201525f60608201525f60808201525f60a08201525f60c08201525f60e08201525f6101008201525f6101208201525f6101408201525f6101608201525f6101808201525f6101a08201526101c060405191614c70836145a0565b5f83525f60208401525f60408401525f60608401525f60808401520152565b91908201809211614b0a57565b67ffffffffffffffff811161456f57601f01601f191660200190565b6020818303126106e25780519067ffffffffffffffff82116106e2570181601f820112156106e257805190614cec82614c9c565b92614cfa60405194856145d9565b828452602083830101116106e257815f9260208093018386015e8301015290565b908160609103126106e2578051916040602083015192015190565b15614d3d57565b60405162461bcd60e51b81526020600482015260076024820152661156141254915160ca1b6044820152606490fd5b60a43560ff811681036106e25790565b91908203918211614b0a57565b6001600160a01b039091168152610100810194939260e092614daf9060208401906143a7565b60c08201520152565b91908260409103126106e2576020825192015190565b6001600160a01b03909116815260208101919091526102a0810192916144f491604001906143ea565b15614dfe57565b60405162461bcd60e51b815260206004820152600f60248201526e09a92a4a49ea4bea89e9ebe9aaa869608b1b6044820152606490fd5b91908260809103126106e2578151916020810151916060604083015192015190565b81810292918115918404141715614b0a57565b6001600160a01b0391821681529181166020830152604082019290925291166060820152608081019190915260a00190565b90949392614eb96102a0936102c0840197845260208401906143ea565b6001600160a01b03166102808201520152565b6001600160a01b039182168152911660208201526040810191909152606081019190915260800190565b15614efd57565b60405162461bcd60e51b81526020600482015260126024820152714e4f545f454e4f5547485f5245534552564560701b6044820152606490fd5b6001600160a01b0316929183614f945750604051630476982d60e21b81529250602091839160049183916001600160a01b03165af18015613c7557614f795750565b614f919060203d602011611d2557611d1681836145d9565b50565b916001600160a01b0390911690813b156106e257604051632961046560e21b815260048101859052925a935f816024818388819af18015613c7557615097575b509293849360209392916001600160a01b03909116903082146150595761502992604051926323b872dd60e01b8785015260248401528460448401526064830152606482526150246084836145d9565b615671565b600460405180958193630476982d60e21b83525af190811561504d5750614f795750565b604051903d90823e3d90fd5b60405163a9059cbb60e01b868201526001600160a01b038516602482015260448101939093526150929291506150248260648101610a53565b615029565b602093929194505f6150a8916145d9565b5f93909192614fd4565b9192906001600160a01b0316803b156106e257604051637a94c56560e11b81526001600160a01b03948516600482015293909216602484015260448301525f908290818381606481015b03925af18015613c755761510d5750565b5f6144f4916145d9565b9192906001600160a01b0316803b156106e257604051630ab714fb60e11b81526001600160a01b03948516600482015293909216602484015260448301525f908290818381606481016150fc565b91906001600160a01b0316803b156106e257604051630b0d9c0960e01b81526001600160a01b03938416600482015291909216602482015260448101929092525f908290606490829084905af18015613c755761510d5750565b81156151c9570490565b634e487b7160e01b5f52601260045260245ffd5b61523290614bf893925f14615238576001600160701b0361522b81615223615204856154f0565b9662ffffff60406101c0615217896154d1565b985b015101511661550f565b931683614e57565b9316614c8f565b906151bf565b6001600160701b0361522b81615223615250856154d1565b9662ffffff60406101c0615263896154f0565b98615219565b3d15615293573d9061527a82614c9c565b9161528860405193846145d9565b82523d5f602084013e565b606090565b5f9182918160405192839283378101838152039082305af1906152b9615269565b916144f457508051156152ce57602081519101fd5b6314815f4760e31b5f5260045ffd5b604080516001600160a01b03909216602083019081528282019390935281526153076060826145d9565b51902090565b90620f42408202905f19620f424084099282808510940393808503941461539d578382111561538e57620f4240829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b63227bc15360e01b5f5260045ffd5b5090614bf892506151bf565b9190915f838202915f198582099183808410930392808403931461541e5782620f4240111561540f57507fde8f6cefed634549b62c77574f722e1ac57e23f24d8fd5cb790fb65668c261399394620f4240910990828211900360fa1b910360061c170290565b63227bc15360e01b8152600490fd5b505050620f42409192500490565b9091828202915f19848209938380861095039480860395146154a4578483111561538e57829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b505090614bf892506151bf565b906001600160701b03809116911601906001600160701b038211614b0a57565b614bf8906001600160701b0360808160408401511692015116906154b1565b614bf8906001600160701b0360608160208401511692015116906154b1565b62ffffff16620f424003620f42408111614b0a57614bf8916153a9565b801561566c576155fa6001825f908460801c80615660575b508060401c80615653575b508060201c80615646575b508060101c80615639575b508060081c8061562c575b508060041c8061561f575b508060021c80615612575b50821c61560b575b811c1b61559b81846151bf565b0160011c6155a981846151bf565b0160011c6155b781846151bf565b0160011c6155c581846151bf565b0160011c6155d381846151bf565b0160011c6155e181846151bf565b0160011c6155ef81846151bf565b0160011c80926151bf565b80821015615606575090565b905090565b810161558e565b600291509101905f615586565b600491509101905f61557b565b600891509101905f615570565b601091509101905f615565565b602091509101905f61555a565b604091509101905f61554f565b9150506080905f615544565b505f90565b905f602091828151910182855af115613c75575f513d6156c057506001600160a01b0381163b155b6156a05750565b635274afe760e01b5f9081526001600160a01b0391909116600452602490fd5b6001141561569956fe1d9d1025f06575cd23c8334c2f057422670381e5e2513b4a4bd6ecc63f649d4fa26469706673582212207ac8cec8c3f7a138721c41bf0e8d69d64d6e9f72d25e4f6cb2b27fdabda202db64736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000004945b4d356edc02caab24d2407e87962696426730000000000000000000000001f984000000000000000000000000000000000040000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb350000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b
-----Decoded View---------------
Arg [0] : initialOwner (address): 0x4945b4D356edC02caab24d2407e8796269642673
Arg [1] : _manager (address): 0x1F98400000000000000000000000000000000004
Arg [2] : _mirrorTokenManager (address): 0x5Bb48066B848e910a789673Bb5970FFD3A4c0cac
Arg [3] : _lendingPoolManager (address): 0x58B5Fb66b90259b8B97888BB6eC2b63A5723cb35
Arg [4] : _marginLiquidity (address): 0x4d610043A6aF9728a336620F70BA03217cCcD11b
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000004945b4d356edc02caab24d2407e8796269642673
Arg [1] : 0000000000000000000000001f98400000000000000000000000000000000004
Arg [2] : 0000000000000000000000005bb48066b848e910a789673bb5970ffd3a4c0cac
Arg [3] : 00000000000000000000000058b5fb66b90259b8b97888bb6ec2b63a5723cb35
Arg [4] : 0000000000000000000000004d610043a6af9728a336620f70ba03217cccd11b
Net Worth in USD
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.