diff --git a/.solcover.js b/.solcover.js index dbe8cc0b..1d15d051 100644 --- a/.solcover.js +++ b/.solcover.js @@ -6,7 +6,7 @@ module.exports = { timeout: 100000, }, configureYulOptimizer: true, - skipFiles: ['test/', 'mocks/', 'HATArbitrator.sol', 'HATKlerosV2Connector.sol'], + skipFiles: ['test/', 'mocks/', 'HATArbitrator.sol', 'HATKlerosV2Connector.sol', 'tge/HATAirdropFactory.sol'], providerOptions: { accounts: [ { diff --git a/contracts/tge/HATAirdrop.sol b/contracts/tge/HATAirdrop.sol index 945e8318..964ec48f 100644 --- a/contracts/tge/HATAirdrop.sol +++ b/contracts/tge/HATAirdrop.sol @@ -18,6 +18,7 @@ contract HATAirdrop is IHATAirdrop, Initializable { error InvalidMerkleProof(); error CannotRecoverBeforeDeadline(); error RedeemerMustBeBeneficiary(); + error InvalidAmountToDeposit(); using SafeERC20Upgradeable for IERC20Upgradeable; @@ -71,7 +72,7 @@ contract HATAirdrop is IHATAirdrop, Initializable { emit MerkleTreeSet(_merkleTreeIPFSRef, _root, _startTime, _deadline); } - function redeem(address _account, uint256 _amount, bytes32[] calldata _proof) external { + function redeem(address _account, uint256 _amount, bytes32[] calldata _proof, IHATVault _depositIntoVault, uint256 _amountToDeposit, uint256 _minShares) external { if (msg.sender != _account && msg.sender != factory) { revert RedeemerMustBeBeneficiary(); } @@ -102,7 +103,17 @@ contract HATAirdrop is IHATAirdrop, Initializable { ); token.safeTransferFrom(factory, _tokenLock, _amount); } else { - token.safeTransferFrom(factory, _account, _amount); + if (address(_depositIntoVault) != address(0)) { + if (_amountToDeposit > _amount || _amountToDeposit == 0) { + revert InvalidAmountToDeposit(); + } + token.safeApprove(address(_depositIntoVault), _amountToDeposit); + token.safeTransferFrom(factory, address(this), _amountToDeposit); + _depositIntoVault.deposit(_amountToDeposit, _account, _minShares); + token.safeTransferFrom(factory, _account, _amount - _amountToDeposit); + } else { + token.safeTransferFrom(factory, _account, _amount); + } } emit TokensRedeemed(_account, _tokenLock, _amount); diff --git a/contracts/tge/HATAirdropFactory.sol b/contracts/tge/HATAirdropFactory.sol index de34f4a3..5cce2397 100644 --- a/contracts/tge/HATAirdropFactory.sol +++ b/contracts/tge/HATAirdropFactory.sol @@ -9,6 +9,7 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IHATAirdrop.sol"; import "../interfaces/IHATToken.sol"; +import "../interfaces/IHATVault.sol"; contract HATAirdropFactory is Ownable { error RedeemDataArraysLengthMismatch(); @@ -33,8 +34,20 @@ contract HATAirdropFactory is Ownable { emit TokensWithdrawn(owner, _amount); } - function redeemMultipleAirdrops(IHATAirdrop[] calldata _airdrops, uint256[] calldata _amounts, bytes32[][] calldata _proofs) public { - if (_airdrops.length != _amounts.length || _airdrops.length != _proofs.length) { + function redeemMultipleAirdrops( + IHATAirdrop[] calldata _airdrops, + uint256[] calldata _amounts, + bytes32[][] calldata _proofs, + IHATVault[] calldata _depositIntoVaults, + uint256[] calldata _amountsToDeposit, + uint256[] calldata _minShares + ) public { + if ( + _airdrops.length != _amounts.length || + _airdrops.length != _proofs.length || + _airdrops.length != _depositIntoVaults.length || + _airdrops.length != _amountsToDeposit.length || + _airdrops.length != _minShares.length) { revert RedeemDataArraysLengthMismatch(); } @@ -44,7 +57,7 @@ contract HATAirdropFactory is Ownable { revert ContractIsNotHATAirdrop(); } - _airdrops[i].redeem(caller, _amounts[i], _proofs[i]); + _airdrops[i].redeem(caller, _amounts[i], _proofs[i], _depositIntoVaults[i], _amountsToDeposit[i], _minShares[i]); unchecked { ++i; @@ -56,6 +69,9 @@ contract HATAirdropFactory is Ownable { IHATAirdrop[] calldata _airdrops, uint256[] calldata _amounts, bytes32[][] calldata _proofs, + IHATVault[] calldata _depositIntoVaults, + uint256[] calldata _amountsToDeposit, + uint256[] calldata _minShares, address _delegatee, uint256 _nonce, uint256 _expiry, @@ -63,7 +79,7 @@ contract HATAirdropFactory is Ownable { bytes32 _r, bytes32 _s ) external { - redeemMultipleAirdrops(_airdrops, _amounts, _proofs); + redeemMultipleAirdrops(_airdrops, _amounts, _proofs, _depositIntoVaults, _amountsToDeposit, _minShares); HAT.delegateBySig(_delegatee, _nonce, _expiry, _v, _r, _s); } diff --git a/contracts/tge/interfaces/IHATAirdrop.sol b/contracts/tge/interfaces/IHATAirdrop.sol index a9c5f2f1..f37d729f 100644 --- a/contracts/tge/interfaces/IHATAirdrop.sol +++ b/contracts/tge/interfaces/IHATAirdrop.sol @@ -3,7 +3,9 @@ pragma solidity 0.8.16; +import "../../interfaces/IHATVault.sol"; + interface IHATAirdrop { - function redeem(address _account, uint256 _amount, bytes32[] calldata _proof) external; + function redeem(address _account, uint256 _amount, bytes32[] calldata _proof, IHATVault _depositIntoVault, uint256 _amountToDeposit, uint256 _minShares) external; } \ No newline at end of file diff --git a/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.md b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.md new file mode 100644 index 00000000..cf74c636 --- /dev/null +++ b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.md @@ -0,0 +1,686 @@ +# ERC4626Upgradeable + + + + + + + +*Implementation of the ERC4626 "Tokenized Vault Standard" as defined in https://eips.ethereum.org/EIPS/eip-4626[EIP-4626]. This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this contract and not the "assets" token which is an independent contract. CAUTION: When the vault is empty or nearly empty, deposits are at high risk of being stolen through frontrunning with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may similarly be affected by slippage. Users can protect against this attack as well unexpected slippage in general by verifying the amount received is as expected, using a wrapper that performs these checks such as https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router]. _Available since v4.7._* + +## Methods + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*See {IERC20-allowance}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### asset + +```solidity +function asset() external view returns (address) +``` + + + +*See {IERC4626-asset}. * + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*See {IERC20-balanceOf}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### convertToAssets + +```solidity +function convertToAssets(uint256 shares) external view returns (uint256 assets) +``` + + + +*See {IERC4626-convertToAssets}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +### convertToShares + +```solidity +function convertToShares(uint256 assets) external view returns (uint256 shares) +``` + + + +*See {IERC4626-convertToShares}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + +*Decimals are read from the underlying asset in the constructor and cached. If this fails (e.g., the asset has not been created yet), the cached value is set to a default obtained by `super.decimals()` (which depends on inheritance but is most likely 18). Override this function in order to set a guaranteed hardcoded value. See {IERC20Metadata-decimals}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### decreaseAllowance + +```solidity +function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool) +``` + + + +*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`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| subtractedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### deposit + +```solidity +function deposit(uint256 assets, address receiver) external nonpayable returns (uint256) +``` + + + +*See {IERC4626-deposit}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | +| receiver | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### increaseAllowance + +```solidity +function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| addedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### maxDeposit + +```solidity +function maxDeposit(address) external view returns (uint256) +``` + + + +*See {IERC4626-maxDeposit}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxMint + +```solidity +function maxMint(address) external view returns (uint256) +``` + + + +*See {IERC4626-maxMint}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxRedeem + +```solidity +function maxRedeem(address owner) external view returns (uint256) +``` + + + +*See {IERC4626-maxRedeem}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxWithdraw + +```solidity +function maxWithdraw(address owner) external view returns (uint256) +``` + + + +*See {IERC4626-maxWithdraw}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### mint + +```solidity +function mint(uint256 shares, address receiver) external nonpayable returns (uint256) +``` + + + +*See {IERC4626-mint}. As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero. In this case, the shares will be minted without requiring any assets to be deposited.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | +| receiver | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + +*Returns the name of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### previewDeposit + +```solidity +function previewDeposit(uint256 assets) external view returns (uint256) +``` + + + +*See {IERC4626-previewDeposit}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewMint + +```solidity +function previewMint(uint256 shares) external view returns (uint256) +``` + + + +*See {IERC4626-previewMint}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewRedeem + +```solidity +function previewRedeem(uint256 shares) external view returns (uint256) +``` + + + +*See {IERC4626-previewRedeem}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewWithdraw + +```solidity +function previewWithdraw(uint256 assets) external view returns (uint256) +``` + + + +*See {IERC4626-previewWithdraw}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### redeem + +```solidity +function redeem(uint256 shares, address receiver, address owner) external nonpayable returns (uint256) +``` + + + +*See {IERC4626-redeem}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | +| receiver | address | undefined | +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + +*Returns the symbol of the token, usually a shorter version of the name.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalAssets + +```solidity +function totalAssets() external view returns (uint256) +``` + + + +*See {IERC4626-totalAssets}. * + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*See {IERC20-totalSupply}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*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}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### withdraw + +```solidity +function withdraw(uint256 assets, address receiver, address owner) external nonpayable returns (uint256) +``` + + + +*See {IERC4626-withdraw}. * + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | +| receiver | address | undefined | +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Deposit + +```solidity +event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| sender `indexed` | address | undefined | +| owner `indexed` | address | undefined | +| assets | uint256 | undefined | +| shares | uint256 | undefined | + +### Initialized + +```solidity +event Initialized(uint8 version) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| version | uint8 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + +### Withdraw + +```solidity +event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| sender `indexed` | address | undefined | +| receiver `indexed` | address | undefined | +| owner `indexed` | address | undefined | +| assets | uint256 | undefined | +| shares | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.md b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.md new file mode 100644 index 00000000..59c1b46a --- /dev/null +++ b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.md @@ -0,0 +1,237 @@ +# IERC20MetadataUpgradeable + + + + + + + +*Interface for the optional metadata functions from the ERC20 standard. _Available since v4.1._* + +## Methods + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*Returns the amount of tokens owned by `account`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + +*Returns the decimals places of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + +*Returns the name of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + +*Returns the symbol of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*Returns the amount of tokens in existence.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*Moves `amount` tokens from `from` to `to` 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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.md b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.md new file mode 100644 index 00000000..0798f09a --- /dev/null +++ b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.md @@ -0,0 +1,76 @@ +# IERC20PermitUpgradeable + + + + + + + +*Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't need to send a transaction, and thus is not required to hold Ether at all.* + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + +*Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### nonces + +```solidity +function nonces(address owner) external view returns (uint256) +``` + + + +*Returns the current 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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + +*Sets `value` 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: - `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].* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + + + + diff --git a/docs/dodoc/elin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.md b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.md new file mode 100644 index 00000000..77a1b122 --- /dev/null +++ b/docs/dodoc/elin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.md @@ -0,0 +1,12 @@ +# SafeERC20Upgradeable + + + +> SafeERC20 + + + +*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.* + + + diff --git a/docs/dodoc/elin/contracts-upgradeable/utils/StringsUpgradeable.md b/docs/dodoc/elin/contracts-upgradeable/utils/StringsUpgradeable.md deleted file mode 100644 index 84464ba8..00000000 --- a/docs/dodoc/elin/contracts-upgradeable/utils/StringsUpgradeable.md +++ /dev/null @@ -1,12 +0,0 @@ -# StringsUpgradeable - - - - - - - -*String operations.* - - - diff --git a/docs/dodoc/elin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.md b/docs/dodoc/elin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.md deleted file mode 100644 index 5035a7b7..00000000 --- a/docs/dodoc/elin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.md +++ /dev/null @@ -1,12 +0,0 @@ -# ECDSAUpgradeable - - - - - - - -*Elliptic Curve Digital Signature Algorithm (ECDSA) operations. These functions can be used to verify that a message was signed by the holder of the private keys of a given address.* - - - diff --git a/docs/dodoc/elin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.md b/docs/dodoc/elin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.md deleted file mode 100644 index 750d8549..00000000 --- a/docs/dodoc/elin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.md +++ /dev/null @@ -1,31 +0,0 @@ -# EIP712Upgradeable - - - - - - - -*https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in their contracts using a combination of `abi.encode` and `keccak256`. This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA ({_hashTypedDataV4}). The implementation of the domain separator was designed to be as efficient as possible while still properly updating the chain id to protect against replay attacks on an eventual fork of the chain. NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. _Available since v3.4._* - - -## Events - -### Initialized - -```solidity -event Initialized(uint8 version) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| version | uint8 | undefined | - - - diff --git a/docs/dodoc/elin/contracts/token/ERC1155/extensions/ERC1155Supply.md b/docs/dodoc/elin/contracts/token/ERC1155/extensions/ERC1155Supply.md new file mode 100644 index 00000000..320b4e3b --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC1155/extensions/ERC1155Supply.md @@ -0,0 +1,307 @@ +# ERC1155Supply + + + + + + + +*Extension of ERC1155 that adds tracking of total supply per id. Useful for scenarios where Fungible and Non-fungible tokens have to be clearly identified. Note: While a totalSupply of 1 might mean the corresponding is an NFT, there is no guarantees that no other token with the same id are not going to be minted.* + +## Methods + +### balanceOf + +```solidity +function balanceOf(address account, uint256 id) external view returns (uint256) +``` + + + +*See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### balanceOfBatch + +```solidity +function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[]) +``` + + + +*See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have the same length.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| accounts | address[] | undefined | +| ids | uint256[] | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256[] | undefined | + +### exists + +```solidity +function exists(uint256 id) external view returns (bool) +``` + + + +*Indicates whether any token exist with a given id, or not.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### isApprovedForAll + +```solidity +function isApprovedForAll(address account, address operator) external view returns (bool) +``` + + + +*See {IERC1155-isApprovedForAll}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | +| operator | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### safeBatchTransferFrom + +```solidity +function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external nonpayable +``` + + + +*See {IERC1155-safeBatchTransferFrom}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| ids | uint256[] | undefined | +| amounts | uint256[] | undefined | +| data | bytes | undefined | + +### safeTransferFrom + +```solidity +function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external nonpayable +``` + + + +*See {IERC1155-safeTransferFrom}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| id | uint256 | undefined | +| amount | uint256 | undefined | +| data | bytes | undefined | + +### setApprovalForAll + +```solidity +function setApprovalForAll(address operator, bool approved) external nonpayable +``` + + + +*See {IERC1155-setApprovalForAll}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator | address | undefined | +| approved | bool | undefined | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + + + +*See {IERC165-supportsInterface}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### totalSupply + +```solidity +function totalSupply(uint256 id) external view returns (uint256) +``` + + + +*Total amount of tokens in with a given id.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### uri + +```solidity +function uri(uint256) external view returns (string) +``` + + + +*See {IERC1155MetadataURI-uri}. This implementation returns the same URI for *all* token types. It relies on the token type ID substitution mechanism https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. Clients calling this function must replace the `\{id\}` substring with the actual token type ID.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + + + +## Events + +### ApprovalForAll + +```solidity +event ApprovalForAll(address indexed account, address indexed operator, bool approved) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account `indexed` | address | undefined | +| operator `indexed` | address | undefined | +| approved | bool | undefined | + +### TransferBatch + +```solidity +event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| ids | uint256[] | undefined | +| values | uint256[] | undefined | + +### TransferSingle + +```solidity +event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| id | uint256 | undefined | +| value | uint256 | undefined | + +### URI + +```solidity +event URI(string value, uint256 indexed id) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| value | string | undefined | +| id `indexed` | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.md b/docs/dodoc/elin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.md new file mode 100644 index 00000000..44660a40 --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.md @@ -0,0 +1,263 @@ +# IERC1155MetadataURI + + + + + + + +*Interface of the optional ERC1155MetadataExtension interface, as defined in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. _Available since v3.1._* + +## Methods + +### balanceOf + +```solidity +function balanceOf(address account, uint256 id) external view returns (uint256) +``` + + + +*Returns the amount of tokens of token type `id` owned by `account`. Requirements: - `account` cannot be the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### balanceOfBatch + +```solidity +function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[]) +``` + + + +*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. Requirements: - `accounts` and `ids` must have the same length.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| accounts | address[] | undefined | +| ids | uint256[] | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256[] | undefined | + +### isApprovedForAll + +```solidity +function isApprovedForAll(address account, address operator) external view returns (bool) +``` + + + +*Returns true if `operator` is approved to transfer ``account``'s tokens. See {setApprovalForAll}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | +| operator | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### safeBatchTransferFrom + +```solidity +function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external nonpayable +``` + + + +*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. Emits a {TransferBatch} event. Requirements: - `ids` and `amounts` must have the same length. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| ids | uint256[] | undefined | +| amounts | uint256[] | undefined | +| data | bytes | undefined | + +### safeTransferFrom + +```solidity +function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external nonpayable +``` + + + +*Transfers `amount` tokens of token type `id` from `from` to `to`. Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address. - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. - `from` must have a balance of tokens of type `id` of at least `amount`. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| id | uint256 | undefined | +| amount | uint256 | undefined | +| data | bytes | undefined | + +### setApprovalForAll + +```solidity +function setApprovalForAll(address operator, bool approved) external nonpayable +``` + + + +*Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, Emits an {ApprovalForAll} event. Requirements: - `operator` cannot be the caller.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator | address | undefined | +| approved | bool | undefined | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + + + +*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### uri + +```solidity +function uri(uint256 id) external view returns (string) +``` + + + +*Returns the URI for token type `id`. If the `\{id\}` substring is present in the URI, it must be replaced by clients with the actual token type ID.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + + + +## Events + +### ApprovalForAll + +```solidity +event ApprovalForAll(address indexed account, address indexed operator, bool approved) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account `indexed` | address | undefined | +| operator `indexed` | address | undefined | +| approved | bool | undefined | + +### TransferBatch + +```solidity +event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| ids | uint256[] | undefined | +| values | uint256[] | undefined | + +### TransferSingle + +```solidity +event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| id | uint256 | undefined | +| value | uint256 | undefined | + +### URI + +```solidity +event URI(string value, uint256 indexed id) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| value | string | undefined | +| id `indexed` | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Capped.md b/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Capped.md new file mode 100644 index 00000000..cc451fc9 --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Capped.md @@ -0,0 +1,300 @@ +# ERC20Capped + + + + + + + +*Extension of {ERC20} that adds a cap to the supply of tokens.* + +## Methods + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*See {IERC20-allowance}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*See {IERC20-balanceOf}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### cap + +```solidity +function cap() external view returns (uint256) +``` + + + +*Returns the cap on the token's total supply.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + +*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}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### decreaseAllowance + +```solidity +function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool) +``` + + + +*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`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| subtractedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### increaseAllowance + +```solidity +function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| addedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + +*Returns the name of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + +*Returns the symbol of the token, usually a shorter version of the name.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*See {IERC20-totalSupply}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*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}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Permit.md b/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Permit.md new file mode 100644 index 00000000..eab3aff0 --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Permit.md @@ -0,0 +1,344 @@ +# ERC20Permit + + + + + + + +*Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't need to send a transaction, and thus is not required to hold Ether at all. _Available since v3.4._* + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + +*See {IERC20Permit-DOMAIN_SEPARATOR}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*See {IERC20-allowance}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*See {IERC20-balanceOf}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + +*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}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### decreaseAllowance + +```solidity +function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool) +``` + + + +*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`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| subtractedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### increaseAllowance + +```solidity +function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| addedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + +*Returns the name of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### nonces + +```solidity +function nonces(address owner) external view returns (uint256) +``` + + + +*See {IERC20Permit-nonces}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + +*See {IERC20Permit-permit}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + +*Returns the symbol of the token, usually a shorter version of the name.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*See {IERC20-totalSupply}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*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}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Votes.md b/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Votes.md new file mode 100644 index 00000000..f75fd4ae --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC20/extensions/ERC20Votes.md @@ -0,0 +1,551 @@ +# ERC20Votes + + + + + + + +*Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's, and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1. NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting power can be queried through the public accessors {getVotes} and {getPastVotes}. By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. _Available since v4.2._* + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + +*See {IERC20Permit-DOMAIN_SEPARATOR}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*See {IERC20-allowance}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*See {IERC20-balanceOf}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### checkpoints + +```solidity +function checkpoints(address account, uint32 pos) external view returns (struct ERC20Votes.Checkpoint) +``` + + + +*Get the `pos`-th checkpoint for `account`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | +| pos | uint32 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | ERC20Votes.Checkpoint | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + +*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}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### decreaseAllowance + +```solidity +function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool) +``` + + + +*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`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| subtractedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### delegate + +```solidity +function delegate(address delegatee) external nonpayable +``` + + + +*Delegate votes from the sender to `delegatee`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| delegatee | address | undefined | + +### delegateBySig + +```solidity +function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + +*Delegates votes from signer to `delegatee`* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| delegatee | address | undefined | +| nonce | uint256 | undefined | +| expiry | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### delegates + +```solidity +function delegates(address account) external view returns (address) +``` + + + +*Get the address `account` is currently delegating to.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### getPastTotalSupply + +```solidity +function getPastTotalSupply(uint256 blockNumber) external view returns (uint256) +``` + + + +*Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. It is but NOT the sum of all the delegated votes! Requirements: - `blockNumber` must have been already mined* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| blockNumber | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getPastVotes + +```solidity +function getPastVotes(address account, uint256 blockNumber) external view returns (uint256) +``` + + + +*Retrieve the number of votes for `account` at the end of `blockNumber`. Requirements: - `blockNumber` must have been already mined* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | +| blockNumber | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getVotes + +```solidity +function getVotes(address account) external view returns (uint256) +``` + + + +*Gets the current votes balance for `account`* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### increaseAllowance + +```solidity +function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| addedValue | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + +*Returns the name of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### nonces + +```solidity +function nonces(address owner) external view returns (uint256) +``` + + + +*See {IERC20Permit-nonces}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### numCheckpoints + +```solidity +function numCheckpoints(address account) external view returns (uint32) +``` + + + +*Get number of checkpoints for `account`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + +*See {IERC20Permit-permit}.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + +*Returns the symbol of the token, usually a shorter version of the name.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*See {IERC20-totalSupply}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*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}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### DelegateChanged + +```solidity +event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| delegator `indexed` | address | undefined | +| fromDelegate `indexed` | address | undefined | +| toDelegate `indexed` | address | undefined | + +### DelegateVotesChanged + +```solidity +event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| delegate `indexed` | address | undefined | +| previousBalance | uint256 | undefined | +| newBalance | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts/token/ERC20/extensions/IERC20Metadata.md b/docs/dodoc/elin/contracts/token/ERC20/extensions/IERC20Metadata.md new file mode 100644 index 00000000..a4691dab --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC20/extensions/IERC20Metadata.md @@ -0,0 +1,237 @@ +# IERC20Metadata + + + + + + + +*Interface for the optional metadata functions from the ERC20 standard. _Available since v4.1._* + +## Methods + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + +*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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### balanceOf + +```solidity +function balanceOf(address account) external view returns (uint256) +``` + + + +*Returns the amount of tokens owned by `account`.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| account | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + +*Returns the decimals places of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + +*Returns the name of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + +*Returns the symbol of the token.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + +*Returns the amount of tokens in existence.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + +*Moves `amount` tokens from `from` to `to` 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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/dodoc/elin/contracts/token/ERC20/extensions/IERC20Permit.md b/docs/dodoc/elin/contracts/token/ERC20/extensions/IERC20Permit.md new file mode 100644 index 00000000..5a8ae501 --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC20/extensions/IERC20Permit.md @@ -0,0 +1,76 @@ +# IERC20Permit + + + + + + + +*Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't need to send a transaction, and thus is not required to hold Ether at all.* + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + +*Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### nonces + +```solidity +function nonces(address owner) external view returns (uint256) +``` + + + +*Returns the current 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.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + +*Sets `value` 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: - `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].* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + + + + diff --git a/docs/dodoc/elin/contracts/token/ERC20/utils/SafeERC20.md b/docs/dodoc/elin/contracts/token/ERC20/utils/SafeERC20.md new file mode 100644 index 00000000..80367d00 --- /dev/null +++ b/docs/dodoc/elin/contracts/token/ERC20/utils/SafeERC20.md @@ -0,0 +1,12 @@ +# SafeERC20 + + + +> SafeERC20 + + + +*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.* + + + diff --git a/docs/dodoc/tge/HATAirdrop.md b/docs/dodoc/tge/HATAirdrop.md index 9547c337..28c85f29 100644 --- a/docs/dodoc/tge/HATAirdrop.md +++ b/docs/dodoc/tge/HATAirdrop.md @@ -126,7 +126,7 @@ function periods() external view returns (uint256) ### redeem ```solidity -function redeem(address _account, uint256 _amount, bytes32[] _proof) external nonpayable +function redeem(address _account, uint256 _amount, bytes32[] _proof, contract IHATVault _depositIntoVault, uint256 _amountToDeposit, uint256 _minShares) external nonpayable ``` @@ -140,6 +140,9 @@ function redeem(address _account, uint256 _amount, bytes32[] _proof) external no | _account | address | undefined | | _amount | uint256 | undefined | | _proof | bytes32[] | undefined | +| _depositIntoVault | contract IHATVault | undefined | +| _amountToDeposit | uint256 | undefined | +| _minShares | uint256 | undefined | ### root @@ -303,6 +306,17 @@ error CannotRedeemBeforeStartTime() +### InvalidAmountToDeposit + +```solidity +error InvalidAmountToDeposit() +``` + + + + + + ### InvalidMerkleProof ```solidity diff --git a/docs/dodoc/tge/HATAirdropFactory.md b/docs/dodoc/tge/HATAirdropFactory.md index ab5c1086..89e8d0ad 100644 --- a/docs/dodoc/tge/HATAirdropFactory.md +++ b/docs/dodoc/tge/HATAirdropFactory.md @@ -117,7 +117,7 @@ function predictHATAirdropAddress(address _implementation, bytes _initData) exte ### redeemAndDelegateMultipleAirdrops ```solidity -function redeemAndDelegateMultipleAirdrops(contract IHATAirdrop[] _airdrops, uint256[] _amounts, bytes32[][] _proofs, address _delegatee, uint256 _nonce, uint256 _expiry, uint8 _v, bytes32 _r, bytes32 _s) external nonpayable +function redeemAndDelegateMultipleAirdrops(contract IHATAirdrop[] _airdrops, uint256[] _amounts, bytes32[][] _proofs, contract IHATVault[] _depositIntoVaults, uint256[] _amountsToDeposit, uint256[] _minShares, address _delegatee, uint256 _nonce, uint256 _expiry, uint8 _v, bytes32 _r, bytes32 _s) external nonpayable ``` @@ -131,6 +131,9 @@ function redeemAndDelegateMultipleAirdrops(contract IHATAirdrop[] _airdrops, uin | _airdrops | contract IHATAirdrop[] | undefined | | _amounts | uint256[] | undefined | | _proofs | bytes32[][] | undefined | +| _depositIntoVaults | contract IHATVault[] | undefined | +| _amountsToDeposit | uint256[] | undefined | +| _minShares | uint256[] | undefined | | _delegatee | address | undefined | | _nonce | uint256 | undefined | | _expiry | uint256 | undefined | @@ -141,7 +144,7 @@ function redeemAndDelegateMultipleAirdrops(contract IHATAirdrop[] _airdrops, uin ### redeemMultipleAirdrops ```solidity -function redeemMultipleAirdrops(contract IHATAirdrop[] _airdrops, uint256[] _amounts, bytes32[][] _proofs) external nonpayable +function redeemMultipleAirdrops(contract IHATAirdrop[] _airdrops, uint256[] _amounts, bytes32[][] _proofs, contract IHATVault[] _depositIntoVaults, uint256[] _amountsToDeposit, uint256[] _minShares) external nonpayable ``` @@ -155,6 +158,9 @@ function redeemMultipleAirdrops(contract IHATAirdrop[] _airdrops, uint256[] _amo | _airdrops | contract IHATAirdrop[] | undefined | | _amounts | uint256[] | undefined | | _proofs | bytes32[][] | undefined | +| _depositIntoVaults | contract IHATVault[] | undefined | +| _amountsToDeposit | uint256[] | undefined | +| _minShares | uint256[] | undefined | ### renounceOwnership diff --git a/docs/dodoc/tge/interfaces/IHATAirdrop.md b/docs/dodoc/tge/interfaces/IHATAirdrop.md index 3edd6a87..db431742 100644 --- a/docs/dodoc/tge/interfaces/IHATAirdrop.md +++ b/docs/dodoc/tge/interfaces/IHATAirdrop.md @@ -13,7 +13,7 @@ ### redeem ```solidity -function redeem(address _account, uint256 _amount, bytes32[] _proof) external nonpayable +function redeem(address _account, uint256 _amount, bytes32[] _proof, contract IHATVault _depositIntoVault, uint256 _amountToDeposit, uint256 _minShares) external nonpayable ``` @@ -27,6 +27,9 @@ function redeem(address _account, uint256 _amount, bytes32[] _proof) external no | _account | address | undefined | | _amount | uint256 | undefined | | _proof | bytes32[] | undefined | +| _depositIntoVault | contract IHATVault | undefined | +| _amountToDeposit | uint256 | undefined | +| _minShares | uint256 | undefined | diff --git a/hardhat.config.coverage.js b/hardhat.config.coverage.js index c423bbf0..c65b71e4 100644 --- a/hardhat.config.coverage.js +++ b/hardhat.config.coverage.js @@ -7,7 +7,7 @@ subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS) .setAction(async (_, __, runSuper) => { const paths = await runSuper(); // exclude HATAtribritaor as it only compiles with viaIR = true (which does not work with coverage) - return paths.filter(p => !p.endsWith("HATArbitrator.sol") && !p.endsWith("ConnectorMock.sol")); + return paths.filter(p => !p.endsWith("HATArbitrator.sol") && !p.endsWith("ConnectorMock.sol") && !p.endsWith("HATAirdropFactory.sol")); }); config.solidity.settings.viaIR = false; diff --git a/test/common.js b/test/common.js index a6d28c97..c9b73801 100644 --- a/test/common.js +++ b/test/common.js @@ -86,13 +86,17 @@ const setup = async function( rewardInVaults : 2500000, challengePeriod: 60 * 60 * 24, setDefaultArbitrator: true, - isTokenLockRevocable: false + isTokenLockRevocable: false, + stakingToken: null }; options = { ...defaultOptions, ...options}; const committee = accounts[1]; hatToken = await HATTokenMock.new(accounts[0]); await hatToken.setTransferable({from: accounts[0]}); stakingToken = await ERC20Mock.new("Staking", "STK"); + if (options.stakingToken) { + stakingToken = options.stakingToken; + } let wethAddress = utils.NULL_ADDRESS; if (options.weth) { wethAddress = stakingToken.address; diff --git a/test/tge/hatairdrop.js b/test/tge/hatairdrop.js index b4e9b1ad..3d76658a 100644 --- a/test/tge/hatairdrop.js +++ b/test/tge/hatairdrop.js @@ -8,6 +8,7 @@ const IHATAirdrop = new ethers.utils.Interface(HATAirdrop.abi); const { contract, web3 } = require("hardhat"); const { assertFunctionRaisesException, assertVMException, ZERO_ADDRESS, + setup, } = require("../common.js"); const airdropData = require('./airdropData.json'); const { assert } = require("chai"); @@ -16,6 +17,7 @@ const keccak256 = require("keccak256"); const { fromRpcSig } = require("ethereumjs-util"); const ethSigUtil = require("eth-sig-util"); const Wallet = require("ethereumjs-wallet").default; +const MINIMAL_AMOUNT_OF_SHARES = 1000; const EIP712Domain = [ { name: 'name', type: 'string' }, @@ -190,7 +192,15 @@ contract("HATAirdrop", (accounts) => { for (const [account, amount] of Object.entries(airdropData)) { let currentBalance = await token.balanceOf(hatAirdropFactory.address); const proof = merkleTree.getHexProof(hashTokens(account, amount)); - let tx = await hatAirdrop.redeem(accounts[i], amount, proof, { from: accounts[i] }); + let tx = await hatAirdrop.redeem( + accounts[i], + amount, + proof, + ZERO_ADDRESS, + 0, + 0, + { from: accounts[i] } + ); i++; assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); @@ -247,7 +257,15 @@ contract("HATAirdrop", (accounts) => { for (const [account, amount] of Object.entries(airdropData)) { let currentBalance = await token.balanceOf(hatAirdropFactory.address); const proof = merkleTree.getHexProof(hashTokens(account, amount)); - await hatAirdropFactory.redeemMultipleAirdrops([hatAirdrop.address, hatAirdrop2.address], [amount, amount], [proof, proof], { from: accounts[i] }); + await hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address, hatAirdrop2.address], + [amount, amount], + [proof, proof], + [ZERO_ADDRESS, ZERO_ADDRESS], + [0, 0], + [0, 0], + { from: accounts[i] } + ); i++; assert.equal((await token.balanceOf(hatAirdropFactory.address)).toString(), currentBalance.sub(web3.utils.toBN(amount * 2)).toString()); } @@ -308,6 +326,9 @@ contract("HATAirdrop", (accounts) => { [hatAirdrop.address, hatAirdrop2.address], [amount, amount], [proof, proof], + [ZERO_ADDRESS, ZERO_ADDRESS], + [0, 0], + [0, 0], accounts[2], await token.nonces(wallet.getAddressString()), expiry, @@ -347,7 +368,14 @@ contract("HATAirdrop", (accounts) => { const proof = merkleTree.getHexProof(hashTokens(account, amount)); await assertFunctionRaisesException( - hatAirdropFactory.redeemMultipleAirdrops([hatAirdrop.address, accounts[0]], [amount, amount], [proof, proof], { from: accounts[0] }), + hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address, accounts[0]], + [amount, amount], [proof, proof], + [ZERO_ADDRESS, ZERO_ADDRESS], + [0, 0], + [0, 0], + { from: accounts[0] } + ), "ContractIsNotHATAirdrop" ); }); @@ -361,12 +389,67 @@ contract("HATAirdrop", (accounts) => { const proof = merkleTree.getHexProof(hashTokens(account, amount)); await assertFunctionRaisesException( - hatAirdropFactory.redeemMultipleAirdrops([hatAirdrop.address], [amount, amount], [proof, proof], { from: accounts[0] }), + hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address], + [amount, amount], + [proof, proof], + [ZERO_ADDRESS, ZERO_ADDRESS], + [0, 0], + [0, 0], + { from: accounts[0] } + ), + "RedeemDataArraysLengthMismatch" + ); + + await assertFunctionRaisesException( + hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address], + [amount], + [proof, proof], + [ZERO_ADDRESS, ZERO_ADDRESS], + [0, 0], + [0, 0], + { from: accounts[0] } + ), + "RedeemDataArraysLengthMismatch" + ); + + await assertFunctionRaisesException( + hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address], + [amount], + [proof], + [ZERO_ADDRESS, ZERO_ADDRESS], + [0], + [0], + { from: accounts[0] } + ), + "RedeemDataArraysLengthMismatch" + ); + + await assertFunctionRaisesException( + hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address], + [amount], + [proof, proof], + [ZERO_ADDRESS], + [0, 0], + [0], + { from: accounts[0] } + ), "RedeemDataArraysLengthMismatch" ); await assertFunctionRaisesException( - hatAirdropFactory.redeemMultipleAirdrops([hatAirdrop.address], [amount], [proof, proof], { from: accounts[0] }), + hatAirdropFactory.redeemMultipleAirdrops( + [hatAirdrop.address], + [amount], + [proof], + [ZERO_ADDRESS], + [0], + [0, 0], + { from: accounts[0] } + ), "RedeemDataArraysLengthMismatch" ); }); @@ -380,7 +463,15 @@ contract("HATAirdrop", (accounts) => { for (const [account, amount] of Object.entries(airdropData)) { let currentBalance = await token.balanceOf(hatAirdropFactory.address); const proof = merkleTree.getHexProof(hashTokens(account, amount)); - let tx = await hatAirdrop.redeem(accounts[i], amount, proof, { from: accounts[i] }); + let tx = await hatAirdrop.redeem( + accounts[i], + amount, + proof, + ZERO_ADDRESS, + 0, + 0, + { from: accounts[i] } + ); i++; assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); @@ -403,7 +494,15 @@ contract("HATAirdrop", (accounts) => { for (const [account, amount] of Object.entries(airdropData).slice(0, dataLength / 2)) { let currentBalance = await token.balanceOf(hatAirdropFactory.address); const proof = merkleTree.getHexProof(hashTokens(account, amount)); - let tx = await hatAirdrop.redeem(accounts[i], amount, proof, { from: accounts[i] }); + let tx = await hatAirdrop.redeem( + accounts[i], + amount, + proof, + ZERO_ADDRESS, + 0, + 0, + { from: accounts[i] } + ); i++; assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); @@ -430,7 +529,15 @@ contract("HATAirdrop", (accounts) => { for (const [account, amount] of Object.entries(airdropData).slice(dataLength / 2)) { let currentBalance = await token.balanceOf(hatAirdropFactory.address); const proof = merkleTree.getHexProof(hashTokens(account, amount)); - let tx = await hatAirdrop.redeem(accounts[i], amount, proof, { from: accounts[i] }); + let tx = await hatAirdrop.redeem( + accounts[i], + amount, + proof, + ZERO_ADDRESS, + 0, + 0, + { from: accounts[i] } + ); i++; assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); @@ -449,13 +556,27 @@ contract("HATAirdrop", (accounts) => { const [account, amount] = Object.entries(airdropData)[0]; const proof = merkleTree.getHexProof(hashTokens(account, amount)); await assertFunctionRaisesException( - hatAirdrop.redeem(accounts[0], amount, proof), + hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ), "CannotRedeemBeforeStartTime" ); await utils.increaseTime(7 * 24 * 3600); - let tx = await hatAirdrop.redeem(accounts[0], amount, proof); + let tx = await hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ); assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); assert.equal(tx.logs[0].args._amount, amount); @@ -470,7 +591,14 @@ contract("HATAirdrop", (accounts) => { await utils.increaseTime(7 * 24 * 3600); - let tx = await hatAirdrop.redeem(accounts[0], amount, proof); + let tx = await hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ); assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); assert.equal(tx.logs[0].args._amount, amount); @@ -482,7 +610,15 @@ contract("HATAirdrop", (accounts) => { const proof2 = merkleTree.getHexProof(hashTokens(account2, amount2)); await assertFunctionRaisesException( - hatAirdrop.redeem(accounts[1], amount2, proof2, { from: accounts[1] }), + hatAirdrop.redeem( + accounts[1], + amount2, + proof2, + ZERO_ADDRESS, + 0, + 0, + { from: accounts[1] } + ), "CannotRedeemAfterDeadline" ); }); @@ -496,11 +632,26 @@ contract("HATAirdrop", (accounts) => { await utils.increaseTime(7 * 24 * 3600); await assertFunctionRaisesException( - hatAirdrop.redeem(accounts[0], amount, proof, { from: accounts[1] }), + hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0, + { from: accounts[1] } + ), "RedeemerMustBeBeneficiary" ); - let tx = await hatAirdrop.redeem(accounts[0], amount, proof); + let tx = await hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ); assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); assert.equal(tx.logs[0].args._amount, amount); @@ -516,14 +667,28 @@ contract("HATAirdrop", (accounts) => { await utils.increaseTime(7 * 24 * 3600); - let tx = await hatAirdrop.redeem(accounts[0], amount, proof); + let tx = await hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ); assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); assert.equal(tx.logs[0].args._amount, amount); assert.equal(await token.balanceOf(tx.logs[0].args._tokenLock), amount); await assertFunctionRaisesException( - hatAirdrop.redeem(accounts[0], amount, proof), + hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ), "LeafAlreadyRedeemed" ); }); @@ -536,18 +701,39 @@ contract("HATAirdrop", (accounts) => { await utils.increaseTime(7 * 24 * 3600); await assertFunctionRaisesException( - hatAirdrop.redeem(accounts[0], amount, [web3.utils.randomHex(32)]), + hatAirdrop.redeem( + accounts[0], + amount, + [web3.utils.randomHex(32)], + ZERO_ADDRESS, + 0, + 0 + ), "InvalidMerkleProof" ); const proof = merkleTree.getHexProof(hashTokens(account, amount)); await assertFunctionRaisesException( - hatAirdrop.redeem(accounts[0], "0", proof), + hatAirdrop.redeem( + accounts[0], + "0", + proof, + ZERO_ADDRESS, + 0, + 0 + ), "InvalidMerkleProof" ); - let tx = await hatAirdrop.redeem(accounts[0], amount, proof); + let tx = await hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ); assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); assert.equal(tx.logs[0].args._amount, amount); @@ -567,7 +753,14 @@ contract("HATAirdrop", (accounts) => { const [account, amount] = Object.entries(airdropData)[0]; const proof = merkleTree.getHexProof(hashTokens(account, amount)); - let tx = await hatAirdrop.redeem(accounts[0], amount, proof); + let tx = await hatAirdrop.redeem( + accounts[0], + amount, + proof, + ZERO_ADDRESS, + 0, + 0 + ); assert.equal(tx.logs[0].event, "TokensRedeemed"); assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); assert.equal(tx.logs[0].args._amount, amount); @@ -582,4 +775,68 @@ contract("HATAirdrop", (accounts) => { assert.equal(tx.logs[0].args._amount.toString(), web3.utils.toBN((totalAmount - parseInt(amount))).toString()); assert.equal((await token.balanceOf(hatAirdropFactory.address)).toString(), "0"); }); + + it("Redeem all and deposit in vault", async () => { + await setupHATAirdrop(false); + + const { vault } = await setup(accounts, { stakingToken: token }); + + await utils.increaseTime(7 * 24 * 3600); + + const [account0, amount0] = Object.entries(airdropData)[0]; + const proof0 = merkleTree.getHexProof(hashTokens(account0, amount0)); + await assertFunctionRaisesException( + hatAirdrop.redeem( + account0, + amount0, + proof0, + vault.address, + 0, + 0 + ), + "InvalidAmountToDeposit" + ); + + await assertFunctionRaisesException( + hatAirdrop.redeem( + account0, + amount0, + proof0, + vault.address, + amount0 + 1, + 0 + ), + "InvalidAmountToDeposit" + ); + + await token.setMinter(accounts[0], MINIMAL_AMOUNT_OF_SHARES); + await token.mint(accounts[0], MINIMAL_AMOUNT_OF_SHARES); + await token.approve(vault.address, MINIMAL_AMOUNT_OF_SHARES, { from: accounts[0]}); + await vault.deposit(MINIMAL_AMOUNT_OF_SHARES, "0x000000000000000000000000000000000000dead", { from: accounts[0] }); + + let i = 0; + for (const [account, amount] of Object.entries(airdropData)) { + let currentBalance = await token.balanceOf(hatAirdropFactory.address); + const proof = merkleTree.getHexProof(hashTokens(account, amount)); + let tx = await hatAirdrop.redeem( + accounts[i], + amount, + proof, + vault.address, + parseInt(amount / 2), + 0, + { from: accounts[i] } + ); + i++; + assert.equal(tx.logs[0].event, "TokensRedeemed"); + assert.equal(tx.logs[0].args._account.toLowerCase(), account.toLowerCase()); + assert.equal(tx.logs[0].args._tokenLock, ZERO_ADDRESS); + assert.equal(tx.logs[0].args._amount, amount); + assert.equal((await token.balanceOf(account)).toString(), Math.round(amount / 2)); + assert.equal((await vault.balanceOf(account)).toString(), parseInt(amount / 2)); + assert.equal((await token.balanceOf(hatAirdropFactory.address)).toString(), currentBalance.sub(web3.utils.toBN(amount)).toString()); + } + + assert.equal((await token.balanceOf(hatAirdropFactory.address)).toString(), "0"); + }); });