编译器
0.8.11+commit.d7f03943
文件 1 的 7:Address.sol
pragma solidity ^0.8.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
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");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
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");
}
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);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
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);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
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);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 7:AuraMath.sol
pragma solidity 0.8.11;
library AuraMath {
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
}
function to224(uint256 a) internal pure returns (uint224 c) {
require(a <= type(uint224).max, "AuraMath: uint224 Overflow");
c = uint224(a);
}
function to128(uint256 a) internal pure returns (uint128 c) {
require(a <= type(uint128).max, "AuraMath: uint128 Overflow");
c = uint128(a);
}
function to112(uint256 a) internal pure returns (uint112 c) {
require(a <= type(uint112).max, "AuraMath: uint112 Overflow");
c = uint112(a);
}
function to96(uint256 a) internal pure returns (uint96 c) {
require(a <= type(uint96).max, "AuraMath: uint96 Overflow");
c = uint96(a);
}
function to32(uint256 a) internal pure returns (uint32 c) {
require(a <= type(uint32).max, "AuraMath: uint32 Overflow");
c = uint32(a);
}
}
library AuraMath32 {
function sub(uint32 a, uint32 b) internal pure returns (uint32 c) {
c = a - b;
}
}
library AuraMath112 {
function add(uint112 a, uint112 b) internal pure returns (uint112 c) {
c = a + b;
}
function sub(uint112 a, uint112 b) internal pure returns (uint112 c) {
c = a - b;
}
}
library AuraMath224 {
function add(uint224 a, uint224 b) internal pure returns (uint224 c) {
c = a + b;
}
}
文件 3 的 7:AuraVestedEscrow.sol
pragma solidity 0.8.11;
import { IAuraLocker } from "./Interfaces.sol";
import { IERC20 } from "@openzeppelin/contracts-0.8/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts-0.8/token/ERC20/utils/SafeERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts-0.8/security/ReentrancyGuard.sol";
import { AuraMath } from "./AuraMath.sol";
contract AuraVestedEscrow is ReentrancyGuard {
using SafeERC20 for IERC20;
IERC20 public immutable rewardToken;
address public admin;
address public immutable funder;
IAuraLocker public auraLocker;
uint256 public immutable startTime;
uint256 public immutable endTime;
uint256 public immutable totalTime;
bool public initialised = false;
mapping(address => uint256) public totalLocked;
mapping(address => uint256) public totalClaimed;
event Funded(address indexed recipient, uint256 reward);
event Cancelled(address indexed recipient);
event Claim(address indexed user, uint256 amount, bool locked);
constructor(
address rewardToken_,
address admin_,
address auraLocker_,
uint256 starttime_,
uint256 endtime_
) {
require(starttime_ >= block.timestamp, "start must be future");
require(endtime_ > starttime_, "end must be greater");
rewardToken = IERC20(rewardToken_);
admin = admin_;
funder = msg.sender;
auraLocker = IAuraLocker(auraLocker_);
startTime = starttime_;
endTime = endtime_;
totalTime = endTime - startTime;
require(totalTime >= 16 weeks, "!short");
}
function setAdmin(address _admin) external {
require(msg.sender == admin, "!auth");
admin = _admin;
}
function setLocker(address _auraLocker) external {
require(msg.sender == admin, "!auth");
auraLocker = IAuraLocker(_auraLocker);
}
function fund(address[] calldata _recipient, uint256[] calldata _amount) external nonReentrant {
require(_recipient.length == _amount.length, "!arr");
require(!initialised, "initialised already");
require(msg.sender == funder, "!funder");
require(block.timestamp < startTime, "already started");
uint256 totalAmount = 0;
for (uint256 i = 0; i < _recipient.length; i++) {
uint256 amount = _amount[i];
totalLocked[_recipient[i]] += amount;
totalAmount += amount;
emit Funded(_recipient[i], amount);
}
rewardToken.safeTransferFrom(msg.sender, address(this), totalAmount);
initialised = true;
}
function cancel(address _recipient) external nonReentrant {
require(msg.sender == admin, "!auth");
require(totalLocked[_recipient] > 0, "!funding");
_claim(_recipient, false);
uint256 delta = remaining(_recipient);
rewardToken.safeTransfer(admin, delta);
totalLocked[_recipient] = 0;
emit Cancelled(_recipient);
}
function available(address _recipient) public view returns (uint256) {
uint256 vested = _totalVestedOf(_recipient, block.timestamp);
return vested - totalClaimed[_recipient];
}
function remaining(address _recipient) public view returns (uint256) {
uint256 vested = _totalVestedOf(_recipient, block.timestamp);
return totalLocked[_recipient] - vested;
}
function _totalVestedOf(address _recipient, uint256 _time) internal view returns (uint256 total) {
if (_time < startTime) {
return 0;
}
uint256 locked = totalLocked[_recipient];
uint256 elapsed = _time - startTime;
total = AuraMath.min((locked * elapsed) / totalTime, locked);
}
function claim(bool _lock) external nonReentrant {
_claim(msg.sender, _lock);
}
function _claim(address _recipient, bool _lock) internal {
uint256 claimable = available(_recipient);
totalClaimed[_recipient] += claimable;
if (_lock) {
require(address(auraLocker) != address(0), "!auraLocker");
rewardToken.safeApprove(address(auraLocker), claimable);
auraLocker.lock(_recipient, claimable);
} else {
rewardToken.safeTransfer(_recipient, claimable);
}
emit Claim(_recipient, claimable, _lock);
}
}
文件 4 的 7:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 5 的 7:Interfaces.sol
pragma solidity 0.8.11;
interface IPriceOracle {
struct OracleAverageQuery {
Variable variable;
uint256 secs;
uint256 ago;
}
enum Variable {
PAIR_PRICE,
BPT_PRICE,
INVARIANT
}
function getTimeWeightedAverage(OracleAverageQuery[] memory queries)
external
view
returns (uint256[] memory results);
}
interface IVault {
enum PoolSpecialization {
GENERAL,
MINIMAL_SWAP_INFO,
TWO_TOKEN
}
enum JoinKind {
INIT,
EXACT_TOKENS_IN_FOR_BPT_OUT,
TOKEN_IN_FOR_EXACT_BPT_OUT,
ALL_TOKENS_IN_FOR_EXACT_BPT_OUT
}
enum SwapKind {
GIVEN_IN,
GIVEN_OUT
}
struct SingleSwap {
bytes32 poolId;
SwapKind kind;
IAsset assetIn;
IAsset assetOut;
uint256 amount;
bytes userData;
}
struct FundManagement {
address sender;
bool fromInternalBalance;
address payable recipient;
bool toInternalBalance;
}
struct JoinPoolRequest {
IAsset[] assets;
uint256[] maxAmountsIn;
bytes userData;
bool fromInternalBalance;
}
function getPool(bytes32 poolId) external view returns (address, PoolSpecialization);
function getPoolTokens(bytes32 poolId)
external
view
returns (
address[] memory tokens,
uint256[] memory balances,
uint256 lastChangeBlock
);
function joinPool(
bytes32 poolId,
address sender,
address recipient,
JoinPoolRequest memory request
) external payable;
function swap(
SingleSwap memory singleSwap,
FundManagement memory funds,
uint256 limit,
uint256 deadline
) external returns (uint256 amountCalculated);
function exitPool(
bytes32 poolId,
address sender,
address payable recipient,
ExitPoolRequest memory request
) external;
struct ExitPoolRequest {
IAsset[] assets;
uint256[] minAmountsOut;
bytes userData;
bool toInternalBalance;
}
enum ExitKind {
EXACT_BPT_IN_FOR_ONE_TOKEN_OUT,
EXACT_BPT_IN_FOR_TOKENS_OUT,
BPT_IN_FOR_EXACT_TOKENS_OUT,
MANAGEMENT_FEE_TOKENS_OUT
}
}
interface IAsset {
}
interface IAuraLocker {
function lock(address _account, uint256 _amount) external;
function checkpointEpoch() external;
function epochCount() external view returns (uint256);
function balanceAtEpochOf(uint256 _epoch, address _user) external view returns (uint256 amount);
function totalSupplyAtEpoch(uint256 _epoch) external view returns (uint256 supply);
function queueNewRewards(address _rewardsToken, uint256 reward) external;
function getReward(address _account, bool _stake) external;
function getReward(address _account) external;
}
interface IExtraRewardsDistributor {
function addReward(address _token, uint256 _amount) external;
}
interface ICrvDepositorWrapper {
function getMinOut(uint256, uint256) external view returns (uint256);
function deposit(
uint256,
uint256,
bool,
address _stakeAddress
) external;
}
文件 6 的 7:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 7 的 7:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
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));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
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));
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
{
"compilationTarget": {
"contracts/AuraVestedEscrow.sol": "AuraVestedEscrow"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 800
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"rewardToken_","type":"address"},{"internalType":"address","name":"admin_","type":"address"},{"internalType":"address","name":"auraLocker_","type":"address"},{"internalType":"uint256","name":"starttime_","type":"uint256"},{"internalType":"uint256","name":"endtime_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"Cancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"locked","type":"bool"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"Funded","type":"event"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auraLocker","outputs":[{"internalType":"contract IAuraLocker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"available","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_lock","type":"bool"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_recipient","type":"address[]"},{"internalType":"uint256[]","name":"_amount","type":"uint256[]"}],"name":"fund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"funder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialised","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"remaining","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_auraLocker","type":"address"}],"name":"setLocker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalLocked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]