Latest 25 from a total of 97 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Stack Underlying | 38084076 | 4 hrs ago | IN | 0 ETH | 0.00000283 | ||||
| Set Configs | 38083992 | 4 hrs ago | IN | 0 ETH | 0.00000048 | ||||
| Stack Underlying | 38045286 | 25 hrs ago | IN | 0 ETH | 0.0000036 | ||||
| Set Configs | 38045230 | 25 hrs ago | IN | 0 ETH | 0.00000032 | ||||
| Request Supply | 38017274 | 41 hrs ago | IN | 0 ETH | 0.00000026 | ||||
| Stack Underlying | 38012796 | 43 hrs ago | IN | 0 ETH | 0.00000226 | ||||
| Set Configs | 38008459 | 46 hrs ago | IN | 0 ETH | 0.00000014 | ||||
| Stack Underlying | 38002626 | 2 days ago | IN | 0 ETH | 0.00000285 | ||||
| Set Configs | 38002600 | 2 days ago | IN | 0 ETH | 0.00000024 | ||||
| Stack Underlying | 37994797 | 2 days ago | IN | 0 ETH | 0.00000132 | ||||
| Set Configs | 37994743 | 2 days ago | IN | 0 ETH | 0.00000019 | ||||
| Request Supply | 37972900 | 2 days ago | IN | 0 ETH | 0.00000027 | ||||
| Stack Underlying | 37968786 | 2 days ago | IN | 0 ETH | 0.0000013 | ||||
| Rage Crush | 37965186 | 2 days ago | IN | 0 ETH | 0.00000137 | ||||
| Stack Underlying | 37912896 | 4 days ago | IN | 0 ETH | 0.00000201 | ||||
| Stack Underlying | 37879056 | 4 days ago | IN | 0 ETH | 0.00000237 | ||||
| Set Configs | 37878952 | 4 days ago | IN | 0 ETH | 0.0000002 | ||||
| Stack Underlying | 37871406 | 5 days ago | IN | 0 ETH | 0.00000192 | ||||
| Stack Underlying | 37864116 | 5 days ago | IN | 0 ETH | 0.00000289 | ||||
| Stack Underlying | 37850527 | 5 days ago | IN | 0 ETH | 0.00000178 | ||||
| Set Configs | 37850435 | 5 days ago | IN | 0 ETH | 0.00000028 | ||||
| Stack Underlying | 37843146 | 5 days ago | IN | 0 ETH | 0.00000236 | ||||
| Stack Underlying | 37842382 | 5 days ago | IN | 0 ETH | 0.00000007 | ||||
| Set Configs | 37841699 | 5 days ago | IN | 0 ETH | 0.00000014 | ||||
| Stack Underlying | 37835103 | 5 days ago | IN | 0 ETH | 0.00000267 |
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
RageChaosEngine
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {IRage} from "./IRage.sol";
import {ReentrancyGuard} from "./ReentrancyGuard.sol";
import {IERC20} from "./IERC20.sol";
import {ERC20} from "./ERC20.sol";
import {TickMath} from "./TickMath.sol";
import {LiquidityAmounts} from "./LiquidityAmounts.sol";
import {INonfungiblePositionManager} from "./INonfungiblePositionManager.sol";
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {IUniswapV3Factory} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import {RageStructs} from "./RageStructs.sol";
import {IRageSwapper} from "./IRageSwapper.sol";
contract RageChaosEngine is ReentrancyGuard {
// constant
IERC20 private constant USDC = IERC20(0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913);
IERC20 private constant PHESTIA = IERC20(0xF760fD8fEB1F5E3bf3651E2E4f227285a82470Ff);
IERC20 private constant PCIRCLE = IERC20(0x55A81dA2a319dD60fB028c53Cb4419493B56f6c0);
INonfungiblePositionManager private constant POSITION_MANAGER = INonfungiblePositionManager(0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1);
IUniswapV3Factory private constant FACTORY = IUniswapV3Factory(0x33128a8fC17869897dcE68Ed026d694621f6FDfD);
uint256 private constant VERSION = 1;
uint24 private constant POOL_FEE = 10_000;
uint256 private constant BPS = 10000;
uint256 private constant MAX_DEADLINE_DURATION = 2 minutes;
uint256 private constant CONFIG_INTERVAL = 1 hours;
uint256 private constant STACK_INTERVAL = 4 hours;
uint256 private constant BOOST_INTERVAL = 8 hours;
uint256 private constant CRUSH_INTERVAL = 8 hours;
uint256 private constant BURST_INTERVAL = 8 hours;
uint256 private constant YEARLY_ALLOWANCE_MAX_PERCENT = 20; // 20% of active supply can be sent yearly to multisig, all other rage tokens either go in the pool or in RBP
uint256 private constant YEARLY_ALLOWANCE_DELAY = 365 days;
address private constant MULTISIG = 0x507fbdE39ba40DA4Fc79426AD5E3C64944fE43d4;
// state
IUniswapV3Pool private POOL;
RageStructs.RceStateValue private STATE;
RageStructs.RceConfig private CONFIG;
// immutable
IRage private immutable RAGE;
uint256 private immutable NFT_ID;
IRageSwapper private immutable RAGE_SWAPPER;
// events
event LockNft(uint256 nftId);
event AutomatorSet(address automator);
event RageBuyingProtocolProposed(address indexed proposer, address indexed pendingRbp);
event RageBuyingProtocolSet(address indexed newRbp);
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
event SupplyRequested(uint256 percent);
event SupplyBurned(uint256 amount);
event YearlyAllowanceRequested(address indexed requester, address indexed recipient, uint256 amount, uint256 activeSupply);
event RageTransferred(address recipient, uint256 amount);
event ConfigChanged(uint256 stackRage, uint256 stackHestia, uint256 boostRage, uint128 crushDecrease, bool crushBuy, uint256 burstRage, uint256 burstLoop, uint256 slippage, address podAddress, address sideAddress1, address sideAddress2);
event PoolBoosted(uint256 rageIncrease, uint256 usdcIncrease);
event UnderlyingStacked(uint256 rageSold, uint256 pHestia, uint256 pCircle);
event RageCrushed(uint256 rageBurned, uint256 usdcBought);
event RageBursted(uint256 rageCollected, uint256 usdcCollected);
// constructor
constructor(address rage, address rSwap, uint256 nftId, address owner1, address owner2) {
RAGE = IRage(rage);
RAGE_SWAPPER = IRageSwapper(rSwap);
STATE.owner1 = owner1;
STATE.owner2 = owner2;
STATE.automator = 0xCBe5a4103d4C7Ed5D73d9942101473C1Bc0A8020;
CONFIG = RageStructs.RceConfig({
stackRage: 100,
stackHestia: 80,
boostRage: 100,
crushDecrease: 0,
crushBuy: true,
burstRage: 10e18,
burstLoop: 2,
slippage: 1000,
podAddress: address(0),
sideAddress1: 0xb278F52bC80B883da0729a863F853845965aF009,
sideAddress2: address(0)
});
// approve rage swapper
USDC.approve(address(RAGE_SWAPPER), type(uint256).max);
RAGE.approve(address(RAGE_SWAPPER), type(uint256).max);
// approve position manager
RAGE.approve(address(POSITION_MANAGER), type(uint256).max);
USDC.approve(address(POSITION_MANAGER), type(uint256).max);
// nft and pool initialization
(
,
,
address nftToken0,
address nftToken1,
uint24 nftFee,
,
,
,
,
,
,
) = POSITION_MANAGER.positions(nftId);
// check nft has correct tokens and fees
require(
(nftToken0 == address(USDC) && nftToken1 == address(RAGE)) ||
(nftToken0 == address(RAGE) && nftToken1 == address(USDC)),
"nftTokensDoNoMatchPoolTokens"
);
require(nftFee == POOL_FEE, "nftFeeTierDoesNotMatchPool");
// initialize the usdc/rage pool
POOL = IUniswapV3Pool(FACTORY.getPool(address(USDC), address(RAGE), POOL_FEE));
require(address(POOL) != address(0),"invalidPoolAddress");
// need to approve for liquidity increase
USDC.approve(address(POOL), type(uint256).max);
RAGE.approve(address(POOL), type(uint256).max);
STATE.poolToken0 = POOL.token0();
// set the nft
NFT_ID = nftId;
}
// withdrawEth
function withdrawEth() external {
require(msg.sender == STATE.automator, "unauthorized");
uint256 balance = address(this).balance;
require(balance > 0, "noEthBalance");
(bool success, ) = payable(MULTISIG).call{value: balance}("");
require(success, "ethTransferFailed");
}
// withdrawToken
// rage and usdc withdrawal is blocked
// the only way to withdraw Rage to multisig is through the yearly allowance function
function withdrawToken(address tokenAdr) external {
require(msg.sender == STATE.automator, "unauthorized");
require(tokenAdr != address(RAGE) && tokenAdr != address(USDC), "usdcAndRageNotWithdrawable");
IERC20 token = IERC20(tokenAdr);
uint256 balance = token.balanceOf(address(this));
require(balance > 0, "noTokenBalance");
require(token.transfer(MULTISIG, balance), "transferFailed");
}
// lockNft
// transfer it to controller contract, only for owners
function lockNFT() external nonReentrant {
require(msg.sender == STATE.owner1 || msg.sender == STATE.owner2, "unauthorized");
require(NFT_ID > 0, "nftNotSet");
require(STATE.nftLocked == 0, "nftAlreadyLocked");
POSITION_MANAGER.transferFrom(msg.sender, address(this), NFT_ID);
STATE.nftLocked = 1;
emit LockNft(NFT_ID);
}
// transferOwnership
// the owner is able to transfer his own ownership to another address
function transferOwnership(address newOwner) external nonReentrant {
require(msg.sender == STATE.owner1 || msg.sender == STATE.owner2, "unauthorized");
require(newOwner != address(0), "invalidOwnerAddress");
require(newOwner != STATE.rageBuyingProtocol, "ownerCannotBeRbp");
require(newOwner != STATE.automator, "ownerCannotBeAutomator");
if (msg.sender == STATE.owner1) {
require(newOwner != STATE.owner2, "ownersMustBeDifferent");
STATE.owner1 = newOwner;
}
else {
require(newOwner != STATE.owner1, "ownersMustBeDifferent");
STATE.owner2 = newOwner;
}
emit OwnershipTransferred(msg.sender, newOwner);
}
// setRageBuyingProtocol
// both owners must specify the same new rbp address for the change to go in effect
// this is a critical change as the rage buying protocol can mint Rage tokens
function setRageBuyingProtocol(address newRbp) external nonReentrant {
require(msg.sender == STATE.owner1 || msg.sender == STATE.owner2, "unauthorized");
require(newRbp != address(0), "invalidRbpAddress");
require(newRbp != STATE.owner1 && newRbp != STATE.owner2, "ownerCannotBeRbp");
// if no pending rbp, this is the first proposal
if (STATE.pendingRbp == address(0)) {
STATE.pendingRbp = newRbp;
STATE.ownerProposer = msg.sender;
emit RageBuyingProtocolProposed(msg.sender, newRbp);
}
// if there's a pending rbp and it matches what the other owner proposed
else if (STATE.pendingRbp == newRbp && STATE.ownerProposer != msg.sender) {
STATE.rageBuyingProtocol = newRbp;
STATE.pendingRbp = address(0);
STATE.ownerProposer = address(0);
emit RageBuyingProtocolSet(newRbp);
}
// if a same owner tries to set again or proposes a different address
else {
STATE.pendingRbp = newRbp;
STATE.ownerProposer = msg.sender;
emit RageBuyingProtocolProposed(msg.sender, newRbp);
}
}
// setAutomator
// even though its not the best practice, we choose to allow automator to name a successor himself
function setAutomator(address automator) external nonReentrant {
require(msg.sender == STATE.automator || msg.sender == STATE.owner1 || msg.sender == STATE.owner2, "unauthorized");
require(automator != STATE.owner1 && automator != STATE.owner2 && automator != address(0), "invalidAutomatorAddress");
STATE.automator = automator;
emit AutomatorSet(automator);
}
// requestSupply
// the rage chaos engine requests supply to the rage contract
// the rage is stored within rce contract
function requestSupply(uint256 percent) external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(percent > 0, "invalidPercent"); // the rage contract will have further checks on the percent variable
uint256 rageBalanceBefore = getRageBalance();
RAGE.requestSupply(percent);
uint256 rageBalanceAfter = getRageBalance();
uint256 actualMintAmount = rageBalanceAfter - rageBalanceBefore;
require(actualMintAmount > 0, "noSupplyMinted" );
STATE.amountMint += actualMintAmount;
emit SupplyRequested(percent);
}
// burnSupply
// the automator can request to burn rage supply within the rce contract
function burnSupply(uint256 amount) external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(amount > 0, "invalidAmount");
uint256 rageBalance = getRageBalance();
require(rageBalance >= amount, "insufficientBalance");
RAGE.burn(amount);
emit SupplyBurned(amount);
}
// requestYearlyAllowance
// automator can request once per year an allowance of activeSupply be sent to Multisig
function requestYearlyAllowance(uint256 percent) external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(block.timestamp >= STATE.nextYearlyAllowance, "mustWait1Year");
require(percent <= YEARLY_ALLOWANCE_MAX_PERCENT, "invalidPercent" );
uint256 activeSupply = getActiveSupply();
uint256 allowanceAmount = (activeSupply * percent) / 100;
require(allowanceAmount > 0, "noActiveSupply");
uint256 rceBalance = getRageBalance();
require(allowanceAmount <= rceBalance, "insufficientRceBalance");
require(RAGE.transfer(MULTISIG, allowanceAmount), "transferFailed");
STATE.amountAllowance += allowanceAmount;
STATE.nextYearlyAllowance = block.timestamp + YEARLY_ALLOWANCE_DELAY;
emit YearlyAllowanceRequested(STATE.automator, MULTISIG, allowanceAmount, activeSupply);
}
// setConfigs
// automator can change a number of configuration on the contract
function setConfigs(RageStructs.RceConfig calldata newConfig) external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(block.timestamp >= STATE.nextConfigTime, "configTimeout");
STATE.nextConfigTime = block.timestamp + CONFIG_INTERVAL;
require(newConfig.stackRage >= 100 && newConfig.stackRage <= 10000, "invalidStackRage");
require(newConfig.stackHestia >= 0 && newConfig.stackHestia <= 100, "invalidStackHestia");
require(newConfig.boostRage == 0 || (newConfig.boostRage >= 100 && newConfig.boostRage <= 10000), "invalidBoostRage");
require(newConfig.crushDecrease == 0 || (newConfig.crushDecrease >= 100 && newConfig.crushDecrease <= 10000), "invalidCrushDecrease");
require(newConfig.burstRage >= 1e18 && newConfig.burstRage <= 200e18, "invalidBurstRage");
require(newConfig.burstLoop >= 1 && newConfig.burstLoop <= 5, "invalidBurstLoop");
require(newConfig.slippage <= 2500, "invalidLiquiditySlippage");
require(newConfig.podAddress != MULTISIG && newConfig.podAddress != address(this), "invalidPodAddress");
require(newConfig.sideAddress1 != MULTISIG && newConfig.sideAddress1 != address(this), "invalidSideAddress1");
require(newConfig.sideAddress2 != MULTISIG && newConfig.sideAddress2 != address(this), "invalidSideAddress2");
CONFIG = newConfig;
emit ConfigChanged(
newConfig.stackRage,
newConfig.stackHestia,
newConfig.boostRage,
newConfig.crushDecrease,
newConfig.crushBuy,
newConfig.burstRage,
newConfig.burstLoop,
newConfig.slippage,
newConfig.podAddress,
newConfig.sideAddress1,
newConfig.sideAddress2
);
}
// getMultisig
// returns the multisig address
function getMultisig() external pure returns (address) {
return MULTISIG;
}
// getAutomator
// returns the automator address
function getAutomator() external view returns (address) {
return STATE.automator;
}
// getOwners
// returns both owner addresses
function getOwners() external view returns (address owner1, address owner2) {
return (STATE.owner1, STATE.owner2);
}
// getRageBuyingProtocol
// returns the rage buying protocol address
function getRageBuyingProtocol() external view returns (address) {
return STATE.rageBuyingProtocol;
}
// getState
// returns the full state of the contract
function getState() external view returns (RageStructs.RceState memory) {
return RageStructs.RceState({
version: VERSION,
rageSwapper: address(RAGE_SWAPPER),
multisig: MULTISIG,
poolAddress: address(POOL),
nftId: NFT_ID,
activeSupply: getActiveSupply(),
nftSupply: getRageInNft(),
rageBalance: getRageBalance(),
usdcBalance: getUsdcBalance(),
config: CONFIG,
state: STATE
});
}
// transferRage
// only the rbp address can make request to transfer Rage tokens
function transferRage(address recipient, uint256 amount) external nonReentrant {
require(msg.sender == STATE.rageBuyingProtocol, "notRbp");
require(STATE.rageBuyingProtocol != address(0), "rbpNotSet");
require(recipient != address(0), "invalidRecipient");
require(amount > 0, "invalidAmount");
uint256 rageBalance = getRageBalance();
require(rageBalance >= amount, "insufficientRageBalance");
require(RAGE.transfer(recipient, amount), "transferFailed");
STATE.amountTransfer += amount;
emit RageTransferred(recipient, amount);
}
// getRageBalance
function getRageBalance() internal view returns(uint256) {
return RAGE.balanceOf(address(this));
}
// getUsdcBalance
function getUsdcBalance() internal view returns(uint256) {
return USDC.balanceOf(address(this));
}
// getActiveSupply
// returns the active supply of RAGE tokens
// excludes: RCE balance, multisig balance, RAGE in liquidity NFT
function getActiveSupply() public view returns (uint256) {
// get total supply (already excludes tokens sent to 0 address and dead address)
uint256 totalSupply = RAGE.getTotalSupply();
uint256 rceBalance = getRageBalance();
uint256 multisigBalance = RAGE.balanceOf(MULTISIG);
uint256 rageInNft = getRageInNft();
uint256 automatorBalance = RAGE.balanceOf(STATE.automator);
// calculate active supply
uint256 activeSupply = totalSupply - rceBalance - multisigBalance - rageInNft - automatorBalance;
// those 3 exclusion addresses can be configured through setConfigs, we will use them to exclude side pools and pRage pool from active supply
if(CONFIG.podAddress != address(0)) {
activeSupply -= RAGE.balanceOf(CONFIG.podAddress);
}
if(CONFIG.sideAddress1 != address(0)) {
activeSupply -= RAGE.balanceOf(CONFIG.sideAddress1);
}
if(CONFIG.sideAddress2 != address(0)) {
activeSupply -= RAGE.balanceOf(CONFIG.sideAddress2);
}
return activeSupply;
}
// stackUnderlying
// this function sends an amount of rage to the RBP contract
// the rbp contract will sell the rage to pTokens and stack in the contract
// this will boost fmv for all holders
function stackUnderlying() external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(block.timestamp >= STATE.nextStackTime, "stackTimeout");
STATE.nextStackTime = block.timestamp + STACK_INTERVAL;
// calculate percentage of RAGE in NFT to sell (CONFIG.stackRage is divider: 100 = 1%, 10000 = 0.01%)
uint256 rageInNft = getRageInNft();
require(rageInNft > 0, "noRageInNft");
uint256 rageToSell = rageInNft / CONFIG.stackRage;
require(rageToSell > 0, "amountTooSmall");
// check we have enough RAGE to sell
uint256 rageBalance = getRageBalance();
require(rageBalance >= rageToSell, "insufficientRageBalance");
// calculate stack circle amount
uint256 stackCircle = 100 - CONFIG.stackHestia;
// get initial balances
uint256 pHestiaBefore = PHESTIA.balanceOf(address(this));
uint256 pCircleBefore = PCIRCLE.balanceOf(address(this));
// swap RAGE for underlying pTokens
(uint256 pHestiaReceived, uint256 pCircleReceived) =
RAGE_SWAPPER.swapRageForUnderlying(
rageToSell,
CONFIG.stackHestia,
stackCircle,
CONFIG.slippage,
block.timestamp + MAX_DEADLINE_DURATION
);
// verify balances increased correctly
require(PHESTIA.balanceOf(address(this)) == pHestiaBefore + pHestiaReceived, "incorrectPHestiaBalance");
require(PCIRCLE.balanceOf(address(this)) == pCircleBefore + pCircleReceived, "incorrectPCircleBalance");
// transfer pTokens to RBP
if(pHestiaReceived > 0) require(PHESTIA.transfer(STATE.rageBuyingProtocol, pHestiaReceived), "pHestiaTransferFailed");
if(pCircleReceived > 0) require(PCIRCLE.transfer(STATE.rageBuyingProtocol, pCircleReceived), "pCircleTransferFailed");
// finally collect the fees and leave them in contract, this prevents the fees from the sells to be added to active supply
POSITION_MANAGER.collect(
INonfungiblePositionManager.CollectParams({
tokenId: NFT_ID,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
})
);
STATE.amountRageStack += rageToSell;
STATE.lastStackTime = block.timestamp;
STATE.lastStackAmount = rageToSell;
emit UnderlyingStacked(rageToSell, pHestiaReceived, pCircleReceived);
}
// poolBoost
// this function is used to process liquidity increase
// it is possible to sell rage to usdc before doing liquidity increase
// we want to use this mostly when rage price is over fmv
function poolBoost() external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(block.timestamp >= STATE.nextBoostTime, "boostTimeout");
STATE.nextBoostTime = block.timestamp + BOOST_INTERVAL;
uint256 rageIncrease;
uint256 usdcIncrease;
uint256 rageToSell;
// sell rage for usdc if configured (CONFIG.boostRage > 0 means enabled)
if(CONFIG.boostRage > 0) {
// calculate percentage of RAGE in NFT to sell (CONFIG.boostRage is divider: 100 = 1%, 10000 = 0.01%)
uint256 rageInNft = getRageInNft();
require(rageInNft > 0, "noRageInNft");
rageToSell = rageInNft / CONFIG.boostRage;
require(rageToSell > 0, "amountTooSmall");
uint256 rageBalance = getRageBalance();
require(rageBalance >= rageToSell, "insufficientRageBalance");
uint256 usdcBefore = getUsdcBalance();
uint256 usdcReceived = RAGE_SWAPPER.swapRageForUsdc(rageToSell, CONFIG.slippage, block.timestamp + MAX_DEADLINE_DURATION);
require(usdcReceived > 0, "noUsdcReceived");
require(getUsdcBalance() == usdcBefore + usdcReceived, "incorrectUsdcBalance");
// then collect the fees and leave them in contract to be used in liquidity increase, this prevents the fees from the sells to be added to active supply
POSITION_MANAGER.collect(
INonfungiblePositionManager.CollectParams({
tokenId: NFT_ID,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
})
);
}
// liquidity increase
uint256 rageAmount = getRageBalance();
uint256 usdcAmount = getUsdcBalance();
if(rageAmount > 0 && usdcAmount > 0) {
(rageIncrease, usdcIncrease) = increaseLiquidity(rageAmount, usdcAmount);
}
STATE.amountUsdcBoost += usdcIncrease;
STATE.amountRageBoost += rageToSell;
STATE.lastBoostTime = block.timestamp;
STATE.lastBoostAmount = rageIncrease;
emit PoolBoosted(rageIncrease, usdcIncrease);
}
// rageCrush
// this daily function is use the acquiered trading fees to buy & burn rage
// it is possible to decrease liquidity on the pool to make the buy & burn bigger
function rageCrush() external nonReentrant {
require(msg.sender == STATE.automator, "unauthorized");
require(block.timestamp >= STATE.nextCrushTime, "rageTimeout");
STATE.nextCrushTime = block.timestamp + CRUSH_INTERVAL;
uint256 usdcBought = 0;
uint256 rageToBurn = 0;
// get initial balances before collecting fees
uint256 rageBalanceBefore = getRageBalance();
uint256 usdcBalanceBefore = getUsdcBalance();
// liquidity decrease if requested, this will be collected as fees in the next step
if(CONFIG.crushDecrease >= 100)
{
(, , , , , , , uint128 liquidity, , , , ) = POSITION_MANAGER.positions(NFT_ID);
uint128 liquidityToBurn = liquidity / CONFIG.crushDecrease;
uint256 amount0Min = 0;
uint256 amount1Min = 0;
// calculate slippage protection, can be disabled
if(CONFIG.slippage >= 50)
(amount0Min, amount1Min) = calculateMinimalDecreaseAmounts(liquidityToBurn);
POSITION_MANAGER.decreaseLiquidity(
INonfungiblePositionManager.DecreaseLiquidityParams({
tokenId: NFT_ID,
liquidity: liquidityToBurn,
amount0Min: amount0Min,
amount1Min: amount1Min,
deadline: block.timestamp + MAX_DEADLINE_DURATION
})
);
}
// then collect fees
POSITION_MANAGER.collect(
INonfungiblePositionManager.CollectParams({
tokenId: NFT_ID,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
})
);
// calculate collected fees
uint256 rageCollected = getRageBalance() - rageBalanceBefore;
uint256 usdcCollected = getUsdcBalance() - usdcBalanceBefore;
// add collected RAGE to burn amount
rageToBurn = rageCollected;
// buy more RAGE if enabled
if(CONFIG.crushBuy && usdcCollected > 0) {
uint256 rageBeforeSwap = getRageBalance();
uint256 rageObtained = RAGE_SWAPPER.swapUsdcForRage(usdcCollected, CONFIG.slippage, block.timestamp + MAX_DEADLINE_DURATION);
require(rageObtained > 0, "noRageObtained");
require(getRageBalance() == rageBeforeSwap + rageObtained, "incorrectSwapAmount");
usdcBought = usdcCollected;
// add bought RAGE to burn amount
rageToBurn += rageObtained;
}
if(rageToBurn > 0) {
RAGE.burn(rageToBurn);
}
STATE.amountUsdcCrush += usdcBought;
STATE.lastCrushTime = block.timestamp;
STATE.lastCrushAmount = rageToBurn;
emit RageCrushed(rageToBurn, usdcBought);
}
// rageBurst
// simple volume generation using the rage within rce contract
// this function will have a slight negative effect on price
function rageBurst() external {
require(msg.sender == STATE.automator, "unauthorized");
require(block.timestamp >= STATE.nextBurstTime, "burstTimeout");
require(CONFIG.burstLoop > 0, "noBurstLoop" );
STATE.nextBurstTime = block.timestamp + BURST_INTERVAL;
for(uint256 i = 0; i < CONFIG.burstLoop; i++)
{
if(getRageBalance() >= CONFIG.burstRage)
{
uint256 usdcBeforeSwap = getUsdcBalance();
uint256 usdcReceived = RAGE_SWAPPER.swapRageForUsdc(CONFIG.burstRage, CONFIG.slippage, block.timestamp + MAX_DEADLINE_DURATION);
require(usdcReceived > 0, "noUsdcReceived");
require(getUsdcBalance() == usdcBeforeSwap + usdcReceived, "incorrectUsdcBalance");
uint256 rageBeforeSwap = getRageBalance();
uint256 rageReceived = RAGE_SWAPPER.swapUsdcForRage(usdcReceived, CONFIG.slippage, block.timestamp + MAX_DEADLINE_DURATION);
require(rageReceived > 0, "noRageReceived");
require(getRageBalance() == rageBeforeSwap + rageReceived, "incorrectRageBalance");
}
}
// then collect fees
uint256 rageBeforeFees = getRageBalance();
uint256 usdcBeforeFees = getUsdcBalance();
POSITION_MANAGER.collect(
INonfungiblePositionManager.CollectParams({
tokenId: NFT_ID,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
})
);
uint256 rageCollected = getRageBalance() - rageBeforeFees;
uint256 usdcCollected = getUsdcBalance() - usdcBeforeFees;
STATE.lastBurstAmount = rageCollected;
STATE.lastBurstTime = block.timestamp;
emit RageBursted(rageCollected, usdcCollected);
}
// getRageInNft
// helper function to calculate how much RAGE is locked in the NFT position
function getRageInNft() public view returns (uint256) {
if (NFT_ID == 0) {
return 0;
}
(
,
,
address token0,
,
,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
,
,
,
) = POSITION_MANAGER.positions(NFT_ID);
if (liquidity == 0) {
return 0;
}
(uint160 sqrtPriceX96, , , , , , ) = POOL.slot0();
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);
(uint256 amount0, uint256 amount1) = LiquidityAmounts.getAmountsForLiquidity(
sqrtPriceX96,
sqrtRatioAX96,
sqrtRatioBX96,
liquidity
);
return (token0 == address(RAGE))? amount0 : amount1;
}
// increaseLiquidity
function increaseLiquidity(uint256 rageGained, uint256 usdcGained) internal returns(uint256 rageIncrease, uint256 usdcIncrease) {
bool isToken0Usdc = STATE.poolToken0 == address(USDC);
(uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min) = calculateOptimalIncreaseAmounts(
isToken0Usdc ? usdcGained : rageGained,
isToken0Usdc ? rageGained : usdcGained
);
if(amount0Desired > 0 && amount1Desired > 0)
{
POSITION_MANAGER.increaseLiquidity(
INonfungiblePositionManager.IncreaseLiquidityParams({
tokenId: NFT_ID,
amount0Desired: amount0Desired,
amount1Desired: amount1Desired,
amount0Min: amount0Min,
amount1Min: amount1Min,
deadline: block.timestamp + MAX_DEADLINE_DURATION
})
);
rageIncrease = isToken0Usdc ? amount1Desired: amount0Desired;
usdcIncrease = isToken0Usdc ? amount0Desired: amount1Desired;
}
}
// calculateOptimalIncreaseAmounts
// function used to increaseLiquidity to NFT, slippage can be enable or disabled in config
function calculateOptimalIncreaseAmounts(uint256 amount0Available, uint256 amount1Available) internal view returns (uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min) {
require(amount0Available > 0 && amount1Available > 0, "invalidAmounts");
// get position details
(
,
,
,
,
,
int24 tickLower,
int24 tickUpper,
,
,
,
,
) = POSITION_MANAGER.positions(NFT_ID);
// get current sqrt price
(uint160 sqrtPriceX96, , , , , , ) = POOL.slot0();
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);
uint128 liquidity = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
sqrtRatioAX96,
sqrtRatioBX96,
amount0Available,
amount1Available
);
require(liquidity > 0, "insufficientLiquidity");
(amount0Desired, amount1Desired) = LiquidityAmounts.getAmountsForLiquidity(
sqrtPriceX96,
sqrtRatioAX96,
sqrtRatioBX96,
liquidity
);
require(amount0Desired > 0 || amount1Desired > 0, "invalidDesiredAmounts");
// calculate minimum amounts accounting for slippage
amount0Min = (CONFIG.slippage >= 50)? (amount0Desired * (BPS - CONFIG.slippage)) / BPS: 0;
amount1Min = (CONFIG.slippage >= 50)? (amount1Desired * (BPS - CONFIG.slippage)) / BPS: 0;
}
// function used to decreaseLiquidity in NFT
// this will only be called if decrease function wants slippage calculation
function calculateMinimalDecreaseAmounts(uint128 liquidityToRemove) internal view returns (uint256 amount0Min, uint256 amount1Min) {
require(liquidityToRemove > 0, "invalidLiquidityAmount");
// get position details
(
,
,
,
,
,
int24 tickLower,
int24 tickUpper,
,
,
,
,
) = POSITION_MANAGER.positions(NFT_ID);
// get current sqrt price
(uint160 sqrtPriceX96, , , , , , ) = POOL.slot0();
// calculate expected amounts from liquidity
(uint256 amount0Expected, uint256 amount1Expected) = LiquidityAmounts.getAmountsForLiquidity(
sqrtPriceX96,
TickMath.getSqrtRatioAtTick(tickLower),
TickMath.getSqrtRatioAtTick(tickUpper),
liquidityToRemove
);
// calculate minimum amounts accounting for slippage
amount0Min = (amount0Expected * (BPS - CONFIG.slippage)) / BPS;
amount1Min = (amount1Expected * (BPS - CONFIG.slippage)) / BPS;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
/// @notice Emitted when the owner of the factory is changed
/// @param oldOwner The owner before the owner was changed
/// @param newOwner The owner after the owner was changed
event OwnerChanged(address indexed oldOwner, address indexed newOwner);
/// @notice Emitted when a pool is created
/// @param token0 The first token of the pool by address sort order
/// @param token1 The second token 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 pool The address of the created pool
event PoolCreated(
address indexed token0,
address indexed token1,
uint24 indexed fee,
int24 tickSpacing,
address pool
);
/// @notice Emitted when a new fee amount is enabled for pool creation via the factory
/// @param fee The enabled fee, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);
/// @notice Returns the current owner of the factory
/// @dev Can be changed by the current owner via setOwner
/// @return The address of the factory owner
function owner() external view returns (address);
/// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
/// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
/// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
/// @return The tick spacing
function feeAmountTickSpacing(uint24 fee) external view returns (int24);
/// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @return pool The pool address
function getPool(
address tokenA,
address tokenB,
uint24 fee
) external view returns (address pool);
/// @notice Creates a pool for the given two tokens and fee
/// @param tokenA One of the two tokens in the desired pool
/// @param tokenB The other of the two tokens in the desired pool
/// @param fee The desired fee for the pool
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
/// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
/// are invalid.
/// @return pool The address of the newly created pool
function createPool(
address tokenA,
address tokenB,
uint24 fee
) external returns (address pool);
/// @notice Updates the owner of the factory
/// @dev Must be called by the current owner
/// @param _owner The new owner of the factory
function setOwner(address _owner) external;
/// @notice Enables a fee amount with the given tickSpacing
/// @dev Fee amounts may never be removed once enabled
/// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
/// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
IUniswapV3PoolImmutables,
IUniswapV3PoolState,
IUniswapV3PoolDerivedState,
IUniswapV3PoolActions,
IUniswapV3PoolOwnerActions,
IUniswapV3PoolEvents
{
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
/// you must call it with secondsAgos = [3600, 0].
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
/// timestamp
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
/// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
/// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
/// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
/// snapshot is taken and the second snapshot is taken.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
/// @return tickCumulativeInside The snapshot of the tick accumulator for the range
/// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
/// @return secondsInside The snapshot of seconds per liquidity for the range
function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 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 price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld,
uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
/// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
/// @param feeProtocol0 new protocol fee for token0 of the pool
/// @param feeProtocol1 new protocol fee for token1 of the pool
function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// observationIndex The index of the last oracle observation that was written,
/// observationCardinality The current maximum number of observations stored in the pool,
/// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper,
/// liquidityNet how much liquidity changes when the pool price crosses the tick,
/// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// secondsOutside the seconds spent on the other side of the tick from the current tick,
/// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return _liquidity The amount of liquidity in the position,
/// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// Returns initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;
/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
uint8 internal constant RESOLUTION = 96;
uint256 internal constant Q96 = 0x1000000000000000000000000;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
/// @notice The permit typehash used in the permit signature
/// @return The typehash for the permit
function PERMIT_TYPEHASH() external pure returns (bytes32);
/// @notice The domain separator used in the permit signature
/// @return The domain seperator used in encoding of permit signature
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Approve of a specific token ID for spending by spender via signature
/// @param spender The account that is being approved
/// @param tokenId The ID of the token that is being approved for spending
/// @param deadline The deadline timestamp by which the call must be mined for the approve to work
/// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
/// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
/// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
/// @return Returns the address of the Uniswap V3 factory
function factory() external view returns (address);
/// @return Returns the address of WETH9
function WETH9() external view returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
/// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
/// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
/// @param amountMinimum The minimum amount of WETH9 to unwrap
/// @param recipient The address receiving ETH
function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;
/// @notice Refunds any ETH balance held by this contract to the `msg.sender`
/// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
/// that use ether for the input amount
function refundETH() external payable;
/// @notice Transfers the full amount of a token held by this contract to recipient
/// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
/// @param token The contract address of the token which will be transferred to `recipient`
/// @param amountMinimum The minimum amount of token required for a transfer
/// @param recipient The destination address of the token
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
/// @notice Creates a new pool if it does not exist, then initializes if not initialized
/// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
/// @param token0 The contract address of token0 of the pool
/// @param token1 The contract address of token1 of the pool
/// @param fee The fee amount of the v3 pool for the specified token pair
/// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
/// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then 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; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
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
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use 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.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // 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 precoditions 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 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.26;
/**
* @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: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
import '@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol';
import '@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol';
import '@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol';
import '@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol';
import './PoolAddress.sol';
/// @title Non-fungible token for positions
/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager is
IPoolInitializer,
IPeripheryPayments,
IPeripheryImmutableState,
IERC721Metadata,
IERC721Enumerable,
IERC721Permit
{
/// @notice Emitted when liquidity is increased for a position NFT
/// @dev Also emitted when a token is minted
/// @param tokenId The ID of the token for which liquidity was increased
/// @param liquidity The amount by which liquidity for the NFT position was increased
/// @param amount0 The amount of token0 that was paid for the increase in liquidity
/// @param amount1 The amount of token1 that was paid for the increase in liquidity
event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when liquidity is decreased for a position NFT
/// @param tokenId The ID of the token for which liquidity was decreased
/// @param liquidity The amount by which liquidity for the NFT position was decreased
/// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
/// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when tokens are collected for a position NFT
/// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
/// @param tokenId The ID of the token for which underlying tokens were collected
/// @param recipient The address of the account that received the collected tokens
/// @param amount0 The amount of token0 owed to the position that was collected
/// @param amount1 The amount of token1 owed to the position that was collected
event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);
/// @notice Returns the position information associated with a given token ID.
/// @dev Throws if the token ID is not valid.
/// @param tokenId The ID of the token that represents the position
/// @return nonce The nonce for permits
/// @return operator The address that is approved for spending
/// @return token0 The address of the token0 for a specific pool
/// @return token1 The address of the token1 for a specific pool
/// @return fee The fee associated with the pool
/// @return tickLower The lower end of the tick range for the position
/// @return tickUpper The higher end of the tick range for the position
/// @return liquidity The liquidity of the position
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function positions(uint256 tokenId)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
/// @notice Creates a new position wrapped in a NFT
/// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
/// a method does not exist, i.e. the pool is assumed to be initialized.
/// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
/// @return tokenId The ID of the token that represents the minted position
/// @return liquidity The amount of liquidity for this position
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function mint(MintParams calldata params)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
/// @param params tokenId The ID of the token for which liquidity is being increased,
/// amount0Desired The desired amount of token0 to be spent,
/// amount1Desired The desired amount of token1 to be spent,
/// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
/// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
/// deadline The time by which the transaction must be included to effect the change
/// @return liquidity The new liquidity amount as a result of the increase
/// @return amount0 The amount of token0 to acheive resulting liquidity
/// @return amount1 The amount of token1 to acheive resulting liquidity
function increaseLiquidity(IncreaseLiquidityParams calldata params)
external
payable
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
struct DecreaseLiquidityParams {
uint256 tokenId;
uint128 liquidity;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Decreases the amount of liquidity in a position and accounts it to the position
/// @param params tokenId The ID of the token for which liquidity is being decreased,
/// amount The amount by which liquidity will be decreased,
/// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
/// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
/// deadline The time by which the transaction must be included to effect the change
/// @return amount0 The amount of token0 accounted to the position's tokens owed
/// @return amount1 The amount of token1 accounted to the position's tokens owed
function decreaseLiquidity(DecreaseLiquidityParams calldata params)
external
payable
returns (uint256 amount0, uint256 amount1);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
/// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
/// @param params tokenId The ID of the NFT for which tokens are being collected,
/// recipient The account that should receive the tokens,
/// amount0Max The maximum amount of token0 to collect,
/// amount1Max The maximum amount of token1 to collect
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
/// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
/// must be collected first.
/// @param tokenId The ID of the token that is being burned
function burn(uint256 tokenId) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {RageStructs} from "./RageStructs.sol";
interface IRage {
// ERC20 Events
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
// Rage Events
event RageChaosEngineSet(address indexed oldOwner, address indexed newOwner);
event SupplyRequested(address indexed rce, uint256 amount, uint256 percent);
event RageBurned(uint256 amount);
// ERC20 Functions
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
// ERC20 Metadata
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
// Rage Constants
function FINAL_MAX_SUPPLY() external view returns (uint256);
// Rage View Functions
function getTotalSupply() external view returns (uint256);
function getInitialSupply() external view returns (uint256);
function getMintedSupply() external view returns (uint256);
function getBurnedSupply() external view returns (uint256);
function getMintableSupply() external view returns (uint256);
function getState() external view returns (RageStructs.RageState memory);
// Rage State-Changing Functions
function burn(uint256 amount) external;
function requestSupply(uint256 percent) external;
function setRageChaosEngine(address newOwner) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IRageSwapper {
// Administrative functions
function withdrawEth() external;
function withdrawToken(address tokenAdr) external;
// ETH swap
function swapEthForUsdc(uint256 deadline) external payable returns (uint256);
// Individual token swaps
function swapHestiaForUsdc(uint256 amount, uint256 slippage, uint256 deadline) external returns (uint256);
function swapUsdcForHestia(uint256 amount, uint256 slippage, uint256 deadline) external returns (uint256);
function swapRageForUsdc(uint256 amount, uint256 slippage, uint256 deadline) external returns (uint256);
function swapUsdcForRage(uint256 amount, uint256 slippage, uint256 deadline) external returns (uint256);
function swapCircleForUsdc(uint256 amount, uint256 slippage, uint256 deadline) external returns (uint256);
function swapUsdcForCircle(uint256 amount, uint256 slippage, uint256 deadline) external returns (uint256);
// Rage to underlying swap
function swapRageForUnderlying(
uint256 amount,
uint256 percentHestia,
uint256 percentCircle,
uint256 slippage,
uint256 deadline
) external returns (uint256 pHestiaOut, uint256 pCircleOut);
// Bond/Debond conversions
function convertHestiaToPHestia(uint256 amount, uint256 deadline) external returns (uint256);
function convertPHestiaToHestia(uint256 amount, uint256 deadline) external returns (uint256);
function convertCircleToPCircle(uint256 amount, uint256 deadline) external returns (uint256);
function convertPCircleToCircle(uint256 amount, uint256 deadline) external returns (uint256);
// Multi-asset swaps
function swapUsdcToAssets(
uint256 usdcIn,
uint256 percentHestia,
uint256 percentCircle,
uint256 hestiaSlippage,
uint256 circleSlippage,
uint256 deadline
) external returns (uint256 hestiaOut, uint256 circleOut);
function swapAssetsToUsdc(
uint256 hestiaIn,
uint256 circleIn,
uint256 hestiaSlippage,
uint256 circleSlippage,
uint256 deadline
) external returns (uint256);
// Multi-asset bond/debond
function bondAssets(
uint256 hestiaIn,
uint256 circleIn,
uint256 deadline
) external returns (uint256 pHestiaOut, uint256 pCircleOut);
function debondAssets(
uint256 pHestiaIn,
uint256 pCircleIn,
uint256 deadline
) external returns (uint256 hestiaOut, uint256 circleOut);
// Uniswap callback
function uniswapV3SwapCallback(int amount0, int amount1, bytes calldata data) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import {FullMath} from './FullMath.sol';
import {FixedPoint96} from '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol';
/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
/// @notice Downcasts uint256 to uint128
/// @param x The uint258 to be downcasted
/// @return y The passed value, downcasted to uint128
function toUint128(uint256 x) private pure returns (uint128 y) {
require((y = uint128(x)) == x);
}
/// @notice Computes the amount of liquidity received for a given amount of token0 and price range
/// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount0 The amount0 being sent in
/// @return liquidity The amount of returned liquidity
function getLiquidityForAmount0(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount0
) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);
return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));
}
/// @notice Computes the amount of liquidity received for a given amount of token1 and price range
/// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount1 The amount1 being sent in
/// @return liquidity The amount of returned liquidity
function getLiquidityForAmount1(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount1
) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));
}
/// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
/// pool prices and the prices at the tick boundaries
/// @param sqrtRatioX96 A sqrt price representing the current pool prices
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount0 The amount of token0 being sent in
/// @param amount1 The amount of token1 being sent in
/// @return liquidity The maximum amount of liquidity received
function getLiquidityForAmounts(
uint160 sqrtRatioX96,
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount0,
uint256 amount1
) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
if (sqrtRatioX96 <= sqrtRatioAX96) {
liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
} else if (sqrtRatioX96 < sqrtRatioBX96) {
uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);
uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);
liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
} else {
liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
}
}
/// @notice Computes the amount of token0 for a given amount of liquidity and a price range
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount0 The amount of token0
function getAmount0ForLiquidity(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
) internal pure returns (uint256 amount0) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return
FullMath.mulDiv(
uint256(liquidity) << FixedPoint96.RESOLUTION,
sqrtRatioBX96 - sqrtRatioAX96,
sqrtRatioBX96
) / sqrtRatioAX96;
}
/// @notice Computes the amount of token1 for a given amount of liquidity and a price range
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount1 The amount of token1
function getAmount1ForLiquidity(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
) internal pure returns (uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
}
/// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
/// pool prices and the prices at the tick boundaries
/// @param sqrtRatioX96 A sqrt price representing the current pool prices
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function getAmountsForLiquidity(
uint160 sqrtRatioX96,
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity
) internal pure returns (uint256 amount0, uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
if (sqrtRatioX96 <= sqrtRatioAX96) {
amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
} else if (sqrtRatioX96 < sqrtRatioBX96) {
amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);
amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);
} else {
amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddress {
bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;
/// @notice The identifying key of the pool
struct PoolKey {
address token0;
address token1;
uint24 fee;
}
/// @notice Returns PoolKey: the ordered tokens with the matched fee levels
/// @param tokenA The first token of a pool, unsorted
/// @param tokenB The second token of a pool, unsorted
/// @param fee The fee level of the pool
/// @return Poolkey The pool details with ordered token0 and token1 assignments
function getPoolKey(
address tokenA,
address tokenB,
uint24 fee
) internal pure returns (PoolKey memory) {
if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
}
/// @notice Deterministically computes the pool address given the factory and PoolKey
/// @param factory The Uniswap V3 factory contract address
/// @param key The PoolKey
/// @return pool The contract address of the V3 pool
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
require(key.token0 < key.token1);
pool = factory;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
library RageStructs {
struct RbpState {
uint256 version; // rbp version
RageStructs.RbpStateValue state; // rbp internal state
RageStructs.RbpConfig config; // rbp internal configurations
RageStructs.RbpRecent recent; // rbp most recent actions
}
struct RbpViewState {
uint256 price; // current rage price
uint256 activeSupply; // active supply as declared by rce
uint256 fmv; // current rage fmv
uint256 backingPerShare; // current rage backing per share
uint256 activeAssetsUsdcValue; // Total USDC value of active assets
uint256 rawHestia; // Raw HESTIA balance
uint256 rawCircle; // Raw CIRCLE balance
uint256 pendingHestia; // Pending HESTIA
uint256 pendingCircle; // Pending CIRCLE
uint256 bonusHestia; // Available bonus HESTIA
uint256 bonusCircle; // Available bonus CIRCLE
uint256 activePhestia; // Active pHESTIA balance
uint256 activePcircle; // Active pCIRCLE balance
uint256 activeHestia; // Active HESTIA balance
uint256 activeCircle; // Active CIRCLE balance
uint256 investPercentHestia; // HESTIA investment percentage
uint256 investPercentCircle; // CIRCLE investment percentage
uint256 underlyingHestia; // HESTIA per RAGE
uint256 underlyingCircle; // CIRCLE per RAGE
uint256 underlyingHestiaValue; // USDC value of HESTIA per RAGE
uint256 underlyingCircleValue; // USDC value of CIRCLE per RAGE
uint256 underlyingTotalValue; // Total USDC value per RAGE
uint256 underlyingHestiaPercent; // HESTIA percentage
uint256 underlyingCirclePercent; // CIRCLE percentage
uint256 rageFromOnePercentUsdc; // RAGE received from one percent of active value in USDC
uint256 hestiaFromOnePercentRage; // HESTIA received from one percent of Rage active supply
uint256 circleFromOnePercentRage; // CIRCLE received from one percent of Rage active supply
}
struct RageState {
uint256 version; // version of the rage contract
address owner; // owner of the rage token
uint256 supply; // current rage supply
uint256 initial; // rage initial supply
uint256 mint; // total minted rage
uint256 burn; // total burned rage
uint256 mintable; // supply that can still be minted
uint256 lastRequestSupply; // timestamp of last supply request
}
struct RonState {
uint256 version; // version of the rage option contract
address rce; // address of the rce contract
address rbp; // address of the rbp contract
uint256 supply; // total nft supply
string baseUri; // base uri for the nft metadata
string contractUri; // uri of the contract metadata json file
}
struct RbpStateValue {
uint256 status; // Protocol status (0 = off, 1 = on)
uint256 nextConfigTime; // Next allowed configuration update timestamp
uint256 pendingHestia; // Amount of HESTIA tokens in pending backing
uint256 pendingCircle; // Amount of CIRCLE tokens in pending backing
uint256 totalOptions; // Total number of investment options created
uint256 optionsMint; // Options converted to RAGE tokens
uint256 optionsAdp; // Options minted using Asset Decline Protection
uint256 optionsAdpValue; // USDC value of options minted using Asset Decline Protection
uint256 optionsRefund; // Options that were refunded
uint256 optionsRefundValue; // USDC value of refunded options
uint256 totalInvest; // USDC value of invest
uint256 totalInvestorBonus; // USDC value of bonus given to investor
uint256 totalEcosystemBonus; // USDC value of bonus given to ecosystem
uint256 totalDebt; // Total USDC owed for potential refunds
uint256 totalClaims; // Total number of unique claim wallets
uint256 totalAdpDilution; // Total USDC value diluted through ADP
uint256 claimsProcessed; // Number of claims successfully processed
uint256 claimsHestia; // Total HESTIA tokens claimed
uint256 claimsCircle; // Total CIRCLE tokens claimed
}
struct OraclePrices {
uint256 wethTwapUsdcPrice; // TWAP price of WETH in USDC
uint256 hestiaTwapUsdcPrice; // TWAP price of HESTIA in USDC
uint256 circleTwapUsdcPrice; // TWAP price of CIRCLE in USDC
uint256 hestiaCircleTwapUsdcPrice; // TWAP price of 1 Hestia and 1 Circle in USDC
uint256 rageTwapUsdcPrice; // TWAP price of RAGE in USDC
uint256 hestiaUsdcPriceAfterBondDebond; // HESTIA price after bond/debond fees
uint256 circleUsdcPriceAfterBondDebond; // CIRCLE price after bond/debond fees
uint256 pHestiaUsdcPriceAfterDebond; // pHESTIA value in USDC after debonding
uint256 pCircleUsdcPriceAfterDebond; // pCIRCLE value in USDC after debonding
uint256 pHestiaInHestiaAfterDebond; // HESTIA received per pHESTIA after debond
uint256 pCircleInCircleAfterDebond; // CIRCLE received per pCIRCLE after debond
uint256 pHestiaRequiredForHestia; // pHESTIA needed to get 1 HESTIA
uint256 pCircleRequiredForCircle; // pCIRCLE needed to get 1 CIRCLE
uint256 pHestiaRequiredForHestiaResult; // HESTIA received when doing pHestiaRequiredForHestia (should be close to 1)
uint256 pCircleRequiredForCircleResult; // CIRCLE received when doing pHestiaRequiredForHestia (should be close to 1)
}
struct RbpConfig {
uint256 minInvest; // Adjustable from $1 to $100 (default $10) - determines the minimum amount of USDC to receive to create a position
uint256 maxInvest; // Adjustable from $1000 to $100000 (default $10000) - determines the maximum amount of USDC to receive to create a position
uint256 hestiaPercent; // Adjustable from 55% to 95% (default: 80%) - determines the percentage of each investment and bonus allocated to HESTIA tokens
uint256 investorBonus; // Adjustable from 1% to 15% (default: 6%) - sets the bonus percentage in both tokens (at their ratios) given to investors on their token purchases to cover wrapping fees and provide net benefit
uint256 mintDelay; // Adjustable from 1 to 90 days (default: 3 days) - controls the mandatory waiting period after investment before NFT receipts can be converted to RAGE tokens
uint256 adpDelay; // Adjustable from 30 to 300 days (default: 60 days) - sets the waiting period after investment before Asset Decline Protection becomes available for NFT conversion
uint256 adpPercent; // Adjustable from 55% to 90% (default: 75%) - determines the percentage of original investment value used for Asset Decline Protection calculations. Cannot be more than refund percent.
uint256 ecosystemBonus; // Adjustable from 1% to 15% (default: 6%) - controls the bonus tokens (distributed at their ratios) added to active assets with each new investment
uint256 refundPercent; // Adjustable from 55% to 95% (default: 85%) - sets the percentage of original investment recoverable through the USDC refund mechanism (does not affect Asset Decline Protection calculations)
uint256 refundDelay; // Adjustable from 500 days to 1500 days (default 1000 days) - sets the waiting period after investment before a refund can be requested
uint256 minClaim; // Adjustable from 1e15 to 1e18 (default 1e18) - sets the minimum amount of Rage to reserve a claim
uint256 maxClaim; // Adjustable from 100e18 to infinity (default 1000e18) - sets the maximum amount of Rage to reserve a claim
uint256 claimFee; // Adjustable from 1% to 20% (default: 10%) - determines the fee applied when users claim their RAGE tokens
uint256 claimDelay; // Adjustable from 10 to 100 days (default: 30 days) - sets the waiting period between creating and executing claims
uint256 claimValidity; // Adjustable from 1 to 30 days (default: 10 days) - sets the validity period of a claim
uint256 slippage; // Adjustable from 0 (off) to 2500 (25%), default is 500 or 5%, slippage when swapping on the pool
uint32 twap; // Adjustable from 1 seconds to 3600 seconds, default is 30 seconds, twap duration for price calculation
}
struct RceConfig {
uint256 stackRage; // amount of rage to sell in stack underlying (range: 100-10000, default: 100)
uint256 stackHestia; // percent of hestia for stack underlying (range: 0-100, default: 80)
uint256 boostRage; // amount of rage to sell in pool boost (0=off, range: 100-10000, default: 100)
uint128 crushDecrease; // liquidity decrease for rageCrush (0=off, range: 100-10000, default: 0)
bool crushBuy; // whether rageCrush buys with collected USDC (default: true)
uint256 burstRage; // amount of rage to sell in rage burst (range: 1e18-200e18, default: 10e18)
uint256 burstLoop; // number of loops to do in rage burst (range: 1-5, default: 2)
uint256 slippage; // slippage for swaps/liquidity (0=off, max: 2500, default: 500)
address podAddress; // pod address excluded from active supply (default: address(0))
address sideAddress1; // side pool address #1 excluded from active supply (default: address(0))
address sideAddress2; // side pool address #2 excluded from active supply (default: address(0))
}
struct RbpRecent {
uint256 lastInvest; // Option ID of most recent investment
uint256 lastMintRage; // Option ID of most recent RAGE mint
uint256 lastRefund; // Option ID of most recent refund
address lastReserveClaim; // Wallet address of most recent claim reservation
address lastClaim; // Wallet address of most recent claim execution
}
struct Option {
uint256 id; // Unique option identifier
uint256 version; // Contract version when created
uint8 status; // Option status (1=active, 2=minted, 3=minted with ADP, 4=refunded)
string transactionType; // Transaction type ("i"=invest, "e"=ETH invest, "r"=receive)
address walletCreated; // Original creator wallet address
address walletUpdated; // Wallet that last updated the option
address referral; // Referral address if applicable
uint256 dateCreated; // Timestamp when option was created
uint256 dateUpdated; // Timestamp of last update
uint256 dateMintable; // Timestamp when RAGE minting becomes available
uint256 dateAdpAble; // Timestamp when ADP protection activates
uint256 dateRefundable; // Timestamp when refund becomes available
uint256 price; // price per rage when option was created
uint256 fmv; // fmv when option was created
uint256 backingPerShare; // backing per share at the moment the option was created
uint256 usdcInvest; // Original USDC investment amount
uint256 usdcAdp; // USDC value protected by ADP
uint256 usdcRefund; // USDC amount refundable
uint256 pendingHestia; // HESTIA tokens pending in this option
uint256 pendingCircle; // CIRCLE tokens pending in this option
uint256 rageEstimated; // Estimated RAGE tokens at creation
uint256 rageMinted; // Actual RAGE tokens minted
uint256 usdcAdpDilution; // USDC value diluted if ADP was used
uint256 usdcInvestorBonus; // USDC value of bonus given to investor
uint256 hestiaInvestorBonus; // HESTIA bonus given to investor
uint256 circleInvestorBonus; // CIRCLE bonus given to investor
uint256 usdcEcosystemBonus; // USDC value of bonus given to ecosystem
uint256 hestiaEcosystemBonus; // HESTIA bonus given to ecosystem
uint256 circleEcosystemBonus; // CIRCLE bonus given to ecosystem
uint256 configHestiaPercent; // HESTIA allocation % at creation
uint256 configCirclePercent; // CIRCLE allocation % at creation
uint256 configInvestorBonus; // Investor bonus % at creation
uint256 configMintDelay; // Mint delay at creation
uint256 configAdpDelay; // ADP delay at creation
uint256 configAdpPercent; // ADP percentage at creation
uint256 configRefundPercent; // Refund percentage at creation
uint256 configRefundDelay; // Refund delay at creation
}
struct Claim {
address wallet; // Wallet address making the claim
uint256 version; // Contract version when created
uint8 status; // Claim status (1=active, 2=claimed)
uint256 claimedCount; // Number of times this wallet has claimed
uint256 dateCreated; // Timestamp when claim was reserved
uint256 dateUpdated; // Timestamp of last update
uint256 dateClaimableStart; // Start of claim validity window
uint256 dateClaimableEnd; // End of claim validity window
uint256 rageBurn; // RAGE tokens to burn (before fee)
uint256 rageAfterFee; // RAGE tokens after fee deduction
uint256 price; // price per rage when claim was created
uint256 fmv; // fmv when claim was created
uint256 backingPerShare; // backing per share at the moment the claim was created
uint256 claimHestia; // HESTIA tokens claimable
uint256 claimCircle; // CIRCLE tokens claimable
uint256 lastClaimHestia; // HESTIA claimed in last execution
uint256 lastClaimCircle; // CIRCLE claimed in last execution
uint256 totalClaimHestia; // All HESTIA claimed by this wallet
uint256 totalClaimCircle; // All CIRCLE claimed by this wallet
uint256 configClaimFee; // Claim fee % at reservation
uint256 configClaimDelay; // Claim delay at reservation
uint256 configClaimValidity; // Validity period at reservation
}
struct OptionsOverview {
uint256 totalDebt; // Total USDC owed for potential refunds
uint256 totalDebtReal; // Real debt considering current asset values
uint256 adpDebt; // USDC owed for ADP-eligible options
uint256 adpDebtReal; // Real ADP debt considering current asset values
uint256 refundDebt; // USDC owed for refundable options
uint256 refundDebtReal; // Real refund debt considering current asset values
uint256 mintableRage; // Total RAGE tokens mintable from active options
uint256 usdcInvested; // Total USDC invested across all options
uint256 usdcBonus; // Total USDC value of all bonuses
uint256 hestiaInvestorBonus; // Total HESTIA given as investor bonus
uint256 circleInvestorBonus; // Total CIRCLE given as investor bonus
uint256 optionActiveCount; // Count of options with status 1
uint256 optionMintCount; // Count of options with status 2
uint256 optionAdpCount; // Count of options with status 3
uint256 optionRefundCount; // Count of options with status 4
uint256 totalPendingHestia; // Sum of all pendingHestia in active options
uint256 totalPendingCircle; // Sum of all pendingCircle in active options
uint256 optionsRefundableWithinThreshold; // Options becoming refundable soon (for liquidation planning)
uint256 refundDebtRealThreshold; // Real refund debt in the next 30 days considering current asset values
uint256 optionsMintableNow; // Active options that can be minted right now
uint256 optionsAdpAbleNow; // Active options eligible for ADP right now
uint256 optionsRefundableNow; // Active options that can be refunded right now
uint256 totalAdpDilution; // Total USDC diluted through ADP (from status 3 options)
uint256 totalRefundValue; // Total USDC refunded (from status 4 options)
uint256 totalRageMinted; // Sum of rageMinted from minted options
}
struct ClaimsOverview {
uint256 activeClaimsCount; // Count of active claims (status 1)
uint256 claimedCount; // Count of claimed (status 2)
uint256 pendingClaimsCount; // Active claims not yet in claim window
uint256 claimableNowCount; // Active claims currently in claim window
uint256 expiredClaimsCount; // Active claims past their window
uint256 pendingHestia; // Total HESTIA in pending claims
uint256 pendingCircle; // Total CIRCLE in pending claims
uint256 claimableHestia; // Total HESTIA in claimable-now claims
uint256 claimableCircle; // Total CIRCLE in claimable-now claims
uint256 totalRageToBurn; // Total RAGE that will be burned from active claims
uint256 totalClaimedHestia; // Historical total of HESTIA claimed
uint256 totalClaimedCircle; // Historical total of CIRCLE claimed
}
struct InvestOverview {
address wallet; // Investor wallet address
string transactionType; // Transaction type identifier
bool canInvest; // Whether investment is allowed
bool isAmountValid; // Whether amount is within min/max limits
bool isPercentValid; // Whether allocation percentages sum to 100%
bool hasBonus; // Whether bonus HESTIA is available
uint256 rageEstimated; // Estimated RAGE tokens to receive
uint256 rageEstimatedValue; // Estimated USDC value of Rage tokens to receive
uint256 dateMintable; // When RAGE minting becomes available
uint256 dateAdpAble; // When ADP protection activates
uint256 dateRefundable; // When refund becomes available
uint256 usdcInvest; // USDC amount to invest
uint256 usdcAdp; // USDC protected by ADP
uint256 usdcRefund; // USDC refundable amount
uint256 usdcInvestorBonus; // USDC value of investor bonus
uint256 usdcEcosystemBonus; // USDC value of ecosystem bonus
uint256 usdcHestiaBonus; // USDC value of Hestia investor + ecosystem bonus
uint256 usdcCircleBonus; // USDC value of Circle investor + ecosystem bonus
uint256 hestiaInvestorBonus; // HESTIA tokens as investor bonus
uint256 hestiaEcosystemBonus; // HESTIA tokens as ecosystem bonus
uint256 circleInvestorBonus; // CIRCLE tokens as investor bonus
uint256 circleEcosystemBonus; // CIRCLE tokens as ecosystem bonus
uint256 configHestiaPercent; // Current HESTIA allocation %
uint256 configCirclePercent; // Current CIRCLE allocation %
uint256 configInvestorBonus; // Current investor bonus %
uint256 configMintDelay; // Current mint delay setting
uint256 configAdpDelay; // Current ADP delay setting
uint256 configAdpPercent; // Current ADP percentage
uint256 configRefundPercent; // Current refund percentage
uint256 configRefundDelay; // Current refund delay
}
struct OptionOverview {
address wallet; // Option owner wallet address
uint256 optionId; // Id of the option nft
bool canMint; // Whether RAGE minting is available
bool canMintWithAdp; // Whether ADP minting is available
bool canRefund; // Whether refund is available
bool hasRefundUsdc; // Whether contract has USDC for refund
uint256 rageMint; // RAGE tokens that can be minted
uint256 rageMintValue; // USDC value of Rage tokens to be minted
uint256 usdcAssets; // Current USDC value of the assets
uint256 usdcCurrent; // Current USDC value for minting
uint256 usdcBalance; // Contract's USDC balance
uint256 usdcAdpDilution; // ADP dilution amount in USDC
uint256 backingPerShare; // Current backing per share
bool mintValueProfitable; // Whether minting rage is profitable (rageMintValue higher than assets or adp value)
bool mintBackingProfitable; // Whether minting rage now has less backing that when option was created
}
struct ReserveClaimOverview {
address wallet; // Claimer wallet address
bool canReserve; // Whether claim can be reserved
bool hasActiveClaim; // Whether wallet has active claim
bool isFirstClaim; // Whether this is wallet's first claim
uint256 rageBurn; // RAGE to burn (before fee)
uint256 rageBurnValue; // USDC value of rage to burn (before fee)
uint256 rageAfterFee; // RAGE after fee deduction
uint256 claimHestia; // HESTIA claimable
uint256 claimCircle; // CIRCLE claimable
uint256 claimValue; // USDC value of claim assets
uint256 dateClaimableStart; // Start of validity window
uint256 dateClaimableEnd; // End of validity window
uint256 configClaimFee; // Current claim fee %
uint256 configClaimDelay; // Current claim delay
uint256 configClaimValidity; // Current validity period
}
struct ClaimOverview {
address wallet; // Claimer wallet address
bool canClaim; // Whether claim can be executed
bool hasBalance; // Whether wallet has RAGE balance
bool isValid; // Whether within validity window
uint256 rageBurn; // RAGE to burn (before fee)
uint256 rageBurnValue; // USDC value of rage to burn (before fee)
uint256 claimHestia; // HESTIA to receive
uint256 claimCircle; // CIRCLE to receive
uint256 claimValue; // USDC value of claim assets
uint256 pHestiaNeeded; // pHestia needed for debond
uint256 pCircleNeeded; // pCircle needed for debond
uint256 recalcClaimHestia; // Recalculated HESTIA amount
uint256 recalcClaimCircle; // Recalculated CIRCLE amount
uint256 recalcClaimValue; // USDC value of recalculated claim assets
uint256 backingPerShare; // Current backing per share
}
struct RceStateValue {
uint256 nextBoostTime;
uint256 nextStackTime;
uint256 nextCrushTime;
uint256 nextBurstTime;
uint256 nextConfigTime;
uint256 nextYearlyAllowance;
address poolToken0;
uint256 nftLocked;
address rageBuyingProtocol;
address pendingRbp;
address ownerProposer;
address owner1;
address owner2;
address automator;
uint256 amountAllowance;
uint256 amountTransfer;
uint256 amountMint;
uint256 amountRageStack;
uint256 amountUsdcBoost;
uint256 amountRageBoost;
uint256 amountUsdcCrush;
uint256 lastStackTime;
uint256 lastStackAmount;
uint256 lastBoostTime;
uint256 lastBoostAmount;
uint256 lastCrushTime;
uint256 lastCrushAmount;
uint256 lastBurstTime;
uint256 lastBurstAmount;
}
struct RceState {
uint256 version; // Contract version identifier
address rageSwapper; // Address of the Rage Swapper contract for DEX operations
address multisig; // Multisig wallet address for admin operations
address poolAddress; // Uniswap V3 pool address for RAGE/USDC
uint256 nftId; // Uniswap V3 NFT position ID
uint256 nftSupply; // RAGE tokens within the NFT of the RAGE/USDC pool
uint256 activeSupply; // RAGE tokens that are active and backed by underlying assets
uint256 rageBalance; // Current RAGE balance in contract
uint256 usdcBalance; // Current USDC balance in contract
RceConfig config;
RceStateValue state;
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Gas optimized reentrancy protection for smart contracts.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ReentrancyGuard.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
uint256 private locked = 1;
modifier nonReentrant() virtual {
require(locked == 1, "REENTRANCY");
locked = 2;
_;
locked = 1;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.26;
/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
error T();
error R();
/// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
int24 internal constant MIN_TICK = -887272;
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
int24 internal constant MAX_TICK = -MIN_TICK;
/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
uint160 internal constant MIN_SQRT_RATIO = 4295128739;
/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
/// @notice Calculates sqrt(1.0001^tick) * 2^96
/// @dev Throws if |tick| > max tick
/// @param tick The input tick for the above formula
/// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the given tick
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
unchecked {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
if (absTick > uint256(int256(MAX_TICK))) revert T();
uint256 ratio = absTick & 0x1 != 0
? 0xfffcb933bd6fad37aa2d162d1a594001
: 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
}
/// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
/// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
/// ever return.
/// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
/// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
unchecked {
// second inequality must be < because the price can never reach the price at the max tick
if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R();
uint256 ratio = uint256(sqrtPriceX96) << 32;
uint256 r = ratio;
uint256 msb = 0;
assembly {
let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(5, gt(r, 0xFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(4, gt(r, 0xFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(3, gt(r, 0xFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(2, gt(r, 0xF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(1, gt(r, 0x3))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := gt(r, 0x1)
msb := or(msb, f)
}
if (msb >= 128) r = ratio >> (msb - 127);
else r = ratio << (127 - msb);
int256 log_2 = (int256(msb) - 128) << 64;
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(63, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(62, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(61, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(60, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(59, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(58, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(57, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(56, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(55, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(54, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(53, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(52, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(51, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(50, f))
}
int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);
tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
}
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"rage","type":"address"},{"internalType":"address","name":"rSwap","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"address","name":"owner1","type":"address"},{"internalType":"address","name":"owner2","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"automator","type":"address"}],"name":"AutomatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"stackRage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stackHestia","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boostRage","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"crushDecrease","type":"uint128"},{"indexed":false,"internalType":"bool","name":"crushBuy","type":"bool"},{"indexed":false,"internalType":"uint256","name":"burstRage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"burstLoop","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"slippage","type":"uint256"},{"indexed":false,"internalType":"address","name":"podAddress","type":"address"},{"indexed":false,"internalType":"address","name":"sideAddress1","type":"address"},{"indexed":false,"internalType":"address","name":"sideAddress2","type":"address"}],"name":"ConfigChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"LockNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rageIncrease","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usdcIncrease","type":"uint256"}],"name":"PoolBoosted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rageCollected","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usdcCollected","type":"uint256"}],"name":"RageBursted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"proposer","type":"address"},{"indexed":true,"internalType":"address","name":"pendingRbp","type":"address"}],"name":"RageBuyingProtocolProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newRbp","type":"address"}],"name":"RageBuyingProtocolSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rageBurned","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usdcBought","type":"uint256"}],"name":"RageCrushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RageTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SupplyBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"percent","type":"uint256"}],"name":"SupplyRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rageSold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pHestia","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pCircle","type":"uint256"}],"name":"UnderlyingStacked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"activeSupply","type":"uint256"}],"name":"YearlyAllowanceRequested","type":"event"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getActiveSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAutomator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMultisig","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getOwners","outputs":[{"internalType":"address","name":"owner1","type":"address"},{"internalType":"address","name":"owner2","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRageBuyingProtocol","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRageInNft","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getState","outputs":[{"components":[{"internalType":"uint256","name":"version","type":"uint256"},{"internalType":"address","name":"rageSwapper","type":"address"},{"internalType":"address","name":"multisig","type":"address"},{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"nftSupply","type":"uint256"},{"internalType":"uint256","name":"activeSupply","type":"uint256"},{"internalType":"uint256","name":"rageBalance","type":"uint256"},{"internalType":"uint256","name":"usdcBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"stackRage","type":"uint256"},{"internalType":"uint256","name":"stackHestia","type":"uint256"},{"internalType":"uint256","name":"boostRage","type":"uint256"},{"internalType":"uint128","name":"crushDecrease","type":"uint128"},{"internalType":"bool","name":"crushBuy","type":"bool"},{"internalType":"uint256","name":"burstRage","type":"uint256"},{"internalType":"uint256","name":"burstLoop","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"address","name":"podAddress","type":"address"},{"internalType":"address","name":"sideAddress1","type":"address"},{"internalType":"address","name":"sideAddress2","type":"address"}],"internalType":"struct RageStructs.RceConfig","name":"config","type":"tuple"},{"components":[{"internalType":"uint256","name":"nextBoostTime","type":"uint256"},{"internalType":"uint256","name":"nextStackTime","type":"uint256"},{"internalType":"uint256","name":"nextCrushTime","type":"uint256"},{"internalType":"uint256","name":"nextBurstTime","type":"uint256"},{"internalType":"uint256","name":"nextConfigTime","type":"uint256"},{"internalType":"uint256","name":"nextYearlyAllowance","type":"uint256"},{"internalType":"address","name":"poolToken0","type":"address"},{"internalType":"uint256","name":"nftLocked","type":"uint256"},{"internalType":"address","name":"rageBuyingProtocol","type":"address"},{"internalType":"address","name":"pendingRbp","type":"address"},{"internalType":"address","name":"ownerProposer","type":"address"},{"internalType":"address","name":"owner1","type":"address"},{"internalType":"address","name":"owner2","type":"address"},{"internalType":"address","name":"automator","type":"address"},{"internalType":"uint256","name":"amountAllowance","type":"uint256"},{"internalType":"uint256","name":"amountTransfer","type":"uint256"},{"internalType":"uint256","name":"amountMint","type":"uint256"},{"internalType":"uint256","name":"amountRageStack","type":"uint256"},{"internalType":"uint256","name":"amountUsdcBoost","type":"uint256"},{"internalType":"uint256","name":"amountRageBoost","type":"uint256"},{"internalType":"uint256","name":"amountUsdcCrush","type":"uint256"},{"internalType":"uint256","name":"lastStackTime","type":"uint256"},{"internalType":"uint256","name":"lastStackAmount","type":"uint256"},{"internalType":"uint256","name":"lastBoostTime","type":"uint256"},{"internalType":"uint256","name":"lastBoostAmount","type":"uint256"},{"internalType":"uint256","name":"lastCrushTime","type":"uint256"},{"internalType":"uint256","name":"lastCrushAmount","type":"uint256"},{"internalType":"uint256","name":"lastBurstTime","type":"uint256"},{"internalType":"uint256","name":"lastBurstAmount","type":"uint256"}],"internalType":"struct RageStructs.RceStateValue","name":"state","type":"tuple"}],"internalType":"struct RageStructs.RceState","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poolBoost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rageBurst","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rageCrush","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"percent","type":"uint256"}],"name":"requestSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"percent","type":"uint256"}],"name":"requestYearlyAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"automator","type":"address"}],"name":"setAutomator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"stackRage","type":"uint256"},{"internalType":"uint256","name":"stackHestia","type":"uint256"},{"internalType":"uint256","name":"boostRage","type":"uint256"},{"internalType":"uint128","name":"crushDecrease","type":"uint128"},{"internalType":"bool","name":"crushBuy","type":"bool"},{"internalType":"uint256","name":"burstRage","type":"uint256"},{"internalType":"uint256","name":"burstLoop","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"address","name":"podAddress","type":"address"},{"internalType":"address","name":"sideAddress1","type":"address"},{"internalType":"address","name":"sideAddress2","type":"address"}],"internalType":"struct RageStructs.RceConfig","name":"newConfig","type":"tuple"}],"name":"setConfigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRbp","type":"address"}],"name":"setRageBuyingProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stackUnderlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferRage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAdr","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60e080604052346105d75760a081615581803803809161001f82856108df565b8339810103126105d75761003281610902565b61003e60208301610902565b9160408101519261005d608061005660608501610902565b9301610902565b60016000556001600160a01b0393841660805290831660c052600d80549284166001600160a01b0319938416179055600e80549190931690821617909155600f805473cbe5a4103d4c7ed5d73d9942101473c1bc0a8020921691909117905560405161016081018181106001600160401b038211176108c9576000916101409160405260648152605060208201526064604082015282606082015260016080820152678ac7230489e8000060a0820152600260c08201526103e860e08201528261010082015273b278f52bc80b883da0729a863f853845965af00961012082015201526064601f5560506020556064602155600160801b60018060881b03196022541617602255678ac7230489e8000060235560026024556103e860255560018060a01b03196026541660265573b278f52bc80b883da0729a863f853845965af00960018060a01b0319602754161760275560018060a01b03196028541660285560018060a01b0360c051166040519063095ea7b360e01b82526004820152600019602482015260208160448160006000805160206155618339815191525af180156105e4576108ac575b5060805160c05160405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529160209183916044918391600091165af180156105e45761088f575b5060805160405163095ea7b360e01b81527303a520b32c04bf3beef7beb72e919cf822ed34f16004820152600019602482015290602090829060449082906000906001600160a01b03165af180156105e457610872575b5060405163095ea7b360e01b81527303a520b32c04bf3beef7beb72e919cf822ed34f16004820152600019602482015260208160448160006000805160206155618339815191525af180156105e457610855575b5060405163133f757160e31b815260048101829052610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa9081156105e45760008091819361078e575b5060018060a01b03169060008051602061556183398151915282149182610776575b8215610738575b5050156106f35762ffffff6127109116036106ae57608051604051630b4c774160e11b815260008051602061556183398151915260048201526001600160a01b03909116602482015261271060448201526020816064817333128a8fc17869897dce68ed026d694621f6fdfd5afa9081156105e457600091610674575b50600180546001600160a01b0319166001600160a01b03929092169182179055801561063a5760405163095ea7b360e01b81526004810191909152600019602482015260208160448160006000805160206155618339815191525af180156105e45761061d575b5060805160015460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529160209183916044918391600091165af180156105e4576105f0575b50600154604051630dfe168160e01b815290602090829060049082906001600160a01b03165afa9081156105e4576000916105a5575b50600880546001600160a01b0319166001600160a01b039290921691909117905560a052604051614c10908161095182396080518181816116190152818161189e01528181611fe201528181612300015281816124df0152818161315201528181613b970152818161438f0152614460015260a0518181816104fc01528181610e84015281816114a80152818161179001528181611aa301528181611e38015281816129240152818161351c01526142be015260c05181818161040a0152818161143f015281816119670152818161272501526134d00152f35b90506020813d6020116105dc575b816105c0602093836108df565b810103126105d7576105d190610902565b386104cb565b600080fd5b3d91506105b3565b6040513d6000823e3d90fd5b6106119060203d602011610616575b61060981836108df565b810190610916565b610495565b503d6105ff565b6106359060203d6020116106165761060981836108df565b61044d565b60405162461bcd60e51b8152602060048201526012602482015271696e76616c6964506f6f6c4164647265737360701b6044820152606490fd5b90506020813d6020116106a6575b8161068f602093836108df565b810103126105d7576106a090610902565b386103e6565b3d9150610682565b60405162461bcd60e51b815260206004820152601a60248201527f6e667446656554696572446f65734e6f744d61746368506f6f6c0000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601c60248201527f6e6674546f6b656e73446f4e6f4d61746368506f6f6c546f6b656e73000000006044820152606490fd5b6080516001600160a01b031614915081610755575b503880610369565b6001600160a01b03166000805160206155618339815191521490503861074d565b6080516001600160a01b038381169116149250610362565b92509050610180823d821161084d575b816107ac61018093836108df565b8101031261084a5781516001600160601b0381160361084a576107d160208301610902565b506107de60408301610902565b6107ea60608401610902565b9260808101519262ffffff8416840361084a57506101608161081160a0610840940161092e565b5061081e60c0820161092e565b5061082b60e0820161093c565b50610839610140820161093c565b500161093c565b5091909138610340565b80fd5b3d915061079e565b61086d9060203d6020116106165761060981836108df565b6102fb565b61088a9060203d6020116106165761060981836108df565b6102a7565b6108a79060203d6020116106165761060981836108df565b610250565b6108c49060203d6020116106165761060981836108df565b610208565b634e487b7160e01b600052604160045260246000fd5b601f909101601f19168101906001600160401b038211908210176108c957604052565b51906001600160a01b03821682036105d757565b908160209103126105d7575180151581036105d75790565b51908160020b82036105d757565b51906001600160801b03821682036105d75756fe608080604052600436101561001357600080fd5b600090813560e01c9081631865c57d1461330c575080633c81df21146132dd5780634429bfc1146130b457806371c62810146130995780637825fe3a14612a73578063825949a1146126a357806389476069146124a25780639be804481461224f578063a0e67e2b1461221c578063a0ef91df1461210d578063add1488c146120e4578063b198e1b514611f91578063bee2660914611df6578063ce34ba1014611703578063d595c331146115c2578063da990f7d14610d5f578063e244818514610b55578063e7c5a6e814610a17578063ea3adfa0146109ee578063ef280ce5146109cb578063f24f30e6146102a75763f2fde38b1461011357600080fd5b346102a45760203660031901126102a45761012c6139a9565b6101396001835414613a4d565b6002825560018060a01b03600d541680331491828015610290575b61015d90613ec0565b6001600160a01b031691821561025557600a54610185906001600160a01b0316841415614200565b600f546001600160a01b0316831461021757156101f45750600e546101b5906001600160a01b0316821415614401565b600d80546001600160a01b031916821790555b337f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a36001815580f35b61020090821415614401565b600e80546001600160a01b031916821790556101c8565b60405162461bcd60e51b815260206004820152601660248201527537bbb732b921b0b73737ba2132a0baba37b6b0ba37b960511b6044820152606490fd5b60405162461bcd60e51b8152602060048201526013602482015272696e76616c69644f776e65724164647265737360681b6044820152606490fd5b50600e546001600160a01b03163314610154565b80fd5b50346102a457806003193601126102a4576102c56001825414613a4d565b600281556102de60018060a01b03600f54163314613ec0565b6003544210610997576138404201804211610983576003556103156103016142bc565b61030c811515614189565b601f5490614088565b6103208115156141c3565b6103338161032c614445565b1015613ac2565b60205480606403916064831161096f576040516370a0823160e01b81523060048201529260208460248173f760fd8feb1f5e3bf3651e2e4f227285a82470ff5afa93841561060e57859461093b575b506040516370a0823160e01b8152306004820152906020826024817355a81da2a319dd60fb028c53cb4419493b56f6c05afa91821561083b578692610907575b5060255460784201918242116108f35760405195639632612f60e01b8752856004880152602487015260448601526064850152608484015260408360a4818860018060a01b037f0000000000000000000000000000000000000000000000000000000000000000165af193841561060e57859386956108cc575b506040516370a0823160e01b815230600482015260208160248173f760fd8feb1f5e3bf3651e2e4f227285a82470ff5afa9081156108c1578590889261088b575b506104889192613b58565b03610846576040516370a0823160e01b81523060048201526020816024817355a81da2a319dd60fb028c53cb4419493b56f6c05afa90811561083b5785908792610800575b506104d89192613b58565b036107bb57816106ec575b82610619575b61055592604080516104fa81613a0f565b7f000000000000000000000000000000000000000000000000000000000000000081523060208201526001600160801b03828201526001600160801b03606082015281518096819263fc6f786560e01b835260048301613ffb565b0381887303a520b32c04bf3beef7beb72e919cf822ed34f15af190811561060e577fc44fbd841549722b6a376f7c182d096677479286d7bef1b116b766073d08130b946105d6926105e0575b506105ae83601354613b58565b6013554260175582601855604051938493846040919493926060820195825260208201520152565b0390a16001815580f35b6106019060403d604011610607575b6105f98183613a2b565b810190613fe5565b506105a1565b503d6105ef565b6040513d87823e3d90fd5b600a5460405163a9059cbb60e01b81526001600160a01b03909116600482015260248101849052602081604481887355a81da2a319dd60fb028c53cb4419493b56f6c05af190811561060e5785916106ae575b506104e95760405162461bcd60e51b81526020600482015260156024820152741c10da5c98db19551c985b9cd9995c91985a5b1959605a1b6044820152606490fd5b90506020813d6020116106e4575b816106c960209383613a2b565b810103126106e0576106da90613b0e565b3861066c565b8480fd5b3d91506106bc565b600a5460405163a9059cbb60e01b81526001600160a01b039091166004820152602481018390526020816044818873f760fd8feb1f5e3bf3651e2e4f227285a82470ff5af190811561060e578591610781575b506104e35760405162461bcd60e51b81526020600482015260156024820152741c12195cdd1a58551c985b9cd9995c91985a5b1959605a1b6044820152606490fd5b90506020813d6020116107b3575b8161079c60209383613a2b565b810103126106e0576107ad90613b0e565b3861073f565b3d915061078f565b60405162461bcd60e51b815260206004820152601760248201527f696e636f727265637450436972636c6542616c616e63650000000000000000006044820152606490fd5b9150506020813d602011610833575b8161081c60209383613a2b565b8101031261082e5751846104d86104cd565b600080fd5b3d915061080f565b6040513d88823e3d90fd5b60405162461bcd60e51b815260206004820152601760248201527f696e636f72726563745048657374696142616c616e63650000000000000000006044820152606490fd5b9150506020813d6020116108b9575b816108a760209383613a2b565b8101031261082e57518461048861047d565b3d915061089a565b6040513d89823e3d90fd5b9094506108e991935060403d604011610607576105f98183613a2b565b929092933861043c565b634e487b7160e01b88526011600452602488fd5b9091506020813d602011610933575b8161092360209383613a2b565b8101031261082e575190386103c2565b3d9150610916565b9093506020813d602011610967575b8161095760209383613a2b565b8101031261082e57519238610382565b3d915061094a565b634e487b7160e01b84526011600452602484fd5b634e487b7160e01b82526011600452602482fd5b60405162461bcd60e51b815260206004820152600c60248201526b1cdd1858dad51a5b595bdd5d60a21b6044820152606490fd5b50346102a457806003193601126102a45760206109e66142bc565b604051908152f35b50346102a457806003193601126102a457600a546040516001600160a01b039091168152602090f35b50346102a45760203660031901126102a457610a316139a9565b610a3e6001835414613a4d565b600f54336001600160a01b038216148015610b41575b8015610b2d575b610a6490613ec0565b600d546001600160a01b03928316921682141580610b18575b80610b0f575b15610aca576001600160a01b0319168117600f556040519081527fc204ac232c537a1868633339726708c068266d6db4b719603647317f83eb078790602090a16001815580f35b60405162461bcd60e51b815260206004820152601760248201527f696e76616c69644175746f6d61746f72416464726573730000000000000000006044820152606490fd5b50811515610a83565b50600e546001600160a01b0316821415610a7d565b50600e546001600160a01b03163314610a5b565b50600d546001600160a01b03163314610a54565b50346102a45760203660031901126102a457610b6f6139a9565b610b7c6001835414613a4d565b60028255600d546001600160a01b0316903382148015610d4b575b610ba090613ec0565b6001600160a01b0316908115610d125781141580610cfd575b610bc290614200565b600b5481906001600160a01b03811680610c2c5750506001600160601b0360a01b600b541617600b55336001600160601b0360a01b600c541617600c55337f5215ccf78d328d472c0a84d821b4dd0b0d519d8d2a37186e58c53dd755cc63218380a35b6001815580f35b821480610ce8575b15610c9a57506001600160601b0360a01b600a541617600a556001600160601b0360a01b600b5416600b556001600160601b0360a01b600c5416600c557fc8ecf0dcdae8ec1c0864472c0fd074e61bbfdd54a8fa66f90dd8b650e8bc6fce8280a2610c25565b6001600160601b0360a01b1617600b55336001600160601b0360a01b600c541617600c55337f5215ccf78d328d472c0a84d821b4dd0b0d519d8d2a37186e58c53dd755cc63218380a3610c25565b50600c546001600160a01b0316331415610c34565b50600e546001600160a01b0316811415610bb9565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c69645262704164647265737360781b6044820152606490fd5b50600e546001600160a01b03163314610b97565b50346102a457806003193601126102a457610d7d6001825414613a4d565b60028155610d9660018060a01b03600f54163314613ec0565b600254421061158e57617080420180421161098357600255808182602154806113be575b50610dc3614445565b610dcb6144cb565b90801515806113b5575b610e38575b857f2cd9c3da3b7b01964b0429b8643a0ab067ffbc1b87bce27580a38291bde7d06a60408787610e1b88610e1083601454613b58565b601455601554613b58565b6015554260195581601a5582519182526020820152a16001815580f35b60085486955092935084926001600160a01b031673833589fcd6edb6e08f4c7c32d4f71b54bda02913149081156113ae57825b82156113a65750915b8015158061139d575b15611367577f0000000000000000000000000000000000000000000000000000000000000000926040519163133f757160e31b8352846004840152610180836024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa91821561135c576004938a908b9461131d575b50600154604051633850c7bd60e01b81529560e09187919082906001600160a01b03165afa948515611312578b956112d3575b50610f29610f2f9161450d565b9361450d565b9182846001600160a01b03808316908216116112ca575b6001600160a01b038781169490889083168611611266575050610f699350614b8c565b915b6001600160801b0383161561122957610f8393614884565b9092831580158091611220575b156111e3576025546032811080159291906111dc57806127100361271081116111c857610fc06127109189614075565b04925b156111c0576127100361271081116111ac57610fe26127109186614075565b04905b806111a3575b611005575b5094959450859350610e1b9250610dda915050565b9193955091939650607842019182421161118f576040519360c0850185811067ffffffffffffffff82111761117b576040528452602084018881526040850190868252606086019283526080860193845260a086019485526040519563219f5d1760e01b87525160048701525160248601525160448501525160648401525160848301525160a482015260608160c481897303a520b32c04bf3beef7beb72e919cf822ed34f15af1801561083b5761110d575b5090610e1b7f2cd9c3da3b7b01964b0429b8643a0ab067ffbc1b87bce27580a38291bde7d06a94604094938360001461110757805b931561110057505b929382953880610ff0565b90506110f5565b816110ed565b606093929193813d606011611173575b8161112a60609383613a2b565b8101031261116f577f2cd9c3da3b7b01964b0429b8643a0ab067ffbc1b87bce27580a38291bde7d06a94604094611163610e1b936140ca565b509293945094506110b8565b8580fd5b3d915061111d565b634e487b7160e01b8b52604160045260248bfd5b634e487b7160e01b89526011600452602489fd5b50831515610feb565b634e487b7160e01b8b52601160045260248bfd5b508990610fe5565b634e487b7160e01b8c52601160045260248cfd5b8a92610fc3565b60405162461bcd60e51b8152602060048201526015602482015274696e76616c696444657369726564416d6f756e747360581b6044820152606490fd5b50821515610f90565b60405162461bcd60e51b8152602060048201526015602482015274696e73756666696369656e744c697175696469747960581b6044820152606490fd5b919490939192906001600160a01b03821611156112be57829161128d916112939594614b8c565b93614b3e565b6001600160801b0381166001600160801b038316106000146112b757505b91610f6b565b90506112b1565b9150506112b192614b3e565b50508383610f46565b610f2f9195506112fd610f299160e03d60e01161130b575b6112f58183613a2b565b81019061424e565b505050505050959150610f1c565b503d6112eb565b6040513d8d823e3d90fd5b90506113429193506101803d8111611355575b61133a8183613a2b565b8101906140de565b5050505050979550935050505038610ee9565b503d611330565b6040513d8b823e3d90fd5b60405162461bcd60e51b815260206004820152600e60248201526d696e76616c6964416d6f756e747360901b6044820152606490fd5b50821515610e7d565b905091610e74565b8092610e6b565b50811515610dd5565b6113db91506113cb6142bc565b6113d6811515614189565b614088565b6113e68115156141c3565b6113f28161032c614445565b6113fa6144cb565b602554607842019081421161157a57604051630d4f2ff160e21b8152600481018590526024810191909152604481019190915290602082606481896001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af191821561083b578692611544575b5061149082611482611496941515613f65565b61148a6144cb565b92613b58565b14613fa2565b611501604080516114a681613a0f565b7f000000000000000000000000000000000000000000000000000000000000000081523060208201526001600160801b03828201526001600160801b03606082015281518093819263fc6f786560e01b835260048301613ffb565b0381887303a520b32c04bf3beef7beb72e919cf822ed34f15af1801561060e5715610dba5761153e9060403d604011610607576105f98183613a2b565b50610dba565b91506020823d602011611572575b8161155f60209383613a2b565b8101031261082e5790519061149061146f565b3d9150611552565b634e487b7160e01b87526011600452602487fd5b60405162461bcd60e51b815260206004820152600c60248201526b189bdbdcdd151a5b595bdd5d60a21b6044820152606490fd5b50346102a45760203660031901126102a4576004356115e46001835414613a4d565b600282556115fd60018060a01b03600f54163314613ec0565b611608811515613a86565b80611611614445565b106116c857817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316803b156116b957818091602460405180948193630852cd8d60e31b83528860048401525af180156116bd576116a4575b507f28941df3d5adeda84b4ab5e4451312e1bda083a3959fc0ba717178cc1b53a7ad602083604051908152a16001815580f35b816116ae91613a2b565b6116b9578138611671565b5080fd5b6040513d84823e3d90fd5b60405162461bcd60e51b8152602060048201526013602482015272696e73756666696369656e7442616c616e636560681b6044820152606490fd5b50346102a457806003193601126102a4576117216001825414613a4d565b6002815561173a60018060a01b03600f54163314613ec0565b6004544210611dc3576170804201804211610983576004558061175b614445565b906117646144cb565b916001600160801b0360225416906064821015611aa1575b6117e991506040805161178e81613a0f565b7f000000000000000000000000000000000000000000000000000000000000000081523060208201526001600160801b03828201526001600160801b03606082015281518094819263fc6f786560e01b835260048301613ffb565b0381887303a520b32c04bf3beef7beb72e919cf822ed34f15af190811561060e5761182e9261182592611a83575b50611820614445565b613b7b565b926118206144cb565b91809260ff60225460801c1680611a7a575b611916575b50508161189b575b7fae7c7827e9dff0d67b1c26a466dcbbf38065e5a0c0819da7d8d7744cc45497c7918161187e604093601654613b58565b60165542601b5581601c5582519182526020820152a16001815580f35b827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316803b156116b957818091602460405180948193630852cd8d60e31b83528960048401525af180156116bd576118fd575b505061184d565b8161190791613a2b565b6119125782386118f6565b8280fd5b91509150611922614445565b6025546078420190814211611a6657604051631ef8617760e01b8152600481018590526024810191909152604481019190915290602082606481886001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af191821561060e578592611a32575b5081156119fc576119aa8261148a614445565b036119c1576119b99192613b58565b903880611845565b60405162461bcd60e51b81526020600482015260136024820152721a5b98dbdc9c9958dd14ddd85c105b5bdd5b9d606a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd49859d953d89d185a5b995960921b6044820152606490fd5b9091506020813d602011611a5e575b81611a4e60209383613a2b565b8101031261082e57519038611997565b3d9150611a41565b634e487b7160e01b86526011600452602486fd5b50801515611840565b611a9b9060403d604011610607576105f98183613a2b565b50611817565b7f00000000000000000000000000000000000000000000000000000000000000009160405163133f757160e31b8152836004820152610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa9081156108c1578791611d98575b508115611d84576001600160801b0316048586906025546032811015611bf8575b50607842019283421161118f576040519560a0870187811067ffffffffffffffff82111761117b57906001600160801b039291604052875281602088019116815260408701928352606087019384526080870194855260405196630624e65f60e11b88525160048801525116602486015251604485015251606484015251608483015260408260a481887303a520b32c04bf3beef7beb72e919cf822ed34f15af191821561060e576117e992611bda575b5061177c565b611bf29060403d604011610607576105f98183613a2b565b50611bd4565b9150506001600160801b03821615611d465760405163133f757160e31b815260048101859052610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa8015611d3b5788918991611d0a575b50600154604051633850c7bd60e01b8152919060e090839060049082906001600160a01b03165afa908115611cff57611ca09386938c93611cd0575b50611c94611c9a9161450d565b9161450d565b91614884565b916127100390612710821161118f5781612710611cc18194611cc894614075565b0493614075565b049038611b23565b611c9a919350611cf1611c949160e03d60e01161130b576112f58183613a2b565b505050505050939150611c87565b6040513d8c823e3d90fd5b60049250611d2791506101803d81116113555761133a8183613a2b565b505050505096955093505050509190611c4b565b6040513d8a823e3d90fd5b60405162461bcd60e51b81526020600482015260166024820152751a5b9d985b1a59131a5c5d5a591a5d1e505b5bdd5b9d60521b6044820152606490fd5b634e487b7160e01b87526012600452602487fd5b611db191506101803d81116113555761133a8183613a2b565b50505050965050505050505038611b02565b60405162461bcd60e51b815260206004820152600b60248201526a1c9859d9551a5b595bdd5d60aa1b6044820152606490fd5b50346102a457806003193601126102a457611e146001825414613a4d565b60028155600d546001600160a01b031633148015611f7d575b611e3690613ec0565b7f00000000000000000000000000000000000000000000000000000000000000008015611f4c57600954611f14577303a520b32c04bf3beef7beb72e919cf822ed34f13b156116b957816040516323b872dd60e01b81523360048201523060248201528260448201528181606481837303a520b32c04bf3beef7beb72e919cf822ed34f15af180156116bd57611eff575b507fba51082b7645d1b4f632b76df55cb331092d45b3f08a77bba7f5be7f5ce95a1b6020836001600955604051908152a16001815580f35b81611f0991613a2b565b6116b9578138611ec7565b60405162461bcd60e51b815260206004820152601060248201526f1b999d105b1c9958591e531bd8dad95960821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260096024820152681b999d139bdd14d95d60ba1b6044820152606490fd5b50600e546001600160a01b03163314611e2d565b50346102a45760203660031901126102a457600435611fb36001835414613a4d565b60028255611fcc60018060a01b03600f54163314613ec0565b611fd7811515614038565b611fdf614445565b827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316803b156116b957819060246040518094819363b198e1b560e01b83528860048401525af180156120d9576120c3575b5061204690611820614445565b801561208d577f69a47f1c91190a04d0f9b04ecab441680fe101a91709a0167ac046004b7967599161207c602092601254613b58565b601255604051908152a16001815580f35b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd4dd5c1c1b1e535a5b9d195960921b6044820152606490fd5b926120d2816120469395613a2b565b9290612039565b6040513d86823e3d90fd5b50346102a457806003193601126102a457600f546040516001600160a01b039091168152602090f35b50346102a457806003193601126102a45761213360018060a01b03600f54163314613ec0565b4780156121e857818080809373507fbde39ba40da4fc79426ad5e3c64944fe43d45af13d156121e3573d67ffffffffffffffff81116121cf5760405190612184601f8201601f191660200183613a2b565b81528260203d92013e5b156121965780f35b60405162461bcd60e51b8152602060048201526011602482015270195d1a151c985b9cd9995c91985a5b1959607a1b6044820152606490fd5b634e487b7160e01b83526041600452602483fd5b61218e565b60405162461bcd60e51b815260206004820152600c60248201526b6e6f45746842616c616e636560a01b6044820152606490fd5b50346102a457806003193601126102a457600d54600e54604080516001600160a01b039384168152919092166020820152f35b50346102a45760203660031901126102a4576004356122716001835414613a4d565b6002825561228a60018060a01b03600f54163314613ec0565b600754421061246d576122a06014821115614038565b60646122b46122ad613b88565b9283614075565b048015612437576122c3614445565b81116123f95760405163a9059cbb60e01b815273507fbde39ba40da4fc79426ad5e3c64944fe43d4600482015260248101829052602081604481877f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af180156120d95784906123ba575b6123419150613b1b565b61234d81601054613b58565b6010556301e13380420180421161096f57604073507fbde39ba40da4fc79426ad5e3c64944fe43d493927f64c05fb63aaacb0695067680e413596ae48229f6b4a0027592e6bd22fb8594b49260075560018060a01b03600f54169382519182526020820152a36001815580f35b506020813d6020116123f1575b816123d460209383613a2b565b810103126123ed576123e861234191613b0e565b612337565b8380fd5b3d91506123c7565b60405162461bcd60e51b8152602060048201526016602482015275696e73756666696369656e7452636542616c616e636560501b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d6e6f416374697665537570706c7960901b6044820152606490fd5b60405162461bcd60e51b815260206004820152600d60248201526c36bab9ba2bb0b4ba18acb2b0b960991b6044820152606490fd5b50346102a45760203660031901126102a4576124bc6139a9565b6124d160018060a01b03600f54163314613ec0565b6001600160a01b03908116907f00000000000000000000000000000000000000000000000000000000000000001681141580612685575b15612640576040516370a0823160e01b8152306004820152602081602481855afa908115612635578391612603575b5080156125cd5782916044602092604051948593849263a9059cbb60e01b845273507fbde39ba40da4fc79426ad5e3c64944fe43d4600485015260248401525af180156116bd578290612592575b61258f9150613b1b565b80f35b506020813d6020116125c5575b816125ac60209383613a2b565b810103126116b9576125c061258f91613b0e565b612585565b3d915061259f565b60405162461bcd60e51b815260206004820152600e60248201526d6e6f546f6b656e42616c616e636560901b6044820152606490fd5b90506020813d60201161262d575b8161261e60209383613a2b565b81010312611912575138612537565b3d9150612611565b6040513d85823e3d90fd5b60405162461bcd60e51b815260206004820152601a60248201527f75736463416e64526167654e6f74576974686472617761626c650000000000006044820152606490fd5b5073833589fcd6edb6e08f4c7c32d4f71b54bda02913811415612508565b50346102a457806003193601126102a4576126c960018060a01b03600f54163314613ec0565b6005544210612a3f5760245415612a0c57617080420180421161098357600555805b602454811015612901576126fd614445565b60235480911015612712575b506001016126eb565b61271a6144cb565b6025544260788101937f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316939291851061157a57604051630d4f2ff160e21b8152600481019190915260248101919091526044810184905292919060208460648189865af193841561083b5786946128c7575b50916020916127b86127f4946127ac871515613f65565b6114908761148a6144cb565b6127c0614445565b94876025549160405196879586948593631ef8617760e01b8552600485016040919493926060820195825260208201520152565b03925af19081156120d9578491612896575b508015612860576128199061148a614445565b036128245738612709565b60405162461bcd60e51b8152602060048201526014602482015273696e636f72726563745261676542616c616e636560601b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd49859d9549958d95a5d995960921b6044820152606490fd5b90506020813d82116128bf575b816128b060209383613a2b565b810103126123ed575138612806565b3d91506128a3565b91929093506020823d82116128f9575b816128e460209383613a2b565b8101031261116f579051929091906020612795565b3d91506128d7565b5061297d61290d614445565b6129156144cb565b6040805161292281613a0f565b7f000000000000000000000000000000000000000000000000000000000000000081523060208201526001600160801b03828201526001600160801b03606082015281518095819263fc6f786560e01b835260048301613ffb565b0381877303a520b32c04bf3beef7beb72e919cf822ed34f15af19283156120d9576129d76040936129e0927feedc2d0b9aa116d5a66762d9fd2b6d567d48bc4e29b61e22235d965bd16ada44966129f65750611820614445565b916118206144cb565b81601e5542601d5582519182526020820152a180f35b611a9b90863d8811610607576105f98183613a2b565b60405162461bcd60e51b815260206004820152600b60248201526a06e6f42757273744c6f6f760ac1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600c60248201526b189d5c9cdd151a5b595bdd5d60a21b6044820152606490fd5b50346102a4576101603660031901126102a457612a936001825414613a4d565b60028155612aac60018060a01b03600f54163314613ec0565b600654421061306457610e10420180421161098357600655600435606481101580613058575b15613020576024359060648211612fe6576044359081158015612fce575b15612f96576001600160801b03612b05613efb565b16158015612f5e575b15612f225760a43592670de0b6b3a764000084101580612f0f575b15612ed75760c43592600184101580612ecc575b15612e945760e435946109c48611612e4f5773507fbde39ba40da4fc79426ad5e3c64944fe43d46001600160a01b03612b74613f11565b16141580612e35575b15612dfc5773507fbde39ba40da4fc79426ad5e3c64944fe43d46001600160a01b03612ba7613f28565b16141580612de2575b15612da75773507fbde39ba40da4fc79426ad5e3c64944fe43d46001600160a01b03612bda613f3f565b16141580612d8d575b15612d52577fdb835d6ae3f1526fb30bb3f3b4ed7a34fb4f59626084ca485ef03e7df5ba7c58956101609585601f5584602055836021556001600160801b03612c2a613efb565b602254911660ff60801b612c3c613f56565b151560801b16916001600160881b031916171760225582602355806024558160255560018060a01b03612c6d613f11565b166001600160601b0360a01b602654161760265560018060a01b03612c90613f28565b166001600160601b0360a01b602754161760275560018060a01b03612cb3613f3f565b166001600160601b0360a01b6028541617602855612ccf613efb565b92612cd8613f56565b6001600160801b03612ce8613f11565b95612cf1613f28565b97612cfa613f3f565b604080519c8d5260208d019b909b52998b01521660608901521515608088015260a087015260c086015260e08501526001600160a01b0390811661010085015290811661012084015216610140820152a16001815580f35b60405162461bcd60e51b815260206004820152601360248201527234b73b30b634b229b4b232a0b2323932b9b99960691b6044820152606490fd5b50612d96613f3f565b6001600160a01b0316301415612be3565b60405162461bcd60e51b8152602060048201526013602482015272696e76616c696453696465416464726573733160681b6044820152606490fd5b50612deb613f28565b6001600160a01b0316301415612bb0565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964506f644164647265737360781b6044820152606490fd5b50612e3e613f11565b6001600160a01b0316301415612b7d565b60405162461bcd60e51b815260206004820152601860248201527f696e76616c69644c6971756964697479536c69707061676500000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f0696e76616c696442757273744c6f6f760841b6044820152606490fd5b506005841115612b3d565b60405162461bcd60e51b815260206004820152601060248201526f696e76616c696442757273745261676560801b6044820152606490fd5b50680ad78ebc5ac6200000841115612b29565b60405162461bcd60e51b8152602060048201526014602482015273696e76616c69644372757368446563726561736560601b6044820152606490fd5b5060646001600160801b03612f71613efb565b1610158015612b0e57506127106001600160801b03612f8e613efb565b161115612b0e565b60405162461bcd60e51b815260206004820152601060248201526f696e76616c6964426f6f73745261676560801b6044820152606490fd5b5060648210158015612af05750612710821115612af0565b60405162461bcd60e51b8152602060048201526012602482015271696e76616c6964537461636b48657374696160701b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f696e76616c6964537461636b5261676560801b6044820152606490fd5b50612710811115612ad2565b60405162461bcd60e51b815260206004820152600d60248201526c18dbdb999a59d51a5b595bdd5d609a1b6044820152606490fd5b50346102a457806003193601126102a45760206109e6613b88565b50346102a45760403660031901126102a4576130ce6139a9565b6024356130de6001845414613a4d565b60028355600a546001600160a01b0316338190036132af571561327e576001600160a01b0382161561324657613115811515613a86565b6131218161032c614445565b60405163a9059cbb60e01b81526001600160a01b0383166004820152602481018290529160208380604481010381877f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19283156120d95784936131e7575b506131b57f2b10214e09faa870b0ac9a20e6ffd58a5543ceaccb5fac56a36aaff06c3003cc93613b1b565b6131c182601154613b58565b601155604080516001600160a01b039092168252602082019290925290819081016105d6565b92506020833d60201161323e575b8161320260209383613a2b565b810103126123ed576131b56132377f2b10214e09faa870b0ac9a20e6ffd58a5543ceaccb5fac56a36aaff06c3003cc94613b0e565b935061318a565b3d91506131f5565b60405162461bcd60e51b815260206004820152601060248201526f1a5b9d985b1a59149958da5c1a595b9d60821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260096024820152681c989c139bdd14d95d60ba1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600660248201526506e6f745262760d41b6044820152606490fd5b50346102a457806003193601126102a457602060405173507fbde39ba40da4fc79426ad5e3c64944fe43d48152f35b9050346116b957816003193601126116b9578061332b610140926139bf565b8281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015260405161336b816139bf565b8381528360208201528360408201528360608201528360808201528360a08201528360c08201528360e082015283610100820152836101208201528383820152610120820152604051926133be846139f2565b8084528060208501528060408501528060608501528060808501528060a08501528060c08501528060e0850152806101008501528061012085015280838501528061016085015280610180850152806101a0850152806101c0850152806101e08501528061020085015280610220850152806102408501528061026085015280610280850152806102a0850152806102c0850152806102e085015280610300850152806103208501528061034085015280610360850152610380840152015261062060018060a01b0360015416610380613496613b88565b9161349f6142bc565b906134a8614445565b6134b06144cb565b90604051956134be876139bf565b60018752602087019460018060a01b037f0000000000000000000000000000000000000000000000000000000000000000168652604088019473507fbde39ba40da4fc79426ad5e3c64944fe43d486526060890190815260808901907f0000000000000000000000000000000000000000000000000000000000000000825260a08a0192835260c08a0193845260e08a019485526101008a0195865260405196613567886139bf565b601f5488526020546020890152602154604089015260ff6022546001600160801b03811660608b015260801c161515608089015260235460a089015260245460c089015260255460e089015260018060a01b036026541661010089015260018060a01b036027541661012089015260018060a01b03602854166101408901526101208b01978852604051986135fb8a6139f2565b6002548a5260035460208b015260045460408b015260055460608b015260065460808b015260075460a08b015260018060a01b036008541660c08b015260095460e08b015260018060a01b03600a54166101008b015260018060a01b03600b54166101208b015260018060a01b03600c54166101408b015260018060a01b03600d54166101608b015260018060a01b03600e54166101808b015260018060a01b03600f54166101a08b01526010546101c08b01526011546101e08b01526012546102008b01526013546102208b01526014546102408b01526015546102608b01526016546102808b01526017546102a08b01526018546102c08b01526019546102e08b0152601a546103008b0152601b546103208b0152601c546103408b0152601d546103608b0152601e548b8b01526101408c01998a526040519b518c5260018060a01b0390511660208c015260018060a01b0390511660408b015260018060a01b0390511660608a01525160808901525160a08801525160c08701525160e086015251610100850152518051610120850152602081015161014085015260408101516101608501526001600160801b03606082015116610180850152608081015115156101a085015260a08101516101c085015260c08101516101e085015260e081015161020085015260018060a01b036101008201511661022085015260018060a01b036101208201511661024085015261014060018060a01b039101511661026084015251805161028084015260208101516102a084015260408101516102c084015260608101516102e0840152608081015161030084015260a081015161032084015260018060a01b0360c08201511661034084015260e081015161036084015260018060a01b03610100820151168284015260018060a01b03610120820151166103a084015260018060a01b03610140820151166103c084015260018060a01b03610160820151166103e084015260018060a01b036101808201511661040084015260018060a01b036101a0820151166104208401526101c08101516104408401526101e08101516104608401526102008101516104808401526102208101516104a08401526102408101516104c08401526102608101516104e08401526102808101516105008401526102a08101516105208401526102c08101516105408401526102e08101516105608401526103008101516105808401526103208101516105a08401526103408101516105c08401526103608101516105e08401520151610600820152f35b600435906001600160a01b038216820361082e57565b610160810190811067ffffffffffffffff8211176139dc57604052565b634e487b7160e01b600052604160045260246000fd5b6103a0810190811067ffffffffffffffff8211176139dc57604052565b6080810190811067ffffffffffffffff8211176139dc57604052565b90601f8019910116810190811067ffffffffffffffff8211176139dc57604052565b15613a5457565b60405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b6044820152606490fd5b15613a8d57565b60405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59105b5bdd5b9d609a1b6044820152606490fd5b15613ac957565b60405162461bcd60e51b815260206004820152601760248201527f696e73756666696369656e745261676542616c616e63650000000000000000006044820152606490fd5b5190811515820361082e57565b15613b2257565b60405162461bcd60e51b815260206004820152600e60248201526d1d1c985b9cd9995c91985a5b195960921b6044820152606490fd5b91908201809211613b6557565b634e487b7160e01b600052601160045260246000fd5b91908203918211613b6557565b6040516362720d9160e11b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690602081600481855afa908115613d2e57600091613e8e575b50613be1614445565b6040516370a0823160e01b815273507fbde39ba40da4fc79426ad5e3c64944fe43d460048201529190602083602481875afa928315613d2e57600093613e5a575b50613c2b6142bc565b600f546040516370a0823160e01b81526001600160a01b03909116600482015292909190602084602481895afa938415613d2e57600094613e1e575b50613c7d94611820611820949361182093613b7b565b6026546001600160a01b031680613dac575b506027546001600160a01b031680613d3a575b506028546001600160a01b031680613cbb575b50905090565b6020906024604051809581936370a0823160e01b835260048301525afa908115613d2e57600091613cf8575b613cf19250613b7b565b8038613cb5565b90506020823d602011613d26575b81613d1360209383613a2b565b8101031261082e57613cf1915190613ce7565b3d9150613d06565b6040513d6000823e3d90fd5b90604051916370a0823160e01b83526004830152602082602481865afa908115613d2e57600091613d76575b613d709250613b7b565b38613ca2565b90506020823d602011613da4575b81613d9160209383613a2b565b8101031261082e57613d70915190613d66565b3d9150613d84565b90604051916370a0823160e01b83526004830152602082602481865afa908115613d2e57600091613de8575b613de29250613b7b565b38613c8f565b90506020823d602011613e16575b81613e0360209383613a2b565b8101031261082e57613de2915190613dd8565b3d9150613df6565b92919093506020833d602011613e52575b81613e3c60209383613a2b565b8101031261082e57915192909190613c7d613c67565b3d9150613e2f565b9092506020813d602011613e86575b81613e7660209383613a2b565b8101031261082e57519138613c22565b3d9150613e69565b90506020813d602011613eb8575b81613ea960209383613a2b565b8101031261082e575138613bd8565b3d9150613e9c565b15613ec757565b60405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5e995960a21b6044820152606490fd5b6064356001600160801b038116810361082e5790565b610104356001600160a01b038116810361082e5790565b610124356001600160a01b038116810361082e5790565b610144356001600160a01b038116810361082e5790565b608435801515810361082e5790565b15613f6c57565b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd55cd918d49958d95a5d995960921b6044820152606490fd5b15613fa957565b60405162461bcd60e51b8152602060048201526014602482015273696e636f72726563745573646342616c616e636560601b6044820152606490fd5b919082604091031261082e576020825192015190565b91909160606001600160801b038160808401958051855260018060a01b036020820151166020860152826040820151166040860152015116910152565b1561403f57565b60405162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5914195c98d95b9d60921b6044820152606490fd5b81810292918115918404141715613b6557565b8115614092570490565b634e487b7160e01b600052601260045260246000fd5b51906001600160a01b038216820361082e57565b51908160020b820361082e57565b51906001600160801b038216820361082e57565b91908261018091031261082e5781516001600160601b038116810361082e579161410a602082016140a8565b91614117604083016140a8565b91614124606082016140a8565b91608082015162ffffff8116810361082e579161414360a082016140bc565b9161415060c083016140bc565b9161415d60e082016140ca565b91610100820151916101208101519161418661016061417f61014085016140ca565b93016140ca565b90565b1561419057565b60405162461bcd60e51b815260206004820152600b60248201526a1b9bd49859d9525b93999d60aa1b6044820152606490fd5b156141ca57565b60405162461bcd60e51b815260206004820152600e60248201526d185b5bdd5b9d151bdbd4db585b1b60921b6044820152606490fd5b1561420757565b60405162461bcd60e51b815260206004820152601060248201526f06f776e657243616e6e6f7442655262760841b6044820152606490fd5b519061ffff8216820361082e57565b908160e091031261082e5780516001600160a01b038116810361082e5791614278602083016140bc565b916142856040820161423f565b916142926060830161423f565b9161429f6080820161423f565b9160a082015160ff8116810361082e5760c0614186919301613b0e565b7f000000000000000000000000000000000000000000000000000000000000000080156143fb576040519063133f757160e31b82526004820152610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa908115613d2e57600091600080926000926143c8575b506001600160801b038216156143bf57600154604051633850c7bd60e01b8152939060e090859060049082906001600160a01b03165afa918215613d2e5761438094600093611cd05750611c94611c9a9161450d565b90916001600160a01b039081167f0000000000000000000000000000000000000000000000000000000000000000909116036143ba575090565b905090565b50505050600090565b925050506143e591506101803d81116113555761133a8183613a2b565b505050509550939250945050929091903861432a565b50600090565b1561440857565b60405162461bcd60e51b81526020600482015260156024820152741bdddb995c9cd35d5cdd1099511a5999995c995b9d605a1b6044820152606490fd5b6040516370a0823160e01b81523060048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115613d2e5760009161449c575090565b90506020813d6020116144c3575b816144b760209383613a2b565b8101031261082e575190565b3d91506144aa565b6040516370a0823160e01b815230600482015260208160248173833589fcd6edb6e08f4c7c32d4f71b54bda029135afa908115613d2e5760009161449c575090565b60020b600081121561487e5780600003905b620d89e8821161486d57600182161561485b576001600160881b036ffffcb933bd6fad37aa2d162d1a5940015b16916002811661483f575b60048116614823575b60088116614807575b601081166147eb575b602081166147cf575b604081166147b3575b60808116614797575b610100811661477b575b610200811661475f575b6104008116614743575b6108008116614727575b611000811661470b575b61200081166146ef575b61400081166146d3575b61800081166146b7575b62010000811661469b575b620200008116614680575b620400008116614665575b620800001661464c575b60001261463d575b63ffffffff8116614635576000905b60201c60ff91909116016001600160a01b031690565b60019061461f565b80156140925760001904614610565b6b048a170391f7dc42444e8fa290910260801c90614608565b6d2216e584f5fa1ea926041bedfe9890920260801c916145fe565b916e5d6af8dedb81196699c329225ee6040260801c916145f3565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c916145e8565b916f31be135f97d08fd981231505542fcfa60260801c916145dd565b916f70d869a156d2a1b890bb3df62baf32f70260801c916145d3565b916fa9f746462d870fdf8a65dc1f90e061e50260801c916145c9565b916fd097f3bdfd2022b8845ad8f792aa58250260801c916145bf565b916fe7159475a2c29b7443b29c7fa6e889d90260801c916145b5565b916ff3392b0822b70005940c7a398e4b70f30260801c916145ab565b916ff987a7253ac413176f2b074cf7815e540260801c916145a1565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c91614597565b916ffe5dee046a99a2a811c461f1969c30530260801c9161458d565b916fff2ea16466c96a3843ec78b326b528610260801c91614584565b916fff973b41fa98c081472e6896dfb254c00260801c9161457b565b916fffcb9843d60f6159c9db58835c9266440260801c91614572565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c91614569565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91614560565b916ffff97272373d413259a46990580e213a0260801c91614557565b6001600160881b03600160801b61454c565b6315e4079d60e11b60005260046000fd5b8061451f565b9093926000929091836001600160a01b03808416908816116148fe575b6001600160a01b0382811690881681116148c6575050506148c3929394614962565b91565b93945090926001600160a01b03831611156148f25750906148ec83614186949383614962565b9461491f565b9461418693925061491f565b9591956148a1565b6001600160a01b039182169082160391908211613b6557565b61418692916001600160801b03916001600160a01b038083169082161161495c575b6001600160a01b03916149549190614906565b1691166149d6565b90614941565b6141869290916149bf91906001600160a01b03808216908516116149d0575b6001600160a01b036149938583614906565b6001600160a01b039092169291169060601b6fffffffffffffffffffffffffffffffff60601b16614ab6565b6001600160a01b0390911690614088565b92614981565b600091906000198282099180820293848085109403938085039414614a1b57600160601b8410156102a45750600160601b910990828211900360a01b910360601c1790565b5050505060601c90565b600019600160601b8209918160601b91828085109403938085039414614aa9578382111561082e578190600160601b9009818060000316809204600281600302188082026002030280820260020302808202600203028082026002030280820260020302809102600203029360018380600003040190848311900302920304170290565b508092501561082e570490565b916000198284099282810292838086109503948086039514614b30578483111561082e57829109818060000316809204600281600302188082026002030280820260020302808202600203028082026002030280820260020302809102600203029360018380600003040190848311900302920304170290565b50508092501561082e570490565b614b729291906001600160a01b0380831690821611614b86575b6001600160a01b0391614b6b9190614906565b1690614a25565b6001600160801b03811690810361082e5790565b90614b58565b614b7292916001600160a01b0380821690831611614bd4575b614bcd614bbe6001600160a01b038381169085166149d6565b926001600160a01b0392614906565b1691614ab6565b90614ba556fea264697066735822122098dcb7f54779df8d39be1ff32319465ae9d1e196f22ee5a0a4f0cd078ec78a9264736f6c634300081a0033000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea1500000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c4400000000000000000000000000000000000000000000000000000000003e7f89000000000000000000000000b278f52bc80b883da0729a863f853845965af009000000000000000000000000035a12973c7d6de9e3d3d450899913f07f68edee
Deployed Bytecode
0x608080604052600436101561001357600080fd5b600090813560e01c9081631865c57d1461330c575080633c81df21146132dd5780634429bfc1146130b457806371c62810146130995780637825fe3a14612a73578063825949a1146126a357806389476069146124a25780639be804481461224f578063a0e67e2b1461221c578063a0ef91df1461210d578063add1488c146120e4578063b198e1b514611f91578063bee2660914611df6578063ce34ba1014611703578063d595c331146115c2578063da990f7d14610d5f578063e244818514610b55578063e7c5a6e814610a17578063ea3adfa0146109ee578063ef280ce5146109cb578063f24f30e6146102a75763f2fde38b1461011357600080fd5b346102a45760203660031901126102a45761012c6139a9565b6101396001835414613a4d565b6002825560018060a01b03600d541680331491828015610290575b61015d90613ec0565b6001600160a01b031691821561025557600a54610185906001600160a01b0316841415614200565b600f546001600160a01b0316831461021757156101f45750600e546101b5906001600160a01b0316821415614401565b600d80546001600160a01b031916821790555b337f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a36001815580f35b61020090821415614401565b600e80546001600160a01b031916821790556101c8565b60405162461bcd60e51b815260206004820152601660248201527537bbb732b921b0b73737ba2132a0baba37b6b0ba37b960511b6044820152606490fd5b60405162461bcd60e51b8152602060048201526013602482015272696e76616c69644f776e65724164647265737360681b6044820152606490fd5b50600e546001600160a01b03163314610154565b80fd5b50346102a457806003193601126102a4576102c56001825414613a4d565b600281556102de60018060a01b03600f54163314613ec0565b6003544210610997576138404201804211610983576003556103156103016142bc565b61030c811515614189565b601f5490614088565b6103208115156141c3565b6103338161032c614445565b1015613ac2565b60205480606403916064831161096f576040516370a0823160e01b81523060048201529260208460248173f760fd8feb1f5e3bf3651e2e4f227285a82470ff5afa93841561060e57859461093b575b506040516370a0823160e01b8152306004820152906020826024817355a81da2a319dd60fb028c53cb4419493b56f6c05afa91821561083b578692610907575b5060255460784201918242116108f35760405195639632612f60e01b8752856004880152602487015260448601526064850152608484015260408360a4818860018060a01b037f00000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c44165af193841561060e57859386956108cc575b506040516370a0823160e01b815230600482015260208160248173f760fd8feb1f5e3bf3651e2e4f227285a82470ff5afa9081156108c1578590889261088b575b506104889192613b58565b03610846576040516370a0823160e01b81523060048201526020816024817355a81da2a319dd60fb028c53cb4419493b56f6c05afa90811561083b5785908792610800575b506104d89192613b58565b036107bb57816106ec575b82610619575b61055592604080516104fa81613a0f565b7f00000000000000000000000000000000000000000000000000000000003e7f8981523060208201526001600160801b03828201526001600160801b03606082015281518096819263fc6f786560e01b835260048301613ffb565b0381887303a520b32c04bf3beef7beb72e919cf822ed34f15af190811561060e577fc44fbd841549722b6a376f7c182d096677479286d7bef1b116b766073d08130b946105d6926105e0575b506105ae83601354613b58565b6013554260175582601855604051938493846040919493926060820195825260208201520152565b0390a16001815580f35b6106019060403d604011610607575b6105f98183613a2b565b810190613fe5565b506105a1565b503d6105ef565b6040513d87823e3d90fd5b600a5460405163a9059cbb60e01b81526001600160a01b03909116600482015260248101849052602081604481887355a81da2a319dd60fb028c53cb4419493b56f6c05af190811561060e5785916106ae575b506104e95760405162461bcd60e51b81526020600482015260156024820152741c10da5c98db19551c985b9cd9995c91985a5b1959605a1b6044820152606490fd5b90506020813d6020116106e4575b816106c960209383613a2b565b810103126106e0576106da90613b0e565b3861066c565b8480fd5b3d91506106bc565b600a5460405163a9059cbb60e01b81526001600160a01b039091166004820152602481018390526020816044818873f760fd8feb1f5e3bf3651e2e4f227285a82470ff5af190811561060e578591610781575b506104e35760405162461bcd60e51b81526020600482015260156024820152741c12195cdd1a58551c985b9cd9995c91985a5b1959605a1b6044820152606490fd5b90506020813d6020116107b3575b8161079c60209383613a2b565b810103126106e0576107ad90613b0e565b3861073f565b3d915061078f565b60405162461bcd60e51b815260206004820152601760248201527f696e636f727265637450436972636c6542616c616e63650000000000000000006044820152606490fd5b9150506020813d602011610833575b8161081c60209383613a2b565b8101031261082e5751846104d86104cd565b600080fd5b3d915061080f565b6040513d88823e3d90fd5b60405162461bcd60e51b815260206004820152601760248201527f696e636f72726563745048657374696142616c616e63650000000000000000006044820152606490fd5b9150506020813d6020116108b9575b816108a760209383613a2b565b8101031261082e57518461048861047d565b3d915061089a565b6040513d89823e3d90fd5b9094506108e991935060403d604011610607576105f98183613a2b565b929092933861043c565b634e487b7160e01b88526011600452602488fd5b9091506020813d602011610933575b8161092360209383613a2b565b8101031261082e575190386103c2565b3d9150610916565b9093506020813d602011610967575b8161095760209383613a2b565b8101031261082e57519238610382565b3d915061094a565b634e487b7160e01b84526011600452602484fd5b634e487b7160e01b82526011600452602482fd5b60405162461bcd60e51b815260206004820152600c60248201526b1cdd1858dad51a5b595bdd5d60a21b6044820152606490fd5b50346102a457806003193601126102a45760206109e66142bc565b604051908152f35b50346102a457806003193601126102a457600a546040516001600160a01b039091168152602090f35b50346102a45760203660031901126102a457610a316139a9565b610a3e6001835414613a4d565b600f54336001600160a01b038216148015610b41575b8015610b2d575b610a6490613ec0565b600d546001600160a01b03928316921682141580610b18575b80610b0f575b15610aca576001600160a01b0319168117600f556040519081527fc204ac232c537a1868633339726708c068266d6db4b719603647317f83eb078790602090a16001815580f35b60405162461bcd60e51b815260206004820152601760248201527f696e76616c69644175746f6d61746f72416464726573730000000000000000006044820152606490fd5b50811515610a83565b50600e546001600160a01b0316821415610a7d565b50600e546001600160a01b03163314610a5b565b50600d546001600160a01b03163314610a54565b50346102a45760203660031901126102a457610b6f6139a9565b610b7c6001835414613a4d565b60028255600d546001600160a01b0316903382148015610d4b575b610ba090613ec0565b6001600160a01b0316908115610d125781141580610cfd575b610bc290614200565b600b5481906001600160a01b03811680610c2c5750506001600160601b0360a01b600b541617600b55336001600160601b0360a01b600c541617600c55337f5215ccf78d328d472c0a84d821b4dd0b0d519d8d2a37186e58c53dd755cc63218380a35b6001815580f35b821480610ce8575b15610c9a57506001600160601b0360a01b600a541617600a556001600160601b0360a01b600b5416600b556001600160601b0360a01b600c5416600c557fc8ecf0dcdae8ec1c0864472c0fd074e61bbfdd54a8fa66f90dd8b650e8bc6fce8280a2610c25565b6001600160601b0360a01b1617600b55336001600160601b0360a01b600c541617600c55337f5215ccf78d328d472c0a84d821b4dd0b0d519d8d2a37186e58c53dd755cc63218380a3610c25565b50600c546001600160a01b0316331415610c34565b50600e546001600160a01b0316811415610bb9565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c69645262704164647265737360781b6044820152606490fd5b50600e546001600160a01b03163314610b97565b50346102a457806003193601126102a457610d7d6001825414613a4d565b60028155610d9660018060a01b03600f54163314613ec0565b600254421061158e57617080420180421161098357600255808182602154806113be575b50610dc3614445565b610dcb6144cb565b90801515806113b5575b610e38575b857f2cd9c3da3b7b01964b0429b8643a0ab067ffbc1b87bce27580a38291bde7d06a60408787610e1b88610e1083601454613b58565b601455601554613b58565b6015554260195581601a5582519182526020820152a16001815580f35b60085486955092935084926001600160a01b031673833589fcd6edb6e08f4c7c32d4f71b54bda02913149081156113ae57825b82156113a65750915b8015158061139d575b15611367577f00000000000000000000000000000000000000000000000000000000003e7f89926040519163133f757160e31b8352846004840152610180836024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa91821561135c576004938a908b9461131d575b50600154604051633850c7bd60e01b81529560e09187919082906001600160a01b03165afa948515611312578b956112d3575b50610f29610f2f9161450d565b9361450d565b9182846001600160a01b03808316908216116112ca575b6001600160a01b038781169490889083168611611266575050610f699350614b8c565b915b6001600160801b0383161561122957610f8393614884565b9092831580158091611220575b156111e3576025546032811080159291906111dc57806127100361271081116111c857610fc06127109189614075565b04925b156111c0576127100361271081116111ac57610fe26127109186614075565b04905b806111a3575b611005575b5094959450859350610e1b9250610dda915050565b9193955091939650607842019182421161118f576040519360c0850185811067ffffffffffffffff82111761117b576040528452602084018881526040850190868252606086019283526080860193845260a086019485526040519563219f5d1760e01b87525160048701525160248601525160448501525160648401525160848301525160a482015260608160c481897303a520b32c04bf3beef7beb72e919cf822ed34f15af1801561083b5761110d575b5090610e1b7f2cd9c3da3b7b01964b0429b8643a0ab067ffbc1b87bce27580a38291bde7d06a94604094938360001461110757805b931561110057505b929382953880610ff0565b90506110f5565b816110ed565b606093929193813d606011611173575b8161112a60609383613a2b565b8101031261116f577f2cd9c3da3b7b01964b0429b8643a0ab067ffbc1b87bce27580a38291bde7d06a94604094611163610e1b936140ca565b509293945094506110b8565b8580fd5b3d915061111d565b634e487b7160e01b8b52604160045260248bfd5b634e487b7160e01b89526011600452602489fd5b50831515610feb565b634e487b7160e01b8b52601160045260248bfd5b508990610fe5565b634e487b7160e01b8c52601160045260248cfd5b8a92610fc3565b60405162461bcd60e51b8152602060048201526015602482015274696e76616c696444657369726564416d6f756e747360581b6044820152606490fd5b50821515610f90565b60405162461bcd60e51b8152602060048201526015602482015274696e73756666696369656e744c697175696469747960581b6044820152606490fd5b919490939192906001600160a01b03821611156112be57829161128d916112939594614b8c565b93614b3e565b6001600160801b0381166001600160801b038316106000146112b757505b91610f6b565b90506112b1565b9150506112b192614b3e565b50508383610f46565b610f2f9195506112fd610f299160e03d60e01161130b575b6112f58183613a2b565b81019061424e565b505050505050959150610f1c565b503d6112eb565b6040513d8d823e3d90fd5b90506113429193506101803d8111611355575b61133a8183613a2b565b8101906140de565b5050505050979550935050505038610ee9565b503d611330565b6040513d8b823e3d90fd5b60405162461bcd60e51b815260206004820152600e60248201526d696e76616c6964416d6f756e747360901b6044820152606490fd5b50821515610e7d565b905091610e74565b8092610e6b565b50811515610dd5565b6113db91506113cb6142bc565b6113d6811515614189565b614088565b6113e68115156141c3565b6113f28161032c614445565b6113fa6144cb565b602554607842019081421161157a57604051630d4f2ff160e21b8152600481018590526024810191909152604481019190915290602082606481896001600160a01b037f00000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c44165af191821561083b578692611544575b5061149082611482611496941515613f65565b61148a6144cb565b92613b58565b14613fa2565b611501604080516114a681613a0f565b7f00000000000000000000000000000000000000000000000000000000003e7f8981523060208201526001600160801b03828201526001600160801b03606082015281518093819263fc6f786560e01b835260048301613ffb565b0381887303a520b32c04bf3beef7beb72e919cf822ed34f15af1801561060e5715610dba5761153e9060403d604011610607576105f98183613a2b565b50610dba565b91506020823d602011611572575b8161155f60209383613a2b565b8101031261082e5790519061149061146f565b3d9150611552565b634e487b7160e01b87526011600452602487fd5b60405162461bcd60e51b815260206004820152600c60248201526b189bdbdcdd151a5b595bdd5d60a21b6044820152606490fd5b50346102a45760203660031901126102a4576004356115e46001835414613a4d565b600282556115fd60018060a01b03600f54163314613ec0565b611608811515613a86565b80611611614445565b106116c857817f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b0316803b156116b957818091602460405180948193630852cd8d60e31b83528860048401525af180156116bd576116a4575b507f28941df3d5adeda84b4ab5e4451312e1bda083a3959fc0ba717178cc1b53a7ad602083604051908152a16001815580f35b816116ae91613a2b565b6116b9578138611671565b5080fd5b6040513d84823e3d90fd5b60405162461bcd60e51b8152602060048201526013602482015272696e73756666696369656e7442616c616e636560681b6044820152606490fd5b50346102a457806003193601126102a4576117216001825414613a4d565b6002815561173a60018060a01b03600f54163314613ec0565b6004544210611dc3576170804201804211610983576004558061175b614445565b906117646144cb565b916001600160801b0360225416906064821015611aa1575b6117e991506040805161178e81613a0f565b7f00000000000000000000000000000000000000000000000000000000003e7f8981523060208201526001600160801b03828201526001600160801b03606082015281518094819263fc6f786560e01b835260048301613ffb565b0381887303a520b32c04bf3beef7beb72e919cf822ed34f15af190811561060e5761182e9261182592611a83575b50611820614445565b613b7b565b926118206144cb565b91809260ff60225460801c1680611a7a575b611916575b50508161189b575b7fae7c7827e9dff0d67b1c26a466dcbbf38065e5a0c0819da7d8d7744cc45497c7918161187e604093601654613b58565b60165542601b5581601c5582519182526020820152a16001815580f35b827f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b0316803b156116b957818091602460405180948193630852cd8d60e31b83528960048401525af180156116bd576118fd575b505061184d565b8161190791613a2b565b6119125782386118f6565b8280fd5b91509150611922614445565b6025546078420190814211611a6657604051631ef8617760e01b8152600481018590526024810191909152604481019190915290602082606481886001600160a01b037f00000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c44165af191821561060e578592611a32575b5081156119fc576119aa8261148a614445565b036119c1576119b99192613b58565b903880611845565b60405162461bcd60e51b81526020600482015260136024820152721a5b98dbdc9c9958dd14ddd85c105b5bdd5b9d606a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd49859d953d89d185a5b995960921b6044820152606490fd5b9091506020813d602011611a5e575b81611a4e60209383613a2b565b8101031261082e57519038611997565b3d9150611a41565b634e487b7160e01b86526011600452602486fd5b50801515611840565b611a9b9060403d604011610607576105f98183613a2b565b50611817565b7f00000000000000000000000000000000000000000000000000000000003e7f899160405163133f757160e31b8152836004820152610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa9081156108c1578791611d98575b508115611d84576001600160801b0316048586906025546032811015611bf8575b50607842019283421161118f576040519560a0870187811067ffffffffffffffff82111761117b57906001600160801b039291604052875281602088019116815260408701928352606087019384526080870194855260405196630624e65f60e11b88525160048801525116602486015251604485015251606484015251608483015260408260a481887303a520b32c04bf3beef7beb72e919cf822ed34f15af191821561060e576117e992611bda575b5061177c565b611bf29060403d604011610607576105f98183613a2b565b50611bd4565b9150506001600160801b03821615611d465760405163133f757160e31b815260048101859052610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa8015611d3b5788918991611d0a575b50600154604051633850c7bd60e01b8152919060e090839060049082906001600160a01b03165afa908115611cff57611ca09386938c93611cd0575b50611c94611c9a9161450d565b9161450d565b91614884565b916127100390612710821161118f5781612710611cc18194611cc894614075565b0493614075565b049038611b23565b611c9a919350611cf1611c949160e03d60e01161130b576112f58183613a2b565b505050505050939150611c87565b6040513d8c823e3d90fd5b60049250611d2791506101803d81116113555761133a8183613a2b565b505050505096955093505050509190611c4b565b6040513d8a823e3d90fd5b60405162461bcd60e51b81526020600482015260166024820152751a5b9d985b1a59131a5c5d5a591a5d1e505b5bdd5b9d60521b6044820152606490fd5b634e487b7160e01b87526012600452602487fd5b611db191506101803d81116113555761133a8183613a2b565b50505050965050505050505038611b02565b60405162461bcd60e51b815260206004820152600b60248201526a1c9859d9551a5b595bdd5d60aa1b6044820152606490fd5b50346102a457806003193601126102a457611e146001825414613a4d565b60028155600d546001600160a01b031633148015611f7d575b611e3690613ec0565b7f00000000000000000000000000000000000000000000000000000000003e7f898015611f4c57600954611f14577303a520b32c04bf3beef7beb72e919cf822ed34f13b156116b957816040516323b872dd60e01b81523360048201523060248201528260448201528181606481837303a520b32c04bf3beef7beb72e919cf822ed34f15af180156116bd57611eff575b507fba51082b7645d1b4f632b76df55cb331092d45b3f08a77bba7f5be7f5ce95a1b6020836001600955604051908152a16001815580f35b81611f0991613a2b565b6116b9578138611ec7565b60405162461bcd60e51b815260206004820152601060248201526f1b999d105b1c9958591e531bd8dad95960821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260096024820152681b999d139bdd14d95d60ba1b6044820152606490fd5b50600e546001600160a01b03163314611e2d565b50346102a45760203660031901126102a457600435611fb36001835414613a4d565b60028255611fcc60018060a01b03600f54163314613ec0565b611fd7811515614038565b611fdf614445565b827f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b0316803b156116b957819060246040518094819363b198e1b560e01b83528860048401525af180156120d9576120c3575b5061204690611820614445565b801561208d577f69a47f1c91190a04d0f9b04ecab441680fe101a91709a0167ac046004b7967599161207c602092601254613b58565b601255604051908152a16001815580f35b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd4dd5c1c1b1e535a5b9d195960921b6044820152606490fd5b926120d2816120469395613a2b565b9290612039565b6040513d86823e3d90fd5b50346102a457806003193601126102a457600f546040516001600160a01b039091168152602090f35b50346102a457806003193601126102a45761213360018060a01b03600f54163314613ec0565b4780156121e857818080809373507fbde39ba40da4fc79426ad5e3c64944fe43d45af13d156121e3573d67ffffffffffffffff81116121cf5760405190612184601f8201601f191660200183613a2b565b81528260203d92013e5b156121965780f35b60405162461bcd60e51b8152602060048201526011602482015270195d1a151c985b9cd9995c91985a5b1959607a1b6044820152606490fd5b634e487b7160e01b83526041600452602483fd5b61218e565b60405162461bcd60e51b815260206004820152600c60248201526b6e6f45746842616c616e636560a01b6044820152606490fd5b50346102a457806003193601126102a457600d54600e54604080516001600160a01b039384168152919092166020820152f35b50346102a45760203660031901126102a4576004356122716001835414613a4d565b6002825561228a60018060a01b03600f54163314613ec0565b600754421061246d576122a06014821115614038565b60646122b46122ad613b88565b9283614075565b048015612437576122c3614445565b81116123f95760405163a9059cbb60e01b815273507fbde39ba40da4fc79426ad5e3c64944fe43d4600482015260248101829052602081604481877f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b03165af180156120d95784906123ba575b6123419150613b1b565b61234d81601054613b58565b6010556301e13380420180421161096f57604073507fbde39ba40da4fc79426ad5e3c64944fe43d493927f64c05fb63aaacb0695067680e413596ae48229f6b4a0027592e6bd22fb8594b49260075560018060a01b03600f54169382519182526020820152a36001815580f35b506020813d6020116123f1575b816123d460209383613a2b565b810103126123ed576123e861234191613b0e565b612337565b8380fd5b3d91506123c7565b60405162461bcd60e51b8152602060048201526016602482015275696e73756666696369656e7452636542616c616e636560501b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d6e6f416374697665537570706c7960901b6044820152606490fd5b60405162461bcd60e51b815260206004820152600d60248201526c36bab9ba2bb0b4ba18acb2b0b960991b6044820152606490fd5b50346102a45760203660031901126102a4576124bc6139a9565b6124d160018060a01b03600f54163314613ec0565b6001600160a01b03908116907f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea151681141580612685575b15612640576040516370a0823160e01b8152306004820152602081602481855afa908115612635578391612603575b5080156125cd5782916044602092604051948593849263a9059cbb60e01b845273507fbde39ba40da4fc79426ad5e3c64944fe43d4600485015260248401525af180156116bd578290612592575b61258f9150613b1b565b80f35b506020813d6020116125c5575b816125ac60209383613a2b565b810103126116b9576125c061258f91613b0e565b612585565b3d915061259f565b60405162461bcd60e51b815260206004820152600e60248201526d6e6f546f6b656e42616c616e636560901b6044820152606490fd5b90506020813d60201161262d575b8161261e60209383613a2b565b81010312611912575138612537565b3d9150612611565b6040513d85823e3d90fd5b60405162461bcd60e51b815260206004820152601a60248201527f75736463416e64526167654e6f74576974686472617761626c650000000000006044820152606490fd5b5073833589fcd6edb6e08f4c7c32d4f71b54bda02913811415612508565b50346102a457806003193601126102a4576126c960018060a01b03600f54163314613ec0565b6005544210612a3f5760245415612a0c57617080420180421161098357600555805b602454811015612901576126fd614445565b60235480911015612712575b506001016126eb565b61271a6144cb565b6025544260788101937f00000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c446001600160a01b0316939291851061157a57604051630d4f2ff160e21b8152600481019190915260248101919091526044810184905292919060208460648189865af193841561083b5786946128c7575b50916020916127b86127f4946127ac871515613f65565b6114908761148a6144cb565b6127c0614445565b94876025549160405196879586948593631ef8617760e01b8552600485016040919493926060820195825260208201520152565b03925af19081156120d9578491612896575b508015612860576128199061148a614445565b036128245738612709565b60405162461bcd60e51b8152602060048201526014602482015273696e636f72726563745261676542616c616e636560601b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd49859d9549958d95a5d995960921b6044820152606490fd5b90506020813d82116128bf575b816128b060209383613a2b565b810103126123ed575138612806565b3d91506128a3565b91929093506020823d82116128f9575b816128e460209383613a2b565b8101031261116f579051929091906020612795565b3d91506128d7565b5061297d61290d614445565b6129156144cb565b6040805161292281613a0f565b7f00000000000000000000000000000000000000000000000000000000003e7f8981523060208201526001600160801b03828201526001600160801b03606082015281518095819263fc6f786560e01b835260048301613ffb565b0381877303a520b32c04bf3beef7beb72e919cf822ed34f15af19283156120d9576129d76040936129e0927feedc2d0b9aa116d5a66762d9fd2b6d567d48bc4e29b61e22235d965bd16ada44966129f65750611820614445565b916118206144cb565b81601e5542601d5582519182526020820152a180f35b611a9b90863d8811610607576105f98183613a2b565b60405162461bcd60e51b815260206004820152600b60248201526a06e6f42757273744c6f6f760ac1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600c60248201526b189d5c9cdd151a5b595bdd5d60a21b6044820152606490fd5b50346102a4576101603660031901126102a457612a936001825414613a4d565b60028155612aac60018060a01b03600f54163314613ec0565b600654421061306457610e10420180421161098357600655600435606481101580613058575b15613020576024359060648211612fe6576044359081158015612fce575b15612f96576001600160801b03612b05613efb565b16158015612f5e575b15612f225760a43592670de0b6b3a764000084101580612f0f575b15612ed75760c43592600184101580612ecc575b15612e945760e435946109c48611612e4f5773507fbde39ba40da4fc79426ad5e3c64944fe43d46001600160a01b03612b74613f11565b16141580612e35575b15612dfc5773507fbde39ba40da4fc79426ad5e3c64944fe43d46001600160a01b03612ba7613f28565b16141580612de2575b15612da75773507fbde39ba40da4fc79426ad5e3c64944fe43d46001600160a01b03612bda613f3f565b16141580612d8d575b15612d52577fdb835d6ae3f1526fb30bb3f3b4ed7a34fb4f59626084ca485ef03e7df5ba7c58956101609585601f5584602055836021556001600160801b03612c2a613efb565b602254911660ff60801b612c3c613f56565b151560801b16916001600160881b031916171760225582602355806024558160255560018060a01b03612c6d613f11565b166001600160601b0360a01b602654161760265560018060a01b03612c90613f28565b166001600160601b0360a01b602754161760275560018060a01b03612cb3613f3f565b166001600160601b0360a01b6028541617602855612ccf613efb565b92612cd8613f56565b6001600160801b03612ce8613f11565b95612cf1613f28565b97612cfa613f3f565b604080519c8d5260208d019b909b52998b01521660608901521515608088015260a087015260c086015260e08501526001600160a01b0390811661010085015290811661012084015216610140820152a16001815580f35b60405162461bcd60e51b815260206004820152601360248201527234b73b30b634b229b4b232a0b2323932b9b99960691b6044820152606490fd5b50612d96613f3f565b6001600160a01b0316301415612be3565b60405162461bcd60e51b8152602060048201526013602482015272696e76616c696453696465416464726573733160681b6044820152606490fd5b50612deb613f28565b6001600160a01b0316301415612bb0565b60405162461bcd60e51b8152602060048201526011602482015270696e76616c6964506f644164647265737360781b6044820152606490fd5b50612e3e613f11565b6001600160a01b0316301415612b7d565b60405162461bcd60e51b815260206004820152601860248201527f696e76616c69644c6971756964697479536c69707061676500000000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f0696e76616c696442757273744c6f6f760841b6044820152606490fd5b506005841115612b3d565b60405162461bcd60e51b815260206004820152601060248201526f696e76616c696442757273745261676560801b6044820152606490fd5b50680ad78ebc5ac6200000841115612b29565b60405162461bcd60e51b8152602060048201526014602482015273696e76616c69644372757368446563726561736560601b6044820152606490fd5b5060646001600160801b03612f71613efb565b1610158015612b0e57506127106001600160801b03612f8e613efb565b161115612b0e565b60405162461bcd60e51b815260206004820152601060248201526f696e76616c6964426f6f73745261676560801b6044820152606490fd5b5060648210158015612af05750612710821115612af0565b60405162461bcd60e51b8152602060048201526012602482015271696e76616c6964537461636b48657374696160701b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f696e76616c6964537461636b5261676560801b6044820152606490fd5b50612710811115612ad2565b60405162461bcd60e51b815260206004820152600d60248201526c18dbdb999a59d51a5b595bdd5d609a1b6044820152606490fd5b50346102a457806003193601126102a45760206109e6613b88565b50346102a45760403660031901126102a4576130ce6139a9565b6024356130de6001845414613a4d565b60028355600a546001600160a01b0316338190036132af571561327e576001600160a01b0382161561324657613115811515613a86565b6131218161032c614445565b60405163a9059cbb60e01b81526001600160a01b0383166004820152602481018290529160208380604481010381877f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b03165af19283156120d95784936131e7575b506131b57f2b10214e09faa870b0ac9a20e6ffd58a5543ceaccb5fac56a36aaff06c3003cc93613b1b565b6131c182601154613b58565b601155604080516001600160a01b039092168252602082019290925290819081016105d6565b92506020833d60201161323e575b8161320260209383613a2b565b810103126123ed576131b56132377f2b10214e09faa870b0ac9a20e6ffd58a5543ceaccb5fac56a36aaff06c3003cc94613b0e565b935061318a565b3d91506131f5565b60405162461bcd60e51b815260206004820152601060248201526f1a5b9d985b1a59149958da5c1a595b9d60821b6044820152606490fd5b60405162461bcd60e51b81526020600482015260096024820152681c989c139bdd14d95d60ba1b6044820152606490fd5b60405162461bcd60e51b815260206004820152600660248201526506e6f745262760d41b6044820152606490fd5b50346102a457806003193601126102a457602060405173507fbde39ba40da4fc79426ad5e3c64944fe43d48152f35b9050346116b957816003193601126116b9578061332b610140926139bf565b8281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015260405161336b816139bf565b8381528360208201528360408201528360608201528360808201528360a08201528360c08201528360e082015283610100820152836101208201528383820152610120820152604051926133be846139f2565b8084528060208501528060408501528060608501528060808501528060a08501528060c08501528060e0850152806101008501528061012085015280838501528061016085015280610180850152806101a0850152806101c0850152806101e08501528061020085015280610220850152806102408501528061026085015280610280850152806102a0850152806102c0850152806102e085015280610300850152806103208501528061034085015280610360850152610380840152015261062060018060a01b0360015416610380613496613b88565b9161349f6142bc565b906134a8614445565b6134b06144cb565b90604051956134be876139bf565b60018752602087019460018060a01b037f00000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c44168652604088019473507fbde39ba40da4fc79426ad5e3c64944fe43d486526060890190815260808901907f00000000000000000000000000000000000000000000000000000000003e7f89825260a08a0192835260c08a0193845260e08a019485526101008a0195865260405196613567886139bf565b601f5488526020546020890152602154604089015260ff6022546001600160801b03811660608b015260801c161515608089015260235460a089015260245460c089015260255460e089015260018060a01b036026541661010089015260018060a01b036027541661012089015260018060a01b03602854166101408901526101208b01978852604051986135fb8a6139f2565b6002548a5260035460208b015260045460408b015260055460608b015260065460808b015260075460a08b015260018060a01b036008541660c08b015260095460e08b015260018060a01b03600a54166101008b015260018060a01b03600b54166101208b015260018060a01b03600c54166101408b015260018060a01b03600d54166101608b015260018060a01b03600e54166101808b015260018060a01b03600f54166101a08b01526010546101c08b01526011546101e08b01526012546102008b01526013546102208b01526014546102408b01526015546102608b01526016546102808b01526017546102a08b01526018546102c08b01526019546102e08b0152601a546103008b0152601b546103208b0152601c546103408b0152601d546103608b0152601e548b8b01526101408c01998a526040519b518c5260018060a01b0390511660208c015260018060a01b0390511660408b015260018060a01b0390511660608a01525160808901525160a08801525160c08701525160e086015251610100850152518051610120850152602081015161014085015260408101516101608501526001600160801b03606082015116610180850152608081015115156101a085015260a08101516101c085015260c08101516101e085015260e081015161020085015260018060a01b036101008201511661022085015260018060a01b036101208201511661024085015261014060018060a01b039101511661026084015251805161028084015260208101516102a084015260408101516102c084015260608101516102e0840152608081015161030084015260a081015161032084015260018060a01b0360c08201511661034084015260e081015161036084015260018060a01b03610100820151168284015260018060a01b03610120820151166103a084015260018060a01b03610140820151166103c084015260018060a01b03610160820151166103e084015260018060a01b036101808201511661040084015260018060a01b036101a0820151166104208401526101c08101516104408401526101e08101516104608401526102008101516104808401526102208101516104a08401526102408101516104c08401526102608101516104e08401526102808101516105008401526102a08101516105208401526102c08101516105408401526102e08101516105608401526103008101516105808401526103208101516105a08401526103408101516105c08401526103608101516105e08401520151610600820152f35b600435906001600160a01b038216820361082e57565b610160810190811067ffffffffffffffff8211176139dc57604052565b634e487b7160e01b600052604160045260246000fd5b6103a0810190811067ffffffffffffffff8211176139dc57604052565b6080810190811067ffffffffffffffff8211176139dc57604052565b90601f8019910116810190811067ffffffffffffffff8211176139dc57604052565b15613a5457565b60405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b6044820152606490fd5b15613a8d57565b60405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59105b5bdd5b9d609a1b6044820152606490fd5b15613ac957565b60405162461bcd60e51b815260206004820152601760248201527f696e73756666696369656e745261676542616c616e63650000000000000000006044820152606490fd5b5190811515820361082e57565b15613b2257565b60405162461bcd60e51b815260206004820152600e60248201526d1d1c985b9cd9995c91985a5b195960921b6044820152606490fd5b91908201809211613b6557565b634e487b7160e01b600052601160045260246000fd5b91908203918211613b6557565b6040516362720d9160e11b81527f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b031690602081600481855afa908115613d2e57600091613e8e575b50613be1614445565b6040516370a0823160e01b815273507fbde39ba40da4fc79426ad5e3c64944fe43d460048201529190602083602481875afa928315613d2e57600093613e5a575b50613c2b6142bc565b600f546040516370a0823160e01b81526001600160a01b03909116600482015292909190602084602481895afa938415613d2e57600094613e1e575b50613c7d94611820611820949361182093613b7b565b6026546001600160a01b031680613dac575b506027546001600160a01b031680613d3a575b506028546001600160a01b031680613cbb575b50905090565b6020906024604051809581936370a0823160e01b835260048301525afa908115613d2e57600091613cf8575b613cf19250613b7b565b8038613cb5565b90506020823d602011613d26575b81613d1360209383613a2b565b8101031261082e57613cf1915190613ce7565b3d9150613d06565b6040513d6000823e3d90fd5b90604051916370a0823160e01b83526004830152602082602481865afa908115613d2e57600091613d76575b613d709250613b7b565b38613ca2565b90506020823d602011613da4575b81613d9160209383613a2b565b8101031261082e57613d70915190613d66565b3d9150613d84565b90604051916370a0823160e01b83526004830152602082602481865afa908115613d2e57600091613de8575b613de29250613b7b565b38613c8f565b90506020823d602011613e16575b81613e0360209383613a2b565b8101031261082e57613de2915190613dd8565b3d9150613df6565b92919093506020833d602011613e52575b81613e3c60209383613a2b565b8101031261082e57915192909190613c7d613c67565b3d9150613e2f565b9092506020813d602011613e86575b81613e7660209383613a2b565b8101031261082e57519138613c22565b3d9150613e69565b90506020813d602011613eb8575b81613ea960209383613a2b565b8101031261082e575138613bd8565b3d9150613e9c565b15613ec757565b60405162461bcd60e51b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5e995960a21b6044820152606490fd5b6064356001600160801b038116810361082e5790565b610104356001600160a01b038116810361082e5790565b610124356001600160a01b038116810361082e5790565b610144356001600160a01b038116810361082e5790565b608435801515810361082e5790565b15613f6c57565b60405162461bcd60e51b815260206004820152600e60248201526d1b9bd55cd918d49958d95a5d995960921b6044820152606490fd5b15613fa957565b60405162461bcd60e51b8152602060048201526014602482015273696e636f72726563745573646342616c616e636560601b6044820152606490fd5b919082604091031261082e576020825192015190565b91909160606001600160801b038160808401958051855260018060a01b036020820151166020860152826040820151166040860152015116910152565b1561403f57565b60405162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5914195c98d95b9d60921b6044820152606490fd5b81810292918115918404141715613b6557565b8115614092570490565b634e487b7160e01b600052601260045260246000fd5b51906001600160a01b038216820361082e57565b51908160020b820361082e57565b51906001600160801b038216820361082e57565b91908261018091031261082e5781516001600160601b038116810361082e579161410a602082016140a8565b91614117604083016140a8565b91614124606082016140a8565b91608082015162ffffff8116810361082e579161414360a082016140bc565b9161415060c083016140bc565b9161415d60e082016140ca565b91610100820151916101208101519161418661016061417f61014085016140ca565b93016140ca565b90565b1561419057565b60405162461bcd60e51b815260206004820152600b60248201526a1b9bd49859d9525b93999d60aa1b6044820152606490fd5b156141ca57565b60405162461bcd60e51b815260206004820152600e60248201526d185b5bdd5b9d151bdbd4db585b1b60921b6044820152606490fd5b1561420757565b60405162461bcd60e51b815260206004820152601060248201526f06f776e657243616e6e6f7442655262760841b6044820152606490fd5b519061ffff8216820361082e57565b908160e091031261082e5780516001600160a01b038116810361082e5791614278602083016140bc565b916142856040820161423f565b916142926060830161423f565b9161429f6080820161423f565b9160a082015160ff8116810361082e5760c0614186919301613b0e565b7f00000000000000000000000000000000000000000000000000000000003e7f8980156143fb576040519063133f757160e31b82526004820152610180816024817303a520b32c04bf3beef7beb72e919cf822ed34f15afa908115613d2e57600091600080926000926143c8575b506001600160801b038216156143bf57600154604051633850c7bd60e01b8152939060e090859060049082906001600160a01b03165afa918215613d2e5761438094600093611cd05750611c94611c9a9161450d565b90916001600160a01b039081167f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea15909116036143ba575090565b905090565b50505050600090565b925050506143e591506101803d81116113555761133a8183613a2b565b505050509550939250945050929091903861432a565b50600090565b1561440857565b60405162461bcd60e51b81526020600482015260156024820152741bdddb995c9cd35d5cdd1099511a5999995c995b9d605a1b6044820152606490fd5b6040516370a0823160e01b81523060048201526020816024817f000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea156001600160a01b03165afa908115613d2e5760009161449c575090565b90506020813d6020116144c3575b816144b760209383613a2b565b8101031261082e575190565b3d91506144aa565b6040516370a0823160e01b815230600482015260208160248173833589fcd6edb6e08f4c7c32d4f71b54bda029135afa908115613d2e5760009161449c575090565b60020b600081121561487e5780600003905b620d89e8821161486d57600182161561485b576001600160881b036ffffcb933bd6fad37aa2d162d1a5940015b16916002811661483f575b60048116614823575b60088116614807575b601081166147eb575b602081166147cf575b604081166147b3575b60808116614797575b610100811661477b575b610200811661475f575b6104008116614743575b6108008116614727575b611000811661470b575b61200081166146ef575b61400081166146d3575b61800081166146b7575b62010000811661469b575b620200008116614680575b620400008116614665575b620800001661464c575b60001261463d575b63ffffffff8116614635576000905b60201c60ff91909116016001600160a01b031690565b60019061461f565b80156140925760001904614610565b6b048a170391f7dc42444e8fa290910260801c90614608565b6d2216e584f5fa1ea926041bedfe9890920260801c916145fe565b916e5d6af8dedb81196699c329225ee6040260801c916145f3565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c916145e8565b916f31be135f97d08fd981231505542fcfa60260801c916145dd565b916f70d869a156d2a1b890bb3df62baf32f70260801c916145d3565b916fa9f746462d870fdf8a65dc1f90e061e50260801c916145c9565b916fd097f3bdfd2022b8845ad8f792aa58250260801c916145bf565b916fe7159475a2c29b7443b29c7fa6e889d90260801c916145b5565b916ff3392b0822b70005940c7a398e4b70f30260801c916145ab565b916ff987a7253ac413176f2b074cf7815e540260801c916145a1565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c91614597565b916ffe5dee046a99a2a811c461f1969c30530260801c9161458d565b916fff2ea16466c96a3843ec78b326b528610260801c91614584565b916fff973b41fa98c081472e6896dfb254c00260801c9161457b565b916fffcb9843d60f6159c9db58835c9266440260801c91614572565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c91614569565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91614560565b916ffff97272373d413259a46990580e213a0260801c91614557565b6001600160881b03600160801b61454c565b6315e4079d60e11b60005260046000fd5b8061451f565b9093926000929091836001600160a01b03808416908816116148fe575b6001600160a01b0382811690881681116148c6575050506148c3929394614962565b91565b93945090926001600160a01b03831611156148f25750906148ec83614186949383614962565b9461491f565b9461418693925061491f565b9591956148a1565b6001600160a01b039182169082160391908211613b6557565b61418692916001600160801b03916001600160a01b038083169082161161495c575b6001600160a01b03916149549190614906565b1691166149d6565b90614941565b6141869290916149bf91906001600160a01b03808216908516116149d0575b6001600160a01b036149938583614906565b6001600160a01b039092169291169060601b6fffffffffffffffffffffffffffffffff60601b16614ab6565b6001600160a01b0390911690614088565b92614981565b600091906000198282099180820293848085109403938085039414614a1b57600160601b8410156102a45750600160601b910990828211900360a01b910360601c1790565b5050505060601c90565b600019600160601b8209918160601b91828085109403938085039414614aa9578382111561082e578190600160601b9009818060000316809204600281600302188082026002030280820260020302808202600203028082026002030280820260020302809102600203029360018380600003040190848311900302920304170290565b508092501561082e570490565b916000198284099282810292838086109503948086039514614b30578483111561082e57829109818060000316809204600281600302188082026002030280820260020302808202600203028082026002030280820260020302809102600203029360018380600003040190848311900302920304170290565b50508092501561082e570490565b614b729291906001600160a01b0380831690821611614b86575b6001600160a01b0391614b6b9190614906565b1690614a25565b6001600160801b03811690810361082e5790565b90614b58565b614b7292916001600160a01b0380821690831611614bd4575b614bcd614bbe6001600160a01b038381169085166149d6565b926001600160a01b0392614906565b1691614ab6565b90614ba556fea264697066735822122098dcb7f54779df8d39be1ff32319465ae9d1e196f22ee5a0a4f0cd078ec78a9264736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea1500000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c4400000000000000000000000000000000000000000000000000000000003e7f89000000000000000000000000b278f52bc80b883da0729a863f853845965af009000000000000000000000000035a12973c7d6de9e3d3d450899913f07f68edee
-----Decoded View---------------
Arg [0] : rage (address): 0xc0df50143EA93AeC63e38A6ED4E92B378079eA15
Arg [1] : rSwap (address): 0x03FEe5bA01D5B71c7F7689490826Ba75a2750c44
Arg [2] : nftId (uint256): 4095881
Arg [3] : owner1 (address): 0xb278F52bC80B883da0729a863F853845965aF009
Arg [4] : owner2 (address): 0x035A12973C7d6dE9E3D3D450899913F07f68edee
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000c0df50143ea93aec63e38a6ed4e92b378079ea15
Arg [1] : 00000000000000000000000003fee5ba01d5b71c7f7689490826ba75a2750c44
Arg [2] : 00000000000000000000000000000000000000000000000000000000003e7f89
Arg [3] : 000000000000000000000000b278f52bc80b883da0729a863f853845965af009
Arg [4] : 000000000000000000000000035a12973c7d6de9e3d3d450899913f07f68edee
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.