More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 8,486 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Close Trove | 20174632 | 80 days ago | IN | 0 ETH | 0.0011903 | ||||
Close Trove | 20053077 | 97 days ago | IN | 0 ETH | 0.0015285 | ||||
Close Trove | 20038397 | 99 days ago | IN | 0 ETH | 0.00409916 | ||||
Adjust Trove | 20038355 | 99 days ago | IN | 0 ETH | 0.00490634 | ||||
Close Trove | 19902174 | 118 days ago | IN | 0 ETH | 0.0012826 | ||||
Close Trove | 19902115 | 118 days ago | IN | 0 ETH | 0.00102826 | ||||
Close Trove | 19762328 | 138 days ago | IN | 0 ETH | 0.00393985 | ||||
Adjust Trove | 19762299 | 138 days ago | IN | 0 ETH | 0.00517405 | ||||
Close Trove | 19760289 | 138 days ago | IN | 0 ETH | 0.00301737 | ||||
Close Trove | 19719667 | 144 days ago | IN | 0 ETH | 0.00417464 | ||||
Adjust Trove | 19719615 | 144 days ago | IN | 0 ETH | 0.0062783 | ||||
Repay DCHF | 19714338 | 144 days ago | IN | 0 ETH | 0.00186352 | ||||
Adjust Trove | 19714305 | 144 days ago | IN | 0 ETH | 0.00256875 | ||||
Close Trove | 19703103 | 146 days ago | IN | 0 ETH | 0.00232514 | ||||
Adjust Trove | 19613919 | 158 days ago | IN | 0 ETH | 0.00898977 | ||||
Adjust Trove | 19613190 | 159 days ago | IN | 0 ETH | 0.01111373 | ||||
Repay DCHF | 19595601 | 161 days ago | IN | 0 ETH | 0.00399523 | ||||
Adjust Trove | 19595575 | 161 days ago | IN | 0 ETH | 0.00470208 | ||||
Adjust Trove | 19589196 | 162 days ago | IN | 7 ETH | 0.00544571 | ||||
Claim Collateral | 19559963 | 166 days ago | IN | 0 ETH | 0.00082844 | ||||
Adjust Trove | 19513201 | 173 days ago | IN | 0 ETH | 0.01358983 | ||||
Close Trove | 19498215 | 175 days ago | IN | 0 ETH | 0.00757872 | ||||
Close Trove | 19497016 | 175 days ago | IN | 0 ETH | 0.00544321 | ||||
Claim Collateral | 19490276 | 176 days ago | IN | 0 ETH | 0.00100869 | ||||
Close Trove | 19489287 | 176 days ago | IN | 0 ETH | 0.0090647 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
19589196 | 162 days ago | 7 ETH | ||||
19421371 | 186 days ago | 2.72 ETH | ||||
19416504 | 186 days ago | 2.8 ETH | ||||
19319152 | 200 days ago | 4.09999999 ETH | ||||
19235594 | 212 days ago | 20 ETH | ||||
18995743 | 245 days ago | 0.434 ETH | ||||
18995605 | 245 days ago | 0.8585 ETH | ||||
18982710 | 247 days ago | 3.25 ETH | ||||
18919366 | 256 days ago | 0.51 ETH | ||||
18891142 | 260 days ago | 2.92 ETH | ||||
18856082 | 265 days ago | 5.32 ETH | ||||
18768985 | 277 days ago | 5 ETH | ||||
18712131 | 285 days ago | 2.4 ETH | ||||
18712121 | 285 days ago | 5.9 ETH | ||||
18683370 | 289 days ago | 7.07 ETH | ||||
18642737 | 295 days ago | 6.13 ETH | ||||
18629959 | 296 days ago | 7.76 ETH | ||||
18566140 | 305 days ago | 7.96 ETH | ||||
18533707 | 310 days ago | 5.7 ETH | ||||
18486772 | 317 days ago | 0.12 ETH | ||||
18420155 | 326 days ago | 5.96 ETH | ||||
18406271 | 328 days ago | 2.29999999 ETH | ||||
18324764 | 339 days ago | 2.2 ETH | ||||
18304011 | 342 days ago | 2.7 ETH | ||||
18293114 | 344 days ago | 19 ETH |
Loading...
Loading
Contract Name:
BorrowerOperations
Compiler Version
v0.8.14+commit.80d49f37
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./Interfaces/IBorrowerOperations.sol"; import "./Interfaces/ITroveManager.sol"; import "./Interfaces/ITroveManagerHelpers.sol"; import "./Interfaces/IDCHFToken.sol"; import "./Interfaces/ICollSurplusPool.sol"; import "./Interfaces/ISortedTroves.sol"; import "./Interfaces/IMONStaking.sol"; import "./Interfaces/IStabilityPoolManager.sol"; import "./Dependencies/DfrancBase.sol"; import "./Dependencies/CheckContract.sol"; import "./Dependencies/SafetyTransfer.sol"; import "./Dependencies/Initializable.sol"; contract BorrowerOperations is DfrancBase, CheckContract, IBorrowerOperations, Initializable { using SafeMath for uint256; using SafeERC20 for IERC20; string public constant NAME = "BorrowerOperations"; // --- Connected contract declarations --- ITroveManager public troveManager; ITroveManagerHelpers public troveManagerHelpers; IStabilityPoolManager stabilityPoolManager; address gasPoolAddress; ICollSurplusPool collSurplusPool; IMONStaking public MONStaking; address public MONStakingAddress; IDCHFToken public DCHFToken; // A doubly linked list of Troves, sorted by their collateral ratios ISortedTroves public sortedTroves; bool public isInitialized; /* --- Variable container structs --- Used to hold, return and assign variables inside a function, in order to avoid the error: "CompilerError: Stack too deep". */ struct LocalVariables_adjustTrove { address asset; uint256 price; uint256 collChange; uint256 netDebtChange; bool isCollIncrease; uint256 debt; uint256 coll; uint256 oldICR; uint256 newICR; uint256 newTCR; uint256 DCHFFee; uint256 newDebt; uint256 newColl; uint256 stake; } struct LocalVariables_openTrove { address asset; uint256 price; uint256 DCHFFee; uint256 netDebt; uint256 compositeDebt; uint256 ICR; uint256 NICR; uint256 stake; uint256 arrayIndex; } struct ContractsCache { ITroveManager troveManager; ITroveManagerHelpers troveManagerHelpers; IActivePool activePool; IDCHFToken DCHFToken; } enum BorrowerOperation { openTrove, closeTrove, adjustTrove } event TroveUpdated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, BorrowerOperation operation ); // --- Dependency setters --- function setAddresses( address _troveManagerAddress, address _troveManagerHelpersAddress, address _stabilityPoolManagerAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _sortedTrovesAddress, address _dchfTokenAddress, address _MONStakingAddress, address _dfrancParamsAddress ) external override initializer onlyOwner { require(!isInitialized, "Already initialized"); checkContract(_troveManagerAddress); checkContract(_troveManagerHelpersAddress); checkContract(_stabilityPoolManagerAddress); checkContract(_gasPoolAddress); checkContract(_collSurplusPoolAddress); checkContract(_sortedTrovesAddress); checkContract(_dchfTokenAddress); checkContract(_MONStakingAddress); checkContract(_dfrancParamsAddress); isInitialized = true; troveManager = ITroveManager(_troveManagerAddress); troveManagerHelpers = ITroveManagerHelpers(_troveManagerHelpersAddress); stabilityPoolManager = IStabilityPoolManager(_stabilityPoolManagerAddress); gasPoolAddress = _gasPoolAddress; collSurplusPool = ICollSurplusPool(_collSurplusPoolAddress); sortedTroves = ISortedTroves(_sortedTrovesAddress); DCHFToken = IDCHFToken(_dchfTokenAddress); MONStakingAddress = _MONStakingAddress; MONStaking = IMONStaking(_MONStakingAddress); setDfrancParameters(_dfrancParamsAddress); emit TroveManagerAddressChanged(_troveManagerAddress); emit StabilityPoolAddressChanged(_stabilityPoolManagerAddress); emit GasPoolAddressChanged(_gasPoolAddress); emit CollSurplusPoolAddressChanged(_collSurplusPoolAddress); emit SortedTrovesAddressChanged(_sortedTrovesAddress); emit DCHFTokenAddressChanged(_dchfTokenAddress); emit MONStakingAddressChanged(_MONStakingAddress); } // --- Borrower Trove Operations Getter functions --- function isContractBorrowerOps() public pure returns (bool) { return true; } // --- Borrower Trove Operations --- function openTrove( address _asset, uint256 _tokenAmount, uint256 _maxFeePercentage, uint256 _DCHFamount, address _upperHint, address _lowerHint ) external payable override { dfrancParams.sanitizeParameters(_asset); ContractsCache memory contractsCache = ContractsCache( troveManager, troveManagerHelpers, dfrancParams.activePool(), DCHFToken ); LocalVariables_openTrove memory vars; vars.asset = _asset; _tokenAmount = getMethodValue(vars.asset, _tokenAmount, false); vars.price = dfrancParams.priceFeed().fetchPrice(vars.asset); bool isRecoveryMode = _checkRecoveryMode(vars.asset, vars.price); _requireValidMaxFeePercentage(vars.asset, _maxFeePercentage, isRecoveryMode); _requireTroveisNotActive( vars.asset, contractsCache.troveManager, contractsCache.troveManagerHelpers, msg.sender ); vars.netDebt = _DCHFamount; if (!isRecoveryMode) { vars.DCHFFee = _triggerBorrowingFee( vars.asset, contractsCache.troveManager, contractsCache.troveManagerHelpers, contractsCache.DCHFToken, _DCHFamount, _maxFeePercentage ); vars.netDebt = vars.netDebt.add(vars.DCHFFee); } _requireAtLeastMinNetDebt(vars.asset, vars.netDebt); // ICR is based on the composite debt, i.e. the requested DCHF amount + DCHF borrowing fee + DCHF gas comp. vars.compositeDebt = _getCompositeDebt(vars.asset, vars.netDebt); assert(vars.compositeDebt > 0); vars.ICR = DfrancMath._computeCR(_tokenAmount, vars.compositeDebt, vars.price); vars.NICR = DfrancMath._computeNominalCR(_tokenAmount, vars.compositeDebt); if (isRecoveryMode) { _requireICRisAboveCCR(vars.asset, vars.ICR); } else { _requireICRisAboveMCR(vars.asset, vars.ICR); uint256 newTCR = _getNewTCRFromTroveChange( vars.asset, _tokenAmount, true, vars.compositeDebt, true, vars.price ); // bools: coll increase, debt increase _requireNewTCRisAboveCCR(vars.asset, newTCR); } // Set the trove struct's properties contractsCache.troveManagerHelpers.setTroveStatus(vars.asset, msg.sender, 1); contractsCache.troveManagerHelpers.increaseTroveColl(vars.asset, msg.sender, _tokenAmount); contractsCache.troveManagerHelpers.increaseTroveDebt( vars.asset, msg.sender, vars.compositeDebt ); contractsCache.troveManagerHelpers.updateTroveRewardSnapshots(vars.asset, msg.sender); vars.stake = contractsCache.troveManagerHelpers.updateStakeAndTotalStakes( vars.asset, msg.sender ); sortedTroves.insert(vars.asset, msg.sender, vars.NICR, _upperHint, _lowerHint); vars.arrayIndex = contractsCache.troveManagerHelpers.addTroveOwnerToArray( vars.asset, msg.sender ); emit TroveCreated(vars.asset, msg.sender, vars.arrayIndex); // Move the ether to the Active Pool, and mint the DCHFAmount to the borrower _activePoolAddColl(vars.asset, contractsCache.activePool, _tokenAmount); _withdrawDCHF( vars.asset, contractsCache.activePool, contractsCache.DCHFToken, msg.sender, _DCHFamount, vars.netDebt ); // Move the DCHF gas compensation to the Gas Pool _withdrawDCHF( vars.asset, contractsCache.activePool, contractsCache.DCHFToken, gasPoolAddress, dfrancParams.DCHF_GAS_COMPENSATION(vars.asset), dfrancParams.DCHF_GAS_COMPENSATION(vars.asset) ); emit TroveUpdated( vars.asset, msg.sender, vars.compositeDebt, _tokenAmount, vars.stake, BorrowerOperation.openTrove ); emit DCHFBorrowingFeePaid(vars.asset, msg.sender, vars.DCHFFee); } // Send ETH as collateral to a trove function addColl( address _asset, uint256 _assetSent, address _upperHint, address _lowerHint ) external payable override { _adjustTrove( _asset, getMethodValue(_asset, _assetSent, false), msg.sender, 0, 0, false, _upperHint, _lowerHint, 0 ); } // Send ETH as collateral to a trove. Called by only the Stability Pool. function moveETHGainToTrove( address _asset, uint256 _amountMoved, address _borrower, address _upperHint, address _lowerHint ) external payable override { _requireCallerIsStabilityPool(); _adjustTrove( _asset, getMethodValue(_asset, _amountMoved, false), _borrower, 0, 0, false, _upperHint, _lowerHint, 0 ); } // Withdraw ETH collateral from a trove function withdrawColl( address _asset, uint256 _collWithdrawal, address _upperHint, address _lowerHint ) external override { _adjustTrove(_asset, 0, msg.sender, _collWithdrawal, 0, false, _upperHint, _lowerHint, 0); } // Withdraw DCHF tokens from a trove: mint new DCHF tokens to the owner, and increase the trove's debt accordingly function withdrawDCHF( address _asset, uint256 _maxFeePercentage, uint256 _DCHFamount, address _upperHint, address _lowerHint ) external override { _adjustTrove( _asset, 0, msg.sender, 0, _DCHFamount, true, _upperHint, _lowerHint, _maxFeePercentage ); } // Repay DCHF tokens to a Trove: Burn the repaid DCHF tokens, and reduce the trove's debt accordingly function repayDCHF( address _asset, uint256 _DCHFamount, address _upperHint, address _lowerHint ) external override { _adjustTrove(_asset, 0, msg.sender, 0, _DCHFamount, false, _upperHint, _lowerHint, 0); } function adjustTrove( address _asset, uint256 _assetSent, uint256 _maxFeePercentage, uint256 _collWithdrawal, uint256 _DCHFChange, bool _isDebtIncrease, address _upperHint, address _lowerHint ) external payable override { _adjustTrove( _asset, getMethodValue(_asset, _assetSent, true), msg.sender, _collWithdrawal, _DCHFChange, _isDebtIncrease, _upperHint, _lowerHint, _maxFeePercentage ); } /* * _adjustTrove(): Alongside a debt change, this function can perform either a collateral top-up or a collateral withdrawal. * * It therefore expects either a positive msg.value, or a positive _collWithdrawal argument. * * If both are positive, it will revert. */ function _adjustTrove( address _asset, uint256 _assetSent, address _borrower, uint256 _collWithdrawal, uint256 _DCHFChange, bool _isDebtIncrease, address _upperHint, address _lowerHint, uint256 _maxFeePercentage ) internal { ContractsCache memory contractsCache = ContractsCache( troveManager, troveManagerHelpers, dfrancParams.activePool(), DCHFToken ); LocalVariables_adjustTrove memory vars; vars.asset = _asset; require( msg.value == 0 || msg.value == _assetSent, "BorrowerOp: _AssetSent and Msg.value aren't the same!" ); vars.price = dfrancParams.priceFeed().fetchPrice(vars.asset); bool isRecoveryMode = _checkRecoveryMode(vars.asset, vars.price); if (_isDebtIncrease) { _requireValidMaxFeePercentage(vars.asset, _maxFeePercentage, isRecoveryMode); _requireNonZeroDebtChange(_DCHFChange); } _requireSingularCollChange(_collWithdrawal, _assetSent); _requireNonZeroAdjustment(_collWithdrawal, _DCHFChange, _assetSent); _requireTroveisActive(vars.asset, contractsCache.troveManagerHelpers, _borrower); // Confirm the operation is either a borrower adjusting their own trove, or a pure ETH transfer from the Stability Pool to a trove assert( msg.sender == _borrower || (stabilityPoolManager.isStabilityPool(msg.sender) && _assetSent > 0 && _DCHFChange == 0) ); contractsCache.troveManagerHelpers.applyPendingRewards(vars.asset, _borrower); // Get the collChange based on whether or not ETH was sent in the transaction (vars.collChange, vars.isCollIncrease) = _getCollChange(_assetSent, _collWithdrawal); vars.netDebtChange = _DCHFChange; // If the adjustment incorporates a debt increase and system is in Normal Mode, then trigger a borrowing fee if (_isDebtIncrease && !isRecoveryMode) { vars.DCHFFee = _triggerBorrowingFee( vars.asset, contractsCache.troveManager, contractsCache.troveManagerHelpers, contractsCache.DCHFToken, _DCHFChange, _maxFeePercentage ); vars.netDebtChange = vars.netDebtChange.add(vars.DCHFFee); // The raw debt change includes the fee } vars.debt = contractsCache.troveManagerHelpers.getTroveDebt(vars.asset, _borrower); vars.coll = contractsCache.troveManagerHelpers.getTroveColl(vars.asset, _borrower); // Get the trove's old ICR before the adjustment, and what its new ICR will be after the adjustment vars.oldICR = DfrancMath._computeCR(vars.coll, vars.debt, vars.price); vars.newICR = _getNewICRFromTroveChange( vars.coll, vars.debt, vars.collChange, vars.isCollIncrease, vars.netDebtChange, _isDebtIncrease, vars.price ); require( _collWithdrawal <= vars.coll, "BorrowerOp: Trying to remove more than the trove holds" ); // Check the adjustment satisfies all conditions for the current system mode _requireValidAdjustmentInCurrentMode( vars.asset, isRecoveryMode, _collWithdrawal, _isDebtIncrease, vars ); // When the adjustment is a debt repayment, check it's a valid amount and that the caller has enough DCHF if (!_isDebtIncrease && _DCHFChange > 0) { _requireAtLeastMinNetDebt( vars.asset, _getNetDebt(vars.asset, vars.debt).sub(vars.netDebtChange) ); _requireValidDCHFRepayment(vars.asset, vars.debt, vars.netDebtChange); _requireSufficientDCHFBalance(contractsCache.DCHFToken, _borrower, vars.netDebtChange); } (vars.newColl, vars.newDebt) = _updateTroveFromAdjustment( vars.asset, contractsCache.troveManager, contractsCache.troveManagerHelpers, _borrower, vars.collChange, vars.isCollIncrease, vars.netDebtChange, _isDebtIncrease ); vars.stake = contractsCache.troveManagerHelpers.updateStakeAndTotalStakes( vars.asset, _borrower ); // Re-insert trove in to the sorted list uint256 newNICR = _getNewNominalICRFromTroveChange( vars.coll, vars.debt, vars.collChange, vars.isCollIncrease, vars.netDebtChange, _isDebtIncrease ); sortedTroves.reInsert(vars.asset, _borrower, newNICR, _upperHint, _lowerHint); emit TroveUpdated( vars.asset, _borrower, vars.newDebt, vars.newColl, vars.stake, BorrowerOperation.adjustTrove ); emit DCHFBorrowingFeePaid(vars.asset, msg.sender, vars.DCHFFee); // Use the unmodified _DCHFChange here, as we don't send the fee to the user _moveTokensAndETHfromAdjustment( vars.asset, contractsCache.activePool, contractsCache.DCHFToken, msg.sender, vars.collChange, vars.isCollIncrease, _DCHFChange, _isDebtIncrease, vars.netDebtChange ); } function closeTrove(address _asset) external override { ITroveManagerHelpers troveManagerHelpersCached = troveManagerHelpers; IActivePool activePoolCached = dfrancParams.activePool(); IDCHFToken DCHFTokenCached = DCHFToken; _requireTroveisActive(_asset, troveManagerHelpersCached, msg.sender); uint256 price = dfrancParams.priceFeed().fetchPrice(_asset); _requireNotInRecoveryMode(_asset, price); troveManagerHelpersCached.applyPendingRewards(_asset, msg.sender); uint256 coll = troveManagerHelpersCached.getTroveColl(_asset, msg.sender); uint256 debt = troveManagerHelpersCached.getTroveDebt(_asset, msg.sender); _requireSufficientDCHFBalance( DCHFTokenCached, msg.sender, debt.sub(dfrancParams.DCHF_GAS_COMPENSATION(_asset)) ); uint256 newTCR = _getNewTCRFromTroveChange(_asset, coll, false, debt, false, price); _requireNewTCRisAboveCCR(_asset, newTCR); troveManagerHelpersCached.removeStake(_asset, msg.sender); troveManagerHelpersCached.closeTrove(_asset, msg.sender); emit TroveUpdated(_asset, msg.sender, 0, 0, 0, BorrowerOperation.closeTrove); // Burn the repaid DCHF from the user's balance and the gas compensation from the Gas Pool _repayDCHF( _asset, activePoolCached, DCHFTokenCached, msg.sender, debt.sub(dfrancParams.DCHF_GAS_COMPENSATION(_asset)) ); _repayDCHF( _asset, activePoolCached, DCHFTokenCached, gasPoolAddress, dfrancParams.DCHF_GAS_COMPENSATION(_asset) ); // Send the collateral back to the user activePoolCached.sendAsset(_asset, msg.sender, coll); } /** * Claim remaining collateral from a redemption or from a liquidation with ICR > MCR in Recovery Mode */ function claimCollateral(address _asset) external override { // send ETH from CollSurplus Pool to owner collSurplusPool.claimColl(_asset, msg.sender); } // --- Helper functions --- function _triggerBorrowingFee( address _asset, ITroveManager _troveManager, ITroveManagerHelpers _troveManagerHelpers, IDCHFToken _DCHFToken, uint256 _DCHFamount, uint256 _maxFeePercentage ) internal returns (uint256) { _troveManagerHelpers.decayBaseRateFromBorrowing(_asset); // decay the baseRate state variable uint256 DCHFFee = _troveManagerHelpers.getBorrowingFee(_asset, _DCHFamount); _requireUserAcceptsFee(DCHFFee, _DCHFamount, _maxFeePercentage); // Send fee to MON staking contract _DCHFToken.mint(_asset, MONStakingAddress, DCHFFee); MONStaking.increaseF_DCHF(DCHFFee); return DCHFFee; } function _getCollChange(uint256 _collReceived, uint256 _requestedCollWithdrawal) internal pure returns (uint256 collChange, bool isCollIncrease) { if (_collReceived != 0) { collChange = _collReceived; isCollIncrease = true; } else { collChange = _requestedCollWithdrawal; } } // Update trove's coll and debt based on whether they increase or decrease function _updateTroveFromAdjustment( address _asset, ITroveManager _troveManager, ITroveManagerHelpers _troveManagerHelpers, address _borrower, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease ) internal returns (uint256, uint256) { uint256 newColl = (_isCollIncrease) ? _troveManagerHelpers.increaseTroveColl(_asset, _borrower, _collChange) : _troveManagerHelpers.decreaseTroveColl(_asset, _borrower, _collChange); uint256 newDebt = (_isDebtIncrease) ? _troveManagerHelpers.increaseTroveDebt(_asset, _borrower, _debtChange) : _troveManagerHelpers.decreaseTroveDebt(_asset, _borrower, _debtChange); return (newColl, newDebt); } function _moveTokensAndETHfromAdjustment( address _asset, IActivePool _activePool, IDCHFToken _DCHFToken, address _borrower, uint256 _collChange, bool _isCollIncrease, uint256 _DCHFChange, bool _isDebtIncrease, uint256 _netDebtChange ) internal { if (_isDebtIncrease) { _withdrawDCHF(_asset, _activePool, _DCHFToken, _borrower, _DCHFChange, _netDebtChange); } else { _repayDCHF(_asset, _activePool, _DCHFToken, _borrower, _DCHFChange); } if (_isCollIncrease) { _activePoolAddColl(_asset, _activePool, _collChange); } else { _activePool.sendAsset(_asset, _borrower, _collChange); } } // Send ETH to Active Pool and increase its recorded ETH balance function _activePoolAddColl( address _asset, IActivePool _activePool, uint256 _amount ) internal { if (_asset == ETH_REF_ADDRESS) { (bool success, ) = address(_activePool).call{ value: _amount }(""); require(success, "BorrowerOps: Sending ETH to ActivePool failed"); } else { IERC20(_asset).safeTransferFrom( msg.sender, address(_activePool), SafetyTransfer.decimalsCorrection(_asset, _amount) ); _activePool.receivedERC20(_asset, _amount); } } // Issue the specified amount of DCHF to _account and increases the total active debt (_netDebtIncrease potentially includes a DCHFFee) function _withdrawDCHF( address _asset, IActivePool _activePool, IDCHFToken _DCHFToken, address _account, uint256 _DCHFamount, uint256 _netDebtIncrease ) internal { _activePool.increaseDCHFDebt(_asset, _netDebtIncrease); _DCHFToken.mint(_asset, _account, _DCHFamount); } // Burn the specified amount of DCHF from _account and decreases the total active debt function _repayDCHF( address _asset, IActivePool _activePool, IDCHFToken _DCHFToken, address _account, uint256 _DCHF ) internal { _activePool.decreaseDCHFDebt(_asset, _DCHF); _DCHFToken.burn(_account, _DCHF); } // --- 'Require' wrapper functions --- function _requireSingularCollChange(uint256 _collWithdrawal, uint256 _amountSent) internal view { require( _collWithdrawal == 0 || _amountSent == 0, "BorrowerOperations: Cannot withdraw and add coll" ); } function _requireNonZeroAdjustment( uint256 _collWithdrawal, uint256 _DCHFChange, uint256 _assetSent ) internal view { require( msg.value != 0 || _collWithdrawal != 0 || _DCHFChange != 0 || _assetSent != 0, "BorrowerOps: There must be either a collateral change or a debt change" ); } function _requireTroveisActive( address _asset, ITroveManagerHelpers _troveManagerHelpers, address _borrower ) internal view { uint256 status = _troveManagerHelpers.getTroveStatus(_asset, _borrower); require(status == 1, "BorrowerOps: Trove does not exist or is closed"); } function _requireTroveisNotActive( address _asset, ITroveManager _troveManager, ITroveManagerHelpers _troveManagerHelpers, address _borrower ) internal view { uint256 status = _troveManagerHelpers.getTroveStatus(_asset, _borrower); require(status != 1, "BorrowerOps: Trove is active"); } function _requireNonZeroDebtChange(uint256 _DCHFChange) internal pure { require(_DCHFChange > 0, "BorrowerOps: Debt increase requires non-zero debtChange"); } function _requireNotInRecoveryMode(address _asset, uint256 _price) internal view { require( !_checkRecoveryMode(_asset, _price), "BorrowerOps: Operation not permitted during Recovery Mode" ); } function _requireNoCollWithdrawal(uint256 _collWithdrawal) internal pure { require( _collWithdrawal == 0, "BorrowerOps: Collateral withdrawal not permitted Recovery Mode" ); } function _requireValidAdjustmentInCurrentMode( address _asset, bool _isRecoveryMode, uint256 _collWithdrawal, bool _isDebtIncrease, LocalVariables_adjustTrove memory _vars ) internal view { /* *In Recovery Mode, only allow: * * - Pure collateral top-up * - Pure debt repayment * - Collateral top-up with debt repayment * - A debt increase combined with a collateral top-up which makes the ICR >= 150% and improves the ICR (and by extension improves the TCR). * * In Normal Mode, ensure: * * - The new ICR is above MCR * - The adjustment won't pull the TCR below CCR */ if (_isRecoveryMode) { _requireNoCollWithdrawal(_collWithdrawal); if (_isDebtIncrease) { _requireICRisAboveCCR(_asset, _vars.newICR); _requireNewICRisAboveOldICR(_vars.newICR, _vars.oldICR); } } else { // if Normal Mode _requireICRisAboveMCR(_asset, _vars.newICR); _vars.newTCR = _getNewTCRFromTroveChange( _asset, _vars.collChange, _vars.isCollIncrease, _vars.netDebtChange, _isDebtIncrease, _vars.price ); _requireNewTCRisAboveCCR(_asset, _vars.newTCR); } } function _requireICRisAboveMCR(address _asset, uint256 _newICR) internal view { require( _newICR >= dfrancParams.MCR(_asset), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" ); } function _requireICRisAboveCCR(address _asset, uint256 _newICR) internal view { require( _newICR >= dfrancParams.CCR(_asset), "BorrowerOps: Operation must leave trove with ICR >= CCR" ); } function _requireNewICRisAboveOldICR(uint256 _newICR, uint256 _oldICR) internal pure { require( _newICR >= _oldICR, "BorrowerOps: Cannot decrease your Trove's ICR in Recovery Mode" ); } function _requireNewTCRisAboveCCR(address _asset, uint256 _newTCR) internal view { require( _newTCR >= dfrancParams.CCR(_asset), "BorrowerOps: An operation that would result in TCR < CCR is not permitted" ); } function _requireAtLeastMinNetDebt(address _asset, uint256 _netDebt) internal view { require( _netDebt >= dfrancParams.MIN_NET_DEBT(_asset), "BorrowerOps: Trove's net debt must be greater than minimum" ); } function _requireValidDCHFRepayment( address _asset, uint256 _currentDebt, uint256 _debtRepayment ) internal view { require( _debtRepayment <= _currentDebt.sub(dfrancParams.DCHF_GAS_COMPENSATION(_asset)), "BorrowerOps: Amount repaid must not be larger than the Trove's debt" ); } function _requireCallerIsStabilityPool() internal view { require( stabilityPoolManager.isStabilityPool(msg.sender), "BorrowerOps: Caller is not Stability Pool" ); } function _requireSufficientDCHFBalance( IDCHFToken _DCHFToken, address _borrower, uint256 _debtRepayment ) internal view { require( _DCHFToken.balanceOf(_borrower) >= _debtRepayment, "BorrowerOps: Caller doesnt have enough DCHF to make repayment" ); } function _requireValidMaxFeePercentage( address _asset, uint256 _maxFeePercentage, bool _isRecoveryMode ) internal view { if (_isRecoveryMode) { require( _maxFeePercentage <= dfrancParams.DECIMAL_PRECISION(), "Max fee percentage must less than or equal to 100%" ); } else { require( _maxFeePercentage >= dfrancParams.BORROWING_FEE_FLOOR(_asset) && _maxFeePercentage <= dfrancParams.DECIMAL_PRECISION(), "Max fee percentage must be between 0.5% and 100%" ); } } // --- ICR and TCR getters --- // Compute the new collateral ratio, considering the change in coll and debt. Assumes 0 pending rewards. function _getNewNominalICRFromTroveChange( uint256 _coll, uint256 _debt, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease ) internal pure returns (uint256) { (uint256 newColl, uint256 newDebt) = _getNewTroveAmounts( _coll, _debt, _collChange, _isCollIncrease, _debtChange, _isDebtIncrease ); uint256 newNICR = DfrancMath._computeNominalCR(newColl, newDebt); return newNICR; } // Compute the new collateral ratio, considering the change in coll and debt. Assumes 0 pending rewards. function _getNewICRFromTroveChange( uint256 _coll, uint256 _debt, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease, uint256 _price ) internal pure returns (uint256) { (uint256 newColl, uint256 newDebt) = _getNewTroveAmounts( _coll, _debt, _collChange, _isCollIncrease, _debtChange, _isDebtIncrease ); uint256 newICR = DfrancMath._computeCR(newColl, newDebt, _price); return newICR; } function _getNewTroveAmounts( uint256 _coll, uint256 _debt, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease ) internal pure returns (uint256, uint256) { uint256 newColl = _coll; uint256 newDebt = _debt; newColl = _isCollIncrease ? _coll.add(_collChange) : _coll.sub(_collChange); newDebt = _isDebtIncrease ? _debt.add(_debtChange) : _debt.sub(_debtChange); return (newColl, newDebt); } function _getNewTCRFromTroveChange( address _asset, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease, uint256 _price ) internal view returns (uint256) { uint256 totalColl = getEntireSystemColl(_asset); uint256 totalDebt = getEntireSystemDebt(_asset); totalColl = _isCollIncrease ? totalColl.add(_collChange) : totalColl.sub(_collChange); totalDebt = _isDebtIncrease ? totalDebt.add(_debtChange) : totalDebt.sub(_debtChange); uint256 newTCR = DfrancMath._computeCR(totalColl, totalDebt, _price); return newTCR; } function getCompositeDebt(address _asset, uint256 _debt) external view override returns (uint256) { return _getCompositeDebt(_asset, _debt); } function getMethodValue( address _asset, uint256 _amount, bool canBeZero ) private view returns (uint256) { bool isEth = _asset == address(0); require( (canBeZero || (isEth && msg.value != 0)) || (!isEth && msg.value == 0), "BorrowerOp: Invalid Input. Override msg.value only if using ETH asset, otherwise use _tokenAmount" ); if (_asset == address(0)) { _amount = msg.value; } return _amount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/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() { _setOwner(_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 { _setOwner(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"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; // Common interface for the Trove Manager. interface IBorrowerOperations { // --- Events --- event TroveManagerAddressChanged(address _newTroveManagerAddress); event StabilityPoolAddressChanged(address _stabilityPoolAddress); event GasPoolAddressChanged(address _gasPoolAddress); event CollSurplusPoolAddressChanged(address _collSurplusPoolAddress); event SortedTrovesAddressChanged(address _sortedTrovesAddress); event DCHFTokenAddressChanged(address _dchfTokenAddress); event MONStakingAddressChanged(address _MONStakingAddress); event TroveCreated(address indexed _asset, address indexed _borrower, uint256 arrayIndex); event TroveUpdated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation ); event DCHFBorrowingFeePaid( address indexed _asset, address indexed _borrower, uint256 _DCHFFee ); // --- Functions --- function setAddresses( address _troveManagerAddress, address _troveManagerHelpersAddress, address _stabilityPoolAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _sortedTrovesAddress, address _dchfTokenAddress, address _MONStakingAddress, address _dfrancParamsAddress ) external; function openTrove( address _asset, uint256 _tokenAmount, uint256 _maxFee, uint256 _DCHFamount, address _upperHint, address _lowerHint ) external payable; function addColl( address _asset, uint256 _assetSent, address _upperHint, address _lowerHint ) external payable; function moveETHGainToTrove( address _asset, uint256 _amountMoved, address _user, address _upperHint, address _lowerHint ) external payable; function withdrawColl( address _asset, uint256 _amount, address _upperHint, address _lowerHint ) external; function withdrawDCHF( address _asset, uint256 _maxFee, uint256 _amount, address _upperHint, address _lowerHint ) external; function repayDCHF( address _asset, uint256 _amount, address _upperHint, address _lowerHint ) external; function closeTrove(address _asset) external; function adjustTrove( address _asset, uint256 _assetSent, uint256 _maxFee, uint256 _collWithdrawal, uint256 _debtChange, bool isDebtIncrease, address _upperHint, address _lowerHint ) external payable; function claimCollateral(address _asset) external; function getCompositeDebt(address _asset, uint256 _debt) external view returns (uint256); function isContractBorrowerOps() external pure returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IDfrancBase.sol"; import "./IStabilityPool.sol"; import "./IDCHFToken.sol"; import "./IMONStaking.sol"; import "./ICollSurplusPool.sol"; import "./ISortedTroves.sol"; import "./IActivePool.sol"; import "./IDefaultPool.sol"; import "./IStabilityPoolManager.sol"; import "./ITroveManagerHelpers.sol"; // Common interface for the Trove Manager. interface ITroveManager is IDfrancBase { enum Status { nonExistent, active, closedByOwner, closedByLiquidation, closedByRedemption } // Store the necessary data for a trove struct Trove { address asset; uint256 debt; uint256 coll; uint256 stake; Status status; uint128 arrayIndex; } /* * --- Variable container structs for liquidations --- * * These structs are used to hold, return and assign variables inside the liquidation functions, * in order to avoid the error: "CompilerError: Stack too deep". **/ struct LocalVariables_OuterLiquidationFunction { uint256 price; uint256 DCHFInStabPool; bool recoveryModeAtStart; uint256 liquidatedDebt; uint256 liquidatedColl; } struct LocalVariables_InnerSingleLiquidateFunction { uint256 collToLiquidate; uint256 pendingDebtReward; uint256 pendingCollReward; } struct LocalVariables_LiquidationSequence { uint256 remainingDCHFInStabPool; uint256 i; uint256 ICR; address user; bool backToNormalMode; uint256 entireSystemDebt; uint256 entireSystemColl; } struct LocalVariables_AssetBorrowerPrice { address _asset; address _borrower; uint256 _price; } struct LiquidationValues { uint256 entireTroveDebt; uint256 entireTroveColl; uint256 collGasCompensation; uint256 DCHFGasCompensation; uint256 debtToOffset; uint256 collToSendToSP; uint256 debtToRedistribute; uint256 collToRedistribute; uint256 collSurplus; } struct LiquidationTotals { uint256 totalCollInSequence; uint256 totalDebtInSequence; uint256 totalCollGasCompensation; uint256 totalDCHFGasCompensation; uint256 totalDebtToOffset; uint256 totalCollToSendToSP; uint256 totalDebtToRedistribute; uint256 totalCollToRedistribute; uint256 totalCollSurplus; } struct ContractsCache { IActivePool activePool; IDefaultPool defaultPool; IDCHFToken dchfToken; IMONStaking monStaking; ISortedTroves sortedTroves; ICollSurplusPool collSurplusPool; address gasPoolAddress; } // --- Variable container structs for redemptions --- struct RedemptionTotals { uint256 remainingDCHF; uint256 totalDCHFToRedeem; uint256 totalAssetDrawn; uint256 ETHFee; uint256 ETHToSendToRedeemer; uint256 decayedBaseRate; uint256 price; uint256 totalDCHFSupplyAtStart; } struct SingleRedemptionValues { uint256 DCHFLot; uint256 ETHLot; bool cancelledPartial; } // --- Events --- event Liquidation( address indexed _asset, uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _collGasCompensation, uint256 _DCHFGasCompensation ); event Redemption( address indexed _asset, uint256 _attemptedDCHFAmount, uint256 _actualDCHFAmount, uint256 _AssetSent, uint256 _AssetFee ); event TroveUpdated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation ); event TroveLiquidated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint8 operation ); event BaseRateUpdated(address indexed _asset, uint256 _baseRate); event LastFeeOpTimeUpdated(address indexed _asset, uint256 _lastFeeOpTime); event TotalStakesUpdated(address indexed _asset, uint256 _newTotalStakes); event SystemSnapshotsUpdated( address indexed _asset, uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot ); event LTermsUpdated(address indexed _asset, uint256 _L_ETH, uint256 _L_DCHFDebt); event TroveSnapshotsUpdated(address indexed _asset, uint256 _L_ETH, uint256 _L_DCHFDebt); event TroveIndexUpdated(address indexed _asset, address _borrower, uint256 _newIndex); event TroveUpdated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, TroveManagerOperation _operation ); event TroveLiquidated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, TroveManagerOperation _operation ); enum TroveManagerOperation { applyPendingRewards, liquidateInNormalMode, liquidateInRecoveryMode, redeemCollateral } // --- Functions --- function isContractTroveManager() external pure returns (bool); function troveManagerHelpers() external view returns (ITroveManagerHelpers); function setAddresses( address _stabilityPoolManagerAddress, address _gasPoolAddress, address _collSurplusPoolAddress, address _dchfTokenAddress, address _sortedTrovesAddress, address _monStakingAddress, address _dfrancParamsAddress, address _troveManagerHelpersAddress ) external; function stabilityPoolManager() external view returns (IStabilityPoolManager); function dchfToken() external view returns (IDCHFToken); function monStaking() external view returns (IMONStaking); function liquidate(address _asset, address borrower) external; function liquidateTroves(address _asset, uint256 _n) external; function batchLiquidateTroves(address _asset, address[] memory _troveArray) external; function redeemCollateral( address _asset, uint256 _DCHFamount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFee ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IDfrancBase.sol"; import "./IStabilityPool.sol"; import "./IDCHFToken.sol"; import "./IMONStaking.sol"; import "./ICollSurplusPool.sol"; import "./ISortedTroves.sol"; import "./IActivePool.sol"; import "./IDefaultPool.sol"; import "./IStabilityPoolManager.sol"; // Common interface for the Trove Manager. interface ITroveManagerHelpers is IDfrancBase { enum Status { nonExistent, active, closedByOwner, closedByLiquidation, closedByRedemption } // Store the necessary data for a trove struct Trove { address asset; uint256 debt; uint256 coll; uint256 stake; Status status; uint128 arrayIndex; } /* * --- Variable container structs for liquidations --- * * These structs are used to hold, return and assign variables inside the liquidation functions, * in order to avoid the error: "CompilerError: Stack too deep". **/ struct LocalVariables_OuterLiquidationFunction { uint256 price; uint256 DCHFInStabPool; bool recoveryModeAtStart; uint256 liquidatedDebt; uint256 liquidatedColl; } struct LocalVariables_InnerSingleLiquidateFunction { uint256 collToLiquidate; uint256 pendingDebtReward; uint256 pendingCollReward; } struct LocalVariables_LiquidationSequence { uint256 remainingDCHFInStabPool; uint256 i; uint256 ICR; address user; bool backToNormalMode; uint256 entireSystemDebt; uint256 entireSystemColl; } struct LocalVariables_AssetBorrowerPrice { address _asset; address _borrower; uint256 _price; } struct LiquidationValues { uint256 entireTroveDebt; uint256 entireTroveColl; uint256 collGasCompensation; uint256 DCHFGasCompensation; uint256 debtToOffset; uint256 collToSendToSP; uint256 debtToRedistribute; uint256 collToRedistribute; uint256 collSurplus; } struct LiquidationTotals { uint256 totalCollInSequence; uint256 totalDebtInSequence; uint256 totalCollGasCompensation; uint256 totalDCHFGasCompensation; uint256 totalDebtToOffset; uint256 totalCollToSendToSP; uint256 totalDebtToRedistribute; uint256 totalCollToRedistribute; uint256 totalCollSurplus; } struct ContractsCache { IActivePool activePool; IDefaultPool defaultPool; IDCHFToken dchfToken; IMONStaking monStaking; ISortedTroves sortedTroves; ICollSurplusPool collSurplusPool; address gasPoolAddress; } // --- Variable container structs for redemptions --- struct RedemptionTotals { uint256 remainingDCHF; uint256 totalDCHFToRedeem; uint256 totalAssetDrawn; uint256 ETHFee; uint256 ETHToSendToRedeemer; uint256 decayedBaseRate; uint256 price; uint256 totalDCHFSupplyAtStart; } struct SingleRedemptionValues { uint256 DCHFLot; uint256 ETHLot; bool cancelledPartial; } // Object containing the ETH and DCHF snapshots for a given active trove struct RewardSnapshot { uint256 asset; uint256 DCHFDebt; } // --- Events --- event Liquidation( address indexed _asset, uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _collGasCompensation, uint256 _DCHFGasCompensation ); event Redemption( address indexed _asset, uint256 _attemptedDCHFAmount, uint256 _actualDCHFAmount, uint256 _AssetSent, uint256 _AssetFee ); event TroveUpdated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation ); event TroveLiquidated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint8 operation ); event BaseRateUpdated(address indexed _asset, uint256 _baseRate); event LastFeeOpTimeUpdated(address indexed _asset, uint256 _lastFeeOpTime); event TotalStakesUpdated(address indexed _asset, uint256 _newTotalStakes); event SystemSnapshotsUpdated( address indexed _asset, uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot ); event LTermsUpdated(address indexed _asset, uint256 _L_ETH, uint256 _L_DCHFDebt); event TroveSnapshotsUpdated(address indexed _asset, uint256 _L_ETH, uint256 _L_DCHFDebt); event TroveIndexUpdated(address indexed _asset, address _borrower, uint256 _newIndex); event TroveUpdated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, TroveManagerOperation _operation ); event TroveLiquidated( address indexed _asset, address indexed _borrower, uint256 _debt, uint256 _coll, TroveManagerOperation _operation ); enum TroveManagerOperation { applyPendingRewards, liquidateInNormalMode, liquidateInRecoveryMode, redeemCollateral } // Functions function addTroveOwnerToArray(address _asset, address _borrower) external returns (uint256 index); function applyPendingRewards(address _asset, address _borrower) external; function checkRecoveryMode(address _asset, uint256 _price) external returns (bool); function closeTrove(address _asset, address _borrower) external; function decayBaseRateFromBorrowing(address _asset) external; function decreaseTroveColl( address _asset, address _borrower, uint256 _collDecrease ) external returns (uint256); function decreaseTroveDebt( address _asset, address _borrower, uint256 _collDecrease ) external returns (uint256); function getBorrowingFee(address _asset, uint256 DCHFDebt) external view returns (uint256); function getBorrowingRateWithDecay(address _asset) external view returns (uint256); function getBorrowingRate(address _asset) external view returns (uint256); function getCurrentICR( address _asset, address _borrower, uint256 _price ) external view returns (uint256); function getEntireDebtAndColl(address _asset, address _borrower) external view returns ( uint256 debt, uint256 coll, uint256 pendingDCHFDebtReward, uint256 pendingAssetReward ); function getNominalICR(address _asset, address _borrower) external view returns (uint256); function getPendingAssetReward(address _asset, address _borrower) external view returns (uint256); function getPendingDCHFDebtReward(address _asset, address _borrower) external view returns (uint256); function getRedemptionFeeWithDecay(address _asset, uint256 _assetDraw) external view returns (uint256); function getRedemptionRate(address _asset) external view returns (uint256); function getRedemptionRateWithDecay(address _asset) external view returns (uint256); function getTCR(address _asset, uint256 _price) external view returns (uint256); function getTroveColl(address _asset, address _borrower) external view returns (uint256); function getTroveDebt(address _asset, address _borrower) external view returns (uint256); function getTroveStake(address _asset, address _borrower) external view returns (uint256); function getTroveStatus(address _asset, address _borrower) external view returns (uint256); function hasPendingRewards(address _asset, address _borrower) external view returns (bool); function increaseTroveColl( address _asset, address _borrower, uint256 _collIncrease ) external returns (uint256); function increaseTroveDebt( address _asset, address _borrower, uint256 _debtIncrease ) external returns (uint256); function setTroveStatus( address _asset, address _borrower, uint256 num ) external; function updateTroveRewardSnapshots(address _asset, address _borrower) external; function getBorrowingFeeWithDecay(address _asset, uint256 _DCHFDebt) external view returns (uint256); function getTroveOwnersCount(address _asset) external view returns (uint256); function getTroveFromTroveOwnersArray(address _asset, uint256 _index) external view returns (address); function setTroveDeptAndColl( address _asset, address _borrower, uint256 _debt, uint256 _coll ) external; function isTroveActive(address _asset, address _borrower) external view returns (bool); function movePendingTroveRewardsToActivePool( address _asset, IActivePool _activePool, IDefaultPool _defaultPool, uint256 _DCHF, uint256 _amount ) external; function removeStake(address _asset, address _borrower) external; function closeTrove( // access control address _asset, address _borrower, Status closedStatus ) external; function redistributeDebtAndColl( address _asset, IActivePool _activePool, IDefaultPool _defaultPool, uint256 _debt, uint256 _coll ) external; function updateSystemSnapshots_excludeCollRemainder( // access control address _asset, IActivePool _activePool, uint256 _collRemainder ) external; function _checkPotentialRecoveryMode( // access control address _asset, uint256 _entireSystemColl, uint256 _entireSystemDebt, uint256 _price ) external view returns (bool); function updateBaseRateFromRedemption( address _asset, uint256 _ETHDrawn, uint256 _price, uint256 _totalDCHFSupply ) external returns (uint256); function updateStakeAndTotalStakes(address _asset, address _borrower) external returns (uint256); function _requireValidMaxFeePercentage(address _asset, uint256 _maxFeePercentage) external view; function _requireTCRoverMCR(address _asset, uint256 _price) external view; function _requireAmountGreaterThanZero(uint256 _amount) external pure; function _requireDCHFBalanceCoversRedemption( IDCHFToken _dchfToken, address _redeemer, uint256 _amount ) external view; function applyPendingRewards( address _asset, IActivePool _activePool, IDefaultPool _defaultPool, address _borrower ) external; function _getRedemptionFee(address _asset, uint256 _assetDraw) external view returns (uint256); function getTrove(address _asset, address _borrower) external view returns ( address, uint256, uint256, uint256, Status, uint128 ); function getRewardSnapshots(address _asset, address _troveOwner) external view returns (uint256 asset, uint256 DCHFDebt); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "../Dependencies/ERC20Permit.sol"; import "../Interfaces/IStabilityPoolManager.sol"; abstract contract IDCHFToken is ERC20Permit { // --- Events --- event StabilityPoolAddressChanged(address _newStabilityPoolAddress); event DCHFTokenBalanceUpdated(address _user, uint256 _amount); function emergencyStopMinting(address _asset, bool status) external virtual; function addTroveManager(address _troveManager) external virtual; function removeTroveManager(address _troveManager) external virtual; function addBorrowerOps(address _borrowerOps) external virtual; function removeBorrowerOps(address _borrowerOps) external virtual; function mint( address _asset, address _account, uint256 _amount ) external virtual; function burn(address _account, uint256 _amount) external virtual; function sendToPool( address _sender, address poolAddress, uint256 _amount ) external virtual; function returnFromPool( address poolAddress, address user, uint256 _amount ) external virtual; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IDeposit.sol"; interface ICollSurplusPool is IDeposit { // --- Events --- event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event TroveManagerAddressChanged(address _newTroveManagerAddress); event ActivePoolAddressChanged(address _newActivePoolAddress); event CollBalanceUpdated(address indexed _account, uint256 _newBalance); event AssetSent(address _to, uint256 _amount); // --- Contract setters --- function setAddresses( address _borrowerOperationsAddress, address _troveManagerAddress, address _troveManagerHelpersAddress, address _activePoolAddress ) external; function getAssetBalance(address _asset) external view returns (uint256); function getCollateral(address _asset, address _account) external view returns (uint256); function accountSurplus( address _asset, address _account, uint256 _amount ) external; function claimColl(address _asset, address _account) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; // Common interface for the SortedTroves Doubly Linked List. interface ISortedTroves { // --- Events --- event SortedTrovesAddressChanged(address _sortedDoublyLLAddress); event BorrowerOperationsAddressChanged(address _borrowerOperationsAddress); event NodeAdded(address indexed _asset, address _id, uint256 _NICR); event NodeRemoved(address indexed _asset, address _id); // --- Functions --- function setParams( address _TroveManagerAddress, address _troveManagerHelpersAddress, address _borrowerOperationsAddress ) external; function insert( address _asset, address _id, uint256 _ICR, address _prevId, address _nextId ) external; function remove(address _asset, address _id) external; function reInsert( address _asset, address _id, uint256 _newICR, address _prevId, address _nextId ) external; function contains(address _asset, address _id) external view returns (bool); function isFull(address _asset) external view returns (bool); function isEmpty(address _asset) external view returns (bool); function getSize(address _asset) external view returns (uint256); function getMaxSize(address _asset) external view returns (uint256); function getFirst(address _asset) external view returns (address); function getLast(address _asset) external view returns (address); function getNext(address _asset, address _id) external view returns (address); function getPrev(address _asset, address _id) external view returns (address); function validInsertPosition( address _asset, uint256 _ICR, address _prevId, address _nextId ) external view returns (bool); function findInsertPosition( address _asset, uint256 _ICR, address _prevId, address _nextId ) external view returns (address, address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; interface IMONStaking { // --- Events -- event TreasuryAddressChanged(address _treausury); event SentToTreasury(address indexed _asset, uint256 _amount); event MONTokenAddressSet(address _MONTokenAddress); event DCHFTokenAddressSet(address _dchfTokenAddress); event TroveManagerAddressSet(address _troveManager); event BorrowerOperationsAddressSet(address _borrowerOperationsAddress); event ActivePoolAddressSet(address _activePoolAddress); event StakeChanged(address indexed staker, uint256 newStake); event StakingGainsAssetWithdrawn( address indexed staker, address indexed asset, uint256 AssetGain ); event StakingGainsDCHFWithdrawn(address indexed staker, uint256 DCHFGain); event F_AssetUpdated(address indexed _asset, uint256 _F_ASSET); event F_DCHFUpdated(uint256 _F_DCHF); event TotalMONStakedUpdated(uint256 _totalMONStaked); event AssetSent(address indexed _asset, address indexed _account, uint256 _amount); event StakerSnapshotsUpdated(address _staker, uint256 _F_Asset, uint256 _F_DCHF); function monToken() external view returns (IERC20); // --- Functions --- function setAddresses( address _MONTokenAddress, address _dchfTokenAddress, address _troveManagerAddress, address _troveManagerHelpersAddress, address _borrowerOperationsAddress, address _activePoolAddress, address _treasury ) external; function stake(uint256 _MONamount) external; function unstake(uint256 _MONamount) external; function increaseF_Asset(address _asset, uint256 _AssetFee) external; function increaseF_DCHF(uint256 _MONFee) external; function getPendingAssetGain(address _asset, address _user) external view returns (uint256); function getPendingDCHFGain(address _user) external view returns (uint256); }
pragma solidity ^0.8.14; import "./IStabilityPool.sol"; interface IStabilityPoolManager { event StabilityPoolAdded(address asset, address stabilityPool); event StabilityPoolRemoved(address asset, address stabilityPool); function isStabilityPool(address stabilityPool) external view returns (bool); function addStabilityPool(address asset, address stabilityPool) external; function getAssetStabilityPool(address asset) external view returns (IStabilityPool); function unsafeGetAssetStabilityPool(address asset) external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "@openzeppelin/contracts/access/Ownable.sol"; import "./BaseMath.sol"; import "./DfrancMath.sol"; import "../Interfaces/IActivePool.sol"; import "../Interfaces/IDefaultPool.sol"; import "../Interfaces/IPriceFeed.sol"; import "../Interfaces/IDfrancBase.sol"; /* * Base contract for TroveManager, BorrowerOperations and StabilityPool. Contains global system constants and * common functions. */ contract DfrancBase is BaseMath, IDfrancBase, Ownable { using SafeMath for uint256; address public constant ETH_REF_ADDRESS = address(0); IDfrancParameters public override dfrancParams; function setDfrancParameters(address _vaultParams) public onlyOwner { dfrancParams = IDfrancParameters(_vaultParams); emit VaultParametersBaseChanged(_vaultParams); } // --- Gas compensation functions --- // Returns the composite debt (drawn debt + gas compensation) of a trove, for the purpose of ICR calculation function _getCompositeDebt(address _asset, uint256 _debt) internal view returns (uint256) { return _debt.add(dfrancParams.DCHF_GAS_COMPENSATION(_asset)); } function _getNetDebt(address _asset, uint256 _debt) internal view returns (uint256) { return _debt.sub(dfrancParams.DCHF_GAS_COMPENSATION(_asset)); } // Return the amount of ETH to be drawn from a trove's collateral and sent as gas compensation. function _getCollGasCompensation(address _asset, uint256 _entireColl) internal view returns (uint256) { return _entireColl / dfrancParams.PERCENT_DIVISOR(_asset); } function getEntireSystemColl(address _asset) public view returns (uint256 entireSystemColl) { uint256 activeColl = dfrancParams.activePool().getAssetBalance(_asset); uint256 liquidatedColl = dfrancParams.defaultPool().getAssetBalance(_asset); return activeColl.add(liquidatedColl); } function getEntireSystemDebt(address _asset) public view returns (uint256 entireSystemDebt) { uint256 activeDebt = dfrancParams.activePool().getDCHFDebt(_asset); uint256 closedDebt = dfrancParams.defaultPool().getDCHFDebt(_asset); return activeDebt.add(closedDebt); } function _getTCR(address _asset, uint256 _price) internal view returns (uint256 TCR) { uint256 entireSystemColl = getEntireSystemColl(_asset); uint256 entireSystemDebt = getEntireSystemDebt(_asset); TCR = DfrancMath._computeCR(entireSystemColl, entireSystemDebt, _price); return TCR; } function _checkRecoveryMode(address _asset, uint256 _price) internal view returns (bool) { uint256 TCR = _getTCR(_asset, _price); return TCR < dfrancParams.CCR(_asset); } function _requireUserAcceptsFee( uint256 _fee, uint256 _amount, uint256 _maxFeePercentage ) internal view { uint256 feePercentage = _fee.mul(dfrancParams.DECIMAL_PRECISION()).div(_amount); require(feePercentage <= _maxFeePercentage, "FM"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; contract CheckContract { function checkContract(address _account) internal view { require(_account != address(0), "Account cannot be zero address"); uint256 size; assembly { size := extcodesize(_account) } require(size > 0, "Account code size cannot be zero"); } }
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./ERC20Decimals.sol"; library SafetyTransfer { using SafeMath for uint256; //_amount is in ether (1e18) and we want to convert it to the token decimal function decimalsCorrection(address _token, uint256 _amount) internal view returns (uint256) { if (_token == address(0)) return _amount; if (_amount == 0) return 0; uint8 decimals = ERC20Decimals(_token).decimals(); if (decimals < 18) { return _amount.div(10**(18 - decimals)); } else { return _amount.mul(10**(decimals - 18)); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/utils/Address.sol"; abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT pragma solidity ^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 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) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.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.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IDfrancParameters.sol"; interface IDfrancBase { event VaultParametersBaseChanged(address indexed newAddress); function dfrancParams() external view returns (IDfrancParameters); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IDeposit.sol"; interface IStabilityPool is IDeposit { // --- Events --- event StabilityPoolAssetBalanceUpdated(uint256 _newBalance); event StabilityPoolDCHFBalanceUpdated(uint256 _newBalance); event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event TroveManagerAddressChanged(address _newTroveManagerAddress); event DefaultPoolAddressChanged(address _newDefaultPoolAddress); event DCHFTokenAddressChanged(address _newDCHFTokenAddress); event SortedTrovesAddressChanged(address _newSortedTrovesAddress); event CommunityIssuanceAddressChanged(address _newCommunityIssuanceAddress); event P_Updated(uint256 _P); event S_Updated(uint256 _S, uint128 _epoch, uint128 _scale); event G_Updated(uint256 _G, uint128 _epoch, uint128 _scale); event EpochUpdated(uint128 _currentEpoch); event ScaleUpdated(uint128 _currentScale); event DepositSnapshotUpdated(address indexed _depositor, uint256 _P, uint256 _S, uint256 _G); event SystemSnapshotUpdated(uint256 _P, uint256 _G); event UserDepositChanged(address indexed _depositor, uint256 _newDeposit); event StakeChanged(uint256 _newSystemStake, address _depositor); event AssetGainWithdrawn(address indexed _depositor, uint256 _Asset, uint256 _DCHFLoss); event MONPaidToDepositor(address indexed _depositor, uint256 _MON); event AssetSent(address _to, uint256 _amount); // --- Functions --- function NAME() external view returns (string memory name); /* * Called only once on init, to set addresses of other Dfranc contracts * Callable only by owner, renounces ownership at the end */ function setAddresses( address _assetAddress, address _borrowerOperationsAddress, address _troveManagerAddress, address _troveManagerHelperAddress, address _dchfTokenAddress, address _sortedTrovesAddress, address _communityIssuanceAddress, address _dfrancParamsAddress ) external; /* * Initial checks: * - Frontend is registered or zero address * - Sender is not a registered frontend * - _amount is not zero * --- * - Triggers a MON issuance, based on time passed since the last issuance. The MON 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 (MON, ETH) to depositor * - Sends the tagged front end's accumulated MON gains to the tagged front end * - Increases deposit and tagged front end's stake, and takes new snapshots for each. */ function provideToSP(uint256 _amount) 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 MON issuance, based on time passed since the last issuance. The MON 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 (MON, ETH) to depositor * - Sends the tagged front end's accumulated MON 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(uint256 _amount) external; /* * Initial checks: * - User has a non zero deposit * - User has an open trove * - User has some ETH gain * --- * - Triggers a MON issuance, based on time passed since the last issuance. The MON issuance is shared between *all* depositors and front ends * - Sends all depositor's MON gain to depositor * - Sends all tagged front end's MON 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 withdrawAssetGainToTrove(address _upperHint, address _lowerHint) external; /* * Initial checks: * - Caller is TroveManager * --- * Cancels out the specified debt against the DCHF 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(uint256 _debt, uint256 _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 getAssetBalance() external view returns (uint256); /* * Returns DCHF held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset. */ function getTotalDCHFDeposits() external view returns (uint256); /* * Calculates the ETH gain earned by the deposit since its last snapshots were taken. */ function getDepositorAssetGain(address _depositor) external view returns (uint256); /* * Calculate the MON 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 getDepositorMONGain(address _depositor) external view returns (uint256); /* * Return the user's compounded deposit. */ function getCompoundedDCHFDeposit(address _depositor) external view returns (uint256); /* * Return the front end's compounded stake. * * The front end's compounded stake is equal to the sum of its depositors' compounded deposits. */ function getCompoundedTotalStake() external view returns (uint256); function getNameBytes() external view returns (bytes32); function getAssetType() external view returns (address); /* * Fallback function * Only callable by Active Pool, it just accounts for ETH received * receive() external payable; */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IPool.sol"; interface IActivePool is IPool { // --- Events --- event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress); event TroveManagerAddressChanged(address _newTroveManagerAddress); event ActivePoolDCHFDebtUpdated(address _asset, uint256 _DCHFDebt); event ActivePoolAssetBalanceUpdated(address _asset, uint256 _balance); // --- Functions --- function sendAsset( address _asset, address _account, uint256 _amount ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IPool.sol"; interface IDefaultPool is IPool { // --- Events --- event TroveManagerAddressChanged(address _newTroveManagerAddress); event DefaultPoolDCHFDebtUpdated(address _asset, uint256 _DCHFDebt); event DefaultPoolAssetBalanceUpdated(address _asset, uint256 _balance); // --- Functions --- function sendAssetToActivePool(address _asset, uint256 _amount) external; }
pragma solidity ^0.8.14; import "./IActivePool.sol"; import "./IDefaultPool.sol"; import "./IPriceFeed.sol"; import "./IDfrancBase.sol"; interface IDfrancParameters { error SafeCheckError( string parameter, uint256 valueEntered, uint256 minValue, uint256 maxValue ); event MCRChanged(uint256 oldMCR, uint256 newMCR); event CCRChanged(uint256 oldCCR, uint256 newCCR); event GasCompensationChanged(uint256 oldGasComp, uint256 newGasComp); event MinNetDebtChanged(uint256 oldMinNet, uint256 newMinNet); event PercentDivisorChanged(uint256 oldPercentDiv, uint256 newPercentDiv); event BorrowingFeeFloorChanged(uint256 oldBorrowingFloorFee, uint256 newBorrowingFloorFee); event MaxBorrowingFeeChanged(uint256 oldMaxBorrowingFee, uint256 newMaxBorrowingFee); event RedemptionFeeFloorChanged( uint256 oldRedemptionFeeFloor, uint256 newRedemptionFeeFloor ); event RedemptionBlockRemoved(address _asset); event PriceFeedChanged(address indexed addr); function DECIMAL_PRECISION() external view returns (uint256); function _100pct() external view returns (uint256); // Minimum collateral ratio for individual troves function MCR(address _collateral) external view returns (uint256); // Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered. function CCR(address _collateral) external view returns (uint256); function DCHF_GAS_COMPENSATION(address _collateral) external view returns (uint256); function MIN_NET_DEBT(address _collateral) external view returns (uint256); function PERCENT_DIVISOR(address _collateral) external view returns (uint256); function BORROWING_FEE_FLOOR(address _collateral) external view returns (uint256); function REDEMPTION_FEE_FLOOR(address _collateral) external view returns (uint256); function MAX_BORROWING_FEE(address _collateral) external view returns (uint256); function redemptionBlock(address _collateral) external view returns (uint256); function activePool() external view returns (IActivePool); function defaultPool() external view returns (IDefaultPool); function priceFeed() external view returns (IPriceFeed); function setAddresses( address _activePool, address _defaultPool, address _priceFeed, address _adminContract ) external; function setPriceFeed(address _priceFeed) external; function setMCR(address _asset, uint256 newMCR) external; function setCCR(address _asset, uint256 newCCR) external; function sanitizeParameters(address _asset) external; function setAsDefault(address _asset) external; function setAsDefaultWithRemptionBlock(address _asset, uint256 blockInDays) external; function setDCHFGasCompensation(address _asset, uint256 gasCompensation) external; function setMinNetDebt(address _asset, uint256 minNetDebt) external; function setPercentDivisor(address _asset, uint256 precentDivisor) external; function setBorrowingFeeFloor(address _asset, uint256 borrowingFeeFloor) external; function setMaxBorrowingFee(address _asset, uint256 maxBorrowingFee) external; function setRedemptionFeeFloor(address _asset, uint256 redemptionFeeFloor) external; function removeRedemptionBlock(address _asset) external; }
// SPDX-License-Identifier: MIT import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; pragma solidity ^0.8.14; interface IPriceFeed { struct ChainlinkResponse { uint80 roundId; int256 answer; uint256 timestamp; bool success; uint8 decimals; } struct RegisterOracle { AggregatorV3Interface chainLinkOracle; AggregatorV3Interface chainLinkIndex; bool isRegistered; } enum Status { chainlinkWorking, chainlinkUntrusted } // --- Events --- event PriceFeedStatusChanged(Status newStatus); event LastGoodPriceUpdated(address indexed token, uint256 _lastGoodPrice); event LastGoodIndexUpdated(address indexed token, uint256 _lastGoodIndex); event RegisteredNewOracle( address token, address chainLinkAggregator, address chianLinkIndex ); // --- Function --- function addOracle( address _token, address _chainlinkOracle, address _chainlinkIndexOracle ) external; function fetchPrice(address _token) external returns (uint256); function getDirectPrice(address _asset) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "./IDeposit.sol"; // Common interface for the Pools. interface IPool is IDeposit { // --- Events --- event AssetBalanceUpdated(uint256 _newBalance); event DCHFBalanceUpdated(uint256 _newBalance); event ActivePoolAddressChanged(address _newActivePoolAddress); event DefaultPoolAddressChanged(address _newDefaultPoolAddress); event AssetAddressChanged(address _assetAddress); event StabilityPoolAddressChanged(address _newStabilityPoolAddress); event AssetSent(address _to, address indexed _asset, uint256 _amount); // --- Functions --- function getAssetBalance(address _asset) external view returns (uint256); function getDCHFDebt(address _asset) external view returns (uint256); function increaseDCHFDebt(address _asset, uint256 _amount) external; function decreaseDCHFDebt(address _asset, uint256 _amount) external; }
pragma solidity ^0.8.14; interface IDeposit { function receivedERC20(address _asset, uint256 _amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns ( uint8 ); function description() external view returns ( string memory ); function version() external view returns ( uint256 ); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData( uint80 _roundId ) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
pragma solidity ^0.8.14; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; interface IERC2612Permit { /** * @dev Sets `amount` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current ERC2612 nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); } abstract contract ERC20Permit is ERC20, IERC2612Permit { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; bytes32 public DOMAIN_SEPARATOR; constructor() { uint256 chainID; assembly { chainID := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name())), keccak256(bytes("1")), // Version chainID, address(this) ) ); } /** * @dev See {IERC2612Permit-permit}. * */ function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external virtual override { require(block.timestamp <= deadline, "Permit: expired deadline"); bytes32 hashStruct = keccak256( abi.encode(PERMIT_TYPEHASH, owner, spender, amount, _nonces[owner].current(), deadline) ); bytes32 _hash = keccak256(abi.encodePacked(uint16(0x1901), DOMAIN_SEPARATOR, hashStruct)); address signer = ecrecover(_hash, v, r, s); require(signer != address(0) && signer == owner, "ERC20Permit: Invalid signature"); _nonces[owner].increment(); _approve(owner, spender, amount); } /** * @dev See {IERC2612Permit-nonces}. */ function nonces(address owner) public view override returns (uint256) { return _nonces[owner].current(); } function chainId() public view returns (uint256 chainID) { assembly { chainID := chainid() } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; abstract contract BaseMath { uint256 public constant DECIMAL_PRECISION = 1 ether; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.14; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; library DfrancMath { using SafeMath for uint256; uint256 internal constant DECIMAL_PRECISION = 1 ether; /* Precision for Nominal ICR (independent of price). Rationale for the value: * * - Making it “too high” could lead to overflows. * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division. * * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 ETH, * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator. * */ uint256 internal constant NICR_PRECISION = 1e20; function _min(uint256 _a, uint256 _b) internal pure returns (uint256) { return (_a < _b) ? _a : _b; } function _max(uint256 _a, uint256 _b) internal pure returns (uint256) { return (_a >= _b) ? _a : _b; } /* * 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 * * Used only inside the exponentiation, _decPow(). */ 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); } /* * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n. * * Uses the efficient "exponentiation by squaring" algorithm. O(log(n)) complexity. * * Called by two functions that represent time in units of minutes: * 1) TroveManager._calcDecayedBaseRate * 2) CommunityIssuance._getCumulativeIssuanceFraction * * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals * "minutes in 1000 years": 60 * 24 * 365 * 1000 * * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be * negligibly different from just passing the cap, since: * * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible */ function _decPow(uint256 _base, uint256 _minutes) internal pure returns (uint256) { if (_minutes > 525600000) { _minutes = 525600000; } // cap to avoid overflow if (_minutes == 0) { return DECIMAL_PRECISION; } uint256 y = DECIMAL_PRECISION; uint256 x = _base; uint256 n = _minutes; // Exponentiation-by-squaring while (n > 1) { if (n % 2 == 0) { x = decMul(x, x); n = n.div(2); } else { // if (n % 2 != 0) y = decMul(x, y); x = decMul(x, x); n = (n.sub(1)).div(2); } } return decMul(x, y); } function _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) { return (_a >= _b) ? _a.sub(_b) : _b.sub(_a); } function _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) { if (_debt > 0) { return _coll.mul(NICR_PRECISION).div(_debt); } // Return the maximal value for uint256 if the Trove has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return 2**256 - 1; } } function _computeCR( uint256 _coll, uint256 _debt, uint256 _price ) internal pure returns (uint256) { if (_debt > 0) { return _coll.mul(_price).div(_debt); } // Return the maximal value for uint256 if the Trove has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return type(uint256).max; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } }
pragma solidity ^0.8.14; interface ERC20Decimals { function decimals() external view returns (uint8); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collSurplusPoolAddress","type":"address"}],"name":"CollSurplusPoolAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_asset","type":"address"},{"indexed":true,"internalType":"address","name":"_borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"_DCHFFee","type":"uint256"}],"name":"DCHFBorrowingFeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_dchfTokenAddress","type":"address"}],"name":"DCHFTokenAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_gasPoolAddress","type":"address"}],"name":"GasPoolAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_MONStakingAddress","type":"address"}],"name":"MONStakingAddressChanged","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_sortedTrovesAddress","type":"address"}],"name":"SortedTrovesAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_stabilityPoolAddress","type":"address"}],"name":"StabilityPoolAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_asset","type":"address"},{"indexed":true,"internalType":"address","name":"_borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"arrayIndex","type":"uint256"}],"name":"TroveCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newTroveManagerAddress","type":"address"}],"name":"TroveManagerAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_asset","type":"address"},{"indexed":true,"internalType":"address","name":"_borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"_debt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_coll","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stake","type":"uint256"},{"indexed":false,"internalType":"enum BorrowerOperations.BorrowerOperation","name":"operation","type":"uint8"}],"name":"TroveUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAddress","type":"address"}],"name":"VaultParametersBaseChanged","type":"event"},{"inputs":[],"name":"DCHFToken","outputs":[{"internalType":"contract IDCHFToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DECIMAL_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH_REF_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MONStaking","outputs":[{"internalType":"contract IMONStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MONStakingAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_assetSent","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"addColl","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_assetSent","type":"uint256"},{"internalType":"uint256","name":"_maxFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_collWithdrawal","type":"uint256"},{"internalType":"uint256","name":"_DCHFChange","type":"uint256"},{"internalType":"bool","name":"_isDebtIncrease","type":"bool"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"adjustTrove","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"claimCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"closeTrove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dfrancParams","outputs":[{"internalType":"contract IDfrancParameters","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_debt","type":"uint256"}],"name":"getCompositeDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getEntireSystemColl","outputs":[{"internalType":"uint256","name":"entireSystemColl","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getEntireSystemDebt","outputs":[{"internalType":"uint256","name":"entireSystemDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isContractBorrowerOps","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amountMoved","type":"uint256"},{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"moveETHGainToTrove","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_maxFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_DCHFamount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"openTrove","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_DCHFamount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"repayDCHF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_troveManagerAddress","type":"address"},{"internalType":"address","name":"_troveManagerHelpersAddress","type":"address"},{"internalType":"address","name":"_stabilityPoolManagerAddress","type":"address"},{"internalType":"address","name":"_gasPoolAddress","type":"address"},{"internalType":"address","name":"_collSurplusPoolAddress","type":"address"},{"internalType":"address","name":"_sortedTrovesAddress","type":"address"},{"internalType":"address","name":"_dchfTokenAddress","type":"address"},{"internalType":"address","name":"_MONStakingAddress","type":"address"},{"internalType":"address","name":"_dfrancParamsAddress","type":"address"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vaultParams","type":"address"}],"name":"setDfrancParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sortedTroves","outputs":[{"internalType":"contract ISortedTroves","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"troveManager","outputs":[{"internalType":"contract ITroveManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"troveManagerHelpers","outputs":[{"internalType":"contract ITroveManagerHelpers","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_collWithdrawal","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"withdrawColl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_maxFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_DCHFamount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"withdrawDCHF","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001d3362000023565b62000073565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b614b8a80620000836000396000f3fe6080604052600436106101c25760003560e01c80637da0b1fa116100f7578063a9419ca311610095578063cbd138ae11610064578063cbd138ae146104f0578063e81f707e14610510578063e90f42ba14610530578063f2fde38b1461055057600080fd5b8063a9419ca314610470578063ae91875414610490578063b80dddf9146104b0578063bc04c45a146104d057600080fd5b80639e86d0c4116100d15780639e86d0c4146103c9578063a20baee6146103e9578063a263757f14610405578063a3f4df7e1461042557600080fd5b80637da0b1fa146103785780638235b2841461038b5780638da5cb5b146103ab57600080fd5b806348a4a39d11610164578063662720441161013e578063662720441461031b578063715018a61461033b57806372141e6314610350578063743990211461036557600080fd5b806348a4a39d146102d557806349b010c5146102e8578063501414f51461030857600080fd5b806327d04b35116101a057806327d04b351461023c57806335ecf35e1461025c578063392e53cd146102945780633d83908a146102b557600080fd5b806302540e48146101c757806306f202d2146101fa57806327705b8d1461021a575b600080fd5b3480156101d357600080fd5b506101e76101e23660046144ff565b610570565b6040519081526020015b60405180910390f35b34801561020657600080fd5b5060015b60405190151581526020016101f1565b34801561022657600080fd5b5061023a61023536600461452b565b610585565b005b34801561024857600080fd5b506101e761025736600461457e565b6105a0565b34801561026857600080fd5b5060085461027c906001600160a01b031681565b6040516001600160a01b0390911681526020016101f1565b3480156102a057600080fd5b50600a5461020a90600160a01b900460ff1681565b3480156102c157600080fd5b5060025461027c906001600160a01b031681565b61023a6102e336600461452b565b610782565b3480156102f457600080fd5b5061023a61030336600461452b565b6107a1565b61023a61031636600461459b565b6107b5565b34801561032757600080fd5b5061023a610336366004614603565b6107e3565b34801561034757600080fd5b5061023a610c21565b34801561035c57600080fd5b5061027c600081565b61023a6103733660046146cd565b610c57565b61023a610386366004614752565b610c7d565b34801561039757600080fd5b5061023a6103a636600461457e565b611560565b3480156103b757600080fd5b506000546001600160a01b031661027c565b3480156103d557600080fd5b506101e76103e436600461457e565b6115c0565b3480156103f557600080fd5b506101e7670de0b6b3a764000081565b34801561041157600080fd5b5061023a61042036600461457e565b611751565b34801561043157600080fd5b5061046360405180604001604052806012815260200171426f72726f7765724f7065726174696f6e7360701b81525081565b6040516101f191906147e5565b34801561047c57600080fd5b5060035461027c906001600160a01b031681565b34801561049c57600080fd5b50600a5461027c906001600160a01b031681565b3480156104bc57600080fd5b5061023a6104cb366004614818565b6117c5565b3480156104dc57600080fd5b5060075461027c906001600160a01b031681565b3480156104fc57600080fd5b5061023a61050b36600461457e565b6117d9565b34801561051c57600080fd5b5060095461027c906001600160a01b031681565b34801561053c57600080fd5b5060015461027c906001600160a01b031681565b34801561055c57600080fd5b5061023a61056b36600461457e565b611dc5565b600061057c8383611e60565b90505b92915050565b61059a84600033600087600088886000611edb565b50505050565b600080600160009054906101000a90046001600160a01b03166001600160a01b0316637f7dde4a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061a9190614859565b60405163d1234da760e01b81526001600160a01b038581166004830152919091169063d1234da790602401602060405180830381865afa158015610662573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106869190614876565b90506000600160009054906101000a90046001600160a01b03166001600160a01b0316633cc742256040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107019190614859565b60405163d1234da760e01b81526001600160a01b038681166004830152919091169063d1234da7906024015b602060405180830381865afa15801561074a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076e9190614876565b905061077a82826127b3565b949350505050565b61059a84610792868660006127bf565b33600080600088886000611edb565b61059a846000338660008088886000611edb565b6107bd6128b1565b6107dc856107cd878760006127bf565b85600080600088886000611edb565b5050505050565b600154600160a81b900460ff1615808015610809575060018054600160a01b900460ff16105b806108295750303b158015610829575060018054600160a01b900460ff16145b6108915760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6001805460ff60a01b1916600160a01b17905580156108be576001805460ff60a81b1916600160a81b1790555b6000546001600160a01b031633146108e85760405162461bcd60e51b81526004016108889061488f565b600a54600160a01b900460ff16156109385760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610888565b6109418a61297c565b61094a8961297c565b6109538861297c565b61095c8761297c565b6109658661297c565b61096e8561297c565b6109778461297c565b6109808361297c565b6109898261297c565b600a8054600280546001600160a01b03199081166001600160a01b038f8116919091179092556003805482168e84161790556004805482168d84161790556005805482168c84161790556006805482168b8416179055600160a01b6001600160a81b031990931689831617929092179092556009805482168784161790556008805482169286169283179055600780549091169091179055610a2a82611751565b6040516001600160a01b038b1681527f143219c9e69b09e07e095fcc889b43d8f46ca892bba65f08dc3a0050869a56789060200160405180910390a16040516001600160a01b03891681527f82966d27eea39b038ee0fa30cd16532bb24f6e65d31cb58fb227aa5766cdcc7f9060200160405180910390a16040516001600160a01b03881681527fcfb07d791fcafc032b35837b50eb84b74df518cf4cc287e8084f47630fa70fa09060200160405180910390a16040516001600160a01b03871681527fe67f36a6e961157d6eff83b91f3af5a62131ceb6f04954ef74f51c1c05e7f88d9060200160405180910390a16040516001600160a01b03861681527f65f4cf077bc01e4742eb5ad98326f6e95b63548ea24b17f8d5e823111fe788009060200160405180910390a16040516001600160a01b03851681527ff165f2d7729f02833c6f7dea7d6f0f9c4a505f5557516f4daca827f9637c67909060200160405180910390a16040516001600160a01b03841681527f944e8aa30f20353b5f690ba54feb76ccabc18503cf60ee20f2b9f1418aa732839060200160405180910390a18015610c15576001805460ff60a81b191681556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6000546001600160a01b03163314610c4b5760405162461bcd60e51b81526004016108889061488f565b610c556000612a25565b565b610c7388610c678a8a60016127bf565b3388888888888e611edb565b5050505050505050565b6001546040516362a3b93f60e01b81526001600160a01b038881166004830152909116906362a3b93f90602401600060405180830381600087803b158015610cc457600080fd5b505af1158015610cd8573d6000803e3d6000fd5b5050604080516080810182526002546001600160a01b03908116825260035481166020808401919091526001548451633fbeef2560e11b815285516000985094965094860194921692637f7dde4a9260048082019392918290030181865afa158015610d48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6c9190614859565b6001600160a01b039081168252600954811660209283015260408051610120810182526000938101849052908101839052606081018390526080810183905260a0810183905260c0810183905260e081018390526101008101839052908a1680825292935091610ddd9189906127bf565b9650600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e569190614859565b8151604051635670bcc760e11b81526001600160a01b03918216600482015291169063ace1798e906024016020604051808303816000875af1158015610ea0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec49190614876565b602082018190528151600091610eda9190612a75565b9050610eeb82600001518883612afa565b815183516020850151610f0092919033612d3e565b6060820186905280610f4557610f2a82600001518460000151856020015186606001518a8c612e02565b604083018190526060830151610f3f916127b3565b60608301525b610f5782600001518360600151612fb2565b610f6982600001518360600151611e60565b60808301819052610f7c57610f7c6148c4565b610f8f8883608001518460200151613095565b60a08301526080820151610fa49089906130c1565b60c08301528015610fc657610fc182600001518360a001516130f0565b611008565b610fd882600001518360a001516131d3565b6000610ff683600001518a60018660800151600188602001516132c8565b905061100683600001518261333e565b505b602083015182516040516322894d8f60e21b81526001600160a01b0390921691638a25363c9161103f9133906001906004016148da565b600060405180830381600087803b15801561105957600080fd5b505af115801561106d573d6000803e3d6000fd5b50505050602083015182516040516322cbc1b360e11b81526001600160a01b03909216916345978366916110a79133908d906004016148da565b6020604051808303816000875af11580156110c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ea9190614876565b50602083015182516080840151604051637f2586fb60e11b81526001600160a01b039093169263fe4b0df6926111279290913391906004016148da565b6020604051808303816000875af1158015611146573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116a9190614876565b506020830151825160405163c7a1bbdb60e01b81526001600160a01b039092169163c7a1bbdb9161119f9133906004016148fe565b600060405180830381600087803b1580156111b957600080fd5b505af11580156111cd573d6000803e3d6000fd5b505050506020830151825160405163dbe9f91960e01b81526001600160a01b039092169163dbe9f919916112059133906004016148fe565b6020604051808303816000875af1158015611224573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112489190614876565b60e0830152600a54825160c0840151604051633e499e0560e11b81526001600160a01b039283166004820152336024820152604481019190915287821660648201528682166084820152911690637c933c0a9060a401600060405180830381600087803b1580156112b857600080fd5b505af11580156112cc573d6000803e3d6000fd5b5050505060208301518251604051630706bdff60e11b81526001600160a01b0390921691630e0d7bfe916113049133906004016148fe565b6020604051808303816000875af1158015611323573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113479190614876565b6101008301819052825160405191825233916001600160a01b03909116907fc78aeff453faf39d5a4a56acb99641aa471118956e00bdf4ca3e08ee6687fef69060200160405180910390a36113a5826000015184604001518a613433565b6113c3826000015184604001518560600151338a8760600151613582565b815160408481015160608601516005546001549351635daaf32b60e11b81526001600160a01b0380871660048301526114bb969592811692169063bb55e65690602401602060405180830381865afa158015611423573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114479190614876565b6001548851604051635daaf32b60e11b81526001600160a01b03918216600482015291169063bb55e65690602401602060405180830381865afa158015611492573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b69190614876565b613582565b8151608083015160e084015160405133936001600160a01b0316927f100d2512a463b515ea8d03a69afbcc791f1bd9139132e820631bec236f524ec192611507928e919060009061493a565b60405180910390a38151604080840151905190815233916001600160a01b0316907f9d5794abdd948f6488a3a8660db2d758dca082dddfad9238a376363a0527e1be9060200160405180910390a3505050505050505050565b60065460405163ea16003f60e01b81526001600160a01b039091169063ea16003f9061159290849033906004016148fe565b600060405180830381600087803b1580156115ac57600080fd5b505af11580156107dc573d6000803e3d6000fd5b600080600160009054906101000a90046001600160a01b03166001600160a01b0316637f7dde4a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163a9190614859565b604051635373433f60e01b81526001600160a01b0385811660048301529190911690635373433f90602401602060405180830381865afa158015611682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a69190614876565b90506000600160009054906101000a90046001600160a01b03166001600160a01b0316633cc742256040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117219190614859565b604051635373433f60e01b81526001600160a01b0386811660048301529190911690635373433f9060240161072d565b6000546001600160a01b0316331461177b5760405162461bcd60e51b81526004016108889061488f565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f98c5e303d085e26fdf8af6a41184b0937ed01142ae7fdfa02dcc87e7079c325390600090a250565b6107dc85600033600087600188888c611edb565b60035460015460408051633fbeef2560e11b815290516001600160a01b03938416936000931691637f7dde4a9160048083019260209291908290030181865afa15801561182a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184e9190614859565b6009549091506001600160a01b0316611868848433613642565b60015460408051633a0df78d60e11b815290516000926001600160a01b03169163741bef1a9160048083019260209291908290030181865afa1580156118b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d69190614859565b604051635670bcc760e11b81526001600160a01b038781166004830152919091169063ace1798e906024016020604051808303816000875af1158015611920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119449190614876565b9050611950858261371d565b60405163df4fb9ef60e01b81526001600160a01b0385169063df4fb9ef9061197e90889033906004016148fe565b600060405180830381600087803b15801561199857600080fd5b505af11580156119ac573d6000803e3d6000fd5b505060405163305a536960e01b8152600092506001600160a01b038716915063305a5369906119e190899033906004016148fe565b602060405180830381865afa1580156119fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a229190614876565b90506000856001600160a01b031663f3e2c60888336040518363ffffffff1660e01b8152600401611a549291906148fe565b602060405180830381865afa158015611a71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a959190614876565b600154604051635daaf32b60e11b81526001600160a01b038a81166004830152929350611b1e9287923392611b19929091169063bb55e65690602401602060405180830381865afa158015611aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b129190614876565b859061379a565b6137a6565b6000611b3088846000856000896132c8565b9050611b3c888261333e565b604051633ed3a18f60e21b81526001600160a01b0388169063fb4e863c90611b6a908b9033906004016148fe565b600060405180830381600087803b158015611b8457600080fd5b505af1158015611b98573d6000803e3d6000fd5b50506040516317d5218560e21b81526001600160a01b038a169250635f5486149150611bca908b9033906004016148fe565b600060405180830381600087803b158015611be457600080fd5b505af1158015611bf8573d6000803e3d6000fd5b50505050336001600160a01b0316886001600160a01b03167f100d2512a463b515ea8d03a69afbcc791f1bd9139132e820631bec236f524ec160008060006001604051611c48949392919061493a565b60405180910390a3600154604051635daaf32b60e11b81526001600160a01b03808b166004830152611cda928b928a928a923392611cd5929091169063bb55e65690602401602060405180830381865afa158015611caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cce9190614876565b889061379a565b613887565b600554600154604051635daaf32b60e11b81526001600160a01b03808c166004830152611d59938c938b938b93928316929091169063bb55e65690602401602060405180830381865afa158015611d35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd59190614876565b6040516347878f1560e01b81526001600160a01b038716906347878f1590611d89908b90339088906004016148da565b600060405180830381600087803b158015611da357600080fd5b505af1158015611db7573d6000803e3d6000fd5b505050505050505050505050565b6000546001600160a01b03163314611def5760405162461bcd60e51b81526004016108889061488f565b6001600160a01b038116611e545760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610888565b611e5d81612a25565b50565b600154604051635daaf32b60e11b81526001600160a01b03848116600483015260009261057c9291169063bb55e65690602401602060405180830381865afa158015611eb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed49190614876565b83906127b3565b604080516080810182526002546001600160a01b03908116825260035481166020808401919091526001548451633fbeef2560e11b815285516000968601949290921692637f7dde4a926004808401938290030181865afa158015611f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f689190614859565b6001600160a01b03168152602001600960009054906101000a90046001600160a01b03166001600160a01b03168152509050612017604051806101c0016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000151581526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038b16815234158061202f57508934145b6120995760405162461bcd60e51b815260206004820152603560248201527f426f72726f7765724f703a205f417373657453656e7420616e64204d73672e76604482015274616c7565206172656e2774207468652073616d652160581b6064820152608401610888565b600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121109190614859565b8151604051635670bcc760e11b81526001600160a01b03918216600482015291169063ace1798e906024016020604051808303816000875af115801561215a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217e9190614876565b6020820181905281516000916121949190612a75565b905086156121b25781516121a9908583612afa565b6121b288613952565b6121bc898c6139c8565b6121c789898d613a38565b6121da826000015184602001518c613642565b336001600160a01b038b16148061226f575060048054604051633c5f6d8f60e21b815233928101929092526001600160a01b03169063f17db63c90602401602060405180830381865afa158015612235573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612259919061495c565b8015612265575060008b115b801561226f575087155b61227b5761227b6148c4565b6020830151825160405163df4fb9ef60e01b81526001600160a01b039092169163df4fb9ef916122af918e906004016148fe565b600060405180830381600087803b1580156122c957600080fd5b505af11580156122dd573d6000803e3d6000fd5b505050506122eb8b8a613ada565b15156080840152604083015260608201889052868015612309575080155b156123485761232c82600001518460000151856020015186606001518c89612e02565b61014083018190526060830151612342916127b3565b60608301525b60208301518251604051631e7c58c160e31b81526001600160a01b039092169163f3e2c6089161237c918e906004016148fe565b602060405180830381865afa158015612399573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bd9190614876565b60a08301526020830151825160405163305a536960e01b81526001600160a01b039092169163305a5369916123f6918e906004016148fe565b602060405180830381865afa158015612413573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124379190614876565b60c0830181905260a08301516020840151612453929190613095565b8260e00181815250506124838260c001518360a001518460400151856080015186606001518c8860200151613af9565b61010083015260c08201518911156124fc5760405162461bcd60e51b815260206004820152603660248201527f426f72726f7765724f703a20547279696e6720746f2072656d6f7665206d6f7260448201527565207468616e207468652074726f766520686f6c647360501b6064820152608401610888565b815161250b90828b8a86613b2c565b861580156125195750600088115b156125755761254b8260000151612546846060015161254086600001518760a00151613ba8565b9061379a565b612fb2565b61256282600001518360a001518460600151613c24565b61257583606001518b84606001516137a6565b61259d8260000151846000015185602001518d8660400151876080015188606001518e613cd9565b6101608401526101808301526020830151825160405163dbe9f91960e01b81526001600160a01b039092169163dbe9f919916125dd918e906004016148fe565b6020604051808303816000875af11580156125fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126209190614876565b826101a0018181525050600061264e8360c001518460a001518560400151866080015187606001518d613ed4565b600a54845160405163bc9b5bd560e01b81526001600160a01b0391821660048201528e82166024820152604481018490528a821660648201528982166084820152929350169063bc9b5bd59060a401600060405180830381600087803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b505050508a6001600160a01b031683600001516001600160a01b03167f100d2512a463b515ea8d03a69afbcc791f1bd9139132e820631bec236f524ec1856101600151866101800151876101a00151600260405161272c949392919061493a565b60405180910390a3825161014084015160405190815233916001600160a01b0316907f9d5794abdd948f6488a3a8660db2d758dca082dddfad9238a376363a0527e1be9060200160405180910390a36127a483600001518560400151866060015133876040015188608001518f8f8b60600151613ef7565b50505050505050505050505050565b600061057c828461498f565b60006001600160a01b0384161582806127df57508080156127df57503415155b806127f15750801580156127f1575034155b6128935760405162461bcd60e51b815260206004820152606160248201527f426f72726f7765724f703a20496e76616c696420496e7075742e204f7665727260448201527f696465206d73672e76616c7565206f6e6c79206966207573696e67204554482060648201527f61737365742c206f746865727769736520757365205f746f6b656e416d6f756e6084820152601d60fa1b60a482015260c401610888565b6001600160a01b0385166128a5573493505b839150505b9392505050565b60048054604051633c5f6d8f60e21b815233928101929092526001600160a01b03169063f17db63c90602401602060405180830381865afa1580156128fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291e919061495c565b610c555760405162461bcd60e51b815260206004820152602960248201527f426f72726f7765724f70733a2043616c6c6572206973206e6f742053746162696044820152681b1a5d1e48141bdbdb60ba1b6064820152608401610888565b6001600160a01b0381166129d25760405162461bcd60e51b815260206004820152601e60248201527f4163636f756e742063616e6e6f74206265207a65726f206164647265737300006044820152606401610888565b803b80612a215760405162461bcd60e51b815260206004820181905260248201527f4163636f756e7420636f64652073697a652063616e6e6f74206265207a65726f6044820152606401610888565b5050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080612a828484613f91565b600154604051631f6a526d60e11b81526001600160a01b038781166004830152929350911690633ed4a4da90602401602060405180830381865afa158015612ace573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af29190614876565b119392505050565b8015612be657600160009054906101000a90046001600160a01b03166001600160a01b031663a20baee66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b779190614876565b821115612be15760405162461bcd60e51b815260206004820152603260248201527f4d6178206665652070657263656e74616765206d757374206c657373207468616044820152716e206f7220657175616c20746f203130302560701b6064820152608401610888565b505050565b600154604051631108308b60e31b81526001600160a01b03858116600483015290911690638841845890602401602060405180830381865afa158015612c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c549190614876565b8210158015612cd95750600160009054906101000a90046001600160a01b03166001600160a01b031663a20baee66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd59190614876565b8211155b612be15760405162461bcd60e51b815260206004820152603060248201527f4d6178206665652070657263656e74616765206d75737420626520626574776560448201526f656e20302e352520616e64203130302560801b6064820152608401610888565b60405163614d120960e01b81526000906001600160a01b0384169063614d120990612d6f90889086906004016148fe565b602060405180830381865afa158015612d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612db09190614876565b9050806001036107dc5760405162461bcd60e51b815260206004820152601c60248201527f426f72726f7765724f70733a2054726f766520697320616374697665000000006044820152606401610888565b604051630daba89760e31b81526001600160a01b03878116600483015260009190861690636d5d44b890602401600060405180830381600087803b158015612e4957600080fd5b505af1158015612e5d573d6000803e3d6000fd5b50506040516314757c1360e31b81526001600160a01b038a8116600483015260248201879052600093508816915063a3abe09890604401602060405180830381865afa158015612eb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ed59190614876565b9050612ee2818585613fc0565b600854604051636361ddf360e11b81526001600160a01b038088169263c6c3bbe692612f16928d92169086906004016148da565b600060405180830381600087803b158015612f3057600080fd5b505af1158015612f44573d6000803e3d6000fd5b50506007546040516332aaa95b60e21b8152600481018590526001600160a01b03909116925063caaaa56c9150602401600060405180830381600087803b158015612f8e57600080fd5b505af1158015612fa2573d6000803e3d6000fd5b50929a9950505050505050505050565b60015460405163c4063a1960e01b81526001600160a01b0384811660048301529091169063c4063a1990602401602060405180830381865afa158015612ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130209190614876565b811015612a215760405162461bcd60e51b815260206004820152603a60248201527f426f72726f7765724f70733a2054726f76652773206e65742064656274206d7560448201527f73742062652067726561746572207468616e206d696e696d756d0000000000006064820152608401610888565b600082156130b8576130b1836130ab868561407e565b9061408a565b90506128aa565b506000196128aa565b600081156130e7576130e0826130ab8568056bc75e2d6310000061407e565b905061057f565b5060001961057f565b600154604051631f6a526d60e11b81526001600160a01b03848116600483015290911690633ed4a4da90602401602060405180830381865afa15801561313a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315e9190614876565b811015612a215760405162461bcd60e51b815260206004820152603760248201527f426f72726f7765724f70733a204f7065726174696f6e206d757374206c65617660448201527f652074726f7665207769746820494352203e3d204343520000000000000000006064820152608401610888565b6001546040516305f8cff960e01b81526001600160a01b038481166004830152909116906305f8cff990602401602060405180830381865afa15801561321d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132419190614876565b811015612a215760405162461bcd60e51b815260206004820152604960248201527f426f72726f7765724f70733a20416e206f7065726174696f6e2074686174207760448201527f6f756c6420726573756c7420696e20494352203c204d4352206973206e6f74206064820152681c195c9b5a5d1d195960ba1b608482015260a401610888565b6000806132d4886115c0565b905060006132e1896105a0565b9050866132f7576132f2828961379a565b613301565b61330182896127b3565b91508461331757613312818761379a565b613321565b61332181876127b3565b90506000613330838387613095565b9a9950505050505050505050565b600154604051631f6a526d60e11b81526001600160a01b03848116600483015290911690633ed4a4da90602401602060405180830381865afa158015613388573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ac9190614876565b811015612a215760405162461bcd60e51b815260206004820152604960248201527f426f72726f7765724f70733a20416e206f7065726174696f6e2074686174207760448201527f6f756c6420726573756c7420696e20544352203c20434352206973206e6f74206064820152681c195c9b5a5d1d195960ba1b608482015260a401610888565b6001600160a01b0383166134fa576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461348e576040519150601f19603f3d011682016040523d82523d6000602084013e613493565b606091505b505090508061059a5760405162461bcd60e51b815260206004820152602d60248201527f426f72726f7765724f70733a2053656e64696e672045544820746f204163746960448201526c1d99541bdbdb0819985a5b1959609a1b6064820152608401610888565b61351b33836135098685614096565b6001600160a01b038716929190614177565b604051633ac5bc0160e21b81526001600160a01b0384811660048301526024820183905283169063eb16f00490604401600060405180830381600087803b15801561356557600080fd5b505af1158015613579573d6000803e3d6000fd5b50505050505050565b6040516306df996d60e41b81526001600160a01b03878116600483015260248201839052861690636df996d090604401600060405180830381600087803b1580156135cc57600080fd5b505af11580156135e0573d6000803e3d6000fd5b5050604051636361ddf360e11b81526001600160a01b038716925063c6c3bbe69150613614908990879087906004016148da565b600060405180830381600087803b15801561362e57600080fd5b505af1158015610c15573d6000803e3d6000fd5b60405163614d120960e01b81526000906001600160a01b0384169063614d12099061367390879086906004016148fe565b602060405180830381865afa158015613690573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b49190614876565b90508060011461059a5760405162461bcd60e51b815260206004820152602e60248201527f426f72726f7765724f70733a2054726f766520646f6573206e6f74206578697360448201526d1d081bdc881a5cc818db1bdcd95960921b6064820152608401610888565b6137278282612a75565b15612a215760405162461bcd60e51b815260206004820152603960248201527f426f72726f7765724f70733a204f7065726174696f6e206e6f74207065726d6960448201527f7474656420647572696e67205265636f76657279204d6f6465000000000000006064820152608401610888565b600061057c82846149a7565b6040516370a0823160e01b81526001600160a01b0383811660048301528291908516906370a0823190602401602060405180830381865afa1580156137ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138139190614876565b1015612be15760405162461bcd60e51b815260206004820152603d60248201527f426f72726f7765724f70733a2043616c6c657220646f65736e7420686176652060448201527f656e6f756768204443484620746f206d616b652072657061796d656e740000006064820152608401610888565b60405163fb24e5f760e01b81526001600160a01b0386811660048301526024820183905285169063fb24e5f790604401600060405180830381600087803b1580156138d157600080fd5b505af11580156138e5573d6000803e3d6000fd5b5050604051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905286169250639dc29fac9150604401600060405180830381600087803b15801561393357600080fd5b505af1158015613947573d6000803e3d6000fd5b505050505050505050565b60008111611e5d5760405162461bcd60e51b815260206004820152603760248201527f426f72726f7765724f70733a204465627420696e63726561736520726571756960448201527f726573206e6f6e2d7a65726f20646562744368616e67650000000000000000006064820152608401610888565b8115806139d3575080155b612a215760405162461bcd60e51b815260206004820152603060248201527f426f72726f7765724f7065726174696f6e733a2043616e6e6f7420776974686460448201526f1c985dc8185b99081859190818dbdb1b60821b6064820152608401610888565b34151580613a4557508215155b80613a4f57508115155b80613a5957508015155b612be15760405162461bcd60e51b815260206004820152604660248201527f426f72726f7765724f70733a205468657265206d75737420626520656974686560448201527f72206120636f6c6c61746572616c206368616e6765206f7220612064656274206064820152656368616e676560d01b608482015260a401610888565b6000808315613aee57508290506001613af2565b8291505b9250929050565b6000806000613b0c8a8a8a8a8a8a6141cf565b915091506000613b1d838387613095565b9b9a5050505050505050505050565b8315613b6857613b3b83614223565b8115613b6357613b50858261010001516130f0565b613b638161010001518260e00151614297565b6107dc565b613b77858261010001516131d3565b613b95858260400151836080015184606001518686602001516132c8565b61012082018190526107dc90869061333e565b600154604051635daaf32b60e11b81526001600160a01b03848116600483015260009261057c9291169063bb55e656906024015b602060405180830381865afa158015613bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1d9190614876565b839061379a565b600154604051635daaf32b60e11b81526001600160a01b038581166004830152613c5892169063bb55e65690602401613bdc565b811115612be15760405162461bcd60e51b815260206004820152604360248201527f426f72726f7765724f70733a20416d6f756e7420726570616964206d7573742060448201527f6e6f74206265206c6172676572207468616e207468652054726f76652773206460648201526219589d60ea1b608482015260a401610888565b600080600085613d5a57604051622fae7760e81b81526001600160a01b038a1690632fae770090613d12908e908c908c906004016148da565b6020604051808303816000875af1158015613d31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d559190614876565b613dcd565b6040516322cbc1b360e11b81526001600160a01b038a1690634597836690613d8a908e908c908c906004016148da565b6020604051808303816000875af1158015613da9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dcd9190614876565b9050600084613e4e57604051634231d8b560e11b81526001600160a01b038b1690638463b16a90613e06908f908d908b906004016148da565b6020604051808303816000875af1158015613e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e499190614876565b613ec1565b604051637f2586fb60e11b81526001600160a01b038b169063fe4b0df690613e7e908f908d908b906004016148da565b6020604051808303816000875af1158015613e9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ec19190614876565b919c919b50909950505050505050505050565b6000806000613ee78989898989896141cf565b91509150600061333083836130c1565b8115613f1057613f0b898989898786613582565b613f1d565b613f1d8989898987613887565b8315613f3357613f2e898987613433565b613947565b6040516347878f1560e01b81526001600160a01b038916906347878f1590613f63908c908a908a906004016148da565b600060405180830381600087803b158015613f7d57600080fd5b505af11580156127a4573d6000803e3d6000fd5b600080613f9d846115c0565b90506000613faa856105a0565b9050613fb7828286613095565b95945050505050565b6000614047836130ab600160009054906101000a90046001600160a01b03166001600160a01b031663a20baee66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561401c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140409190614876565b879061407e565b90508181111561059a5760405162461bcd60e51b8152602060048201526002602482015261464d60f01b6044820152606401610888565b600061057c82846149be565b600061057c82846149dd565b60006001600160a01b0383166140ad57508061057f565b816000036140bd5750600061057f565b6000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061412191906149ff565b905060128160ff1610156141575761414f61413d826012614a22565b61414890600a614b29565b849061408a565b91505061057f565b61414f614165601283614a22565b61417090600a614b29565b849061407e565b61059a846323b872dd60e01b858585604051602401614198939291906148da565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261430d565b6000808787866141e8576141e38a8961379a565b6141f2565b6141f28a896127b3565b91508461420857614203898761379a565b614212565b61421289876127b3565b919a91995090975050505050505050565b8015611e5d5760405162461bcd60e51b815260206004820152603e60248201527f426f72726f7765724f70733a20436f6c6c61746572616c20776974686472617760448201527f616c206e6f74207065726d6974746564205265636f76657279204d6f646500006064820152608401610888565b80821015612a215760405162461bcd60e51b815260206004820152603e60248201527f426f72726f7765724f70733a2043616e6e6f7420646563726561736520796f7560448201527f722054726f766527732049435220696e205265636f76657279204d6f646500006064820152608401610888565b6000614362826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166143df9092919063ffffffff16565b805190915015612be15780806020019051810190614380919061495c565b612be15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610888565b606061077a848460008585843b6144385760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610888565b600080866001600160a01b031685876040516144549190614b38565b60006040518083038185875af1925050503d8060008114614491576040519150601f19603f3d011682016040523d82523d6000602084013e614496565b606091505b50915091506144a68282866144b1565b979650505050505050565b606083156144c05750816128aa565b8251156144d05782518084602001fd5b8160405162461bcd60e51b815260040161088891906147e5565b6001600160a01b0381168114611e5d57600080fd5b6000806040838503121561451257600080fd5b823561451d816144ea565b946020939093013593505050565b6000806000806080858703121561454157600080fd5b843561454c816144ea565b9350602085013592506040850135614563816144ea565b91506060850135614573816144ea565b939692955090935050565b60006020828403121561459057600080fd5b81356128aa816144ea565b600080600080600060a086880312156145b357600080fd5b85356145be816144ea565b94506020860135935060408601356145d5816144ea565b925060608601356145e5816144ea565b915060808601356145f5816144ea565b809150509295509295909350565b60008060008060008060008060006101208a8c03121561462257600080fd5b893561462d816144ea565b985060208a013561463d816144ea565b975060408a013561464d816144ea565b965060608a013561465d816144ea565b955060808a013561466d816144ea565b945060a08a013561467d816144ea565b935060c08a013561468d816144ea565b925060e08a013561469d816144ea565b91506101008a01356146ae816144ea565b809150509295985092959850929598565b8015158114611e5d57600080fd5b600080600080600080600080610100898b0312156146ea57600080fd5b88356146f5816144ea565b97506020890135965060408901359550606089013594506080890135935060a0890135614721816146bf565b925060c0890135614731816144ea565b915060e0890135614741816144ea565b809150509295985092959890939650565b60008060008060008060c0878903121561476b57600080fd5b8635614776816144ea565b9550602087013594506040870135935060608701359250608087013561479b816144ea565b915060a08701356147ab816144ea565b809150509295509295509295565b60005b838110156147d45781810151838201526020016147bc565b8381111561059a5750506000910152565b60208152600082518060208401526148048160408501602087016147b9565b601f01601f19169190910160400192915050565b600080600080600060a0868803121561483057600080fd5b853561483b816144ea565b9450602086013593506040860135925060608601356145e5816144ea565b60006020828403121561486b57600080fd5b81516128aa816144ea565b60006020828403121561488857600080fd5b5051919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052600160045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0392831681529116602082015260400190565b6003811061493657634e487b7160e01b600052602160045260246000fd5b9052565b848152602081018490526040810183905260808101613fb76060830184614918565b60006020828403121561496e57600080fd5b81516128aa816146bf565b634e487b7160e01b600052601160045260246000fd5b600082198211156149a2576149a2614979565b500190565b6000828210156149b9576149b9614979565b500390565b60008160001904831182151516156149d8576149d8614979565b500290565b6000826149fa57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215614a1157600080fd5b815160ff811681146128aa57600080fd5b600060ff821660ff841680821015614a3c57614a3c614979565b90039392505050565b600181815b80851115614a80578160001904821115614a6657614a66614979565b80851615614a7357918102915b93841c9390800290614a4a565b509250929050565b600082614a975750600161057f565b81614aa45750600061057f565b8160018114614aba5760028114614ac457614ae0565b600191505061057f565b60ff841115614ad557614ad5614979565b50506001821b61057f565b5060208310610133831016604e8410600b8410161715614b03575081810a61057f565b614b0d8383614a45565b8060001904821115614b2157614b21614979565b029392505050565b600061057c60ff841683614a88565b60008251614b4a8184602087016147b9565b919091019291505056fea2646970667358221220a29bfe2d387c6f51ee77ef4983579204bceaefac8de23242713315aa35ca881564736f6c634300080e0033
Deployed Bytecode
0x6080604052600436106101c25760003560e01c80637da0b1fa116100f7578063a9419ca311610095578063cbd138ae11610064578063cbd138ae146104f0578063e81f707e14610510578063e90f42ba14610530578063f2fde38b1461055057600080fd5b8063a9419ca314610470578063ae91875414610490578063b80dddf9146104b0578063bc04c45a146104d057600080fd5b80639e86d0c4116100d15780639e86d0c4146103c9578063a20baee6146103e9578063a263757f14610405578063a3f4df7e1461042557600080fd5b80637da0b1fa146103785780638235b2841461038b5780638da5cb5b146103ab57600080fd5b806348a4a39d11610164578063662720441161013e578063662720441461031b578063715018a61461033b57806372141e6314610350578063743990211461036557600080fd5b806348a4a39d146102d557806349b010c5146102e8578063501414f51461030857600080fd5b806327d04b35116101a057806327d04b351461023c57806335ecf35e1461025c578063392e53cd146102945780633d83908a146102b557600080fd5b806302540e48146101c757806306f202d2146101fa57806327705b8d1461021a575b600080fd5b3480156101d357600080fd5b506101e76101e23660046144ff565b610570565b6040519081526020015b60405180910390f35b34801561020657600080fd5b5060015b60405190151581526020016101f1565b34801561022657600080fd5b5061023a61023536600461452b565b610585565b005b34801561024857600080fd5b506101e761025736600461457e565b6105a0565b34801561026857600080fd5b5060085461027c906001600160a01b031681565b6040516001600160a01b0390911681526020016101f1565b3480156102a057600080fd5b50600a5461020a90600160a01b900460ff1681565b3480156102c157600080fd5b5060025461027c906001600160a01b031681565b61023a6102e336600461452b565b610782565b3480156102f457600080fd5b5061023a61030336600461452b565b6107a1565b61023a61031636600461459b565b6107b5565b34801561032757600080fd5b5061023a610336366004614603565b6107e3565b34801561034757600080fd5b5061023a610c21565b34801561035c57600080fd5b5061027c600081565b61023a6103733660046146cd565b610c57565b61023a610386366004614752565b610c7d565b34801561039757600080fd5b5061023a6103a636600461457e565b611560565b3480156103b757600080fd5b506000546001600160a01b031661027c565b3480156103d557600080fd5b506101e76103e436600461457e565b6115c0565b3480156103f557600080fd5b506101e7670de0b6b3a764000081565b34801561041157600080fd5b5061023a61042036600461457e565b611751565b34801561043157600080fd5b5061046360405180604001604052806012815260200171426f72726f7765724f7065726174696f6e7360701b81525081565b6040516101f191906147e5565b34801561047c57600080fd5b5060035461027c906001600160a01b031681565b34801561049c57600080fd5b50600a5461027c906001600160a01b031681565b3480156104bc57600080fd5b5061023a6104cb366004614818565b6117c5565b3480156104dc57600080fd5b5060075461027c906001600160a01b031681565b3480156104fc57600080fd5b5061023a61050b36600461457e565b6117d9565b34801561051c57600080fd5b5060095461027c906001600160a01b031681565b34801561053c57600080fd5b5060015461027c906001600160a01b031681565b34801561055c57600080fd5b5061023a61056b36600461457e565b611dc5565b600061057c8383611e60565b90505b92915050565b61059a84600033600087600088886000611edb565b50505050565b600080600160009054906101000a90046001600160a01b03166001600160a01b0316637f7dde4a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061a9190614859565b60405163d1234da760e01b81526001600160a01b038581166004830152919091169063d1234da790602401602060405180830381865afa158015610662573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106869190614876565b90506000600160009054906101000a90046001600160a01b03166001600160a01b0316633cc742256040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107019190614859565b60405163d1234da760e01b81526001600160a01b038681166004830152919091169063d1234da7906024015b602060405180830381865afa15801561074a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076e9190614876565b905061077a82826127b3565b949350505050565b61059a84610792868660006127bf565b33600080600088886000611edb565b61059a846000338660008088886000611edb565b6107bd6128b1565b6107dc856107cd878760006127bf565b85600080600088886000611edb565b5050505050565b600154600160a81b900460ff1615808015610809575060018054600160a01b900460ff16105b806108295750303b158015610829575060018054600160a01b900460ff16145b6108915760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6001805460ff60a01b1916600160a01b17905580156108be576001805460ff60a81b1916600160a81b1790555b6000546001600160a01b031633146108e85760405162461bcd60e51b81526004016108889061488f565b600a54600160a01b900460ff16156109385760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610888565b6109418a61297c565b61094a8961297c565b6109538861297c565b61095c8761297c565b6109658661297c565b61096e8561297c565b6109778461297c565b6109808361297c565b6109898261297c565b600a8054600280546001600160a01b03199081166001600160a01b038f8116919091179092556003805482168e84161790556004805482168d84161790556005805482168c84161790556006805482168b8416179055600160a01b6001600160a81b031990931689831617929092179092556009805482168784161790556008805482169286169283179055600780549091169091179055610a2a82611751565b6040516001600160a01b038b1681527f143219c9e69b09e07e095fcc889b43d8f46ca892bba65f08dc3a0050869a56789060200160405180910390a16040516001600160a01b03891681527f82966d27eea39b038ee0fa30cd16532bb24f6e65d31cb58fb227aa5766cdcc7f9060200160405180910390a16040516001600160a01b03881681527fcfb07d791fcafc032b35837b50eb84b74df518cf4cc287e8084f47630fa70fa09060200160405180910390a16040516001600160a01b03871681527fe67f36a6e961157d6eff83b91f3af5a62131ceb6f04954ef74f51c1c05e7f88d9060200160405180910390a16040516001600160a01b03861681527f65f4cf077bc01e4742eb5ad98326f6e95b63548ea24b17f8d5e823111fe788009060200160405180910390a16040516001600160a01b03851681527ff165f2d7729f02833c6f7dea7d6f0f9c4a505f5557516f4daca827f9637c67909060200160405180910390a16040516001600160a01b03841681527f944e8aa30f20353b5f690ba54feb76ccabc18503cf60ee20f2b9f1418aa732839060200160405180910390a18015610c15576001805460ff60a81b191681556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6000546001600160a01b03163314610c4b5760405162461bcd60e51b81526004016108889061488f565b610c556000612a25565b565b610c7388610c678a8a60016127bf565b3388888888888e611edb565b5050505050505050565b6001546040516362a3b93f60e01b81526001600160a01b038881166004830152909116906362a3b93f90602401600060405180830381600087803b158015610cc457600080fd5b505af1158015610cd8573d6000803e3d6000fd5b5050604080516080810182526002546001600160a01b03908116825260035481166020808401919091526001548451633fbeef2560e11b815285516000985094965094860194921692637f7dde4a9260048082019392918290030181865afa158015610d48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6c9190614859565b6001600160a01b039081168252600954811660209283015260408051610120810182526000938101849052908101839052606081018390526080810183905260a0810183905260c0810183905260e081018390526101008101839052908a1680825292935091610ddd9189906127bf565b9650600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e569190614859565b8151604051635670bcc760e11b81526001600160a01b03918216600482015291169063ace1798e906024016020604051808303816000875af1158015610ea0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec49190614876565b602082018190528151600091610eda9190612a75565b9050610eeb82600001518883612afa565b815183516020850151610f0092919033612d3e565b6060820186905280610f4557610f2a82600001518460000151856020015186606001518a8c612e02565b604083018190526060830151610f3f916127b3565b60608301525b610f5782600001518360600151612fb2565b610f6982600001518360600151611e60565b60808301819052610f7c57610f7c6148c4565b610f8f8883608001518460200151613095565b60a08301526080820151610fa49089906130c1565b60c08301528015610fc657610fc182600001518360a001516130f0565b611008565b610fd882600001518360a001516131d3565b6000610ff683600001518a60018660800151600188602001516132c8565b905061100683600001518261333e565b505b602083015182516040516322894d8f60e21b81526001600160a01b0390921691638a25363c9161103f9133906001906004016148da565b600060405180830381600087803b15801561105957600080fd5b505af115801561106d573d6000803e3d6000fd5b50505050602083015182516040516322cbc1b360e11b81526001600160a01b03909216916345978366916110a79133908d906004016148da565b6020604051808303816000875af11580156110c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ea9190614876565b50602083015182516080840151604051637f2586fb60e11b81526001600160a01b039093169263fe4b0df6926111279290913391906004016148da565b6020604051808303816000875af1158015611146573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116a9190614876565b506020830151825160405163c7a1bbdb60e01b81526001600160a01b039092169163c7a1bbdb9161119f9133906004016148fe565b600060405180830381600087803b1580156111b957600080fd5b505af11580156111cd573d6000803e3d6000fd5b505050506020830151825160405163dbe9f91960e01b81526001600160a01b039092169163dbe9f919916112059133906004016148fe565b6020604051808303816000875af1158015611224573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112489190614876565b60e0830152600a54825160c0840151604051633e499e0560e11b81526001600160a01b039283166004820152336024820152604481019190915287821660648201528682166084820152911690637c933c0a9060a401600060405180830381600087803b1580156112b857600080fd5b505af11580156112cc573d6000803e3d6000fd5b5050505060208301518251604051630706bdff60e11b81526001600160a01b0390921691630e0d7bfe916113049133906004016148fe565b6020604051808303816000875af1158015611323573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113479190614876565b6101008301819052825160405191825233916001600160a01b03909116907fc78aeff453faf39d5a4a56acb99641aa471118956e00bdf4ca3e08ee6687fef69060200160405180910390a36113a5826000015184604001518a613433565b6113c3826000015184604001518560600151338a8760600151613582565b815160408481015160608601516005546001549351635daaf32b60e11b81526001600160a01b0380871660048301526114bb969592811692169063bb55e65690602401602060405180830381865afa158015611423573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114479190614876565b6001548851604051635daaf32b60e11b81526001600160a01b03918216600482015291169063bb55e65690602401602060405180830381865afa158015611492573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b69190614876565b613582565b8151608083015160e084015160405133936001600160a01b0316927f100d2512a463b515ea8d03a69afbcc791f1bd9139132e820631bec236f524ec192611507928e919060009061493a565b60405180910390a38151604080840151905190815233916001600160a01b0316907f9d5794abdd948f6488a3a8660db2d758dca082dddfad9238a376363a0527e1be9060200160405180910390a3505050505050505050565b60065460405163ea16003f60e01b81526001600160a01b039091169063ea16003f9061159290849033906004016148fe565b600060405180830381600087803b1580156115ac57600080fd5b505af11580156107dc573d6000803e3d6000fd5b600080600160009054906101000a90046001600160a01b03166001600160a01b0316637f7dde4a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163a9190614859565b604051635373433f60e01b81526001600160a01b0385811660048301529190911690635373433f90602401602060405180830381865afa158015611682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a69190614876565b90506000600160009054906101000a90046001600160a01b03166001600160a01b0316633cc742256040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117219190614859565b604051635373433f60e01b81526001600160a01b0386811660048301529190911690635373433f9060240161072d565b6000546001600160a01b0316331461177b5760405162461bcd60e51b81526004016108889061488f565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f98c5e303d085e26fdf8af6a41184b0937ed01142ae7fdfa02dcc87e7079c325390600090a250565b6107dc85600033600087600188888c611edb565b60035460015460408051633fbeef2560e11b815290516001600160a01b03938416936000931691637f7dde4a9160048083019260209291908290030181865afa15801561182a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184e9190614859565b6009549091506001600160a01b0316611868848433613642565b60015460408051633a0df78d60e11b815290516000926001600160a01b03169163741bef1a9160048083019260209291908290030181865afa1580156118b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d69190614859565b604051635670bcc760e11b81526001600160a01b038781166004830152919091169063ace1798e906024016020604051808303816000875af1158015611920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119449190614876565b9050611950858261371d565b60405163df4fb9ef60e01b81526001600160a01b0385169063df4fb9ef9061197e90889033906004016148fe565b600060405180830381600087803b15801561199857600080fd5b505af11580156119ac573d6000803e3d6000fd5b505060405163305a536960e01b8152600092506001600160a01b038716915063305a5369906119e190899033906004016148fe565b602060405180830381865afa1580156119fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a229190614876565b90506000856001600160a01b031663f3e2c60888336040518363ffffffff1660e01b8152600401611a549291906148fe565b602060405180830381865afa158015611a71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a959190614876565b600154604051635daaf32b60e11b81526001600160a01b038a81166004830152929350611b1e9287923392611b19929091169063bb55e65690602401602060405180830381865afa158015611aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b129190614876565b859061379a565b6137a6565b6000611b3088846000856000896132c8565b9050611b3c888261333e565b604051633ed3a18f60e21b81526001600160a01b0388169063fb4e863c90611b6a908b9033906004016148fe565b600060405180830381600087803b158015611b8457600080fd5b505af1158015611b98573d6000803e3d6000fd5b50506040516317d5218560e21b81526001600160a01b038a169250635f5486149150611bca908b9033906004016148fe565b600060405180830381600087803b158015611be457600080fd5b505af1158015611bf8573d6000803e3d6000fd5b50505050336001600160a01b0316886001600160a01b03167f100d2512a463b515ea8d03a69afbcc791f1bd9139132e820631bec236f524ec160008060006001604051611c48949392919061493a565b60405180910390a3600154604051635daaf32b60e11b81526001600160a01b03808b166004830152611cda928b928a928a923392611cd5929091169063bb55e65690602401602060405180830381865afa158015611caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cce9190614876565b889061379a565b613887565b600554600154604051635daaf32b60e11b81526001600160a01b03808c166004830152611d59938c938b938b93928316929091169063bb55e65690602401602060405180830381865afa158015611d35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd59190614876565b6040516347878f1560e01b81526001600160a01b038716906347878f1590611d89908b90339088906004016148da565b600060405180830381600087803b158015611da357600080fd5b505af1158015611db7573d6000803e3d6000fd5b505050505050505050505050565b6000546001600160a01b03163314611def5760405162461bcd60e51b81526004016108889061488f565b6001600160a01b038116611e545760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610888565b611e5d81612a25565b50565b600154604051635daaf32b60e11b81526001600160a01b03848116600483015260009261057c9291169063bb55e65690602401602060405180830381865afa158015611eb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed49190614876565b83906127b3565b604080516080810182526002546001600160a01b03908116825260035481166020808401919091526001548451633fbeef2560e11b815285516000968601949290921692637f7dde4a926004808401938290030181865afa158015611f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f689190614859565b6001600160a01b03168152602001600960009054906101000a90046001600160a01b03166001600160a01b03168152509050612017604051806101c0016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000151581526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038b16815234158061202f57508934145b6120995760405162461bcd60e51b815260206004820152603560248201527f426f72726f7765724f703a205f417373657453656e7420616e64204d73672e76604482015274616c7565206172656e2774207468652073616d652160581b6064820152608401610888565b600160009054906101000a90046001600160a01b03166001600160a01b031663741bef1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121109190614859565b8151604051635670bcc760e11b81526001600160a01b03918216600482015291169063ace1798e906024016020604051808303816000875af115801561215a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217e9190614876565b6020820181905281516000916121949190612a75565b905086156121b25781516121a9908583612afa565b6121b288613952565b6121bc898c6139c8565b6121c789898d613a38565b6121da826000015184602001518c613642565b336001600160a01b038b16148061226f575060048054604051633c5f6d8f60e21b815233928101929092526001600160a01b03169063f17db63c90602401602060405180830381865afa158015612235573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612259919061495c565b8015612265575060008b115b801561226f575087155b61227b5761227b6148c4565b6020830151825160405163df4fb9ef60e01b81526001600160a01b039092169163df4fb9ef916122af918e906004016148fe565b600060405180830381600087803b1580156122c957600080fd5b505af11580156122dd573d6000803e3d6000fd5b505050506122eb8b8a613ada565b15156080840152604083015260608201889052868015612309575080155b156123485761232c82600001518460000151856020015186606001518c89612e02565b61014083018190526060830151612342916127b3565b60608301525b60208301518251604051631e7c58c160e31b81526001600160a01b039092169163f3e2c6089161237c918e906004016148fe565b602060405180830381865afa158015612399573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bd9190614876565b60a08301526020830151825160405163305a536960e01b81526001600160a01b039092169163305a5369916123f6918e906004016148fe565b602060405180830381865afa158015612413573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124379190614876565b60c0830181905260a08301516020840151612453929190613095565b8260e00181815250506124838260c001518360a001518460400151856080015186606001518c8860200151613af9565b61010083015260c08201518911156124fc5760405162461bcd60e51b815260206004820152603660248201527f426f72726f7765724f703a20547279696e6720746f2072656d6f7665206d6f7260448201527565207468616e207468652074726f766520686f6c647360501b6064820152608401610888565b815161250b90828b8a86613b2c565b861580156125195750600088115b156125755761254b8260000151612546846060015161254086600001518760a00151613ba8565b9061379a565b612fb2565b61256282600001518360a001518460600151613c24565b61257583606001518b84606001516137a6565b61259d8260000151846000015185602001518d8660400151876080015188606001518e613cd9565b6101608401526101808301526020830151825160405163dbe9f91960e01b81526001600160a01b039092169163dbe9f919916125dd918e906004016148fe565b6020604051808303816000875af11580156125fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126209190614876565b826101a0018181525050600061264e8360c001518460a001518560400151866080015187606001518d613ed4565b600a54845160405163bc9b5bd560e01b81526001600160a01b0391821660048201528e82166024820152604481018490528a821660648201528982166084820152929350169063bc9b5bd59060a401600060405180830381600087803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b505050508a6001600160a01b031683600001516001600160a01b03167f100d2512a463b515ea8d03a69afbcc791f1bd9139132e820631bec236f524ec1856101600151866101800151876101a00151600260405161272c949392919061493a565b60405180910390a3825161014084015160405190815233916001600160a01b0316907f9d5794abdd948f6488a3a8660db2d758dca082dddfad9238a376363a0527e1be9060200160405180910390a36127a483600001518560400151866060015133876040015188608001518f8f8b60600151613ef7565b50505050505050505050505050565b600061057c828461498f565b60006001600160a01b0384161582806127df57508080156127df57503415155b806127f15750801580156127f1575034155b6128935760405162461bcd60e51b815260206004820152606160248201527f426f72726f7765724f703a20496e76616c696420496e7075742e204f7665727260448201527f696465206d73672e76616c7565206f6e6c79206966207573696e67204554482060648201527f61737365742c206f746865727769736520757365205f746f6b656e416d6f756e6084820152601d60fa1b60a482015260c401610888565b6001600160a01b0385166128a5573493505b839150505b9392505050565b60048054604051633c5f6d8f60e21b815233928101929092526001600160a01b03169063f17db63c90602401602060405180830381865afa1580156128fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291e919061495c565b610c555760405162461bcd60e51b815260206004820152602960248201527f426f72726f7765724f70733a2043616c6c6572206973206e6f742053746162696044820152681b1a5d1e48141bdbdb60ba1b6064820152608401610888565b6001600160a01b0381166129d25760405162461bcd60e51b815260206004820152601e60248201527f4163636f756e742063616e6e6f74206265207a65726f206164647265737300006044820152606401610888565b803b80612a215760405162461bcd60e51b815260206004820181905260248201527f4163636f756e7420636f64652073697a652063616e6e6f74206265207a65726f6044820152606401610888565b5050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080612a828484613f91565b600154604051631f6a526d60e11b81526001600160a01b038781166004830152929350911690633ed4a4da90602401602060405180830381865afa158015612ace573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af29190614876565b119392505050565b8015612be657600160009054906101000a90046001600160a01b03166001600160a01b031663a20baee66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b779190614876565b821115612be15760405162461bcd60e51b815260206004820152603260248201527f4d6178206665652070657263656e74616765206d757374206c657373207468616044820152716e206f7220657175616c20746f203130302560701b6064820152608401610888565b505050565b600154604051631108308b60e31b81526001600160a01b03858116600483015290911690638841845890602401602060405180830381865afa158015612c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c549190614876565b8210158015612cd95750600160009054906101000a90046001600160a01b03166001600160a01b031663a20baee66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cd59190614876565b8211155b612be15760405162461bcd60e51b815260206004820152603060248201527f4d6178206665652070657263656e74616765206d75737420626520626574776560448201526f656e20302e352520616e64203130302560801b6064820152608401610888565b60405163614d120960e01b81526000906001600160a01b0384169063614d120990612d6f90889086906004016148fe565b602060405180830381865afa158015612d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612db09190614876565b9050806001036107dc5760405162461bcd60e51b815260206004820152601c60248201527f426f72726f7765724f70733a2054726f766520697320616374697665000000006044820152606401610888565b604051630daba89760e31b81526001600160a01b03878116600483015260009190861690636d5d44b890602401600060405180830381600087803b158015612e4957600080fd5b505af1158015612e5d573d6000803e3d6000fd5b50506040516314757c1360e31b81526001600160a01b038a8116600483015260248201879052600093508816915063a3abe09890604401602060405180830381865afa158015612eb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ed59190614876565b9050612ee2818585613fc0565b600854604051636361ddf360e11b81526001600160a01b038088169263c6c3bbe692612f16928d92169086906004016148da565b600060405180830381600087803b158015612f3057600080fd5b505af1158015612f44573d6000803e3d6000fd5b50506007546040516332aaa95b60e21b8152600481018590526001600160a01b03909116925063caaaa56c9150602401600060405180830381600087803b158015612f8e57600080fd5b505af1158015612fa2573d6000803e3d6000fd5b50929a9950505050505050505050565b60015460405163c4063a1960e01b81526001600160a01b0384811660048301529091169063c4063a1990602401602060405180830381865afa158015612ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130209190614876565b811015612a215760405162461bcd60e51b815260206004820152603a60248201527f426f72726f7765724f70733a2054726f76652773206e65742064656274206d7560448201527f73742062652067726561746572207468616e206d696e696d756d0000000000006064820152608401610888565b600082156130b8576130b1836130ab868561407e565b9061408a565b90506128aa565b506000196128aa565b600081156130e7576130e0826130ab8568056bc75e2d6310000061407e565b905061057f565b5060001961057f565b600154604051631f6a526d60e11b81526001600160a01b03848116600483015290911690633ed4a4da90602401602060405180830381865afa15801561313a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315e9190614876565b811015612a215760405162461bcd60e51b815260206004820152603760248201527f426f72726f7765724f70733a204f7065726174696f6e206d757374206c65617660448201527f652074726f7665207769746820494352203e3d204343520000000000000000006064820152608401610888565b6001546040516305f8cff960e01b81526001600160a01b038481166004830152909116906305f8cff990602401602060405180830381865afa15801561321d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132419190614876565b811015612a215760405162461bcd60e51b815260206004820152604960248201527f426f72726f7765724f70733a20416e206f7065726174696f6e2074686174207760448201527f6f756c6420726573756c7420696e20494352203c204d4352206973206e6f74206064820152681c195c9b5a5d1d195960ba1b608482015260a401610888565b6000806132d4886115c0565b905060006132e1896105a0565b9050866132f7576132f2828961379a565b613301565b61330182896127b3565b91508461331757613312818761379a565b613321565b61332181876127b3565b90506000613330838387613095565b9a9950505050505050505050565b600154604051631f6a526d60e11b81526001600160a01b03848116600483015290911690633ed4a4da90602401602060405180830381865afa158015613388573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ac9190614876565b811015612a215760405162461bcd60e51b815260206004820152604960248201527f426f72726f7765724f70733a20416e206f7065726174696f6e2074686174207760448201527f6f756c6420726573756c7420696e20544352203c20434352206973206e6f74206064820152681c195c9b5a5d1d195960ba1b608482015260a401610888565b6001600160a01b0383166134fa576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461348e576040519150601f19603f3d011682016040523d82523d6000602084013e613493565b606091505b505090508061059a5760405162461bcd60e51b815260206004820152602d60248201527f426f72726f7765724f70733a2053656e64696e672045544820746f204163746960448201526c1d99541bdbdb0819985a5b1959609a1b6064820152608401610888565b61351b33836135098685614096565b6001600160a01b038716929190614177565b604051633ac5bc0160e21b81526001600160a01b0384811660048301526024820183905283169063eb16f00490604401600060405180830381600087803b15801561356557600080fd5b505af1158015613579573d6000803e3d6000fd5b50505050505050565b6040516306df996d60e41b81526001600160a01b03878116600483015260248201839052861690636df996d090604401600060405180830381600087803b1580156135cc57600080fd5b505af11580156135e0573d6000803e3d6000fd5b5050604051636361ddf360e11b81526001600160a01b038716925063c6c3bbe69150613614908990879087906004016148da565b600060405180830381600087803b15801561362e57600080fd5b505af1158015610c15573d6000803e3d6000fd5b60405163614d120960e01b81526000906001600160a01b0384169063614d12099061367390879086906004016148fe565b602060405180830381865afa158015613690573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b49190614876565b90508060011461059a5760405162461bcd60e51b815260206004820152602e60248201527f426f72726f7765724f70733a2054726f766520646f6573206e6f74206578697360448201526d1d081bdc881a5cc818db1bdcd95960921b6064820152608401610888565b6137278282612a75565b15612a215760405162461bcd60e51b815260206004820152603960248201527f426f72726f7765724f70733a204f7065726174696f6e206e6f74207065726d6960448201527f7474656420647572696e67205265636f76657279204d6f6465000000000000006064820152608401610888565b600061057c82846149a7565b6040516370a0823160e01b81526001600160a01b0383811660048301528291908516906370a0823190602401602060405180830381865afa1580156137ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138139190614876565b1015612be15760405162461bcd60e51b815260206004820152603d60248201527f426f72726f7765724f70733a2043616c6c657220646f65736e7420686176652060448201527f656e6f756768204443484620746f206d616b652072657061796d656e740000006064820152608401610888565b60405163fb24e5f760e01b81526001600160a01b0386811660048301526024820183905285169063fb24e5f790604401600060405180830381600087803b1580156138d157600080fd5b505af11580156138e5573d6000803e3d6000fd5b5050604051632770a7eb60e21b81526001600160a01b0385811660048301526024820185905286169250639dc29fac9150604401600060405180830381600087803b15801561393357600080fd5b505af1158015613947573d6000803e3d6000fd5b505050505050505050565b60008111611e5d5760405162461bcd60e51b815260206004820152603760248201527f426f72726f7765724f70733a204465627420696e63726561736520726571756960448201527f726573206e6f6e2d7a65726f20646562744368616e67650000000000000000006064820152608401610888565b8115806139d3575080155b612a215760405162461bcd60e51b815260206004820152603060248201527f426f72726f7765724f7065726174696f6e733a2043616e6e6f7420776974686460448201526f1c985dc8185b99081859190818dbdb1b60821b6064820152608401610888565b34151580613a4557508215155b80613a4f57508115155b80613a5957508015155b612be15760405162461bcd60e51b815260206004820152604660248201527f426f72726f7765724f70733a205468657265206d75737420626520656974686560448201527f72206120636f6c6c61746572616c206368616e6765206f7220612064656274206064820152656368616e676560d01b608482015260a401610888565b6000808315613aee57508290506001613af2565b8291505b9250929050565b6000806000613b0c8a8a8a8a8a8a6141cf565b915091506000613b1d838387613095565b9b9a5050505050505050505050565b8315613b6857613b3b83614223565b8115613b6357613b50858261010001516130f0565b613b638161010001518260e00151614297565b6107dc565b613b77858261010001516131d3565b613b95858260400151836080015184606001518686602001516132c8565b61012082018190526107dc90869061333e565b600154604051635daaf32b60e11b81526001600160a01b03848116600483015260009261057c9291169063bb55e656906024015b602060405180830381865afa158015613bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1d9190614876565b839061379a565b600154604051635daaf32b60e11b81526001600160a01b038581166004830152613c5892169063bb55e65690602401613bdc565b811115612be15760405162461bcd60e51b815260206004820152604360248201527f426f72726f7765724f70733a20416d6f756e7420726570616964206d7573742060448201527f6e6f74206265206c6172676572207468616e207468652054726f76652773206460648201526219589d60ea1b608482015260a401610888565b600080600085613d5a57604051622fae7760e81b81526001600160a01b038a1690632fae770090613d12908e908c908c906004016148da565b6020604051808303816000875af1158015613d31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d559190614876565b613dcd565b6040516322cbc1b360e11b81526001600160a01b038a1690634597836690613d8a908e908c908c906004016148da565b6020604051808303816000875af1158015613da9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dcd9190614876565b9050600084613e4e57604051634231d8b560e11b81526001600160a01b038b1690638463b16a90613e06908f908d908b906004016148da565b6020604051808303816000875af1158015613e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e499190614876565b613ec1565b604051637f2586fb60e11b81526001600160a01b038b169063fe4b0df690613e7e908f908d908b906004016148da565b6020604051808303816000875af1158015613e9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ec19190614876565b919c919b50909950505050505050505050565b6000806000613ee78989898989896141cf565b91509150600061333083836130c1565b8115613f1057613f0b898989898786613582565b613f1d565b613f1d8989898987613887565b8315613f3357613f2e898987613433565b613947565b6040516347878f1560e01b81526001600160a01b038916906347878f1590613f63908c908a908a906004016148da565b600060405180830381600087803b158015613f7d57600080fd5b505af11580156127a4573d6000803e3d6000fd5b600080613f9d846115c0565b90506000613faa856105a0565b9050613fb7828286613095565b95945050505050565b6000614047836130ab600160009054906101000a90046001600160a01b03166001600160a01b031663a20baee66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561401c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140409190614876565b879061407e565b90508181111561059a5760405162461bcd60e51b8152602060048201526002602482015261464d60f01b6044820152606401610888565b600061057c82846149be565b600061057c82846149dd565b60006001600160a01b0383166140ad57508061057f565b816000036140bd5750600061057f565b6000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061412191906149ff565b905060128160ff1610156141575761414f61413d826012614a22565b61414890600a614b29565b849061408a565b91505061057f565b61414f614165601283614a22565b61417090600a614b29565b849061407e565b61059a846323b872dd60e01b858585604051602401614198939291906148da565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261430d565b6000808787866141e8576141e38a8961379a565b6141f2565b6141f28a896127b3565b91508461420857614203898761379a565b614212565b61421289876127b3565b919a91995090975050505050505050565b8015611e5d5760405162461bcd60e51b815260206004820152603e60248201527f426f72726f7765724f70733a20436f6c6c61746572616c20776974686472617760448201527f616c206e6f74207065726d6974746564205265636f76657279204d6f646500006064820152608401610888565b80821015612a215760405162461bcd60e51b815260206004820152603e60248201527f426f72726f7765724f70733a2043616e6e6f7420646563726561736520796f7560448201527f722054726f766527732049435220696e205265636f76657279204d6f646500006064820152608401610888565b6000614362826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166143df9092919063ffffffff16565b805190915015612be15780806020019051810190614380919061495c565b612be15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610888565b606061077a848460008585843b6144385760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610888565b600080866001600160a01b031685876040516144549190614b38565b60006040518083038185875af1925050503d8060008114614491576040519150601f19603f3d011682016040523d82523d6000602084013e614496565b606091505b50915091506144a68282866144b1565b979650505050505050565b606083156144c05750816128aa565b8251156144d05782518084602001fd5b8160405162461bcd60e51b815260040161088891906147e5565b6001600160a01b0381168114611e5d57600080fd5b6000806040838503121561451257600080fd5b823561451d816144ea565b946020939093013593505050565b6000806000806080858703121561454157600080fd5b843561454c816144ea565b9350602085013592506040850135614563816144ea565b91506060850135614573816144ea565b939692955090935050565b60006020828403121561459057600080fd5b81356128aa816144ea565b600080600080600060a086880312156145b357600080fd5b85356145be816144ea565b94506020860135935060408601356145d5816144ea565b925060608601356145e5816144ea565b915060808601356145f5816144ea565b809150509295509295909350565b60008060008060008060008060006101208a8c03121561462257600080fd5b893561462d816144ea565b985060208a013561463d816144ea565b975060408a013561464d816144ea565b965060608a013561465d816144ea565b955060808a013561466d816144ea565b945060a08a013561467d816144ea565b935060c08a013561468d816144ea565b925060e08a013561469d816144ea565b91506101008a01356146ae816144ea565b809150509295985092959850929598565b8015158114611e5d57600080fd5b600080600080600080600080610100898b0312156146ea57600080fd5b88356146f5816144ea565b97506020890135965060408901359550606089013594506080890135935060a0890135614721816146bf565b925060c0890135614731816144ea565b915060e0890135614741816144ea565b809150509295985092959890939650565b60008060008060008060c0878903121561476b57600080fd5b8635614776816144ea565b9550602087013594506040870135935060608701359250608087013561479b816144ea565b915060a08701356147ab816144ea565b809150509295509295509295565b60005b838110156147d45781810151838201526020016147bc565b8381111561059a5750506000910152565b60208152600082518060208401526148048160408501602087016147b9565b601f01601f19169190910160400192915050565b600080600080600060a0868803121561483057600080fd5b853561483b816144ea565b9450602086013593506040860135925060608601356145e5816144ea565b60006020828403121561486b57600080fd5b81516128aa816144ea565b60006020828403121561488857600080fd5b5051919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052600160045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0392831681529116602082015260400190565b6003811061493657634e487b7160e01b600052602160045260246000fd5b9052565b848152602081018490526040810183905260808101613fb76060830184614918565b60006020828403121561496e57600080fd5b81516128aa816146bf565b634e487b7160e01b600052601160045260246000fd5b600082198211156149a2576149a2614979565b500190565b6000828210156149b9576149b9614979565b500390565b60008160001904831182151516156149d8576149d8614979565b500290565b6000826149fa57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215614a1157600080fd5b815160ff811681146128aa57600080fd5b600060ff821660ff841680821015614a3c57614a3c614979565b90039392505050565b600181815b80851115614a80578160001904821115614a6657614a66614979565b80851615614a7357918102915b93841c9390800290614a4a565b509250929050565b600082614a975750600161057f565b81614aa45750600061057f565b8160018114614aba5760028114614ac457614ae0565b600191505061057f565b60ff841115614ad557614ad5614979565b50506001821b61057f565b5060208310610133831016604e8410600b8410161715614b03575081810a61057f565b614b0d8383614a45565b8060001904821115614b2157614b21614979565b029392505050565b600061057c60ff841683614a88565b60008251614b4a8184602087016147b9565b919091019291505056fea2646970667358221220a29bfe2d387c6f51ee77ef4983579204bceaefac8de23242713315aa35ca881564736f6c634300080e0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.