编译器
0.8.22+commit.4fc1097e
文件 1 的 25:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 25:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 25:IAccessManager.sol
pragma solidity =0.8.22;
interface IAccessManager
{
function excludedCountriesUpdated() external;
function grantAccess(bytes calldata signature) external;
function geoVersion() external view returns (uint256);
function walletHasAccess(address wallet) external view returns (bool);
}
文件 4 的 25:IAirdrop.sol
pragma solidity =0.8.22;
interface IAirdrop
{
function authorizeWallet( address wallet, uint256 saltAmount ) external;
function allowClaiming() external;
function claim() external;
function claimedByUser( address wallet) external view returns (uint256);
function claimingAllowed() external view returns (bool);
function claimingStartTimestamp() external view returns (uint256);
function claimableAmount(address wallet) external view returns (uint256);
function airdropForUser( address wallet ) external view returns (uint256);
}
文件 5 的 25:IBootstrapBallot.sol
pragma solidity =0.8.22;
interface IBootstrapBallot
{
function vote( bool voteStartExchangeYes, uint256 saltAmount, bytes calldata signature ) external;
function finalizeBallot() external;
function authorizeAirdrop2( uint256 saltAmount, bytes calldata signature ) external;
function finalizeAirdrop2() external;
function claimableTimestamp1() external view returns (uint256);
function claimableTimestamp2() external view returns (uint256);
function hasVoted(address user) external view returns (bool);
function ballotFinalized() external view returns (bool);
function startExchangeYes() external view returns (uint256);
function startExchangeNo() external view returns (uint256);
}
文件 6 的 25:IDAO.sol
pragma solidity =0.8.22;
import "../../rewards/interfaces/ISaltRewards.sol";
import "../../pools/interfaces/IPools.sol";
import "../../interfaces/ISalt.sol";
interface IDAO
{
function finalizeBallot( uint256 ballotID ) external;
function manuallyRemoveBallot( uint256 ballotID ) external;
function withdrawFromDAO( IERC20 token ) external returns (uint256 withdrawnAmount);
function pools() external view returns (IPools);
function websiteURL() external view returns (string memory);
function countryIsExcluded( string calldata country ) external view returns (bool);
}
文件 7 的 25:IDAOConfig.sol
pragma solidity =0.8.22;
interface IDAOConfig
{
function changeBootstrappingRewards(bool increase) external;
function changePercentRewardsBurned(bool increase) external;
function changeBaseBallotQuorumPercent(bool increase) external;
function changeBallotDuration(bool increase) external;
function changeBallotMaximumDuration(bool increase) external;
function changeRequiredProposalPercentStake(bool increase) external;
function changePercentRewardsForReserve(bool increase) external;
function changeUpkeepRewardPercent(bool increase) external;
function bootstrappingRewards() external view returns (uint256);
function percentRewardsBurned() external view returns (uint256);
function baseBallotQuorumPercentTimes1000() external view returns (uint256);
function ballotMinimumDuration() external view returns (uint256);
function ballotMaximumDuration() external view returns (uint256);
function requiredProposalPercentStakeTimes1000() external view returns (uint256);
function percentRewardsForReserve() external view returns (uint256);
function upkeepRewardPercent() external view returns (uint256);
}
文件 8 的 25:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
}
文件 9 的 25:IERC20Permit.sol
pragma solidity ^0.8.0;
interface IERC20Permit {
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 10 的 25:IEmissions.sol
pragma solidity =0.8.22;
interface IEmissions
{
function performUpkeep( uint256 timeSinceLastUpkeep ) external;
}
文件 11 的 25:IExchangeConfig.sol
pragma solidity =0.8.22;
import "openzeppelin-contracts/contracts/finance/VestingWallet.sol";
import "../staking/interfaces/ILiquidity.sol";
import "../launch/interfaces/IInitialDistribution.sol";
import "../rewards/interfaces/IRewardsEmitter.sol";
import "../rewards/interfaces/ISaltRewards.sol";
import "../rewards/interfaces/IEmissions.sol";
import "../interfaces/IAccessManager.sol";
import "../launch/interfaces/IAirdrop.sol";
import "../dao/interfaces/IDAO.sol";
import "../interfaces/ISalt.sol";
import "./IUpkeep.sol";
interface IExchangeConfig
{
function setContracts( IDAO _dao, IUpkeep _upkeep, IInitialDistribution _initialDistribution, VestingWallet _teamVestingWallet, VestingWallet _daoVestingWallet ) external;
function setAccessManager( IAccessManager _accessManager ) external;
function salt() external view returns (ISalt);
function wbtc() external view returns (IERC20);
function weth() external view returns (IERC20);
function usdc() external view returns (IERC20);
function usdt() external view returns (IERC20);
function daoVestingWallet() external view returns (VestingWallet);
function teamVestingWallet() external view returns (VestingWallet);
function initialDistribution() external view returns (IInitialDistribution);
function accessManager() external view returns (IAccessManager);
function dao() external view returns (IDAO);
function upkeep() external view returns (IUpkeep);
function teamWallet() external view returns (address);
function walletHasAccess( address wallet ) external view returns (bool);
}
文件 12 的 25:IInitialDistribution.sol
pragma solidity =0.8.22;
import "./IBootstrapBallot.sol";
import "./IAirdrop.sol";
interface IInitialDistribution
{
function distributionApproved( IAirdrop airdrop1, IAirdrop airdrop2 ) external;
function bootstrapBallot() external view returns (IBootstrapBallot);
}
文件 13 的 25:ILiquidity.sol
pragma solidity =0.8.22;
import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "./IStakingRewards.sol";
interface ILiquidity is IStakingRewards
{
function depositLiquidityAndIncreaseShare( IERC20 tokenA, IERC20 tokenB, uint256 maxAmountA, uint256 maxAmountB, uint256 minAddedAmountA, uint256 minAddedAmountB, uint256 minAddedLiquidity, uint256 deadline, bool useZapping ) external returns (uint256 addedLiquidity);
function withdrawLiquidityAndClaim( IERC20 tokenA, IERC20 tokenB, uint256 liquidityToWithdraw, uint256 minReclaimedA, uint256 minReclaimedB, uint256 deadline ) external returns (uint256 reclaimedA, uint256 reclaimedB);
}
文件 14 的 25:IPoolStats.sol
pragma solidity =0.8.22;
interface IPoolStats
{
struct ArbitrageIndicies
{
uint64 index1;
uint64 index2;
uint64 index3;
}
function clearProfitsForPools() external;
function updateArbitrageIndicies() external;
function profitsForWhitelistedPools() external view returns (uint256[] memory _calculatedProfits);
function arbitrageIndicies(bytes32 poolID) external view returns (ArbitrageIndicies memory);
}
文件 15 的 25:IPools.sol
pragma solidity =0.8.22;
import "../../staking/interfaces/ILiquidity.sol";
import "../../dao/interfaces/IDAO.sol";
import "./IPoolStats.sol";
interface IPools is IPoolStats
{
function startExchangeApproved() external;
function setContracts( IDAO _dao, ILiquidity _liquidity ) external;
function addLiquidity( IERC20 tokenA, IERC20 tokenB, uint256 maxAmountA, uint256 maxAmountB, uint256 minAddedAmountA, uint256 minAddedAmountB, uint256 totalLiquidity ) external returns (uint256 addedAmountA, uint256 addedAmountB, uint256 addedLiquidity);
function removeLiquidity( IERC20 tokenA, IERC20 tokenB, uint256 liquidityToRemove, uint256 minReclaimedA, uint256 minReclaimedB, uint256 totalLiquidity ) external returns (uint256 reclaimedA, uint256 reclaimedB);
function deposit( IERC20 token, uint256 amount ) external;
function withdraw( IERC20 token, uint256 amount ) external;
function swap( IERC20 swapTokenIn, IERC20 swapTokenOut, uint256 swapAmountIn, uint256 minAmountOut, uint256 deadline ) external returns (uint256 swapAmountOut);
function depositSwapWithdraw(IERC20 swapTokenIn, IERC20 swapTokenOut, uint256 swapAmountIn, uint256 minAmountOut, uint256 deadline ) external returns (uint256 swapAmountOut);
function depositDoubleSwapWithdraw( IERC20 swapTokenIn, IERC20 swapTokenMiddle, IERC20 swapTokenOut, uint256 swapAmountIn, uint256 minAmountOut, uint256 deadline ) external returns (uint256 swapAmountOut);
function depositZapSwapWithdraw(IERC20 swapTokenIn, IERC20 swapTokenOut, uint256 swapAmountIn ) external returns (uint256 swapAmountOut);
function exchangeIsLive() external view returns (bool);
function getPoolReserves(IERC20 tokenA, IERC20 tokenB) external view returns (uint256 reserveA, uint256 reserveB);
function depositedUserBalance(address user, IERC20 token) external view returns (uint256);
}
文件 16 的 25:IPoolsConfig.sol
pragma solidity =0.8.22;
import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "./IPools.sol";
interface IPoolsConfig
{
function whitelistPool( IERC20 tokenA, IERC20 tokenB ) external;
function unwhitelistPool( IERC20 tokenA, IERC20 tokenB ) external;
function changeMaximumWhitelistedPools(bool increase) external;
function maximumWhitelistedPools() external view returns (uint256);
function numberOfWhitelistedPools() external view returns (uint256);
function isWhitelisted( bytes32 poolID ) external view returns (bool);
function whitelistedPools() external view returns (bytes32[] calldata);
function underlyingTokenPair( bytes32 poolID ) external view returns (IERC20 tokenA, IERC20 tokenB);
function tokenHasBeenWhitelisted( IERC20 token, IERC20 weth, IERC20 usdc ) external view returns (bool);
}
文件 17 的 25:IRewardsEmitter.sol
pragma solidity =0.8.22;
import "../../staking/interfaces/IStakingRewards.sol";
interface IRewardsEmitter
{
function addSALTRewards( AddedReward[] calldata addedRewards ) external;
function performUpkeep( uint256 timeSinceLastUpkeep ) external;
function pendingRewardsForPools( bytes32[] calldata pools ) external view returns (uint256[] calldata);
}
文件 18 的 25:ISalt.sol
pragma solidity =0.8.22;
import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
interface ISalt is IERC20
{
function burnTokensInContract() external;
function totalBurned() external view returns (uint256);
}
文件 19 的 25:ISaltRewards.sol
pragma solidity =0.8.22;
import "./IRewardsEmitter.sol";
interface ISaltRewards
{
function sendInitialSaltRewards( uint256 liquidityBootstrapAmount, bytes32[] calldata poolIDs ) external;
function performUpkeep( bytes32[] calldata poolIDs, uint256[] calldata profitsForPools ) external;
function stakingRewardsEmitter() external view returns (IRewardsEmitter);
function liquidityRewardsEmitter() external view returns (IRewardsEmitter);
}
文件 20 的 25:IStakingRewards.sol
pragma solidity =0.8.22;
struct AddedReward
{
bytes32 poolID;
uint256 amountToAdd;
}
struct UserShareInfo
{
uint256 userShare;
uint256 virtualRewards;
uint256 cooldownExpiration;
}
interface IStakingRewards
{
function claimAllRewards( bytes32[] calldata poolIDs ) external returns (uint256 rewardsAmount);
function addSALTRewards( AddedReward[] calldata addedRewards ) external;
function totalShares(bytes32 poolID) external view returns (uint256);
function totalSharesForPools( bytes32[] calldata poolIDs ) external view returns (uint256[] calldata shares);
function totalRewardsForPools( bytes32[] calldata poolIDs ) external view returns (uint256[] calldata rewards);
function userRewardForPool( address wallet, bytes32 poolID ) external view returns (uint256);
function userShareForPool( address wallet, bytes32 poolID ) external view returns (uint256);
function userVirtualRewardsForPool( address wallet, bytes32 poolID ) external view returns (uint256);
function userRewardsForPools( address wallet, bytes32[] calldata poolIDs ) external view returns (uint256[] calldata rewards);
function userShareForPools( address wallet, bytes32[] calldata poolIDs ) external view returns (uint256[] calldata shares);
function userCooldowns( address wallet, bytes32[] calldata poolIDs ) external view returns (uint256[] calldata cooldowns);
}
文件 21 的 25:IUpkeep.sol
pragma solidity =0.8.22;
interface IUpkeep
{
function performUpkeep() external;
function currentRewardsForCallingPerformUpkeep() external view returns (uint256);
function lastUpkeepTimeEmissions() external view returns (uint256);
function lastUpkeepTimeRewardsEmitters() external view returns (uint256);
}
文件 22 的 25: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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
}
function _nonReentrantAfter() private {
_status = _NOT_ENTERED;
}
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
文件 23 的 25:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.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 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
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");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
文件 24 的 25:Upkeep.sol
pragma solidity =0.8.22;
import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
import "openzeppelin-contracts/contracts/finance/VestingWallet.sol";
import "./rewards/interfaces/IEmissions.sol";
import "./pools/interfaces/IPoolsConfig.sol";
import "./interfaces/IExchangeConfig.sol";
import "./dao/interfaces/IDAOConfig.sol";
import "./pools/interfaces/IPools.sol";
import "./dao/interfaces/IDAO.sol";
contract Upkeep is IUpkeep, ReentrancyGuard
{
using SafeERC20 for ISalt;
using SafeERC20 for IERC20;
event UpkeepError(string description, bytes error);
IPools immutable public pools;
IExchangeConfig immutable public exchangeConfig;
IPoolsConfig immutable public poolsConfig;
IDAOConfig immutable public daoConfig;
ISaltRewards immutable public saltRewards;
IEmissions immutable public emissions;
IDAO immutable public dao;
ISalt immutable public salt;
uint256 public lastUpkeepTimeEmissions;
uint256 public lastUpkeepTimeRewardsEmitters;
constructor( IPools _pools, IExchangeConfig _exchangeConfig, IPoolsConfig _poolsConfig, IDAOConfig _daoConfig, ISaltRewards _saltRewards, IEmissions _emissions, IDAO _dao )
{
pools = _pools;
exchangeConfig = _exchangeConfig;
poolsConfig = _poolsConfig;
daoConfig = _daoConfig;
saltRewards = _saltRewards;
emissions = _emissions;
dao = _dao;
salt = _exchangeConfig.salt();
lastUpkeepTimeEmissions = block.timestamp;
lastUpkeepTimeRewardsEmitters = block.timestamp;
}
modifier onlySameContract()
{
require(msg.sender == address(this), "Only callable from within the same contract");
_;
}
function step1(address receiver) public onlySameContract
{
uint256 withdrawnSALT = dao.withdrawFromDAO(salt);
if ( withdrawnSALT == 0 )
return;
uint256 rewardAmount = withdrawnSALT * daoConfig.upkeepRewardPercent() / 100;
salt.safeTransfer(receiver, rewardAmount);
}
function step2() public onlySameContract
{
uint256 saltBalance = salt.balanceOf( address(this) );
if ( saltBalance == 0 )
return;
uint256 burnAmount = saltBalance * daoConfig.percentRewardsBurned() / 100;
salt.transfer( address(salt), burnAmount);
salt.burnTokensInContract();
uint256 reserveAmount = saltBalance * daoConfig.percentRewardsForReserve() / 100;
salt.transfer( address(dao), reserveAmount);
}
function step3() public onlySameContract
{
uint256 saltBalance = salt.balanceOf( address(this) );
if ( saltBalance == 0 )
return;
salt.safeTransfer(address(saltRewards), saltBalance);
}
function step4() public onlySameContract
{
uint256 timeSinceLastUpkeep = block.timestamp - lastUpkeepTimeEmissions;
emissions.performUpkeep(timeSinceLastUpkeep);
lastUpkeepTimeEmissions = block.timestamp;
}
function step5() public onlySameContract
{
uint256[] memory profitsForPools = pools.profitsForWhitelistedPools();
bytes32[] memory poolIDs = poolsConfig.whitelistedPools();
saltRewards.performUpkeep(poolIDs, profitsForPools );
pools.clearProfitsForPools();
}
function step6() public onlySameContract
{
uint256 timeSinceLastUpkeep = block.timestamp - lastUpkeepTimeRewardsEmitters;
saltRewards.stakingRewardsEmitter().performUpkeep(timeSinceLastUpkeep);
saltRewards.liquidityRewardsEmitter().performUpkeep(timeSinceLastUpkeep);
lastUpkeepTimeRewardsEmitters = block.timestamp;
}
function step7() public onlySameContract
{
exchangeConfig.daoVestingWallet().release(address(salt));
}
function step8() public onlySameContract
{
exchangeConfig.teamVestingWallet().release(address(salt));
}
function performUpkeep() public nonReentrant
{
require(lastUpkeepTimeEmissions != block.timestamp, "No time since elapsed since last upkeep");
try this.step1(msg.sender) {}
catch (bytes memory error) { emit UpkeepError("Step 1", error); }
try this.step2() {}
catch (bytes memory error) { emit UpkeepError("Step 2", error); }
try this.step3() {}
catch (bytes memory error) { emit UpkeepError("Step 3", error); }
try this.step4() {}
catch (bytes memory error) { emit UpkeepError("Step 4", error); }
try this.step5() {}
catch (bytes memory error) { emit UpkeepError("Step 5", error); }
try this.step6() {}
catch (bytes memory error) { emit UpkeepError("Step 6", error); }
try this.step7() {}
catch (bytes memory error) { emit UpkeepError("Step 7", error); }
try this.step8() {}
catch (bytes memory error) { emit UpkeepError("Step 8", error); }
}
function currentRewardsForCallingPerformUpkeep() public view returns (uint256)
{
uint256 depositedSALT = pools.depositedUserBalance(address(dao), salt);
return depositedSALT * daoConfig.upkeepRewardPercent() / 100;
}
}
文件 25 的 25:VestingWallet.sol
pragma solidity ^0.8.0;
import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
contract VestingWallet is Context {
event EtherReleased(uint256 amount);
event ERC20Released(address indexed token, uint256 amount);
uint256 private _released;
mapping(address => uint256) private _erc20Released;
address private immutable _beneficiary;
uint64 private immutable _start;
uint64 private immutable _duration;
constructor(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds) payable {
require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address");
_beneficiary = beneficiaryAddress;
_start = startTimestamp;
_duration = durationSeconds;
}
receive() external payable virtual {}
function beneficiary() public view virtual returns (address) {
return _beneficiary;
}
function start() public view virtual returns (uint256) {
return _start;
}
function duration() public view virtual returns (uint256) {
return _duration;
}
function released() public view virtual returns (uint256) {
return _released;
}
function released(address token) public view virtual returns (uint256) {
return _erc20Released[token];
}
function releasable() public view virtual returns (uint256) {
return vestedAmount(uint64(block.timestamp)) - released();
}
function releasable(address token) public view virtual returns (uint256) {
return vestedAmount(token, uint64(block.timestamp)) - released(token);
}
function release() public virtual {
uint256 amount = releasable();
_released += amount;
emit EtherReleased(amount);
Address.sendValue(payable(beneficiary()), amount);
}
function release(address token) public virtual {
uint256 amount = releasable(token);
_erc20Released[token] += amount;
emit ERC20Released(token, amount);
SafeERC20.safeTransfer(IERC20(token), beneficiary(), amount);
}
function vestedAmount(uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(address(this).balance + released(), timestamp);
}
function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp);
}
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual returns (uint256) {
if (timestamp < start()) {
return 0;
} else if (timestamp > start() + duration()) {
return totalAllocation;
} else {
return (totalAllocation * (timestamp - start())) / duration();
}
}
}
{
"compilationTarget": {
"src/Upkeep.sol": "Upkeep"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": [
":chainlink/=lib/chainlink/",
":ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/openzeppelin-contracts/lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/contracts/",
":v3-core/=lib/v3-core/contracts/"
]
}
[{"inputs":[{"internalType":"contract IPools","name":"_pools","type":"address"},{"internalType":"contract IExchangeConfig","name":"_exchangeConfig","type":"address"},{"internalType":"contract IPoolsConfig","name":"_poolsConfig","type":"address"},{"internalType":"contract IDAOConfig","name":"_daoConfig","type":"address"},{"internalType":"contract ISaltRewards","name":"_saltRewards","type":"address"},{"internalType":"contract IEmissions","name":"_emissions","type":"address"},{"internalType":"contract IDAO","name":"_dao","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"bytes","name":"error","type":"bytes"}],"name":"UpkeepError","type":"event"},{"inputs":[],"name":"currentRewardsForCallingPerformUpkeep","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dao","outputs":[{"internalType":"contract IDAO","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"daoConfig","outputs":[{"internalType":"contract IDAOConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emissions","outputs":[{"internalType":"contract IEmissions","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exchangeConfig","outputs":[{"internalType":"contract IExchangeConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpkeepTimeEmissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpkeepTimeRewardsEmitters","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"performUpkeep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pools","outputs":[{"internalType":"contract IPools","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolsConfig","outputs":[{"internalType":"contract IPoolsConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"salt","outputs":[{"internalType":"contract ISalt","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"saltRewards","outputs":[{"internalType":"contract ISaltRewards","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"step1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step3","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step4","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step5","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step6","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step7","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"step8","outputs":[],"stateMutability":"nonpayable","type":"function"}]