Source Code
Latest 25 from a total of 466 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Start New Epoch | 24176730 | 28 days ago | IN | 0 ETH | 0.001668 | ||||
| Start New Epoch | 23875112 | 71 days ago | IN | 0 ETH | 0.00098673 | ||||
| Start New Epoch | 23789293 | 83 days ago | IN | 0 ETH | 0.00118831 | ||||
| Start New Epoch | 23748977 | 88 days ago | IN | 0 ETH | 0.00417339 | ||||
| Start New Epoch | 23719497 | 92 days ago | IN | 0 ETH | 0.0023356 | ||||
| Claim | 23424610 | 134 days ago | IN | 0 ETH | 0.00013268 | ||||
| Start New Epoch | 23418943 | 134 days ago | IN | 0 ETH | 0.00194554 | ||||
| Start New Epoch | 23132014 | 174 days ago | IN | 0 ETH | 0.00130639 | ||||
| Start New Epoch | 23132000 | 174 days ago | IN | 0 ETH | 0.00020616 | ||||
| Start New Epoch | 23131991 | 174 days ago | IN | 0 ETH | 0.00023629 | ||||
| Start New Epoch | 22969303 | 197 days ago | IN | 0 ETH | 0.00220015 | ||||
| Start New Epoch | 22737091 | 230 days ago | IN | 0 ETH | 0.00048243 | ||||
| Start New Epoch | 22594361 | 250 days ago | IN | 0 ETH | 0.00409194 | ||||
| Start New Epoch | 22395148 | 278 days ago | IN | 0 ETH | 0.00036709 | ||||
| Start New Epoch | 22330782 | 287 days ago | IN | 0 ETH | 0.00102833 | ||||
| Start New Epoch | 22265826 | 296 days ago | IN | 0 ETH | 0.0003865 | ||||
| Start New Epoch | 22265816 | 296 days ago | IN | 0 ETH | 0.00009581 | ||||
| Start New Epoch | 22201511 | 305 days ago | IN | 0 ETH | 0.00044217 | ||||
| Start New Epoch | 22151162 | 312 days ago | IN | 0 ETH | 0.00036468 | ||||
| Start New Epoch | 22096432 | 319 days ago | IN | 0 ETH | 0.00064528 | ||||
| Start New Epoch | 22045635 | 326 days ago | IN | 0 ETH | 0.00070804 | ||||
| Start New Epoch | 21237200 | 439 days ago | IN | 0 ETH | 0.02067503 | ||||
| Start New Epoch | 20710932 | 513 days ago | IN | 0 ETH | 0.00510482 | ||||
| Start New Epoch | 20696467 | 515 days ago | IN | 0 ETH | 0.00416749 | ||||
| Start New Epoch | 20682026 | 517 days ago | IN | 0 ETH | 0.00309456 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| Deposit | 23748977 | 88 days ago | 0.31558849 ETH | ||||
| Transfer | 23748977 | 88 days ago | 0.31558849 ETH | ||||
| Deposit | 23719497 | 92 days ago | 1.41173598 ETH | ||||
| Transfer | 23719497 | 92 days ago | 1.41173598 ETH | ||||
| Deposit | 23418943 | 134 days ago | 0.92143113 ETH | ||||
| Transfer | 23418943 | 134 days ago | 0.92143113 ETH | ||||
| Deposit | 22151162 | 312 days ago | 0.11398815 ETH | ||||
| Transfer | 22151162 | 312 days ago | 0.11398815 ETH | ||||
| Deposit | 22045635 | 326 days ago | 0.6192222 ETH | ||||
| Transfer | 22045635 | 326 days ago | 0.6192222 ETH | ||||
| Deposit | 20710932 | 513 days ago | 0.2588236 ETH | ||||
| Transfer | 20710932 | 513 days ago | 0.2588236 ETH | ||||
| Deposit | 20682026 | 517 days ago | 0.25267573 ETH | ||||
| Transfer | 20682026 | 517 days ago | 0.25267573 ETH | ||||
| Deposit | 20623711 | 525 days ago | 0.1111771 ETH | ||||
| Transfer | 20623711 | 525 days ago | 0.1111771 ETH | ||||
| Deposit | 19806681 | 639 days ago | 0.02854858 ETH | ||||
| Transfer | 19806681 | 639 days ago | 0.02854858 ETH | ||||
| Deposit | 19777889 | 643 days ago | 0.03076861 ETH | ||||
| Transfer | 19777889 | 643 days ago | 0.03076861 ETH | ||||
| Deposit | 19600791 | 668 days ago | 45.61358214 ETH | ||||
| Transfer | 19600791 | 668 days ago | 45.61358214 ETH | ||||
| Deposit | 19252645 | 717 days ago | 0.32583738 ETH | ||||
| Transfer | 19252645 | 717 days ago | 0.32583738 ETH | ||||
| Deposit | 19094641 | 739 days ago | 0.03942763 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
GammaFarm
Compiler Version
v0.7.6+commit.7338295f
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;
pragma abicoder v2;
import "Ownable.sol";
import "IERC20.sol";
import "ReentrancyGuard.sol";
import "ISwapRouter.sol";
import "IUniswapV3Pool.sol";
import "GammaLib.sol";
import "IGammaFarm.sol";
import "IStableSwapExchange.sol";
import "ILUSDToken.sol";
import "IStabilityPool.sol";
import "IPriceFeed.sol";
import "IWETH9.sol";
contract GammaFarm is IGammaFarm, ReentrancyGuard, Ownable {
IERC20 constant public malToken = IERC20(0x6619078Bdd8324E01E9a8D4b3d761b050E5ECF06);
ILUSDToken constant public lusdToken = ILUSDToken(0x5f98805A4E8be255a32880FDeC7F6728C6568bA0);
IERC20 constant public lqtyToken = IERC20(0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D);
IWETH9 constant public wethToken = IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IERC20 constant public usdcToken = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
IERC20 constant public daiToken = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
IPriceFeed constant public priceFeed = IPriceFeed(0x4c517D4e2C851CA76d7eC94B805269Df0f2201De);
ISwapRouter constant public uniswapV3Router = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
IStableSwapExchange constant public lusdCurvePool = IStableSwapExchange(0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA);
IStabilityPool public lusdStabilityPool = IStabilityPool(0x66017D22b0f8556afDd19FC67041899Eb65a21bb);
uint256 constant public MAX_GOV_ONLY_EPOCH_DURATION_SECS = 7 * 24 * 60 * 60; // 7 days
uint256 constant public DECIMAL_PRECISION = 1e18;
// --- Global MAL distribution parameters ---
uint256 immutable public deploymentTime;
uint256 immutable public malDistributionEndTime;
uint256 immutable public malDecayPeriodSeconds;
uint256 immutable public malDecayFactor;
uint256 immutable public malToDistribute;
uint256 immutable public malRewardPerSecond;
// --- Data structures ---
struct Snapshot {
uint96 lusdProfitFactorCumP;
uint160 malRewardPerAvailableCumS;
uint256 malRewardPerStakedCumS;
}
struct AccountBalances {
// lusdStakeData stores packed information about LUSD stake: {lusdToStake, lusdStaked, accountEpoch, shouldUnstake}, where:
// * lusdToStake - amount of LUSD to be staked at the start of "accountEpoch + 1" epoch (uint112)
// * lusdStaked - amount of LUSD staked at the start of "accountEpoch" epoch (uint112)
// * accountEpoch - epoch of last user action (uint31)
// * shouldUnstake - 0 or 1, whether an unstake should be done at the start of "accountEpoch + 1" epoch (bool)
uint256 lusdStakeData;
uint96 malRewards; // amount of MAL rewards earned
uint160 malRewardPerAvailableCumS; // MAL cumulative sum value taken at the time of last account action
uint256 lusdUnstaked; // amount of LUSD unstaked
}
// --- Total balances and state variables ---
uint128 public totalLusd;
uint128 public totalLusdToStake;
uint128 public totalLusdStaked;
uint128 public totalLusdToUnstake;
uint96 public lastTotalMalRewards;
uint160 public lastMalRewardPerAvailableCumS;
// --- Per account variables ---
mapping(address => AccountBalances) public accountBalances;
// --- Epoch variables ---
mapping(uint32 => Snapshot) public epochSnapshots; // snapshots of rewards state taken at the start of each epoch
mapping(uint32 => uint32) public previousResetEpoch;
uint256 public epochStartTime;
uint32 public epoch;
uint32 public lastResetEpoch;
// --- Emergency variables ---
bool public isEmergencyState;
// --- Governance variables ---
uint16 public malBurnPct = 3000; // 30% (10000 = 100%)
uint16 public minWethLusdAmountOutPct = 9500; // 95% (10000 = 100%) <=> 5% slippage
uint24 public defaultWethToStableTokenFee = 500;
bool public defaultUseCurveForStableTokenToLusd = true;
address public defaultWethToStableToken = address(usdcToken);
constructor(
uint256 _malToDistribute,
uint256 _malDistributionPeriodSeconds,
uint256 _malRewardPerSecond,
uint256 _malDecayFactor,
uint256 _malDecayPeriodSeconds
) {
deploymentTime = block.timestamp;
malDistributionEndTime = block.timestamp + _malDistributionPeriodSeconds;
malDecayPeriodSeconds = _malDecayPeriodSeconds;
malDecayFactor = _malDecayFactor;
malToDistribute = _malToDistribute;
malRewardPerSecond = _malRewardPerSecond;
epochStartTime = block.timestamp;
epochSnapshots[0].lusdProfitFactorCumP = uint96(DECIMAL_PRECISION);
lqtyToken.approve(address(uniswapV3Router), type(uint256).max);
wethToken.approve(address(uniswapV3Router), type(uint256).max);
usdcToken.approve(address(lusdCurvePool), type(uint256).max);
daiToken.approve(address(lusdCurvePool), type(uint256).max);
}
// --- Account methods ---
function deposit(uint256 _lusdAmount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external override nonReentrant {
require(_lusdAmount >= 1e18, "minimum deposit is 1 LUSD");
uint256 newLastMalRewardPerAvailableCumS = _updateMalRewardCumulativeSum();
AccountBalances memory oldBalances = accountBalances[msg.sender];
AccountBalances memory newBalances = _calculateAccountBalances(oldBalances, newLastMalRewardPerAvailableCumS);
// Transfer LUSD:
lusdToken.permit(msg.sender, address(this), _lusdAmount, _deadline, _v, _r, _s);
lusdToken.transferFrom(msg.sender, address(this), _lusdAmount);
// Update total balances:
totalLusd += uint128(_lusdAmount);
totalLusdToStake += uint128(_lusdAmount);
// Update account balances:
(uint256 lusdToStake, uint256 lusdStaked, uint32 accountEpoch, bool shouldUnstake) = _unpackAccountStakeData(newBalances.lusdStakeData);
newBalances.lusdStakeData = _packAccountStakeData(lusdToStake + _lusdAmount, lusdStaked, accountEpoch, shouldUnstake);
_updateAccountBalances(msg.sender, oldBalances, newBalances);
}
function unstake() external override nonReentrant {
require(!isEmergencyState, "nothing to unstake");
uint256 newLastMalRewardPerAvailableCumS = _updateMalRewardCumulativeSum();
AccountBalances memory oldBalances = accountBalances[msg.sender];
AccountBalances memory newBalances = _calculateAccountBalances(oldBalances, newLastMalRewardPerAvailableCumS);
(uint256 lusdToStake, uint256 lusdStaked, uint32 accountEpoch, bool shouldUnstake) = _unpackAccountStakeData(newBalances.lusdStakeData);
require(lusdStaked != 0, "nothing to unstake");
// Update total balances:
if (!shouldUnstake) {
totalLusdToUnstake += uint128(lusdStaked);
}
// Update account balances:
newBalances.lusdStakeData = _packAccountStakeData(lusdToStake, lusdStaked, accountEpoch, true);
_updateAccountBalances(msg.sender, oldBalances, newBalances);
}
function withdraw() external override nonReentrant returns (uint256 _lusdAmountWithdrawn) {
uint256 newLastMalRewardPerAvailableCumS = _updateMalRewardCumulativeSum();
AccountBalances memory oldBalances = accountBalances[msg.sender];
AccountBalances memory newBalances = _calculateAccountBalances(oldBalances, newLastMalRewardPerAvailableCumS);
(uint256 lusdToStake, uint256 lusdStaked, uint32 accountEpoch, bool shouldUnstake) = _unpackAccountStakeData(newBalances.lusdStakeData);
bool isEmergencyState_ = isEmergencyState;
// Allow withdrawing "staked" balance during emergency:
_lusdAmountWithdrawn = lusdToStake + newBalances.lusdUnstaked + (isEmergencyState_ ? lusdStaked : 0);
require(_lusdAmountWithdrawn != 0, "nothing to withdraw");
// Transfer LUSD:
lusdToken.transfer(msg.sender, _lusdAmountWithdrawn);
// Transfer MAL:
if (newBalances.malRewards != 0) {
malToken.transfer(msg.sender, newBalances.malRewards);
newBalances.malRewards = 0;
}
// Update total balances:
totalLusd -= uint128(_lusdAmountWithdrawn);
if (lusdToStake != 0) {
totalLusdToStake -= uint128(lusdToStake);
lusdToStake = 0;
}
if (isEmergencyState_ && lusdStaked != 0) {
totalLusdStaked -= uint128(lusdStaked);
lusdStaked = 0;
}
// Update account balances:
newBalances.lusdStakeData = _packAccountStakeData(lusdToStake, lusdStaked, accountEpoch, shouldUnstake);
newBalances.lusdUnstaked = 0;
_updateAccountBalances(msg.sender, oldBalances, newBalances);
return _lusdAmountWithdrawn;
}
function unstakeAndWithdraw() external override nonReentrant returns (uint256 _lusdAmountWithdrawn) {
require(!isEmergencyState, "nothing to unstake");
uint256 newLastMalRewardPerAvailableCumS = _updateMalRewardCumulativeSum();
AccountBalances memory oldBalances = accountBalances[msg.sender];
AccountBalances memory newBalances = _calculateAccountBalances(oldBalances, newLastMalRewardPerAvailableCumS);
(uint256 lusdToStake, uint256 lusdStaked,, bool shouldUnstake) = _unpackAccountStakeData(newBalances.lusdStakeData);
require(lusdStaked != 0, "nothing to unstake");
// Get staked LUSD amount at epoch start and after loss:
uint256 totalLusdStakedBefore = totalLusdStaked;
uint256 totalLusdStakedAfter = lusdStabilityPool.getCompoundedLUSDDeposit(address(this));
require(totalLusdStakedBefore != 0 && totalLusdStakedAfter != 0, "nothing to unstake");
// Calculate account new staked amount:
uint256 lusdWithdrawnFromSP = lusdStaked * totalLusdStakedAfter / totalLusdStakedBefore;
require(lusdWithdrawnFromSP != 0, "nothing to unstake");
// Withdraw from stability pool:
lusdStabilityPool.withdrawFromSP(lusdWithdrawnFromSP);
_lusdAmountWithdrawn += lusdWithdrawnFromSP;
// Withdraw from available balance:
_lusdAmountWithdrawn += lusdToStake + newBalances.lusdUnstaked;
// Transfer LUSD:
lusdToken.transfer(msg.sender, _lusdAmountWithdrawn);
// Transfer MAL:
if (newBalances.malRewards != 0) {
malToken.transfer(msg.sender, newBalances.malRewards);
}
// Update total balances:
totalLusd -= uint128(lusdStaked + lusdToStake + newBalances.lusdUnstaked);
totalLusdStaked = uint128(totalLusdStakedBefore - lusdStaked);
if (lusdToStake != 0) {
totalLusdToStake -= uint128(lusdToStake);
}
if (shouldUnstake) {
totalLusdToUnstake -= uint128(lusdStaked);
}
// Update account balances:
delete accountBalances[msg.sender];
}
function claim() external override nonReentrant {
uint256 newLastMalRewardPerAvailableCumS = _updateMalRewardCumulativeSum();
AccountBalances memory oldBalances = accountBalances[msg.sender];
AccountBalances memory newBalances = _calculateAccountBalances(oldBalances, newLastMalRewardPerAvailableCumS);
require(newBalances.malRewards != 0, "nothing to claim");
// Transfer MAL:
if (newBalances.malRewards != 0) {
malToken.transfer(msg.sender, newBalances.malRewards);
newBalances.malRewards = 0;
}
// Update account balances:
_updateAccountBalances(msg.sender, oldBalances, newBalances);
}
// --- View balances methods ---
function getAccountLUSDAvailable(address _account) public view override returns (uint256 _lusdAvailable) {
(_lusdAvailable, , , ,) = getAccountBalances(_account);
}
function getAccountLUSDStaked(address _account) public view override returns (uint256 _lusdStaked) {
(, _lusdStaked, , ,) = getAccountBalances(_account);
}
function getAccountMALRewards(address _account) public view override returns (uint256 _malRewards) {
(, , _malRewards, ,) = getAccountBalances(_account);
}
function getAccountBalances(address _account) public view returns (uint256 _lusdAvailable, uint256 _lusdStaked, uint256 _malRewards, uint256 _lusdToStake, bool _shouldUnstake) {
(,uint256 newLastMalRewardPerAvailableCumS) = _calculateMalRewardCumulativeSum(lastTotalMalRewards, lastMalRewardPerAvailableCumS);
AccountBalances memory newBalances = _calculateAccountBalances(accountBalances[_account], newLastMalRewardPerAvailableCumS);
(_lusdToStake, _lusdStaked,, _shouldUnstake) = _unpackAccountStakeData(newBalances.lusdStakeData);
_lusdAvailable = _lusdToStake + newBalances.lusdUnstaked;
_malRewards = newBalances.malRewards;
if (isEmergencyState) {
return (_lusdAvailable + _lusdStaked, 0, _malRewards, _lusdToStake + _lusdStaked, false);
}
}
function getTotalBalances() public view returns (uint256, uint256) {
return (totalLusd, isEmergencyState ? 0 : totalLusdStaked);
}
function getLastSnapshot() public view returns (Snapshot memory _snapshot) {
return _buildSnapshot(lastMalRewardPerAvailableCumS, epoch);
}
// --- Governance methods ---
function depositAsFarm(uint256 _lusdAmount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external override onlyOwner {
require(_lusdAmount >= 1e18, "minimum deposit is 1 LUSD");
_updateMalRewardCumulativeSum();
// Transfer LUSD to Farm:
lusdToken.permit(msg.sender, address(this), _lusdAmount, _deadline, _v, _r, _s);
lusdToken.transferFrom(msg.sender, address(this), _lusdAmount);
// Update total balances:
totalLusd += uint128(_lusdAmount);
totalLusdToStake += uint128(_lusdAmount);
}
function setMALBurnPercentage(uint16 _pct) external override onlyOwner {
require(_pct <= 10000, "must be <= 10000");
malBurnPct = _pct;
}
function setDefaultTradeData(bytes memory _tradeData) external override onlyOwner {
require(_tradeData.length != 0, "must not be empty");
(defaultWethToStableToken, defaultWethToStableTokenFee, defaultUseCurveForStableTokenToLusd) = _validateTradeData(_tradeData);
}
/*
* startNewEpoch():
* - Harvest LUSD reward accumulated during this epoch
* - Stake/withdraw from/to LUSD Stability Pool
* - Save epoch snapshot
*/
function startNewEpoch(bytes memory _tradeData) public override {
require(!isEmergencyState, "must not be in emergency state");
require(block.timestamp > epochStartTime, "must last at least one second");
// Allow user to start new epoch if current epoch duration is above threshold:
require(msg.sender == owner() || block.timestamp - epochStartTime > MAX_GOV_ONLY_EPOCH_DURATION_SECS, "caller must be an owner");
// Cache:
uint256 totalLusdToUnstake_ = totalLusdToUnstake;
// Get staked LUSD amount at epoch start and after loss:
uint256 totalLusdStakedBefore = totalLusdStaked;
uint256 totalLusdStakedAfter = lusdStabilityPool.getCompoundedLUSDDeposit(address(this));
// Harvest LQTY/ETH gains and unstake LUSD if needed:
uint256 lusdToUnstake = 0;
if (totalLusdStakedBefore != 0) {
// Calculate amount to unstake taking into account compounding loss:
lusdToUnstake = totalLusdStakedAfter * totalLusdToUnstake_ / totalLusdStakedBefore;
lusdStabilityPool.withdrawFromSP(lusdToUnstake);
}
// Swap LQTY/ETH rewards for LUSD:
uint256 lusdReward = _swapStabilityPoolRewardsForLUSD(_tradeData);
// Calculate LUSD reward portion to unstake:
uint256 lusdRewardToHold = 0;
if (totalLusdStakedBefore != 0) {
uint256 newTotalLusdToUnstake = (totalLusdStakedAfter + lusdReward) * totalLusdToUnstake_ / totalLusdStakedBefore;
lusdRewardToHold = newTotalLusdToUnstake - lusdToUnstake;
}
// Stake LUSD to Stability Pool if needed:
uint256 lusdToStake = totalLusdToStake + lusdReward - lusdRewardToHold;
if (lusdToStake != 0) {
lusdStabilityPool.provideToSP(lusdToStake, address(0));
}
// Calculate new total balances:
uint256 newTotalLusd = totalLusd + lusdReward + totalLusdStakedAfter - totalLusdStakedBefore;
uint256 newTotalLusdStaked = totalLusdStakedAfter + lusdToStake - lusdToUnstake;
// Start new epoch:
_updateNewEpochData(lusdReward, totalLusdStakedBefore, totalLusdStakedAfter, newTotalLusd);
// Update total balances:
totalLusd = uint128(newTotalLusd);
totalLusdStaked = uint128(newTotalLusdStaked);
totalLusdToStake = 0;
totalLusdToUnstake = 0;
}
// --- Emergency methods ---
function emergencyWithdraw(bytes memory _tradeData) external override onlyOwner {
require(!isEmergencyState, "already in emergency state");
require(block.timestamp > epochStartTime, "must last at least one second");
// Set emergency state:
isEmergencyState = true;
// Cache:
uint256 totalLusdToUnstake_ = totalLusdToUnstake;
// Get staked LUSD amount at epoch start and after loss:
uint256 totalLusdStakedBefore = totalLusdStaked;
uint256 totalLusdStakedAfter = lusdStabilityPool.getCompoundedLUSDDeposit(address(this));
// Withdraw everything from LUSD Stability Pool:
if (totalLusdStakedBefore != 0) {
lusdStabilityPool.withdrawFromSP(type(uint256).max);
}
// Swap LQTY/ETH rewards for LUSD:
uint256 lusdReward = _swapStabilityPoolRewardsForLUSD(_tradeData);
// Calculate stake/unstake amounts:
uint256 lusdToUnstake = 0;
uint256 lusdRewardToHold = 0;
if (totalLusdStakedBefore != 0) {
lusdToUnstake = totalLusdStakedAfter * totalLusdToUnstake_ / totalLusdStakedBefore;
uint256 newTotalLusdToUnstake = (totalLusdStakedAfter + lusdReward) * totalLusdToUnstake_ / totalLusdStakedBefore;
lusdRewardToHold = newTotalLusdToUnstake - lusdToUnstake;
}
uint256 lusdToStake = totalLusdToStake + lusdReward - lusdRewardToHold;
// Calculate new total balances:
uint256 newTotalLusd = totalLusd + lusdReward + totalLusdStakedAfter - totalLusdStakedBefore;
uint256 newTotalLusdStaked = totalLusdStakedAfter + lusdToStake - lusdToUnstake;
// Start new epoch:
_updateNewEpochData(lusdReward, totalLusdStakedBefore, totalLusdStakedAfter, newTotalLusd);
// Update total balances:
totalLusd = uint128(newTotalLusd);
totalLusdStaked = uint128(newTotalLusdStaked);
totalLusdToStake = 0;
totalLusdToUnstake = 0;
}
function emergencyRecover() external override onlyOwner {
require(isEmergencyState, "must be in emergency state");
// Unset emergency state:
isEmergencyState = false;
// Update cumulative sum:
_updateMalRewardCumulativeSum();
// Stake LUSD to Stability Pool:
uint256 totalLusdStaked_ = totalLusdStaked;
if (totalLusdStaked_ != 0) {
lusdStabilityPool.provideToSP(totalLusdStaked_, address(0));
}
}
// --- Internal methods ---
/*
* _updateNewEpochData():
* - Update MAL cumulative sums
* - Update LUSD profit cumulative product
* - Save new epoch snapshot
* - Advance epoch
*/
function _updateNewEpochData(uint256 _lusdReward, uint256 _totalLusdStakedBefore, uint256 _totalLusdStakedAfter, uint256 _totalLusd) internal {
uint32 epoch_ = epoch;
Snapshot memory epochSnapshot = epochSnapshots[epoch_];
// Calculate new MAL cumulative sums:
uint256 newMalRewardPerAvailableCumS = _updateMalRewardCumulativeSum();
uint256 newMalRewardPerStakedCumS = epochSnapshot.malRewardPerStakedCumS +
(newMalRewardPerAvailableCumS - epochSnapshot.malRewardPerAvailableCumS) * epochSnapshot.lusdProfitFactorCumP / DECIMAL_PRECISION;
// Calculate new LUSD profit cumulative product:
uint256 newLusdProfitFactorCumP = (_totalLusdStakedBefore != 0)
? epochSnapshot.lusdProfitFactorCumP * (_lusdReward + _totalLusdStakedAfter) / _totalLusdStakedBefore
: epochSnapshot.lusdProfitFactorCumP;
if (newLusdProfitFactorCumP == 0) {
newLusdProfitFactorCumP = DECIMAL_PRECISION;
previousResetEpoch[epoch_ + 1] = lastResetEpoch;
lastResetEpoch = epoch_ + 1;
}
// Save epoch snapshot:
epochSnapshots[epoch_ + 1].lusdProfitFactorCumP = uint96(newLusdProfitFactorCumP);
epochSnapshots[epoch_ + 1].malRewardPerAvailableCumS = uint160(newMalRewardPerAvailableCumS);
epochSnapshots[epoch_ + 1].malRewardPerStakedCumS = newMalRewardPerStakedCumS;
// Advance epoch:
epoch = epoch_ + 1;
epochStartTime = block.timestamp;
// Report LUSD gain and loss:
uint256 lusdProfitFactor = (_totalLusdStakedBefore != 0)
? (_lusdReward + _totalLusdStakedAfter) * DECIMAL_PRECISION / _totalLusdStakedBefore
: DECIMAL_PRECISION;
emit LUSDGainLossReported(epoch_, lusdProfitFactor, _lusdReward, _totalLusdStakedBefore - _totalLusdStakedAfter);
// Emit new epoch started event:
emit EpochStarted(epoch_ + 1, block.timestamp, _totalLusd);
}
// --- Update state methods ---
function _updateAccountBalances(address _account, AccountBalances memory _oldBalances, AccountBalances memory _newBalances) internal {
if ((_newBalances.lusdStakeData >> 32) == 0 && _newBalances.malRewards == 0 && _newBalances.lusdUnstaked == 0) {
delete accountBalances[_account];
return;
}
if (_oldBalances.lusdStakeData != _newBalances.lusdStakeData) {
accountBalances[_account].lusdStakeData = _newBalances.lusdStakeData;
}
if (_oldBalances.malRewardPerAvailableCumS != _newBalances.malRewardPerAvailableCumS) {
accountBalances[_account].malRewardPerAvailableCumS = _newBalances.malRewardPerAvailableCumS;
}
if (_oldBalances.malRewards != _newBalances.malRewards) {
accountBalances[_account].malRewards = _newBalances.malRewards;
}
if (_oldBalances.lusdUnstaked != _newBalances.lusdUnstaked) {
accountBalances[_account].lusdUnstaked = _newBalances.lusdUnstaked;
}
}
function _updateMalRewardCumulativeSum() internal returns (uint256) {
uint256 lastTotalMalRewards_ = lastTotalMalRewards;
uint256 lastMalRewardPerAvailableCumS_ = lastMalRewardPerAvailableCumS;
(uint256 newLastTotalMalRewards, uint256 newLastMalRewardPerAvailableCumS) = _calculateMalRewardCumulativeSum(
lastTotalMalRewards_, lastMalRewardPerAvailableCumS_
);
if (lastTotalMalRewards_ != newLastTotalMalRewards) {
lastTotalMalRewards = uint96(newLastTotalMalRewards);
}
if (lastMalRewardPerAvailableCumS_ != newLastMalRewardPerAvailableCumS) {
lastMalRewardPerAvailableCumS = uint160(newLastMalRewardPerAvailableCumS);
}
return newLastMalRewardPerAvailableCumS;
}
// --- Calculate state methods ---
function _buildSnapshot(uint256 _malRewardPerAvailableCumS, uint32 _epoch) internal view returns (Snapshot memory _snapshot) {
_snapshot = epochSnapshots[_epoch];
_snapshot.malRewardPerStakedCumS = _snapshot.malRewardPerStakedCumS +
(_malRewardPerAvailableCumS - _snapshot.malRewardPerAvailableCumS) * _snapshot.lusdProfitFactorCumP / DECIMAL_PRECISION;
_snapshot.malRewardPerAvailableCumS = uint160(_malRewardPerAvailableCumS);
}
function _calculateMalRewardCumulativeSum(uint256 _lastTotalMalRewards, uint256 _lastMalRewardsPerAvailableCumS) internal view returns (
uint256 _newLastTotalMalRewards,
uint256 _newLastMalRewardsPerAvailableCumS
) {
_newLastMalRewardsPerAvailableCumS = _lastMalRewardsPerAvailableCumS;
// Calculate MAL reward since last update:
uint256 newUpdateTime = block.timestamp < malDistributionEndTime ? block.timestamp : malDistributionEndTime;
_newLastTotalMalRewards = _calculateTotalMalRewards(newUpdateTime);
uint256 malRewardSinceLastUpdate = _newLastTotalMalRewards - _lastTotalMalRewards;
if (malRewardSinceLastUpdate == 0) {
return (_newLastTotalMalRewards, _newLastMalRewardsPerAvailableCumS);
}
// Calculate new MAL cumulative sum:
uint256 totalLusd_ = totalLusd;
if (totalLusd_ != 0) {
_newLastMalRewardsPerAvailableCumS += malRewardSinceLastUpdate * DECIMAL_PRECISION / totalLusd_;
}
}
function _calculateAccountBalances(AccountBalances memory _oldBalances, uint256 _newLastMalRewardPerAvailableCumS) internal view returns (AccountBalances memory _newBalances) {
uint32 epoch_ = epoch;
uint32 lastResetEpoch_ = lastResetEpoch;
(uint256 newLusdToStake, uint256 newLusdStaked, uint32 accountEpoch, bool shouldUnstake) = _unpackAccountStakeData(_oldBalances.lusdStakeData);
uint256 newLusdUnstaked = _oldBalances.lusdUnstaked;
uint256 newMalRewards = _oldBalances.malRewards;
// Calculate account balances at the end of last account action epoch:
Snapshot memory fromSnapshot = _buildSnapshot(_oldBalances.malRewardPerAvailableCumS, accountEpoch);
if (accountEpoch != epoch_ && (newLusdToStake != 0 || shouldUnstake)) {
Snapshot memory accountEpochSnapshot = epochSnapshots[accountEpoch + 1];
(newLusdStaked, newMalRewards) = _calculateAccountBalancesFromToSnapshots(
newLusdUnstaked + newLusdToStake, newLusdStaked, newMalRewards, fromSnapshot, accountEpochSnapshot
);
if (lastResetEpoch_ != 0 && (accountEpoch + 1 == lastResetEpoch_ || previousResetEpoch[accountEpoch + 1] != 0)) {
newLusdStaked = 0;
}
// Perform adjustment:
if (shouldUnstake) {
newLusdUnstaked += newLusdStaked;
newLusdStaked = 0;
shouldUnstake = false;
}
if (newLusdToStake != 0) {
newLusdStaked += newLusdToStake;
newLusdToStake = 0;
}
fromSnapshot = accountEpochSnapshot;
}
// Check practically impossible event of epoch reset:
if (lastResetEpoch_ != 0 && lastResetEpoch_ > accountEpoch + 1) {
uint32 resetEpoch = lastResetEpoch_;
while (previousResetEpoch[resetEpoch] > accountEpoch + 1) {
resetEpoch = previousResetEpoch[resetEpoch];
}
Snapshot memory resetEpochSnapshot = epochSnapshots[resetEpoch];
(newLusdStaked, newMalRewards) = _calculateAccountBalancesFromToSnapshots(
newLusdUnstaked + newLusdToStake, newLusdStaked, newMalRewards, fromSnapshot, resetEpochSnapshot
);
newLusdStaked = 0;
fromSnapshot = resetEpochSnapshot;
}
// Calculate account balance changes from fromSnapshot to lastSnapshot:
Snapshot memory lastSnapshot = _buildSnapshot(_newLastMalRewardPerAvailableCumS, epoch_);
(newLusdStaked, newMalRewards) = _calculateAccountBalancesFromToSnapshots(
newLusdUnstaked + newLusdToStake, newLusdStaked, newMalRewards, fromSnapshot, lastSnapshot
);
// New balances:
_newBalances.lusdStakeData = _packAccountStakeData(newLusdToStake, newLusdStaked, epoch_, shouldUnstake);
_newBalances.malRewardPerAvailableCumS = uint160(_newLastMalRewardPerAvailableCumS);
_newBalances.malRewards = uint96(newMalRewards);
_newBalances.lusdUnstaked = newLusdUnstaked;
}
function _calculateAccountBalancesFromToSnapshots(
uint256 _lusdAvailable, uint256 _lusdStaked, uint256 _malRewards,
Snapshot memory _fromSnapshot, Snapshot memory _toSnapshot
) internal pure returns (uint256 _lusdStakedAfter, uint256 _malRewardsAfter) {
_malRewardsAfter = _malRewards +
(_lusdStaked * (_toSnapshot.malRewardPerStakedCumS - _fromSnapshot.malRewardPerStakedCumS) / _fromSnapshot.lusdProfitFactorCumP) +
(_lusdAvailable * (_toSnapshot.malRewardPerAvailableCumS - _fromSnapshot.malRewardPerAvailableCumS) / DECIMAL_PRECISION);
_lusdStakedAfter = _lusdStaked * _toSnapshot.lusdProfitFactorCumP / _fromSnapshot.lusdProfitFactorCumP;
}
function _calculateTotalMalRewards(uint256 timestamp) internal view returns (uint256 _totalMalRewards) {
uint256 F = malDecayFactor;
uint256 elapsedSecs = timestamp - deploymentTime;
if (F == DECIMAL_PRECISION) {
return malRewardPerSecond * elapsedSecs;
}
uint256 decayT = malDecayPeriodSeconds;
uint256 epochs = elapsedSecs / decayT;
uint256 powF = _calculateDecayPower(F, epochs);
uint256 cumFraction = (DECIMAL_PRECISION - powF) * DECIMAL_PRECISION / (DECIMAL_PRECISION - F);
_totalMalRewards = malRewardPerSecond * cumFraction * decayT / DECIMAL_PRECISION;
uint256 secs = elapsedSecs - decayT * epochs;
if (secs != 0) {
_totalMalRewards += malRewardPerSecond * powF * secs / DECIMAL_PRECISION;
}
}
function _calculateDecayPower(uint256 _f, uint256 _n) internal pure returns (uint256) {
return GammaLib.decPow(_f, _n);
}
function _packAccountStakeData(uint256 _lusdToStake, uint256 _lusdStaked, uint32 _epoch, bool _shouldUnstake) internal pure returns (uint256) {
return (_lusdToStake << 144) | (_lusdStaked << 32) | (_epoch << 1) | (_shouldUnstake ? 1 : 0);
}
function _unpackAccountStakeData(uint256 _stakeData) internal pure returns (uint256 _lusdToStake, uint256 _lusdStaked, uint32 _epoch, bool _shouldUnstake) {
_lusdToStake = _stakeData >> 144;
_lusdStaked = (_stakeData >> 32) & ((1 << 112) - 1);
_epoch = uint32((_stakeData >> 1) & ((1 << 31) - 1));
_shouldUnstake = (_stakeData & 1) == 1;
}
// --- Trade methods ---
/*
* _swapStabilityPoolRewardsForLUSD(_tradeData):
* Swaps ETH and LQTY balances for LUSD and returns LUSD amount received:
* 1) LQTY is swapped for WETH on UniswapV3 via [LQTY/WETH/3000]
* 2) "malBurnPct"% of received WETH is swapped for MAL on UniswapV3 via [WETH/MAL/3000] and burned
* 3) Remaining WETH (+ETH amount) is swapped for LUSD using _tradeData:
* If _tradeData is empty:
* WETH->LUSD swap is done using "default" contract variables (defaultWethToStableToken, defaultWethToStableTokenFee,
* defaultUseCurveForStableTokenToLusd) the same way as described below for _tradeData
* Else _tradeData must encode 3 variables: [stableToken, wethToStableTokenFee, useCurveForStableTokenToLusd]
* - stableToken is an address of either LUSD, USDC or DAI,
* - wethToStableTokenFee is uint24 and is either 500 or 3000,
* - useCurveForStableTokenToLusd is a boolean
* If stableToken is LUSD:
* - wethToStableTokenFee must be 3000 and useCurveForStableTokenToLusd must be false
* - WETH is swapped for LUSD on UniswapV3 via [WETH/LUSD/3000]
* If stableToken is USDC or DAI:
* If useCurveForStableTokenToLusd is false:
* - WETH is swapped for LUSD on UniswapV3 via multihop swap: [WETH/stableToken/wethToStableTokenFee, stableToken/LUSD/500]
* If useCurveForStableTokenToLusd is true:
* - WETH is swapped for stableToken (USDC|DAI) on UniswapV3 via: [WETH/stableToken/wethToStableTokenFee]
* - Then stableToken (USDC|DAI) is swapped for LUSD on Curve LUSD3CRV-f Metapool
* 4) Received LUSD amount is checked against PriceFeed ETH/USD price to limit slippage
*/
function _swapStabilityPoolRewardsForLUSD(bytes memory _tradeData) internal virtual returns (uint256) {
// Get amounts to trade:
uint256 lqtyAmount = lqtyToken.balanceOf(address(this));
uint256 ethAmount = address(this).balance;
if (lqtyAmount == 0 && ethAmount == 0) {
return 0;
}
if (ethAmount != 0) {
wethToken.deposit{value: ethAmount}();
}
// Check no trades were done in current block for UniswapV3 pools we are about to use (to avoid beign frontran):
(address stableToken, uint24 wethToStableTokenFee, bool useCurveForStableTokenToLusd) = (_tradeData.length > 0) ?
_validateTradeData(_tradeData)
: (defaultWethToStableToken, defaultWethToStableTokenFee, defaultUseCurveForStableTokenToLusd);
_requireNoTradesInCurrentBlock(stableToken, wethToStableTokenFee, useCurveForStableTokenToLusd);
uint256 wethAmountToBuyLusd = ethAmount;
if (lqtyAmount != 0) {
// Swap LQTY rewards for WETH (via LQTY/WETH/3000):
uint256 wethAmountOut = uniswapV3Router.exactInputSingle(
ISwapRouter.ExactInputSingleParams({
tokenIn: address(lqtyToken),
tokenOut: address(wethToken),
fee: uint24(3000),
recipient: address(this),
deadline: block.timestamp,
amountIn: lqtyAmount,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0
})
);
// Swap "malBurnPct"% of received WETH for MAL (via WETH/MAL/3000):
uint256 wethAmountToBuyMal = wethAmountOut * malBurnPct / 10000;
wethAmountToBuyLusd += (wethAmountOut - wethAmountToBuyMal);
uint256 malAmountOut = uniswapV3Router.exactInputSingle(
ISwapRouter.ExactInputSingleParams({
tokenIn: address(wethToken),
tokenOut: address(malToken),
fee: uint24(3000),
recipient: address(this),
deadline: block.timestamp,
amountIn: wethAmountToBuyMal,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0
})
);
// Burn received MAL tokens:
malToken.transfer(address(0x000000000000000000000000000000000000dEaD), malAmountOut);
}
if (wethAmountToBuyLusd == 0) {
return 0;
}
// Calculate min amount out using oracle price:
uint256 ethUsdPrice = priceFeed.fetchPrice();
uint256 usdAmountOutMin = wethAmountToBuyLusd * ethUsdPrice * minWethLusdAmountOutPct / 10000 / DECIMAL_PRECISION;
// Decode trade data:
uint256 lusdAmountOut;
if (useCurveForStableTokenToLusd || stableToken == address(lusdToken)) {
// Swap WETH for "stableToken" on UniswapV3:
uint256 stableTokenAmountOut = uniswapV3Router.exactInputSingle(
ISwapRouter.ExactInputSingleParams({
tokenIn: address(wethToken),
tokenOut: stableToken,
fee: uint24(wethToStableTokenFee),
recipient: address(this),
deadline: block.timestamp,
amountIn: wethAmountToBuyLusd,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0
})
);
// Swap "stableToken" for LUSD on Curve (if needed):
if (stableToken == address(lusdToken)) {
lusdAmountOut = stableTokenAmountOut;
} else if (stableToken == address(usdcToken)) {
lusdAmountOut = lusdCurvePool.exchange_underlying(2, 0, stableTokenAmountOut, usdAmountOutMin);
} else if (stableToken == address(daiToken)) {
lusdAmountOut = lusdCurvePool.exchange_underlying(1, 0, stableTokenAmountOut, usdAmountOutMin);
}
} else {
// Swap WETH for LUSD on UniswapV3:
lusdAmountOut = uniswapV3Router.exactInput(
ISwapRouter.ExactInputParams({
path: abi.encodePacked(address(wethToken), uint24(wethToStableTokenFee), stableToken, uint24(500), address(lusdToken)),
recipient: address(this),
deadline: block.timestamp,
amountIn: wethAmountToBuyLusd,
amountOutMinimum: usdAmountOutMin
})
);
}
// Check slippage:
require(lusdAmountOut >= usdAmountOutMin, "received too little");
return lusdAmountOut;
}
function _requireNoTradesInCurrentBlock(address _wethToStableToken, uint24 _wethToStableTokenFee, bool _useCurveForStableTokenToLusd) internal {
_requireNoUniswapV3PoolTradesInCurrentBlock(0xD1D5A4c0eA98971894772Dcd6D2f1dc71083C44E); // LQTY/WETH/3000
_requireNoUniswapV3PoolTradesInCurrentBlock(0x41506D56B16794e4F7F423AEFF366740D4bdd387); // WETH/MAL/3000
if (_wethToStableToken == address(lusdToken)) {
_requireNoUniswapV3PoolTradesInCurrentBlock(0x9663f2CA0454acCad3e094448Ea6f77443880454); // WETH/LUSD/3000
} else if (_wethToStableToken == address(usdcToken)) {
(_wethToStableTokenFee == 500) ?
_requireNoUniswapV3PoolTradesInCurrentBlock(0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640) // WETH/USDC/500
: _requireNoUniswapV3PoolTradesInCurrentBlock(0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8); // WETH/USDC/3000
if (!_useCurveForStableTokenToLusd) {
_requireNoUniswapV3PoolTradesInCurrentBlock(0x4e0924d3a751bE199C426d52fb1f2337fa96f736); // USDC/LUSD/500
}
} else if (_wethToStableToken == address(daiToken)) {
(_wethToStableTokenFee == 500) ?
_requireNoUniswapV3PoolTradesInCurrentBlock(0x60594a405d53811d3BC4766596EFD80fd545A270) // WETH/DAI/500
: _requireNoUniswapV3PoolTradesInCurrentBlock(0xC2e9F25Be6257c210d7Adf0D4Cd6E3E881ba25f8); // WETH/DAI/3000
if (!_useCurveForStableTokenToLusd) {
_requireNoUniswapV3PoolTradesInCurrentBlock(0x16980C16811bDe2B3358c1Ce4341541a4C772Ec9); // DAI/LUSD/500
}
}
if (_useCurveForStableTokenToLusd) {
_requireNoLusdCurvePoolTradesInCurrentBlock();
}
}
function _requireNoUniswapV3PoolTradesInCurrentBlock(address _poolAddress) internal view {
(,,uint16 observationIndex,,,,) = IUniswapV3Pool(_poolAddress).slot0();
(uint32 blockTimestamp,,,) = IUniswapV3Pool(_poolAddress).observations(observationIndex);
require(blockTimestamp != block.timestamp, "frontrun protection");
}
function _requireNoLusdCurvePoolTradesInCurrentBlock() internal view {
require(lusdCurvePool.block_timestamp_last() != block.timestamp, "frontrun protection");
}
function _validateTradeData(bytes memory _tradeData) internal pure returns (address _stableToken, uint24 _wethToStableTokenFee, bool _useCurveForStableTokenToLusd) {
(_stableToken, _wethToStableTokenFee, _useCurveForStableTokenToLusd) = abi.decode(_tradeData, (address, uint24, bool));
require(_stableToken == address(lusdToken) || _stableToken == address(usdcToken) || _stableToken == address(daiToken), "invalid trade data");
if (_stableToken == address(lusdToken)) {
require(_wethToStableTokenFee == 3000 && _useCurveForStableTokenToLusd == false, "invalid trade data");
} else {
require(_wethToStableTokenFee == 500 || _wethToStableTokenFee == 3000, "invalid trade data");
}
}
receive() external payable {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import "IUniswapV3SwapCallback.sol";
/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);
struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
/// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
/// @dev In the implementation you must pay the pool tokens owed for the swap.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "IUniswapV3PoolImmutables.sol";
import "IUniswapV3PoolState.sol";
import "IUniswapV3PoolDerivedState.sol";
import "IUniswapV3PoolActions.sol";
import "IUniswapV3PoolOwnerActions.sol";
import "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 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 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.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 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 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 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: MIT
pragma solidity =0.7.6;
import "SafeMath.sol";
library GammaLib {
using SafeMath for uint256;
uint256 internal constant DECIMAL_PRECISION = 1e18;
/*
* Exponentiation function for 18-digit decimal base, and integer exponent n.
* O(log(n)) complexity.
*/
function decPow(uint256 _a, uint256 _n) internal pure returns (uint256) {
if (_n == 0) {return DECIMAL_PRECISION;}
uint256 y = DECIMAL_PRECISION;
uint256 x = _a;
uint256 n = _n;
while (n > 1) {
if (n & 1 == 0) {
x = _decMul(x, x);
n = n.div(2);
} else {
y = _decMul(x, y);
x = _decMul(x, x);
n = (n.sub(1)).div(2);
}
}
return _decMul(x, y);
}
/*
* Multiply two decimal numbers and use normal rounding rules:
* - round product up if 19'th mantissa digit >= 5
* - round product down if 19'th mantissa digit < 5
*/
function _decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {
uint256 prod_xy = x.mul(y);
decProd = prod_xy.add(DECIMAL_PRECISION / 2).div(DECIMAL_PRECISION);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;
interface IGammaFarm {
function deposit(uint256 _lusdAmount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external;
function unstake() external;
function withdraw() external returns (uint256);
function unstakeAndWithdraw() external returns (uint256);
function claim() external;
// --- View methods ---
function getAccountLUSDAvailable(address _account) external view returns (uint256);
function getAccountLUSDStaked(address _account) external view returns (uint256);
function getAccountMALRewards(address _account) external view returns (uint256);
// --- Emergency methods ---
function emergencyWithdraw(bytes memory _tradeData) external;
function emergencyRecover() external;
// --- Owner methods ---
function startNewEpoch(bytes memory _tradeData) external;
function depositAsFarm(uint256 _lusdAmount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external;
function setMALBurnPercentage(uint16 _pct) external;
function setDefaultTradeData(bytes memory _tradeData) external;
// --- Events ---
event EpochStarted(uint256 epoch, uint256 timestamp, uint256 totalLUSD);
event LUSDGainLossReported(uint256 epoch, uint256 LUSDProfitFactor, uint256 LUSDGain, uint256 LUSDLoss);
}// SPDX-License-Identifier: Copyright (c) Curve.Fi, 2021 - all rights reserved
pragma solidity =0.7.6;
interface IStableSwapExchange {
function get_dy_underlying(
int128 i,
int128 j,
uint256 dx
) external view returns (uint256);
function exchange_underlying(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy
) external returns (uint256);
function block_timestamp_last() external view returns (uint256);
}// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;
import "IERC20.sol";
interface ILUSDToken is IERC20 {
// --- Events ---
event TroveManagerAddressChanged(address troveManagerAddress);
event StabilityPoolAddressChanged(address newStabilityPoolAddress);
event BorrowerOperationsAddressChanged(address newBorrowerOperationsAddress);
event LUSDTokenBalanceUpdated(address user, uint amount);
// --- Functions ---
function mint(address account, uint256 amount) external;
function burn(address account, uint256 amount) external;
function sendToPool(address sender, address poolAddress, uint256 amount) external;
function returnFromPool(address poolAddress, address receiver, uint256 amount) external;
// --- EIP 2612 Functionality ---
function permit(address owner, address spender, uint256 amount,
uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
function nonces(address owner) external view returns (uint256);
function domainSeparator() external view returns (bytes32);
function permitTypeHash() external view returns (bytes32);
// --- IERC20 Extra Functionality ---
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function version() external view returns (string memory);
}// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;
/*
* The Stability Pool holds LUSD tokens deposited by Stability Pool depositors.
*
* When a trove is liquidated, then depending on system conditions, some of its LUSD debt gets offset with
* LUSD in the Stability Pool: that is, the offset debt evaporates, and an equal amount of LUSD tokens in the Stability Pool is burned.
*
* Thus, a liquidation causes each depositor to receive a LUSD loss, in proportion to their deposit as a share of total deposits.
* They also receive an ETH gain, as the ETH collateral of the liquidated trove is distributed among Stability depositors,
* in the same proportion.
*
* When a liquidation occurs, it depletes every deposit by the same fraction: for example, a liquidation that depletes 40%
* of the total LUSD in the Stability Pool, depletes 40% of each deposit.
*
* A deposit that has experienced a series of liquidations is termed a "compounded deposit": each liquidation depletes the deposit,
* multiplying it by some factor in range ]0,1[
*
* Please see the implementation spec in the proof document, which closely follows on from the compounded deposit / ETH gain derivations:
* https://github.com/liquity/liquity/blob/master/papers/Scalable_Reward_Distribution_with_Compounding_Stakes.pdf
*
* --- LQTY ISSUANCE TO STABILITY POOL DEPOSITORS ---
*
* An LQTY issuance event occurs at every deposit operation, and every liquidation.
*
* Each deposit is tagged with the address of the front end through which it was made.
*
* All deposits earn a share of the issued LQTY in proportion to the deposit as a share of total deposits. The LQTY earned
* by a given deposit, is split between the depositor and the front end through which the deposit was made, based on the front end's kickbackRate.
*
* Please see the system Readme for an overview:
* https://github.com/liquity/dev/blob/main/README.md#lqty-issuance-to-stability-providers
*/
interface IStabilityPool {
// --- Events ---
event StabilityPoolETHBalanceUpdated(uint _newBalance);
event StabilityPoolLUSDBalanceUpdated(uint _newBalance);
event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress);
event TroveManagerAddressChanged(address _newTroveManagerAddress);
event ActivePoolAddressChanged(address _newActivePoolAddress);
event DefaultPoolAddressChanged(address _newDefaultPoolAddress);
event LUSDTokenAddressChanged(address _newLUSDTokenAddress);
event SortedTrovesAddressChanged(address _newSortedTrovesAddress);
event PriceFeedAddressChanged(address _newPriceFeedAddress);
event CommunityIssuanceAddressChanged(address _newCommunityIssuanceAddress);
event P_Updated(uint _P);
event S_Updated(uint _S, uint128 _epoch, uint128 _scale);
event G_Updated(uint _G, uint128 _epoch, uint128 _scale);
event EpochUpdated(uint128 _currentEpoch);
event ScaleUpdated(uint128 _currentScale);
event FrontEndRegistered(address indexed _frontEnd, uint _kickbackRate);
event FrontEndTagSet(address indexed _depositor, address indexed _frontEnd);
event DepositSnapshotUpdated(address indexed _depositor, uint _P, uint _S, uint _G);
event FrontEndSnapshotUpdated(address indexed _frontEnd, uint _P, uint _G);
event UserDepositChanged(address indexed _depositor, uint _newDeposit);
event FrontEndStakeChanged(address indexed _frontEnd, uint _newFrontEndStake, address _depositor);
event ETHGainWithdrawn(address indexed _depositor, uint _ETH, uint _LUSDLoss);
event LQTYPaidToDepositor(address indexed _depositor, uint _LQTY);
event LQTYPaidToFrontEnd(address indexed _frontEnd, uint _LQTY);
event EtherSent(address _to, uint _amount);
// --- Functions ---
/*
* Called only once on init, to set addresses of other Liquity contracts
* Callable only by owner, renounces ownership at the end
*/
function setAddresses(
address _borrowerOperationsAddress,
address _troveManagerAddress,
address _activePoolAddress,
address _lusdTokenAddress,
address _sortedTrovesAddress,
address _priceFeedAddress,
address _communityIssuanceAddress
) external;
/*
* Initial checks:
* - Frontend is registered or zero address
* - Sender is not a registered frontend
* - _amount is not zero
* ---
* - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends
* - Tags the deposit with the provided front end tag param, if it's a new deposit
* - Sends depositor's accumulated gains (LQTY, ETH) to depositor
* - Sends the tagged front end's accumulated LQTY gains to the tagged front end
* - Increases deposit and tagged front end's stake, and takes new snapshots for each.
*/
function provideToSP(uint _amount, address _frontEndTag) external;
/*
* Initial checks:
* - _amount is zero or there are no under collateralized troves left in the system
* - User has a non zero deposit
* ---
* - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends
* - Removes the deposit's front end tag if it is a full withdrawal
* - Sends all depositor's accumulated gains (LQTY, ETH) to depositor
* - Sends the tagged front end's accumulated LQTY gains to the tagged front end
* - Decreases deposit and tagged front end's stake, and takes new snapshots for each.
*
* If _amount > userDeposit, the user withdraws all of their compounded deposit.
*/
function withdrawFromSP(uint _amount) external;
/*
* Initial checks:
* - User has a non zero deposit
* - User has an open trove
* - User has some ETH gain
* ---
* - Triggers a LQTY issuance, based on time passed since the last issuance. The LQTY issuance is shared between *all* depositors and front ends
* - Sends all depositor's LQTY gain to depositor
* - Sends all tagged front end's LQTY gain to the tagged front end
* - Transfers the depositor's entire ETH gain from the Stability Pool to the caller's trove
* - Leaves their compounded deposit in the Stability Pool
* - Updates snapshots for deposit and tagged front end stake
*/
function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external;
/*
* Initial checks:
* - Frontend (sender) not already registered
* - User (sender) has no deposit
* - _kickbackRate is in the range [0, 100%]
* ---
* Front end makes a one-time selection of kickback rate upon registering
*/
function registerFrontEnd(uint _kickbackRate) external;
/*
* Initial checks:
* - Caller is TroveManager
* ---
* Cancels out the specified debt against the LUSD contained in the Stability Pool (as far as possible)
* and transfers the Trove's ETH collateral from ActivePool to StabilityPool.
* Only called by liquidation functions in the TroveManager.
*/
function offset(uint _debt, uint _coll) external;
/*
* Returns the total amount of ETH held by the pool, accounted in an internal variable instead of `balance`,
* to exclude edge cases like ETH received from a self-destruct.
*/
function getETH() external view returns (uint);
/*
* Returns LUSD held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset.
*/
function getTotalLUSDDeposits() external view returns (uint);
/*
* Calculates the ETH gain earned by the deposit since its last snapshots were taken.
*/
function getDepositorETHGain(address _depositor) external view returns (uint);
/*
* Calculate the LQTY gain earned by a deposit since its last snapshots were taken.
* If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned.
* Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through
* which they made their deposit.
*/
function getDepositorLQTYGain(address _depositor) external view returns (uint);
/*
* Return the LQTY gain earned by the front end.
*/
function getFrontEndLQTYGain(address _frontEnd) external view returns (uint);
/*
* Return the user's compounded deposit.
*/
function getCompoundedLUSDDeposit(address _depositor) external view returns (uint);
/*
* Return the front end's compounded stake.
*
* The front end's compounded stake is equal to the sum of its depositors' compounded deposits.
*/
function getCompoundedFrontEndStake(address _frontEnd) external view returns (uint);
/*
* Fallback function
* Only callable by Active Pool, it just accounts for ETH received
* receive() external payable;
*/
}// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;
interface IPriceFeed {
// --- Events ---
event LastGoodPriceUpdated(uint _lastGoodPrice);
// --- Function ---
function fetchPrice() external returns (uint);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
import "IERC20.sol";
/// @title Interface for WETH9
interface IWETH9 is IERC20 {
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
/// @notice Deposit ether to get wrapped ether
function deposit() external payable;
/// @notice Withdraw wrapped ether to get ether
function withdraw(uint256) external;
}{
"evmVersion": "istanbul",
"optimizer": {
"enabled": true,
"runs": 200
},
"libraries": {
"GammaFarm.sol": {}
},
"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":"uint256","name":"_malToDistribute","type":"uint256"},{"internalType":"uint256","name":"_malDistributionPeriodSeconds","type":"uint256"},{"internalType":"uint256","name":"_malRewardPerSecond","type":"uint256"},{"internalType":"uint256","name":"_malDecayFactor","type":"uint256"},{"internalType":"uint256","name":"_malDecayPeriodSeconds","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalLUSD","type":"uint256"}],"name":"EpochStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"LUSDProfitFactor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"LUSDGain","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"LUSDLoss","type":"uint256"}],"name":"LUSDGainLossReported","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"DECIMAL_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_GOV_ONLY_EPOCH_DURATION_SECS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accountBalances","outputs":[{"internalType":"uint256","name":"lusdStakeData","type":"uint256"},{"internalType":"uint96","name":"malRewards","type":"uint96"},{"internalType":"uint160","name":"malRewardPerAvailableCumS","type":"uint160"},{"internalType":"uint256","name":"lusdUnstaked","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"daiToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultUseCurveForStableTokenToLusd","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultWethToStableToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultWethToStableTokenFee","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deploymentTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lusdAmount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lusdAmount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"depositAsFarm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyRecover","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_tradeData","type":"bytes"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"epoch","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"epochSnapshots","outputs":[{"internalType":"uint96","name":"lusdProfitFactorCumP","type":"uint96"},{"internalType":"uint160","name":"malRewardPerAvailableCumS","type":"uint160"},{"internalType":"uint256","name":"malRewardPerStakedCumS","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getAccountBalances","outputs":[{"internalType":"uint256","name":"_lusdAvailable","type":"uint256"},{"internalType":"uint256","name":"_lusdStaked","type":"uint256"},{"internalType":"uint256","name":"_malRewards","type":"uint256"},{"internalType":"uint256","name":"_lusdToStake","type":"uint256"},{"internalType":"bool","name":"_shouldUnstake","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getAccountLUSDAvailable","outputs":[{"internalType":"uint256","name":"_lusdAvailable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getAccountLUSDStaked","outputs":[{"internalType":"uint256","name":"_lusdStaked","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getAccountMALRewards","outputs":[{"internalType":"uint256","name":"_malRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastSnapshot","outputs":[{"components":[{"internalType":"uint96","name":"lusdProfitFactorCumP","type":"uint96"},{"internalType":"uint160","name":"malRewardPerAvailableCumS","type":"uint160"},{"internalType":"uint256","name":"malRewardPerStakedCumS","type":"uint256"}],"internalType":"struct GammaFarm.Snapshot","name":"_snapshot","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isEmergencyState","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastMalRewardPerAvailableCumS","outputs":[{"internalType":"uint160","name":"","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastResetEpoch","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTotalMalRewards","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lqtyToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lusdCurvePool","outputs":[{"internalType":"contract IStableSwapExchange","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lusdStabilityPool","outputs":[{"internalType":"contract IStabilityPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lusdToken","outputs":[{"internalType":"contract ILUSDToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malBurnPct","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malDecayFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malDecayPeriodSeconds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malDistributionEndTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malRewardPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malToDistribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"malToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minWethLusdAmountOutPct","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"previousResetEpoch","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_tradeData","type":"bytes"}],"name":"setDefaultTradeData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_pct","type":"uint16"}],"name":"setMALBurnPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_tradeData","type":"bytes"}],"name":"startNewEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalLusd","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLusdStaked","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLusdToStake","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLusdToUnstake","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV3Router","outputs":[{"internalType":"contract ISwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unstakeAndWithdraw","outputs":[{"internalType":"uint256","name":"_lusdAmountWithdrawn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdcToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wethToken","outputs":[{"internalType":"contract IWETH9","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[{"internalType":"uint256","name":"_lusdAmountWithdrawn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
610140604052600280547366017d22b0f8556afdd19fc67041899eb65a21bb6001600160a01b031991821617909155600a8054600160801b61ffff60481b199091166a0bb80000000000000000001761ffff60581b19166c251c00000000000000000000001762ffffff60681b1916607d606a1b1760ff60801b1916179055600b805473a0b86991c6218b36c1d19d4a2e9eb0ce3606eb489216919091179055348015620000ac57600080fd5b506040516200507638038062005076833981016040819052620000cf916200046d565b60016000908155620000e062000440565b600180546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35042608081905284810160a05260c082905260e08390526101008690526101208490526009556000805260076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df80546001600160601b031916670de0b6b3a764000017905560405163095ea7b360e01b8152736dea81c8171d0ba574754ef6f8b412f2ed88c54d9063095ea7b390620001e69073e592427a0aece92de3edee1f18e0157c058615649060001990600401620004ad565b602060405180830381600087803b1580156200020157600080fd5b505af115801562000216573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200023c919062000444565b5060405163095ea7b360e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29063095ea7b3906200028e9073e592427a0aece92de3edee1f18e0157c058615649060001990600401620004ad565b602060405180830381600087803b158015620002a957600080fd5b505af1158015620002be573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002e4919062000444565b5060405163095ea7b360e01b815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb489063095ea7b390620003369073ed279fdd11ca84beef15af5d39bb4d4bee23f0ca9060001990600401620004ad565b602060405180830381600087803b1580156200035157600080fd5b505af115801562000366573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200038c919062000444565b5060405163095ea7b360e01b8152736b175474e89094c44da98b954eedeac495271d0f9063095ea7b390620003de9073ed279fdd11ca84beef15af5d39bb4d4bee23f0ca9060001990600401620004ad565b602060405180830381600087803b158015620003f957600080fd5b505af11580156200040e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000434919062000444565b505050505050620004c6565b3390565b60006020828403121562000456578081fd5b8151801515811462000466578182fd5b9392505050565b600080600080600060a0868803121562000485578081fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b6001600160a01b03929092168252602082015260400190565b60805160a05160c05160e0516101005161012051614b3e620005386000398061263a5280613b7d5280613c1a5280613c565250806126165250806109ee5280613b295250806109a25280613ba852508061212652806137d852806137ff5250806124d95280613b4a5250614b3e6000f3fe60806040526004361061036f5760003560e01c806389d81c3f116101c6578063be22f546116100f7578063f167244d11610095578063f3af70a41161006f578063f3af70a414610917578063f414e9671461092c578063f60ca64114610941578063face9c991461095657610376565b8063f167244d146108cd578063f2fde38b146108e2578063f309bcdb1461090257610376565b8063cd682c8a116100d1578063cd682c8a1461086c578063d6b636cb14610881578063e712e89a14610896578063ecda10f5146108b857610376565b8063be22f54614610820578063c95a58aa14610835578063c9af10831461084a57610376565b8063a20baee611610164578063aee0e5811161013e578063aee0e581146107c1578063b38a715e146107e1578063b83f91a2146107f6578063bdee02481461080b57610376565b8063a20baee61461076a578063ab75dbb31461077f578063ac3b26011461079f57610376565b80638dd04faa116101a05780638dd04faa1461070b578063900cf0cf14610720578063997207ad146107355780639ba00f171461074a57610376565b806389d81c3f146106c15780638cef23a8146106e15780638da5cb5b146106f657610376565b80633f8b2a6d116102a05780636ff96d171161023e5780637dacf449116102185780637dacf449146106555780637e34dbe01461067757806380fc45c314610697578063815d8ff8146106ac57610376565b80636ff96d17146105fb578063715018a61461062b578063741bef1a1461064057610376565b80634b57b0be1161027a5780634b57b0be146105805780634e71d92d14610595578063501f1ba3146105aa57806367a5b10b146105ca57610376565b80633f8b2a6d1461051157806342a3fda91461053157806349c1e3ef1461055357610376565b80631f7af3c31161030d5780632c76d7a6116102e75780632c76d7a6146104b25780632def6620146104c757806335cf32ef146104dc5780633ccfd60b146104fc57610376565b80631f7af3c31461045a578063255deaec1461046f5780632baf57d31461048f57610376565b806315064c961161034957806315064c96146103f757806319c2b2e5146104195780631b9922181461042e5780631c4c44ea1461044557610376565b806309c693301461037b5780630e4538d4146103b357806311eac855146103d557610376565b3661037657005b600080fd5b34801561038757600080fd5b5061039b61039636600461434c565b61096b565b6040516103aa939291906149f1565b60405180910390f35b3480156103bf57600080fd5b506103c86109a0565b6040516103aa919061490b565b3480156103e157600080fd5b506103ea6109c4565b6040516103aa9190614423565b34801561040357600080fd5b5061040c6109dc565b6040516103aa91906144d7565b34801561042557600080fd5b506103c86109ec565b34801561043a57600080fd5b50610443610a10565b005b34801561045157600080fd5b506103ea610b35565b34801561046657600080fd5b506103ea610b4b565b34801561047b57600080fd5b5061044361048a36600461419f565b610b63565b34801561049b57600080fd5b506104a4610dd0565b6040516103aa92919061492b565b3480156104be57600080fd5b506103ea610e1d565b3480156104d357600080fd5b50610443610e35565b3480156104e857600080fd5b506104436104f7366004614304565b610fa2565b34801561050857600080fd5b506103c861116d565b34801561051d57600080fd5b5061044361052c366004614234565b611475565b34801561053d57600080fd5b50610546611525565b6040516103aa91906148d8565b34801561055f57600080fd5b5061057361056e36600461434c565b611534565b6040516103aa919061498b565b34801561058c57600080fd5b506103ea61154c565b3480156105a157600080fd5b50610443611564565b3480156105b657600080fd5b506104436105c536600461419f565b61170a565b3480156105d657600080fd5b506105ea6105e536600461411b565b6117f0565b6040516103aa959493929190614939565b34801561060757600080fd5b5061061b61061636600461411b565b6118f1565b6040516103aa949392919061495e565b34801561063757600080fd5b5061044361192e565b34801561064c57600080fd5b506103ea6119da565b34801561066157600080fd5b5061066a6119f2565b6040516103aa91906149dd565b34801561068357600080fd5b50610443610692366004614304565b611a01565b3480156106a357600080fd5b506103ea611c5a565b3480156106b857600080fd5b5061040c611c69565b3480156106cd57600080fd5b506103c86106dc36600461411b565b611c79565b3480156106ed57600080fd5b506103ea611c8f565b34801561070257600080fd5b506103ea611ca7565b34801561071757600080fd5b506103c8611cb6565b34801561072c57600080fd5b50610573612118565b34801561074157600080fd5b506103c8612124565b34801561075657600080fd5b5061044361076536600461419f565b612148565b34801561077657600080fd5b506103c86123c4565b34801561078b57600080fd5b506103c861079a36600461411b565b6123d0565b3480156107ab57600080fd5b506107b46123e6565b6040516103aa91906148ec565b3480156107cd57600080fd5b506103c86107dc36600461411b565b6123f7565b3480156107ed57600080fd5b5061054661240d565b34801561080257600080fd5b506103ea61241c565b34801561081757600080fd5b506103ea61242e565b34801561082c57600080fd5b506103ea612446565b34801561084157600080fd5b506107b461245e565b34801561085657600080fd5b5061085f61246f565b6040516103aa91906148a5565b34801561087857600080fd5b506105736124a2565b34801561088d57600080fd5b506103ea6124b6565b3480156108a257600080fd5b506108ab6124c5565b6040516103aa91906148fb565b3480156108c457600080fd5b506103c86124d7565b3480156108d957600080fd5b506105466124fb565b3480156108ee57600080fd5b506104436108fd36600461411b565b612511565b34801561090e57600080fd5b506103c8612614565b34801561092357600080fd5b506103c8612638565b34801561093857600080fd5b506103c861265c565b34801561094d57600080fd5b506103c8612663565b34801561096257600080fd5b50610546612669565b600760205260009081526040902080546001909101546001600160601b03821691600160601b90046001600160a01b03169083565b7f000000000000000000000000000000000000000000000000000000000000000081565b73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b600a54600160401b900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b610a1861267f565b6001600160a01b0316610a29611ca7565b6001600160a01b031614610a72576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b600a54600160401b900460ff16610aa45760405162461bcd60e51b8152600401610a9b90614776565b60405180910390fd5b600a805460ff60401b19169055610ab9612683565b506004546001600160801b03168015610b3257600254604051635f788d6560e01b81526001600160a01b0390911690635f788d6590610aff908490600090600401614914565b600060405180830381600087803b158015610b1957600080fd5b505af1158015610b2d573d6000803e3d6000fd5b505050505b50565b600554600160601b90046001600160a01b031681565b736dea81c8171d0ba574754ef6f8b412f2ed88c54d81565b610b6b61267f565b6001600160a01b0316610b7c611ca7565b6001600160a01b031614610bc5576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b600a54600160401b900460ff1615610bef5760405162461bcd60e51b8152600401610a9b90614505565b6009544211610c105760405162461bcd60e51b8152600401610a9b906146e9565b600a805460ff60401b1916600160401b17905560048054600254604051621cdc4760e81b81526001600160801b03600160801b84048116949316926000926001600160a01b031691631cdc470091610c6a91309101614423565b60206040518083038186803b158015610c8257600080fd5b505afa158015610c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cba91906142ec565b90508115610d2757600254604051632e54bf9560e01b81526001600160a01b0390911690632e54bf9590610cf4906000199060040161490b565b600060405180830381600087803b158015610d0e57600080fd5b505af1158015610d22573d6000803e3d6000fd5b505050505b6000610d3285612707565b90506000808415610d62578486850281610d4857fe5b049150600085878587010281610d5a57fe5b048390039150505b6003546001600160801b03600160801b820481168501839003911684018501869003858201849003610d9686898985612fcd565b60038054600480546001600160801b039586166001600160801b031993841617861690935592841691161790911690555050505050505050565b600354600a5460009182916001600160801b0390911690600160401b900460ff16610e06576004546001600160801b0316610e09565b60005b6001600160801b0391821693501690509091565b73e592427a0aece92de3edee1f18e0157c0586156481565b60026000541415610e7b576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b6002600055600a54600160401b900460ff1615610eaa5760405162461bcd60e51b8152600401610a9b9061474a565b6000610eb4612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250610f16828461320d565b9050600080600080610f2b85600001516134bb565b93509350935093508260001415610f545760405162461bcd60e51b8152600401610a9b9061474a565b80610f7a57600480546001600160801b03600160801b8083048216870182160291161790555b610f8784848460016134ea565b8552610f94338787613526565b505060016000555050505050565b610faa61267f565b6001600160a01b0316610fbb611ca7565b6001600160a01b031614611004576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b670de0b6b3a764000085101561102c5760405162461bcd60e51b8152600401610a9b90614621565b611034612683565b5060405163d505accf60e01b8152600080516020614ae98339815191529063d505accf9061107290339030908a908a908a908a908a9060040161445b565b600060405180830381600087803b15801561108c57600080fd5b505af11580156110a0573d6000803e3d6000fd5b50506040516323b872dd60e01b8152600080516020614ae983398151915292506323b872dd91506110d990339030908a90600401614437565b602060405180830381600087803b1580156110f357600080fd5b505af1158015611107573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112b9190614185565b5050600380546001600160801b031981166001600160801b039182168701821617808216600160801b9182900483169097019091160294909417909355505050565b6000600260005414156111b5576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b600260009081556111c4612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250611226828461320d565b905060008060008061123b85600001516134bb565b600a5493975091955093509150600160401b900460ff168061125e576000611260565b835b60608701518601019850886112875760405162461bcd60e51b8152600401610a9b906146bc565b60405163a9059cbb60e01b8152600080516020614ae98339815191529063a9059cbb906112ba9033908d9060040161449c565b602060405180830381600087803b1580156112d457600080fd5b505af11580156112e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130c9190614185565b5060208601516001600160601b0316156113b757602086015160405163a9059cbb60e01b8152736619078bdd8324e01e9a8d4b3d761b050e5ecf069163a9059cbb9161135c9133916004016144b5565b602060405180830381600087803b15801561137657600080fd5b505af115801561138a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ae9190614185565b50600060208701525b600380546001600160801b038082168c9003166001600160801b0319909116179055841561140a57600380546001600160801b03808216600160801b928390048216989098031602959095179094556000935b80801561141657508315155b1561144557600480546001600160801b031981166001600160801b039182169690960316949094179093556000925b611451858585856134ea565b865260006060870152611465338888613526565b5050505050505050600160005590565b61147d61267f565b6001600160a01b031661148e611ca7565b6001600160a01b0316146114d7576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b6127108161ffff1611156114fd5760405162461bcd60e51b8152600401610a9b90614720565b600a805461ffff909216600160481b026affff00000000000000000019909216919091179055565b6004546001600160801b031681565b60086020526000908152604090205463ffffffff1681565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b600260005414156115aa576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b600260009081556115b9612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b03169183019190915260020154606082015291925061161b828461320d565b905080602001516001600160601b03166000141561164b5760405162461bcd60e51b8152600401610a9b906145ca565b60208101516001600160601b0316156116f557602081015160405163a9059cbb60e01b8152736619078bdd8324e01e9a8d4b3d761b050e5ecf069163a9059cbb9161169a9133916004016144b5565b602060405180830381600087803b1580156116b457600080fd5b505af11580156116c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ec9190614185565b50600060208201525b611700338383613526565b5050600160005550565b61171261267f565b6001600160a01b0316611723611ca7565b6001600160a01b03161461176c576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b805161178a5760405162461bcd60e51b8152600401610a9b9061453c565b6117938161369c565b600a805462ffffff909316600160681b0262ffffff60681b19921515600160801b0260ff60801b199094169390931791909116919091179055600b80546001600160a01b039092166001600160a01b031990921691909117905550565b60055460009081908190819081908190611824906001600160601b03811690600160601b90046001600160a01b03166137d2565b6001600160a01b03808a16600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b90930490941690820152600290920154606083015291935090915061188c908361320d565b905061189b81600001516134bb565b60608501516020860151600a549186019c50939a506001600160601b039093169850929650919450600160401b900460ff161590506118e5575050509282019260009201826118e8565b50505b91939590929450565b60066020526000908152604090208054600182015460029092015490916001600160601b03811691600160601b9091046001600160a01b03169084565b61193661267f565b6001600160a01b0316611947611ca7565b6001600160a01b031614611990576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b734c517d4e2c851ca76d7ec94b805269df0f2201de81565b6005546001600160601b031681565b60026000541415611a47576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b6002600055670de0b6b3a7640000851015611a745760405162461bcd60e51b8152600401610a9b90614621565b6000611a7e612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250611ae0828461320d565b60405163d505accf60e01b8152909150600080516020614ae98339815191529063d505accf90611b2090339030908d908d908d908d908d9060040161445b565b600060405180830381600087803b158015611b3a57600080fd5b505af1158015611b4e573d6000803e3d6000fd5b50506040516323b872dd60e01b8152600080516020614ae983398151915292506323b872dd9150611b8790339030908d90600401614437565b602060405180830381600087803b158015611ba157600080fd5b505af1158015611bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd99190614185565b50600380546001600160801b031981166001600160801b039182168b01821617808216600160801b9182900483168c01909216021790558051600090819081908190611c24906134bb565b9350935093509350611c3a8c85018484846134ea565b8552611c47338787613526565b5050600160005550505050505050505050565b600b546001600160a01b031681565b600a54600160801b900460ff1681565b6000611c84826117f0565b509295945050505050565b736619078bdd8324e01e9a8d4b3d761b050e5ecf0681565b6001546001600160a01b031690565b600060026000541415611cfe576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b6002600055600a54600160401b900460ff1615611d2d5760405162461bcd60e51b8152600401610a9b9061474a565b6000611d37612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250611d99828461320d565b90506000806000611dad84600001516134bb565b935050925092508160001415611dd55760405162461bcd60e51b8152600401610a9b9061474a565b60048054600254604051621cdc4760e81b81526001600160801b03909216926000926001600160a01b0390921691631cdc470091611e1591309101614423565b60206040518083038186803b158015611e2d57600080fd5b505afa158015611e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6591906142ec565b90508115801590611e7557508015155b611e915760405162461bcd60e51b8152600401610a9b9061474a565b60008282860281611e9e57fe5b04905080611ebe5760405162461bcd60e51b8152600401610a9b9061474a565b600254604051632e54bf9560e01b81526001600160a01b0390911690632e54bf9590611eee90849060040161490b565b600060405180830381600087803b158015611f0857600080fd5b505af1158015611f1c573d6000803e3d6000fd5b50505050606087015160405163a9059cbb60e01b81529a82019087010199600080516020614ae98339815191529063a9059cbb90611f609033908e9060040161449c565b602060405180830381600087803b158015611f7a57600080fd5b505af1158015611f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb29190614185565b5060208701516001600160601b03161561205657602087015160405163a9059cbb60e01b8152736619078bdd8324e01e9a8d4b3d761b050e5ecf069163a9059cbb916120029133916004016144b5565b602060405180830381600087803b15801561201c57600080fd5b505af1158015612030573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120549190614185565b505b6060870151600380546001600160801b03198082168a8a019094016001600160801b03928316038216939093179091556004805490921687860390911617905585156120be57600380546001600160801b03600160801b80830482168a900382160291161790555b83156120e657600480546001600160801b03600160801b808304821689900382160291161790555b505033600090815260066020526040812081815560018082018390556002909101829055905550959695505050505050565b600a5463ffffffff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b600a54600160401b900460ff16156121725760405162461bcd60e51b8152600401610a9b90614658565b60095442116121935760405162461bcd60e51b8152600401610a9b906146e9565b61219b611ca7565b6001600160a01b0316336001600160a01b031614806121c0575062093a806009544203115b6121dc5760405162461bcd60e51b8152600401610a9b90614567565b60048054600254604051621cdc4760e81b81526001600160801b03600160801b84048116949316926000926001600160a01b031691631cdc47009161222391309101614423565b60206040518083038186803b15801561223b57600080fd5b505afa15801561224f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227391906142ec565b9050600082156122ef57828483028161228857fe5b600254604051632e54bf9560e01b81529290910492506001600160a01b031690632e54bf95906122bc90849060040161490b565b600060405180830381600087803b1580156122d657600080fd5b505af11580156122ea573d6000803e3d6000fd5b505050505b60006122fa86612707565b90506000841561231b5760008587848701028161231357fe5b048490039150505b600354600160801b90046001600160801b03168201819003801561239f57600254604051635f788d6560e01b81526001600160a01b0390911690635f788d659061236c908490600090600401614914565b600060405180830381600087803b15801561238657600080fd5b505af115801561239a573d6000803e3d6000fd5b505050505b6003546001600160801b031683018501869003818601859003610d9685898985612fcd565b670de0b6b3a764000081565b60006123db826117f0565b509195945050505050565b600a54600160581b900461ffff1681565b6000612402826117f0565b509095945050505050565b6003546001600160801b031681565b600080516020614ae983398151915281565b73ed279fdd11ca84beef15af5d39bb4d4bee23f0ca81565b736b175474e89094c44da98b954eedeac495271d0f81565b600a54600160481b900461ffff1681565b6124776140b1565b600554600a5461249d91600160601b90046001600160a01b03169063ffffffff16613877565b905090565b600a54640100000000900463ffffffff1681565b6002546001600160a01b031681565b600a54600160681b900462ffffff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b600354600160801b90046001600160801b031681565b61251961267f565b6001600160a01b031661252a611ca7565b6001600160a01b031614612573576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b6001600160a01b0381166125b85760405162461bcd60e51b8152600401808060200182810382526026815260200180614a826026913960400191505060405180910390fd5b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b62093a8081565b60095481565b600454600160801b90046001600160801b031681565b3390565b6005546000906001600160601b03811690600160601b90046001600160a01b031682806126b084846137d2565b915091508184146126d757600580546001600160601b0319166001600160601b0384161790555b8083146126ff57600580546001600160601b0316600160601b6001600160a01b038416021790555b935050505090565b6040516370a0823160e01b81526000908190736dea81c8171d0ba574754ef6f8b412f2ed88c54d906370a0823190612743903090600401614423565b60206040518083038186803b15801561275b57600080fd5b505afa15801561276f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279391906142ec565b905047811580156127a2575080155b156127b257600092505050612fc8565b80156128215773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561280757600080fd5b505af115801561281b573d6000803e3d6000fd5b50505050505b60008060008087511161285c57600b54600a546001600160a01b0390911690600160681b810462ffffff1690600160801b900460ff16612865565b6128658761369c565b9250925092506128768383836138f0565b838515612b11576040805161010081018252736dea81c8171d0ba574754ef6f8b412f2ed88c54d815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26020820152610bb88183015230606082015242608082015260a08101889052600060c0820181905260e08201819052915163414bf38960e01b815273e592427a0aece92de3edee1f18e0157c058615649163414bf38991612918919060040161483c565b602060405180830381600087803b15801561293257600080fd5b505af1158015612946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061296a91906142ec565b600a54604080516101008101825273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28152736619078bdd8324e01e9a8d4b3d761b050e5ecf066020820152610bb881830152306060820152426080820152612710600160481b90930461ffff1684029290920460a08301819052600060c0840181905260e08401819052915163414bf38960e01b8152818503969096019593945092909173e592427a0aece92de3edee1f18e0157c058615649163414bf38991612a2a9160040161483c565b602060405180830381600087803b158015612a4457600080fd5b505af1158015612a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7c91906142ec565b60405163a9059cbb60e01b8152909150736619078bdd8324e01e9a8d4b3d761b050e5ecf069063a9059cbb90612aba9061dead90859060040161449c565b602060405180830381600087803b158015612ad457600080fd5b505af1158015612ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0c9190614185565b505050505b80612b255760009650505050505050612fc8565b6000734c517d4e2c851ca76d7ec94b805269df0f2201de6001600160a01b0316630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612b7657600080fd5b505af1158015612b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bae91906142ec565b90506000670de0b6b3a7640000612710600a600b9054906101000a900461ffff1661ffff168486020281612bde57fe5b0481612be657fe5b04905060008480612c0d57506001600160a01b038716600080516020614ae9833981519152145b15612e9c57604080516101008101825273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281526001600160a01b038916602082015262ffffff88168183015230606082015242608082015260a08101869052600060c0820181905260e08201819052915163414bf38960e01b815273e592427a0aece92de3edee1f18e0157c058615649163414bf38991612ca5919060040161483c565b602060405180830381600087803b158015612cbf57600080fd5b505af1158015612cd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf791906142ec565b90506001600160a01b038816600080516020614ae98339815191521415612d2057809150612e96565b6001600160a01b03881673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481415612ddd57604051635320bf6b60e11b815273ed279fdd11ca84beef15af5d39bb4d4bee23f0ca9063a6417ed690612d8490600290600090869089906004016144e2565b602060405180830381600087803b158015612d9e57600080fd5b505af1158015612db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd691906142ec565b9150612e96565b6001600160a01b038816736b175474e89094c44da98b954eedeac495271d0f1415612e9657604051635320bf6b60e11b815273ed279fdd11ca84beef15af5d39bb4d4bee23f0ca9063a6417ed690612e4190600190600090869089906004016144e2565b602060405180830381600087803b158015612e5b57600080fd5b505af1158015612e6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9391906142ec565b91505b50612f9d565b6040805160a0810190915273e592427a0aece92de3edee1f18e0157c058615649063c04b8d599080612ef973c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28b8d6101f4600080516020614ae983398151915260c087016143d6565b6040516020818303038152906040528152602001306001600160a01b03168152602001428152602001878152602001858152506040518263ffffffff1660e01b8152600401612f4891906147ad565b602060405180830381600087803b158015612f6257600080fd5b505af1158015612f76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f9a91906142ec565b90505b81811015612fbd5760405162461bcd60e51b8152600401610a9b9061468f565b985050505050505050505b919050565b600a5463ffffffff166000818152600760209081526040808320815160608101835281546001600160601b0381168252600160601b90046001600160a01b031693810193909352600101549082015290613025612683565b90506000670de0b6b3a764000083600001516001600160601b031684602001516001600160a01b03168403028161305857fe5b0483604001510190506000876000141561307c5783516001600160601b0316613096565b835188906001600160601b03168a8901028161309457fe5b045b9050806130f65750600a805463ffffffff600187018116600081815260086020526040902080546401000000009485900490931663ffffffff1990931692909217909155825467ffffffff0000000019169102179055670de0b6b3a76400005b600185810163ffffffff16600081815260076020526040812080546001600160601b0319166001600160601b038681169190911716600160601b6001600160a01b03891602178155909201849055600a805463ffffffff19169091179055426009558861316b57670de0b6b3a7640000613182565b88670de0b6b3a7640000898c01028161318057fe5b045b90507f842bd6bf8648efe83695d5fd798f1a26262429c193d854c2682d727b215d86ec86828c8b8d036040516131bb94939291906149ba565b60405180910390a17f29db3deb62ef2036e5eb93aad68d2362aec0711af592cb365566603bd88651d48660010142896040516131f99392919061499c565b60405180910390a150505050505050505050565b6132156140d1565b600a54835163ffffffff808316926401000000009004169060009081908190819061323f906134bb565b935093509350935060008960600151905060008a602001516001600160601b03169050600061327b8c604001516001600160a01b031686613877565b90508863ffffffff168563ffffffff161415801561329f57508615158061329f5750835b1561337e57600185810163ffffffff16600090815260076020908152604091829020825160608101845281546001600160601b0381168252600160601b90046001600160a01b031692810192909252909201549082015261330588850188858585613aa1565b909750925063ffffffff89161580159061335057508863ffffffff168660010163ffffffff161480613350575063ffffffff6001870181166000908152600860205260409020541615155b1561335a57600096505b841561336c5760009687955093909301925b871561337b5760009796909601955b90505b63ffffffff8816158015906133a157508460010163ffffffff168863ffffffff16115b1561345657875b63ffffffff818116600090815260086020526040902054600188018216911611156133ea5763ffffffff908116600090815260086020526040902054166133a8565b63ffffffff8116600090815260076020908152604091829020825160608101845281546001600160601b0381168252600160601b90046001600160a01b031692810192909252600101549181019190915261344a89860189868685613aa1565b60009950945090925050505b60006134628c8b613877565b905061347388850188858585613aa1565b909750925061348488888c886134ea565b8b5250506001600160a01b0390991660408901526001600160601b0390981660208801525050505060608301939093525092915050565b609081901c91602082901c6dffffffffffffffffffffffffffff1691600181811c637fffffff16929181161490565b6000816134f85760006134fb565b60015b60ff1660018463ffffffff16901b63ffffffff16602086901b609088901b1717179050949350505050565b805160201c158015613543575060208101516001600160601b0316155b801561355157506060810151155b15613581576001600160a01b03831660009081526006602052604081208181556001810182905560020155613697565b80518251146135a65780516001600160a01b0384166000908152600660205260409020555b80604001516001600160a01b031682604001516001600160a01b031614613605576040818101516001600160a01b03858116600090815260066020529290922060010180546001600160601b0316600160601b93909216929092021790555b80602001516001600160601b031682602001516001600160601b031614613666576020818101516001600160a01b03851660009081526006909252604090912060010180546001600160601b0319166001600160601b039092169190911790555b80606001518260600151146136975760608101516001600160a01b0384166000908152600660205260409020600201555b505050565b6000806000838060200190518101906136b59190614137565b919450925090506001600160a01b038316600080516020614ae983398151915214806136fd57506001600160a01b03831673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48145b8061372457506001600160a01b038316736b175474e89094c44da98b954eedeac495271d0f145b6137405760405162461bcd60e51b8152600401610a9b9061459e565b6001600160a01b038316600080516020614ae98339815191521415613794578162ffffff16610bb8148015613773575080155b61378f5760405162461bcd60e51b8152600401610a9b9061459e565b6137cb565b8162ffffff166101f414806137af57508162ffffff16610bb8145b6137cb5760405162461bcd60e51b8152600401610a9b9061459e565b9193909250565b600081817f00000000000000000000000000000000000000000000000000000000000000004210613823577f0000000000000000000000000000000000000000000000000000000000000000613825565b425b905061383081613b25565b925084830380613841575050613870565b6003546001600160801b0316801561386c5780670de0b6b3a764000083028161386657fe5b04840193505b5050505b9250929050565b61387f6140b1565b5063ffffffff16600090815260076020908152604091829020825160608101845281546001600160601b038116808352600190930154670de0b6b3a7640000600160601b9092046001600160a01b039081168803909402919091040193810193909352929092169181019190915290565b61390d73d1d5a4c0ea98971894772dcd6d2f1dc71083c44e613c8b565b61392a7341506d56b16794e4f7f423aeff366740d4bdd387613c8b565b6001600160a01b038316600080516020614ae9833981519152141561396b57613966739663f2ca0454accad3e094448ea6f77443880454613c8b565b613a93565b6001600160a01b03831673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4814156139ff578162ffffff166101f4146139c0576139bb738ad599c3a0ff1de082011efddc58f1908eb6e6d8613c8b565b6139dd565b6139dd7388e6a0c2ddd26feeb64f039a2c41296fcb3f5640613c8b565b8061396657613966734e0924d3a751be199c426d52fb1f2337fa96f736613c8b565b6001600160a01b038316736b175474e89094c44da98b954eedeac495271d0f1415613a93578162ffffff166101f414613a5457613a4f73c2e9f25be6257c210d7adf0d4cd6e3e881ba25f8613c8b565b613a71565b613a717360594a405d53811d3bc4766596efd80fd545a270613c8b565b80613a9357613a937316980c16811bde2b3358c1ce4341541a4c772ec9613c8b565b801561369757613697613daf565b600080670de0b6b3a764000084602001518460200151036001600160a01b0316880281613aca57fe5b0484600001516001600160601b03168560400151856040015103880281613aed57fe5b04860101905083600001516001600160601b031683600001516001600160601b0316870281613b1857fe5b0491509550959350505050565b60007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000008303670de0b6b3a7640000821415613ba6577f0000000000000000000000000000000000000000000000000000000000000000029150612fc89050565b7f00000000000000000000000000000000000000000000000000000000000000006000818381613bd257fe5b0490506000613be18583613e55565b9050600085670de0b6b3a764000003670de0b6b3a764000083670de0b6b3a7640000030281613c0c57fe5b049050670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000000000000008202850204965083830285038015613c7f57670de0b6b3a76400007f00000000000000000000000000000000000000000000000000000000000000008402820204880197505b50505050505050919050565b6000816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015613cc657600080fd5b505afa158015613cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cfe9190614250565b50505050925050506000826001600160a01b031663252c09d7836040518263ffffffff1660e01b8152600401613d3491906148ec565b60806040518083038186803b158015613d4c57600080fd5b505afa158015613d60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d849190614368565b5050509050428163ffffffff1614156136975760405162461bcd60e51b8152600401610a9b906145f4565b4273ed279fdd11ca84beef15af5d39bb4d4bee23f0ca6001600160a01b03166363543f066040518163ffffffff1660e01b815260040160206040518083038186803b158015613dfd57600080fd5b505afa158015613e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e3591906142ec565b1415613e535760405162461bcd60e51b8152600401610a9b906145f4565b565b6000613e618383613e6a565b90505b92915050565b600081613e805750670de0b6b3a7640000613e64565b670de0b6b3a764000083835b6001811115613ef15760018116613ebb57613ea78283613f05565b9150613eb4816002613f3a565b9050613eec565b613ec58284613f05565b9250613ed18283613f05565b9150613ee96002613ee3836001613fa1565b90613f3a565b90505b613e8c565b613efb8284613f05565b9695505050505050565b600080613f128484613ffe565b9050613f32670de0b6b3a7640000613ee3836706f05b59d3b20000614057565b949350505050565b6000808211613f90576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613f9957fe5b049392505050565b600082821115613ff8576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261400d57506000613e64565b8282028284828161401a57fe5b0414613e615760405162461bcd60e51b8152600401808060200182810382526021815260200180614aa86021913960400191505060405180910390fd5b600082820183811015613e61576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516060810182526000808252602082018190529181019190915290565b60405180608001604052806000815260200160006001600160601b0316815260200160006001600160a01b03168152602001600081525090565b80518015158114612fc857600080fd5b60006020828403121561412c578081fd5b8135613e6181614a1b565b60008060006060848603121561414b578182fd5b835161415681614a1b565b602085015190935062ffffff8116811461416e578283fd5b915061417c6040850161410b565b90509250925092565b600060208284031215614196578081fd5b613e618261410b565b600060208083850312156141b1578182fd5b823567ffffffffffffffff808211156141c8578384fd5b818501915085601f8301126141db578384fd5b8135818111156141e757fe5b604051601f8201601f191681018501838111828210171561420457fe5b604052818152838201850188101561421a578586fd5b818585018683013790810190930193909352509392505050565b600060208284031215614245578081fd5b8135613e6181614a30565b600080600080600080600060e0888a03121561426a578283fd5b875161427581614a1b565b8097505060208801518060020b811461428c578384fd5b604089015190965061429d81614a30565b60608901519095506142ae81614a30565b60808901519094506142bf81614a30565b60a08901519093506142d081614a52565b91506142de60c0890161410b565b905092959891949750929550565b6000602082840312156142fd578081fd5b5051919050565b600080600080600060a0868803121561431b578081fd5b8535945060208601359350604086013561433481614a52565b94979396509394606081013594506080013592915050565b60006020828403121561435d578081fd5b8135613e6181614a40565b6000806000806080858703121561437d578182fd5b845161438881614a40565b8094505060208501518060060b811461439f578283fd5b60408601519093506143b081614a1b565b91506143be6060860161410b565b905092959194509250565b6001600160a01b03169052565b6001600160601b0319606096871b811682526001600160e81b031960e896871b8116601484015294871b811660178301529290941b909216602b840152921b909116602e82015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039290921682526001600160601b0316602082015260400190565b901515815260200190565b600f94850b81529290930b60208301526040820152606081019190915260800190565b6020808252601a908201527f616c726561647920696e20656d657267656e6379207374617465000000000000604082015260600190565b6020808252601190820152706d757374206e6f7420626520656d70747960781b604082015260600190565b60208082526017908201527f63616c6c6572206d75737420626520616e206f776e6572000000000000000000604082015260600190565b602080825260129082015271696e76616c6964207472616465206461746160701b604082015260600190565b60208082526010908201526f6e6f7468696e6720746f20636c61696d60801b604082015260600190565b602080825260139082015272333937b73a393ab710383937ba32b1ba34b7b760691b604082015260600190565b60208082526019908201527f6d696e696d756d206465706f7369742069732031204c55534400000000000000604082015260600190565b6020808252601e908201527f6d757374206e6f7420626520696e20656d657267656e63792073746174650000604082015260600190565b602080825260139082015272726563656976656420746f6f206c6974746c6560681b604082015260600190565b6020808252601390820152726e6f7468696e6720746f20776974686472617760681b604082015260600190565b6020808252601d908201527f6d757374206c617374206174206c65617374206f6e65207365636f6e64000000604082015260600190565b60208082526010908201526f06d757374206265203c3d2031303030360841b604082015260600190565b6020808252601290820152716e6f7468696e6720746f20756e7374616b6560701b604082015260600190565b6020808252601a908201527f6d75737420626520696e20656d657267656e6379207374617465000000000000604082015260600190565b60006020808352835160a08285015280518060c0860152835b818110156147e25782810184015186820160e0015283016147c6565b818111156147f3578460e083880101525b50918501519161480660408601846143c9565b6040860151606086015260608601516080860152608086015160a086015260e0601f19601f830116860101935050505092915050565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b81516001600160601b031681526020808301516001600160a01b0316908201526040918201519181019190915260600190565b6001600160801b0391909116815260200190565b61ffff91909116815260200190565b62ffffff91909116815260200190565b90815260200190565b9182526001600160a01b0316602082015260400190565b918252602082015260400190565b9485526020850193909352604084019190915260608301521515608082015260a00190565b9384526001600160601b039290921660208401526001600160a01b03166040830152606082015260800190565b63ffffffff91909116815260200190565b63ffffffff9390931683526020830191909152604082015260600190565b63ffffffff94909416845260208401929092526040830152606082015260800190565b6001600160601b0391909116815260200190565b6001600160601b039390931683526001600160a01b03919091166020830152604082015260600190565b6001600160a01b0381168114610b3257600080fd5b61ffff81168114610b3257600080fd5b63ffffffff81168114610b3257600080fd5b60ff81168114610b3257600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65720000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0a26469706673582212207b16fa9d2fb9cd216a3f3be6192dae458784341881fa678289ab670b117cc05d64736f6c63430007060033000000000000000000000000000000000000000000002a5a058fc295ed000000000000000000000000000000000000000000000000000000000000000784ce00000000000000000000000000000000000000000000000000000f0831604188f10000000000000000000000000000000000000000000000000ddac98a9722b1b80000000000000000000000000000000000000000000000000000000000015180
Deployed Bytecode
0x60806040526004361061036f5760003560e01c806389d81c3f116101c6578063be22f546116100f7578063f167244d11610095578063f3af70a41161006f578063f3af70a414610917578063f414e9671461092c578063f60ca64114610941578063face9c991461095657610376565b8063f167244d146108cd578063f2fde38b146108e2578063f309bcdb1461090257610376565b8063cd682c8a116100d1578063cd682c8a1461086c578063d6b636cb14610881578063e712e89a14610896578063ecda10f5146108b857610376565b8063be22f54614610820578063c95a58aa14610835578063c9af10831461084a57610376565b8063a20baee611610164578063aee0e5811161013e578063aee0e581146107c1578063b38a715e146107e1578063b83f91a2146107f6578063bdee02481461080b57610376565b8063a20baee61461076a578063ab75dbb31461077f578063ac3b26011461079f57610376565b80638dd04faa116101a05780638dd04faa1461070b578063900cf0cf14610720578063997207ad146107355780639ba00f171461074a57610376565b806389d81c3f146106c15780638cef23a8146106e15780638da5cb5b146106f657610376565b80633f8b2a6d116102a05780636ff96d171161023e5780637dacf449116102185780637dacf449146106555780637e34dbe01461067757806380fc45c314610697578063815d8ff8146106ac57610376565b80636ff96d17146105fb578063715018a61461062b578063741bef1a1461064057610376565b80634b57b0be1161027a5780634b57b0be146105805780634e71d92d14610595578063501f1ba3146105aa57806367a5b10b146105ca57610376565b80633f8b2a6d1461051157806342a3fda91461053157806349c1e3ef1461055357610376565b80631f7af3c31161030d5780632c76d7a6116102e75780632c76d7a6146104b25780632def6620146104c757806335cf32ef146104dc5780633ccfd60b146104fc57610376565b80631f7af3c31461045a578063255deaec1461046f5780632baf57d31461048f57610376565b806315064c961161034957806315064c96146103f757806319c2b2e5146104195780631b9922181461042e5780631c4c44ea1461044557610376565b806309c693301461037b5780630e4538d4146103b357806311eac855146103d557610376565b3661037657005b600080fd5b34801561038757600080fd5b5061039b61039636600461434c565b61096b565b6040516103aa939291906149f1565b60405180910390f35b3480156103bf57600080fd5b506103c86109a0565b6040516103aa919061490b565b3480156103e157600080fd5b506103ea6109c4565b6040516103aa9190614423565b34801561040357600080fd5b5061040c6109dc565b6040516103aa91906144d7565b34801561042557600080fd5b506103c86109ec565b34801561043a57600080fd5b50610443610a10565b005b34801561045157600080fd5b506103ea610b35565b34801561046657600080fd5b506103ea610b4b565b34801561047b57600080fd5b5061044361048a36600461419f565b610b63565b34801561049b57600080fd5b506104a4610dd0565b6040516103aa92919061492b565b3480156104be57600080fd5b506103ea610e1d565b3480156104d357600080fd5b50610443610e35565b3480156104e857600080fd5b506104436104f7366004614304565b610fa2565b34801561050857600080fd5b506103c861116d565b34801561051d57600080fd5b5061044361052c366004614234565b611475565b34801561053d57600080fd5b50610546611525565b6040516103aa91906148d8565b34801561055f57600080fd5b5061057361056e36600461434c565b611534565b6040516103aa919061498b565b34801561058c57600080fd5b506103ea61154c565b3480156105a157600080fd5b50610443611564565b3480156105b657600080fd5b506104436105c536600461419f565b61170a565b3480156105d657600080fd5b506105ea6105e536600461411b565b6117f0565b6040516103aa959493929190614939565b34801561060757600080fd5b5061061b61061636600461411b565b6118f1565b6040516103aa949392919061495e565b34801561063757600080fd5b5061044361192e565b34801561064c57600080fd5b506103ea6119da565b34801561066157600080fd5b5061066a6119f2565b6040516103aa91906149dd565b34801561068357600080fd5b50610443610692366004614304565b611a01565b3480156106a357600080fd5b506103ea611c5a565b3480156106b857600080fd5b5061040c611c69565b3480156106cd57600080fd5b506103c86106dc36600461411b565b611c79565b3480156106ed57600080fd5b506103ea611c8f565b34801561070257600080fd5b506103ea611ca7565b34801561071757600080fd5b506103c8611cb6565b34801561072c57600080fd5b50610573612118565b34801561074157600080fd5b506103c8612124565b34801561075657600080fd5b5061044361076536600461419f565b612148565b34801561077657600080fd5b506103c86123c4565b34801561078b57600080fd5b506103c861079a36600461411b565b6123d0565b3480156107ab57600080fd5b506107b46123e6565b6040516103aa91906148ec565b3480156107cd57600080fd5b506103c86107dc36600461411b565b6123f7565b3480156107ed57600080fd5b5061054661240d565b34801561080257600080fd5b506103ea61241c565b34801561081757600080fd5b506103ea61242e565b34801561082c57600080fd5b506103ea612446565b34801561084157600080fd5b506107b461245e565b34801561085657600080fd5b5061085f61246f565b6040516103aa91906148a5565b34801561087857600080fd5b506105736124a2565b34801561088d57600080fd5b506103ea6124b6565b3480156108a257600080fd5b506108ab6124c5565b6040516103aa91906148fb565b3480156108c457600080fd5b506103c86124d7565b3480156108d957600080fd5b506105466124fb565b3480156108ee57600080fd5b506104436108fd36600461411b565b612511565b34801561090e57600080fd5b506103c8612614565b34801561092357600080fd5b506103c8612638565b34801561093857600080fd5b506103c861265c565b34801561094d57600080fd5b506103c8612663565b34801561096257600080fd5b50610546612669565b600760205260009081526040902080546001909101546001600160601b03821691600160601b90046001600160a01b03169083565b7f000000000000000000000000000000000000000000000000000000000001518081565b73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b600a54600160401b900460ff1681565b7f0000000000000000000000000000000000000000000000000ddac98a9722b1b881565b610a1861267f565b6001600160a01b0316610a29611ca7565b6001600160a01b031614610a72576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b600a54600160401b900460ff16610aa45760405162461bcd60e51b8152600401610a9b90614776565b60405180910390fd5b600a805460ff60401b19169055610ab9612683565b506004546001600160801b03168015610b3257600254604051635f788d6560e01b81526001600160a01b0390911690635f788d6590610aff908490600090600401614914565b600060405180830381600087803b158015610b1957600080fd5b505af1158015610b2d573d6000803e3d6000fd5b505050505b50565b600554600160601b90046001600160a01b031681565b736dea81c8171d0ba574754ef6f8b412f2ed88c54d81565b610b6b61267f565b6001600160a01b0316610b7c611ca7565b6001600160a01b031614610bc5576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b600a54600160401b900460ff1615610bef5760405162461bcd60e51b8152600401610a9b90614505565b6009544211610c105760405162461bcd60e51b8152600401610a9b906146e9565b600a805460ff60401b1916600160401b17905560048054600254604051621cdc4760e81b81526001600160801b03600160801b84048116949316926000926001600160a01b031691631cdc470091610c6a91309101614423565b60206040518083038186803b158015610c8257600080fd5b505afa158015610c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cba91906142ec565b90508115610d2757600254604051632e54bf9560e01b81526001600160a01b0390911690632e54bf9590610cf4906000199060040161490b565b600060405180830381600087803b158015610d0e57600080fd5b505af1158015610d22573d6000803e3d6000fd5b505050505b6000610d3285612707565b90506000808415610d62578486850281610d4857fe5b049150600085878587010281610d5a57fe5b048390039150505b6003546001600160801b03600160801b820481168501839003911684018501869003858201849003610d9686898985612fcd565b60038054600480546001600160801b039586166001600160801b031993841617861690935592841691161790911690555050505050505050565b600354600a5460009182916001600160801b0390911690600160401b900460ff16610e06576004546001600160801b0316610e09565b60005b6001600160801b0391821693501690509091565b73e592427a0aece92de3edee1f18e0157c0586156481565b60026000541415610e7b576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b6002600055600a54600160401b900460ff1615610eaa5760405162461bcd60e51b8152600401610a9b9061474a565b6000610eb4612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250610f16828461320d565b9050600080600080610f2b85600001516134bb565b93509350935093508260001415610f545760405162461bcd60e51b8152600401610a9b9061474a565b80610f7a57600480546001600160801b03600160801b8083048216870182160291161790555b610f8784848460016134ea565b8552610f94338787613526565b505060016000555050505050565b610faa61267f565b6001600160a01b0316610fbb611ca7565b6001600160a01b031614611004576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b670de0b6b3a764000085101561102c5760405162461bcd60e51b8152600401610a9b90614621565b611034612683565b5060405163d505accf60e01b8152600080516020614ae98339815191529063d505accf9061107290339030908a908a908a908a908a9060040161445b565b600060405180830381600087803b15801561108c57600080fd5b505af11580156110a0573d6000803e3d6000fd5b50506040516323b872dd60e01b8152600080516020614ae983398151915292506323b872dd91506110d990339030908a90600401614437565b602060405180830381600087803b1580156110f357600080fd5b505af1158015611107573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112b9190614185565b5050600380546001600160801b031981166001600160801b039182168701821617808216600160801b9182900483169097019091160294909417909355505050565b6000600260005414156111b5576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b600260009081556111c4612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250611226828461320d565b905060008060008061123b85600001516134bb565b600a5493975091955093509150600160401b900460ff168061125e576000611260565b835b60608701518601019850886112875760405162461bcd60e51b8152600401610a9b906146bc565b60405163a9059cbb60e01b8152600080516020614ae98339815191529063a9059cbb906112ba9033908d9060040161449c565b602060405180830381600087803b1580156112d457600080fd5b505af11580156112e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130c9190614185565b5060208601516001600160601b0316156113b757602086015160405163a9059cbb60e01b8152736619078bdd8324e01e9a8d4b3d761b050e5ecf069163a9059cbb9161135c9133916004016144b5565b602060405180830381600087803b15801561137657600080fd5b505af115801561138a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ae9190614185565b50600060208701525b600380546001600160801b038082168c9003166001600160801b0319909116179055841561140a57600380546001600160801b03808216600160801b928390048216989098031602959095179094556000935b80801561141657508315155b1561144557600480546001600160801b031981166001600160801b039182169690960316949094179093556000925b611451858585856134ea565b865260006060870152611465338888613526565b5050505050505050600160005590565b61147d61267f565b6001600160a01b031661148e611ca7565b6001600160a01b0316146114d7576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b6127108161ffff1611156114fd5760405162461bcd60e51b8152600401610a9b90614720565b600a805461ffff909216600160481b026affff00000000000000000019909216919091179055565b6004546001600160801b031681565b60086020526000908152604090205463ffffffff1681565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b600260005414156115aa576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b600260009081556115b9612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b03169183019190915260020154606082015291925061161b828461320d565b905080602001516001600160601b03166000141561164b5760405162461bcd60e51b8152600401610a9b906145ca565b60208101516001600160601b0316156116f557602081015160405163a9059cbb60e01b8152736619078bdd8324e01e9a8d4b3d761b050e5ecf069163a9059cbb9161169a9133916004016144b5565b602060405180830381600087803b1580156116b457600080fd5b505af11580156116c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ec9190614185565b50600060208201525b611700338383613526565b5050600160005550565b61171261267f565b6001600160a01b0316611723611ca7565b6001600160a01b03161461176c576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b805161178a5760405162461bcd60e51b8152600401610a9b9061453c565b6117938161369c565b600a805462ffffff909316600160681b0262ffffff60681b19921515600160801b0260ff60801b199094169390931791909116919091179055600b80546001600160a01b039092166001600160a01b031990921691909117905550565b60055460009081908190819081908190611824906001600160601b03811690600160601b90046001600160a01b03166137d2565b6001600160a01b03808a16600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b90930490941690820152600290920154606083015291935090915061188c908361320d565b905061189b81600001516134bb565b60608501516020860151600a549186019c50939a506001600160601b039093169850929650919450600160401b900460ff161590506118e5575050509282019260009201826118e8565b50505b91939590929450565b60066020526000908152604090208054600182015460029092015490916001600160601b03811691600160601b9091046001600160a01b03169084565b61193661267f565b6001600160a01b0316611947611ca7565b6001600160a01b031614611990576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b734c517d4e2c851ca76d7ec94b805269df0f2201de81565b6005546001600160601b031681565b60026000541415611a47576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b6002600055670de0b6b3a7640000851015611a745760405162461bcd60e51b8152600401610a9b90614621565b6000611a7e612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250611ae0828461320d565b60405163d505accf60e01b8152909150600080516020614ae98339815191529063d505accf90611b2090339030908d908d908d908d908d9060040161445b565b600060405180830381600087803b158015611b3a57600080fd5b505af1158015611b4e573d6000803e3d6000fd5b50506040516323b872dd60e01b8152600080516020614ae983398151915292506323b872dd9150611b8790339030908d90600401614437565b602060405180830381600087803b158015611ba157600080fd5b505af1158015611bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd99190614185565b50600380546001600160801b031981166001600160801b039182168b01821617808216600160801b9182900483168c01909216021790558051600090819081908190611c24906134bb565b9350935093509350611c3a8c85018484846134ea565b8552611c47338787613526565b5050600160005550505050505050505050565b600b546001600160a01b031681565b600a54600160801b900460ff1681565b6000611c84826117f0565b509295945050505050565b736619078bdd8324e01e9a8d4b3d761b050e5ecf0681565b6001546001600160a01b031690565b600060026000541415611cfe576040805162461bcd60e51b815260206004820152601f6024820152600080516020614a62833981519152604482015290519081900360640190fd5b6002600055600a54600160401b900460ff1615611d2d5760405162461bcd60e51b8152600401610a9b9061474a565b6000611d37612683565b33600090815260066020908152604080832081516080810183528154815260018201546001600160601b03811694820194909452600160601b9093046001600160a01b031691830191909152600201546060820152919250611d99828461320d565b90506000806000611dad84600001516134bb565b935050925092508160001415611dd55760405162461bcd60e51b8152600401610a9b9061474a565b60048054600254604051621cdc4760e81b81526001600160801b03909216926000926001600160a01b0390921691631cdc470091611e1591309101614423565b60206040518083038186803b158015611e2d57600080fd5b505afa158015611e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6591906142ec565b90508115801590611e7557508015155b611e915760405162461bcd60e51b8152600401610a9b9061474a565b60008282860281611e9e57fe5b04905080611ebe5760405162461bcd60e51b8152600401610a9b9061474a565b600254604051632e54bf9560e01b81526001600160a01b0390911690632e54bf9590611eee90849060040161490b565b600060405180830381600087803b158015611f0857600080fd5b505af1158015611f1c573d6000803e3d6000fd5b50505050606087015160405163a9059cbb60e01b81529a82019087010199600080516020614ae98339815191529063a9059cbb90611f609033908e9060040161449c565b602060405180830381600087803b158015611f7a57600080fd5b505af1158015611f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb29190614185565b5060208701516001600160601b03161561205657602087015160405163a9059cbb60e01b8152736619078bdd8324e01e9a8d4b3d761b050e5ecf069163a9059cbb916120029133916004016144b5565b602060405180830381600087803b15801561201c57600080fd5b505af1158015612030573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120549190614185565b505b6060870151600380546001600160801b03198082168a8a019094016001600160801b03928316038216939093179091556004805490921687860390911617905585156120be57600380546001600160801b03600160801b80830482168a900382160291161790555b83156120e657600480546001600160801b03600160801b808304821689900382160291161790555b505033600090815260066020526040812081815560018082018390556002909101829055905550959695505050505050565b600a5463ffffffff1681565b7f000000000000000000000000000000000000000000000000000000006ad4d3bb81565b600a54600160401b900460ff16156121725760405162461bcd60e51b8152600401610a9b90614658565b60095442116121935760405162461bcd60e51b8152600401610a9b906146e9565b61219b611ca7565b6001600160a01b0316336001600160a01b031614806121c0575062093a806009544203115b6121dc5760405162461bcd60e51b8152600401610a9b90614567565b60048054600254604051621cdc4760e81b81526001600160801b03600160801b84048116949316926000926001600160a01b031691631cdc47009161222391309101614423565b60206040518083038186803b15801561223b57600080fd5b505afa15801561224f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227391906142ec565b9050600082156122ef57828483028161228857fe5b600254604051632e54bf9560e01b81529290910492506001600160a01b031690632e54bf95906122bc90849060040161490b565b600060405180830381600087803b1580156122d657600080fd5b505af11580156122ea573d6000803e3d6000fd5b505050505b60006122fa86612707565b90506000841561231b5760008587848701028161231357fe5b048490039150505b600354600160801b90046001600160801b03168201819003801561239f57600254604051635f788d6560e01b81526001600160a01b0390911690635f788d659061236c908490600090600401614914565b600060405180830381600087803b15801561238657600080fd5b505af115801561239a573d6000803e3d6000fd5b505050505b6003546001600160801b031683018501869003818601859003610d9685898985612fcd565b670de0b6b3a764000081565b60006123db826117f0565b509195945050505050565b600a54600160581b900461ffff1681565b6000612402826117f0565b509095945050505050565b6003546001600160801b031681565b600080516020614ae983398151915281565b73ed279fdd11ca84beef15af5d39bb4d4bee23f0ca81565b736b175474e89094c44da98b954eedeac495271d0f81565b600a54600160481b900461ffff1681565b6124776140b1565b600554600a5461249d91600160601b90046001600160a01b03169063ffffffff16613877565b905090565b600a54640100000000900463ffffffff1681565b6002546001600160a01b031681565b600a54600160681b900462ffffff1681565b7f00000000000000000000000000000000000000000000000000000000635005bb81565b600354600160801b90046001600160801b031681565b61251961267f565b6001600160a01b031661252a611ca7565b6001600160a01b031614612573576040805162461bcd60e51b81526020600482018190526024820152600080516020614ac9833981519152604482015290519081900360640190fd5b6001600160a01b0381166125b85760405162461bcd60e51b8152600401808060200182810382526026815260200180614a826026913960400191505060405180910390fd5b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b7f000000000000000000000000000000000000000000002a5a058fc295ed00000081565b7f000000000000000000000000000000000000000000000000000f0831604188f181565b62093a8081565b60095481565b600454600160801b90046001600160801b031681565b3390565b6005546000906001600160601b03811690600160601b90046001600160a01b031682806126b084846137d2565b915091508184146126d757600580546001600160601b0319166001600160601b0384161790555b8083146126ff57600580546001600160601b0316600160601b6001600160a01b038416021790555b935050505090565b6040516370a0823160e01b81526000908190736dea81c8171d0ba574754ef6f8b412f2ed88c54d906370a0823190612743903090600401614423565b60206040518083038186803b15801561275b57600080fd5b505afa15801561276f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279391906142ec565b905047811580156127a2575080155b156127b257600092505050612fc8565b80156128215773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561280757600080fd5b505af115801561281b573d6000803e3d6000fd5b50505050505b60008060008087511161285c57600b54600a546001600160a01b0390911690600160681b810462ffffff1690600160801b900460ff16612865565b6128658761369c565b9250925092506128768383836138f0565b838515612b11576040805161010081018252736dea81c8171d0ba574754ef6f8b412f2ed88c54d815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26020820152610bb88183015230606082015242608082015260a08101889052600060c0820181905260e08201819052915163414bf38960e01b815273e592427a0aece92de3edee1f18e0157c058615649163414bf38991612918919060040161483c565b602060405180830381600087803b15801561293257600080fd5b505af1158015612946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061296a91906142ec565b600a54604080516101008101825273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28152736619078bdd8324e01e9a8d4b3d761b050e5ecf066020820152610bb881830152306060820152426080820152612710600160481b90930461ffff1684029290920460a08301819052600060c0840181905260e08401819052915163414bf38960e01b8152818503969096019593945092909173e592427a0aece92de3edee1f18e0157c058615649163414bf38991612a2a9160040161483c565b602060405180830381600087803b158015612a4457600080fd5b505af1158015612a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7c91906142ec565b60405163a9059cbb60e01b8152909150736619078bdd8324e01e9a8d4b3d761b050e5ecf069063a9059cbb90612aba9061dead90859060040161449c565b602060405180830381600087803b158015612ad457600080fd5b505af1158015612ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0c9190614185565b505050505b80612b255760009650505050505050612fc8565b6000734c517d4e2c851ca76d7ec94b805269df0f2201de6001600160a01b0316630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612b7657600080fd5b505af1158015612b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bae91906142ec565b90506000670de0b6b3a7640000612710600a600b9054906101000a900461ffff1661ffff168486020281612bde57fe5b0481612be657fe5b04905060008480612c0d57506001600160a01b038716600080516020614ae9833981519152145b15612e9c57604080516101008101825273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281526001600160a01b038916602082015262ffffff88168183015230606082015242608082015260a08101869052600060c0820181905260e08201819052915163414bf38960e01b815273e592427a0aece92de3edee1f18e0157c058615649163414bf38991612ca5919060040161483c565b602060405180830381600087803b158015612cbf57600080fd5b505af1158015612cd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf791906142ec565b90506001600160a01b038816600080516020614ae98339815191521415612d2057809150612e96565b6001600160a01b03881673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481415612ddd57604051635320bf6b60e11b815273ed279fdd11ca84beef15af5d39bb4d4bee23f0ca9063a6417ed690612d8490600290600090869089906004016144e2565b602060405180830381600087803b158015612d9e57600080fd5b505af1158015612db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd691906142ec565b9150612e96565b6001600160a01b038816736b175474e89094c44da98b954eedeac495271d0f1415612e9657604051635320bf6b60e11b815273ed279fdd11ca84beef15af5d39bb4d4bee23f0ca9063a6417ed690612e4190600190600090869089906004016144e2565b602060405180830381600087803b158015612e5b57600080fd5b505af1158015612e6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9391906142ec565b91505b50612f9d565b6040805160a0810190915273e592427a0aece92de3edee1f18e0157c058615649063c04b8d599080612ef973c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28b8d6101f4600080516020614ae983398151915260c087016143d6565b6040516020818303038152906040528152602001306001600160a01b03168152602001428152602001878152602001858152506040518263ffffffff1660e01b8152600401612f4891906147ad565b602060405180830381600087803b158015612f6257600080fd5b505af1158015612f76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f9a91906142ec565b90505b81811015612fbd5760405162461bcd60e51b8152600401610a9b9061468f565b985050505050505050505b919050565b600a5463ffffffff166000818152600760209081526040808320815160608101835281546001600160601b0381168252600160601b90046001600160a01b031693810193909352600101549082015290613025612683565b90506000670de0b6b3a764000083600001516001600160601b031684602001516001600160a01b03168403028161305857fe5b0483604001510190506000876000141561307c5783516001600160601b0316613096565b835188906001600160601b03168a8901028161309457fe5b045b9050806130f65750600a805463ffffffff600187018116600081815260086020526040902080546401000000009485900490931663ffffffff1990931692909217909155825467ffffffff0000000019169102179055670de0b6b3a76400005b600185810163ffffffff16600081815260076020526040812080546001600160601b0319166001600160601b038681169190911716600160601b6001600160a01b03891602178155909201849055600a805463ffffffff19169091179055426009558861316b57670de0b6b3a7640000613182565b88670de0b6b3a7640000898c01028161318057fe5b045b90507f842bd6bf8648efe83695d5fd798f1a26262429c193d854c2682d727b215d86ec86828c8b8d036040516131bb94939291906149ba565b60405180910390a17f29db3deb62ef2036e5eb93aad68d2362aec0711af592cb365566603bd88651d48660010142896040516131f99392919061499c565b60405180910390a150505050505050505050565b6132156140d1565b600a54835163ffffffff808316926401000000009004169060009081908190819061323f906134bb565b935093509350935060008960600151905060008a602001516001600160601b03169050600061327b8c604001516001600160a01b031686613877565b90508863ffffffff168563ffffffff161415801561329f57508615158061329f5750835b1561337e57600185810163ffffffff16600090815260076020908152604091829020825160608101845281546001600160601b0381168252600160601b90046001600160a01b031692810192909252909201549082015261330588850188858585613aa1565b909750925063ffffffff89161580159061335057508863ffffffff168660010163ffffffff161480613350575063ffffffff6001870181166000908152600860205260409020541615155b1561335a57600096505b841561336c5760009687955093909301925b871561337b5760009796909601955b90505b63ffffffff8816158015906133a157508460010163ffffffff168863ffffffff16115b1561345657875b63ffffffff818116600090815260086020526040902054600188018216911611156133ea5763ffffffff908116600090815260086020526040902054166133a8565b63ffffffff8116600090815260076020908152604091829020825160608101845281546001600160601b0381168252600160601b90046001600160a01b031692810192909252600101549181019190915261344a89860189868685613aa1565b60009950945090925050505b60006134628c8b613877565b905061347388850188858585613aa1565b909750925061348488888c886134ea565b8b5250506001600160a01b0390991660408901526001600160601b0390981660208801525050505060608301939093525092915050565b609081901c91602082901c6dffffffffffffffffffffffffffff1691600181811c637fffffff16929181161490565b6000816134f85760006134fb565b60015b60ff1660018463ffffffff16901b63ffffffff16602086901b609088901b1717179050949350505050565b805160201c158015613543575060208101516001600160601b0316155b801561355157506060810151155b15613581576001600160a01b03831660009081526006602052604081208181556001810182905560020155613697565b80518251146135a65780516001600160a01b0384166000908152600660205260409020555b80604001516001600160a01b031682604001516001600160a01b031614613605576040818101516001600160a01b03858116600090815260066020529290922060010180546001600160601b0316600160601b93909216929092021790555b80602001516001600160601b031682602001516001600160601b031614613666576020818101516001600160a01b03851660009081526006909252604090912060010180546001600160601b0319166001600160601b039092169190911790555b80606001518260600151146136975760608101516001600160a01b0384166000908152600660205260409020600201555b505050565b6000806000838060200190518101906136b59190614137565b919450925090506001600160a01b038316600080516020614ae983398151915214806136fd57506001600160a01b03831673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48145b8061372457506001600160a01b038316736b175474e89094c44da98b954eedeac495271d0f145b6137405760405162461bcd60e51b8152600401610a9b9061459e565b6001600160a01b038316600080516020614ae98339815191521415613794578162ffffff16610bb8148015613773575080155b61378f5760405162461bcd60e51b8152600401610a9b9061459e565b6137cb565b8162ffffff166101f414806137af57508162ffffff16610bb8145b6137cb5760405162461bcd60e51b8152600401610a9b9061459e565b9193909250565b600081817f000000000000000000000000000000000000000000000000000000006ad4d3bb4210613823577f000000000000000000000000000000000000000000000000000000006ad4d3bb613825565b425b905061383081613b25565b925084830380613841575050613870565b6003546001600160801b0316801561386c5780670de0b6b3a764000083028161386657fe5b04840193505b5050505b9250929050565b61387f6140b1565b5063ffffffff16600090815260076020908152604091829020825160608101845281546001600160601b038116808352600190930154670de0b6b3a7640000600160601b9092046001600160a01b039081168803909402919091040193810193909352929092169181019190915290565b61390d73d1d5a4c0ea98971894772dcd6d2f1dc71083c44e613c8b565b61392a7341506d56b16794e4f7f423aeff366740d4bdd387613c8b565b6001600160a01b038316600080516020614ae9833981519152141561396b57613966739663f2ca0454accad3e094448ea6f77443880454613c8b565b613a93565b6001600160a01b03831673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4814156139ff578162ffffff166101f4146139c0576139bb738ad599c3a0ff1de082011efddc58f1908eb6e6d8613c8b565b6139dd565b6139dd7388e6a0c2ddd26feeb64f039a2c41296fcb3f5640613c8b565b8061396657613966734e0924d3a751be199c426d52fb1f2337fa96f736613c8b565b6001600160a01b038316736b175474e89094c44da98b954eedeac495271d0f1415613a93578162ffffff166101f414613a5457613a4f73c2e9f25be6257c210d7adf0d4cd6e3e881ba25f8613c8b565b613a71565b613a717360594a405d53811d3bc4766596efd80fd545a270613c8b565b80613a9357613a937316980c16811bde2b3358c1ce4341541a4c772ec9613c8b565b801561369757613697613daf565b600080670de0b6b3a764000084602001518460200151036001600160a01b0316880281613aca57fe5b0484600001516001600160601b03168560400151856040015103880281613aed57fe5b04860101905083600001516001600160601b031683600001516001600160601b0316870281613b1857fe5b0491509550959350505050565b60007f0000000000000000000000000000000000000000000000000ddac98a9722b1b87f00000000000000000000000000000000000000000000000000000000635005bb8303670de0b6b3a7640000821415613ba6577f000000000000000000000000000000000000000000000000000f0831604188f1029150612fc89050565b7f00000000000000000000000000000000000000000000000000000000000151806000818381613bd257fe5b0490506000613be18583613e55565b9050600085670de0b6b3a764000003670de0b6b3a764000083670de0b6b3a7640000030281613c0c57fe5b049050670de0b6b3a76400007f000000000000000000000000000000000000000000000000000f0831604188f18202850204965083830285038015613c7f57670de0b6b3a76400007f000000000000000000000000000000000000000000000000000f0831604188f18402820204880197505b50505050505050919050565b6000816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015613cc657600080fd5b505afa158015613cda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cfe9190614250565b50505050925050506000826001600160a01b031663252c09d7836040518263ffffffff1660e01b8152600401613d3491906148ec565b60806040518083038186803b158015613d4c57600080fd5b505afa158015613d60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d849190614368565b5050509050428163ffffffff1614156136975760405162461bcd60e51b8152600401610a9b906145f4565b4273ed279fdd11ca84beef15af5d39bb4d4bee23f0ca6001600160a01b03166363543f066040518163ffffffff1660e01b815260040160206040518083038186803b158015613dfd57600080fd5b505afa158015613e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e3591906142ec565b1415613e535760405162461bcd60e51b8152600401610a9b906145f4565b565b6000613e618383613e6a565b90505b92915050565b600081613e805750670de0b6b3a7640000613e64565b670de0b6b3a764000083835b6001811115613ef15760018116613ebb57613ea78283613f05565b9150613eb4816002613f3a565b9050613eec565b613ec58284613f05565b9250613ed18283613f05565b9150613ee96002613ee3836001613fa1565b90613f3a565b90505b613e8c565b613efb8284613f05565b9695505050505050565b600080613f128484613ffe565b9050613f32670de0b6b3a7640000613ee3836706f05b59d3b20000614057565b949350505050565b6000808211613f90576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613f9957fe5b049392505050565b600082821115613ff8576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261400d57506000613e64565b8282028284828161401a57fe5b0414613e615760405162461bcd60e51b8152600401808060200182810382526021815260200180614aa86021913960400191505060405180910390fd5b600082820183811015613e61576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516060810182526000808252602082018190529181019190915290565b60405180608001604052806000815260200160006001600160601b0316815260200160006001600160a01b03168152602001600081525090565b80518015158114612fc857600080fd5b60006020828403121561412c578081fd5b8135613e6181614a1b565b60008060006060848603121561414b578182fd5b835161415681614a1b565b602085015190935062ffffff8116811461416e578283fd5b915061417c6040850161410b565b90509250925092565b600060208284031215614196578081fd5b613e618261410b565b600060208083850312156141b1578182fd5b823567ffffffffffffffff808211156141c8578384fd5b818501915085601f8301126141db578384fd5b8135818111156141e757fe5b604051601f8201601f191681018501838111828210171561420457fe5b604052818152838201850188101561421a578586fd5b818585018683013790810190930193909352509392505050565b600060208284031215614245578081fd5b8135613e6181614a30565b600080600080600080600060e0888a03121561426a578283fd5b875161427581614a1b565b8097505060208801518060020b811461428c578384fd5b604089015190965061429d81614a30565b60608901519095506142ae81614a30565b60808901519094506142bf81614a30565b60a08901519093506142d081614a52565b91506142de60c0890161410b565b905092959891949750929550565b6000602082840312156142fd578081fd5b5051919050565b600080600080600060a0868803121561431b578081fd5b8535945060208601359350604086013561433481614a52565b94979396509394606081013594506080013592915050565b60006020828403121561435d578081fd5b8135613e6181614a40565b6000806000806080858703121561437d578182fd5b845161438881614a40565b8094505060208501518060060b811461439f578283fd5b60408601519093506143b081614a1b565b91506143be6060860161410b565b905092959194509250565b6001600160a01b03169052565b6001600160601b0319606096871b811682526001600160e81b031960e896871b8116601484015294871b811660178301529290941b909216602b840152921b909116602e82015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039290921682526001600160601b0316602082015260400190565b901515815260200190565b600f94850b81529290930b60208301526040820152606081019190915260800190565b6020808252601a908201527f616c726561647920696e20656d657267656e6379207374617465000000000000604082015260600190565b6020808252601190820152706d757374206e6f7420626520656d70747960781b604082015260600190565b60208082526017908201527f63616c6c6572206d75737420626520616e206f776e6572000000000000000000604082015260600190565b602080825260129082015271696e76616c6964207472616465206461746160701b604082015260600190565b60208082526010908201526f6e6f7468696e6720746f20636c61696d60801b604082015260600190565b602080825260139082015272333937b73a393ab710383937ba32b1ba34b7b760691b604082015260600190565b60208082526019908201527f6d696e696d756d206465706f7369742069732031204c55534400000000000000604082015260600190565b6020808252601e908201527f6d757374206e6f7420626520696e20656d657267656e63792073746174650000604082015260600190565b602080825260139082015272726563656976656420746f6f206c6974746c6560681b604082015260600190565b6020808252601390820152726e6f7468696e6720746f20776974686472617760681b604082015260600190565b6020808252601d908201527f6d757374206c617374206174206c65617374206f6e65207365636f6e64000000604082015260600190565b60208082526010908201526f06d757374206265203c3d2031303030360841b604082015260600190565b6020808252601290820152716e6f7468696e6720746f20756e7374616b6560701b604082015260600190565b6020808252601a908201527f6d75737420626520696e20656d657267656e6379207374617465000000000000604082015260600190565b60006020808352835160a08285015280518060c0860152835b818110156147e25782810184015186820160e0015283016147c6565b818111156147f3578460e083880101525b50918501519161480660408601846143c9565b6040860151606086015260608601516080860152608086015160a086015260e0601f19601f830116860101935050505092915050565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b81516001600160601b031681526020808301516001600160a01b0316908201526040918201519181019190915260600190565b6001600160801b0391909116815260200190565b61ffff91909116815260200190565b62ffffff91909116815260200190565b90815260200190565b9182526001600160a01b0316602082015260400190565b918252602082015260400190565b9485526020850193909352604084019190915260608301521515608082015260a00190565b9384526001600160601b039290921660208401526001600160a01b03166040830152606082015260800190565b63ffffffff91909116815260200190565b63ffffffff9390931683526020830191909152604082015260600190565b63ffffffff94909416845260208401929092526040830152606082015260800190565b6001600160601b0391909116815260200190565b6001600160601b039390931683526001600160a01b03919091166020830152604082015260600190565b6001600160a01b0381168114610b3257600080fd5b61ffff81168114610b3257600080fd5b63ffffffff81168114610b3257600080fd5b60ff81168114610b3257600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65720000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0a26469706673582212207b16fa9d2fb9cd216a3f3be6192dae458784341881fa678289ab670b117cc05d64736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000002a5a058fc295ed000000000000000000000000000000000000000000000000000000000000000784ce00000000000000000000000000000000000000000000000000000f0831604188f10000000000000000000000000000000000000000000000000ddac98a9722b1b80000000000000000000000000000000000000000000000000000000000015180
-----Decoded View---------------
Arg [0] : _malToDistribute (uint256): 200000000000000000000000
Arg [1] : _malDistributionPeriodSeconds (uint256): 126144000
Arg [2] : _malRewardPerSecond (uint256): 4231132811987185
Arg [3] : _malDecayFactor (uint256): 998331864494289336
Arg [4] : _malDecayPeriodSeconds (uint256): 86400
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000002a5a058fc295ed000000
Arg [1] : 000000000000000000000000000000000000000000000000000000000784ce00
Arg [2] : 000000000000000000000000000000000000000000000000000f0831604188f1
Arg [3] : 0000000000000000000000000000000000000000000000000ddac98a9722b1b8
Arg [4] : 0000000000000000000000000000000000000000000000000000000000015180
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.