Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- EsAxnBatchSender
- Optimization enabled
- true
- Compiler version
- v0.6.12+commit.27d51765
- Optimization runs
- 8
- EVM Version
- default
- Verified at
- 2023-07-29T18:26:25.105834Z
Constructor Arguments
0x000000000000000000000000f0449ce85a224c33a62c7d6e3cd0225440a0ff88
Arg [0] (address) : 0xf0449ce85a224c33a62c7d6e3cd0225440a0ff88
contracts/peripherals/EsAxnBatchSender.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "../libraries/token/IERC20.sol";
import "../libraries/math/SafeMath.sol";
import "../staking/interfaces/IVester.sol";
import "../staking/interfaces/IRewardTracker.sol";
contract EsAxnBatchSender {
using SafeMath for uint256;
address public admin;
address public esAxn;
constructor(address _esAxn) public {
admin = msg.sender;
esAxn = _esAxn;
}
modifier onlyAdmin() {
require(msg.sender == admin, "EsAxnBatchSender: forbidden");
_;
}
function send(
IVester _vester,
uint256 _minRatio,
address[] memory _accounts,
uint256[] memory _amounts
) external onlyAdmin {
IRewardTracker rewardTracker = IRewardTracker(_vester.rewardTracker());
for (uint256 i = 0; i < _accounts.length; i++) {
IERC20(esAxn).transferFrom(msg.sender, _accounts[i], _amounts[i]);
uint256 nextTransferredCumulativeReward = _vester.transferredCumulativeRewards(_accounts[i]).add(_amounts[i]);
_vester.setTransferredCumulativeRewards(_accounts[i], nextTransferredCumulativeReward);
uint256 cumulativeReward = rewardTracker.cumulativeRewards(_accounts[i]);
uint256 totalCumulativeReward = cumulativeReward.add(nextTransferredCumulativeReward);
uint256 combinedAverageStakedAmount = _vester.getCombinedAverageStakedAmount(_accounts[i]);
if (combinedAverageStakedAmount > totalCumulativeReward.mul(_minRatio)) {
continue;
}
uint256 nextTransferredAverageStakedAmount = _minRatio.mul(totalCumulativeReward);
nextTransferredAverageStakedAmount = nextTransferredAverageStakedAmount.sub(
rewardTracker.averageStakedAmounts(_accounts[i]).mul(cumulativeReward).div(totalCumulativeReward)
);
nextTransferredAverageStakedAmount = nextTransferredAverageStakedAmount.mul(totalCumulativeReward).div(nextTransferredCumulativeReward);
_vester.setTransferredAverageStakedAmounts(_accounts[i], nextTransferredAverageStakedAmount);
}
}
}
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @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) {
// 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 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts 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) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts 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 mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
/**
* @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);
}
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
interface IRewardTracker {
function depositBalances(address _account, address _depositToken) external view returns (uint256);
function stakedAmounts(address _account) external view returns (uint256);
function updateRewards() external;
function stake(address _depositToken, uint256 _amount) external;
function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external;
function unstake(address _depositToken, uint256 _amount) external;
function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external;
function tokensPerInterval() external view returns (uint256);
function claim(address _receiver) external returns (uint256);
function claimForAccount(address _account, address _receiver) external returns (uint256);
function claimable(address _account) external view returns (uint256);
function averageStakedAmounts(address _account) external view returns (uint256);
function cumulativeRewards(address _account) external view returns (uint256);
}
contracts/staking/interfaces/IVester.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
interface IVester {
function rewardTracker() external view returns (address);
function claimForAccount(address _account, address _receiver) external returns (uint256);
function claimable(address _account) external view returns (uint256);
function cumulativeClaimAmounts(address _account) external view returns (uint256);
function claimedAmounts(address _account) external view returns (uint256);
function pairAmounts(address _account) external view returns (uint256);
function getVestedAmount(address _account) external view returns (uint256);
function transferredAverageStakedAmounts(address _account) external view returns (uint256);
function transferredCumulativeRewards(address _account) external view returns (uint256);
function cumulativeRewardDeductions(address _account) external view returns (uint256);
function bonusRewards(address _account) external view returns (uint256);
function transferStakeValues(address _sender, address _receiver) external;
function setTransferredAverageStakedAmounts(address _account, uint256 _amount) external;
function setTransferredCumulativeRewards(address _account, uint256 _amount) external;
function setCumulativeRewardDeductions(address _account, uint256 _amount) external;
function setBonusRewards(address _account, uint256 _amount) external;
function getMaxVestableAmount(address _account) external view returns (uint256);
function getCombinedAverageStakedAmount(address _account) external view returns (uint256);
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":8,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","inputs":[{"type":"address","name":"_esAxn","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"admin","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"esAxn","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"send","inputs":[{"type":"address","name":"_vester","internalType":"contract IVester"},{"type":"uint256","name":"_minRatio","internalType":"uint256"},{"type":"address[]","name":"_accounts","internalType":"address[]"},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50604051610a3c380380610a3c8339818101604052602081101561003357600080fd5b5051600080546001600160a01b03199081163317909155600180546001600160a01b03909316929091169190911790556109ca806100726000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80638b8f837b146100465780639af7408014610180578063f851a440146101a4575b600080fd5b61017e6004803603608081101561005c57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561008b57600080fd5b82018360208201111561009d57600080fd5b803590602001918460208302840111600160201b831117156100be57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561010d57600080fd5b82018360208201111561011f57600080fd5b803590602001918460208302840111600160201b8311171561014057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506101ac945050505050565b005b61018861071e565b604080516001600160a01b039092168252519081900360200190f35b61018861072d565b6000546001600160a01b03163314610209576040805162461bcd60e51b815260206004820152601b60248201527a22b9a0bc372130ba31b429b2b73232b91d103337b93134b23232b760291b604482015290519081900360640190fd5b6000846001600160a01b0316636bcb411a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561024457600080fd5b505afa158015610258573d6000803e3d6000fd5b505050506040513d602081101561026e57600080fd5b5051905060005b83518110156107165760015484516001600160a01b03909116906323b872dd9033908790859081106102a357fe5b60200260200101518685815181106102b757fe5b60200260200101516040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b15801561031557600080fd5b505af1158015610329573d6000803e3d6000fd5b505050506040513d602081101561033f57600080fd5b505082516000906103f09085908490811061035657fe5b6020026020010151886001600160a01b031663b71bce2a88868151811061037957fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156103be57600080fd5b505afa1580156103d2573d6000803e3d6000fd5b505050506040513d60208110156103e857600080fd5b50519061073c565b9050866001600160a01b031663d0b038b786848151811061040d57fe5b6020026020010151836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561045c57600080fd5b505af1158015610470573d6000803e3d6000fd5b505050506000836001600160a01b0316633792def387858151811061049157fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156104d657600080fd5b505afa1580156104ea573d6000803e3d6000fd5b505050506040513d602081101561050057600080fd5b505190506000610510828461073c565b90506000896001600160a01b03166345f01ee689878151811061052f57fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561057457600080fd5b505afa158015610588573d6000803e3d6000fd5b505050506040513d602081101561059e57600080fd5b505190506105ac828a61079d565b8111156105bc575050505061070e565b60006105c88a8461079d565b905061067461066d84610667878b6001600160a01b031663a31802178f8d815181106105f057fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561063557600080fd5b505afa158015610649573d6000803e3d6000fd5b505050506040513d602081101561065f57600080fd5b50519061079d565b906107f6565b8290610835565b905061068485610667838661079d565b90508a6001600160a01b031663e3ecc4b28a88815181106106a157fe5b6020026020010151836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156106f057600080fd5b505af1158015610704573d6000803e3d6000fd5b5050505050505050505b600101610275565b505050505050565b6001546001600160a01b031681565b6000546001600160a01b031681565b600082820183811015610794576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b90505b92915050565b6000826107ac57506000610797565b828202828482816107b957fe5b04146107945760405162461bcd60e51b81526004018080602001828103825260218152602001806109746021913960400191505060405180910390fd5b600061079483836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250610877565b600061079483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610919565b600081836109035760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108c85781810151838201526020016108b0565b50505050905090810190601f1680156108f55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161090f57fe5b0495945050505050565b6000818484111561096b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108c85781810151838201526020016108b0565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220ddec5bf2442f8f867bbfe7ee02d37eaf38afb0d893404f20cddeb6154c5a18bf64736f6c634300060c0033000000000000000000000000f0449ce85a224c33a62c7d6e3cd0225440a0ff88
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80638b8f837b146100465780639af7408014610180578063f851a440146101a4575b600080fd5b61017e6004803603608081101561005c57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b81111561008b57600080fd5b82018360208201111561009d57600080fd5b803590602001918460208302840111600160201b831117156100be57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561010d57600080fd5b82018360208201111561011f57600080fd5b803590602001918460208302840111600160201b8311171561014057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506101ac945050505050565b005b61018861071e565b604080516001600160a01b039092168252519081900360200190f35b61018861072d565b6000546001600160a01b03163314610209576040805162461bcd60e51b815260206004820152601b60248201527a22b9a0bc372130ba31b429b2b73232b91d103337b93134b23232b760291b604482015290519081900360640190fd5b6000846001600160a01b0316636bcb411a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561024457600080fd5b505afa158015610258573d6000803e3d6000fd5b505050506040513d602081101561026e57600080fd5b5051905060005b83518110156107165760015484516001600160a01b03909116906323b872dd9033908790859081106102a357fe5b60200260200101518685815181106102b757fe5b60200260200101516040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b15801561031557600080fd5b505af1158015610329573d6000803e3d6000fd5b505050506040513d602081101561033f57600080fd5b505082516000906103f09085908490811061035657fe5b6020026020010151886001600160a01b031663b71bce2a88868151811061037957fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156103be57600080fd5b505afa1580156103d2573d6000803e3d6000fd5b505050506040513d60208110156103e857600080fd5b50519061073c565b9050866001600160a01b031663d0b038b786848151811061040d57fe5b6020026020010151836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561045c57600080fd5b505af1158015610470573d6000803e3d6000fd5b505050506000836001600160a01b0316633792def387858151811061049157fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156104d657600080fd5b505afa1580156104ea573d6000803e3d6000fd5b505050506040513d602081101561050057600080fd5b505190506000610510828461073c565b90506000896001600160a01b03166345f01ee689878151811061052f57fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561057457600080fd5b505afa158015610588573d6000803e3d6000fd5b505050506040513d602081101561059e57600080fd5b505190506105ac828a61079d565b8111156105bc575050505061070e565b60006105c88a8461079d565b905061067461066d84610667878b6001600160a01b031663a31802178f8d815181106105f057fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561063557600080fd5b505afa158015610649573d6000803e3d6000fd5b505050506040513d602081101561065f57600080fd5b50519061079d565b906107f6565b8290610835565b905061068485610667838661079d565b90508a6001600160a01b031663e3ecc4b28a88815181106106a157fe5b6020026020010151836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156106f057600080fd5b505af1158015610704573d6000803e3d6000fd5b5050505050505050505b600101610275565b505050505050565b6001546001600160a01b031681565b6000546001600160a01b031681565b600082820183811015610794576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b90505b92915050565b6000826107ac57506000610797565b828202828482816107b957fe5b04146107945760405162461bcd60e51b81526004018080602001828103825260218152602001806109746021913960400191505060405180910390fd5b600061079483836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250610877565b600061079483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610919565b600081836109035760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108c85781810151838201526020016108b0565b50505050905090810190601f1680156108f55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161090f57fe5b0495945050505050565b6000818484111561096b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156108c85781810151838201526020016108b0565b50505090039056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220ddec5bf2442f8f867bbfe7ee02d37eaf38afb0d893404f20cddeb6154c5a18bf64736f6c634300060c0033