DepositBoxERC20
Runs on mainnet, accepts messages from schain, stores deposits of ERC20.
depositERC20 depositERC20(string schainName, address erc20OnMainnet, uint256 amount)
external
Allows msg.sender
to send ERC20 token from mainnet to schain
Requirements:
-
Schain name must not be
Mainnet
. -
Receiver account on schain cannot be null.
-
Schain that receives tokens should not be killed.
-
Receiver contract should be defined.
-
msg.sender
should approve their tokens for DepositBoxERC20 address.
postMessage postMessage(bytes32 schainHash, address sender, bytes data)
external
Allows MessageProxyForMainnet contract to execute transferring ERC20 token from schain to mainnet.
Requirements:
-
Schain from which the tokens came should not be killed.
-
Sender contract should be defined and schain name cannot be
Mainnet
. -
Amount of tokens on DepositBoxERC20 should be equal or more than transferred amount.
addERC20TokenByOwner addERC20TokenByOwner(string schainName, address erc20OnMainnet)
external
Allows Schain owner to add an ERC20 token to DepositBoxERC20.
Emits an ERC20TokenAdded
event.
Requirements:
-
Schain should not be killed.
-
Only owner of the schain able to run function.
getFunds getFunds(string schainName, address erc20OnMainnet, address receiver, uint256 amount)
external
Allows Schain owner to return each user their tokens. The Schain owner decides which tokens to send to which address, since the contract on mainnet does not store information about which tokens belong to whom.
Requirements:
-
Amount of tokens on schain should be equal or more than transferred amount.
-
msg.sender should be an owner of schain
-
IMA transfers Mainnet <→ schain should be killed
setBigTransferValue setBigTransferValue(string schainName, address token, uint256 value)
external
Set a threshold amount of tokens. If amount of tokens that exits IMA is bigger than the threshold the transfer is delayed for configurable amount of time and can be canceled by a voting
Requirements:
-
msg.sender should be an owner of schain
setBigTransferDelay setBigTransferDelay(string schainName, uint256 delayInSeconds)
external
Set a time delay. If amount of tokens that exits IMA is bigger than a threshold the transfer is delayed for set amount of time and can be canceled by a voting
Requirements:
-
msg.sender should be an owner of schain
setArbitrageDuration setArbitrageDuration(string schainName, uint256 delayInSeconds)
external
Set an arbitrage. After escalation the transfer is locked for provided period of time.
Requirements:
-
msg.sender should be an owner of schain
trustReceiver trustReceiver(string schainName, address receiver)
external
Add the address to a whitelist of addresses that can do big transfers without delaying Requirements:
-
msg.sender should be an owner of schain
-
the address must not be in the whitelist
stopTrustingReceiver stopTrustingReceiver(string schainName, address receiver)
external
Remove the address from a whitelist of addresses that can do big transfers without delaying Requirements:
-
msg.sender should be an owner of schain
-
the address must be in the whitelist
retrieve retrieve()
external
Transfers tokens that was locked for delay during exit process. Must be called by a receiver.
escalate escalate(uint256 transferId)
external
Initialize arbitrage of a suspicious big transfer
Requirements:
-
msg.sender should be an owner of schain or have ARBITER_ROLE role
-
transfer must be delayed and arbitrage must not be started
validateTransfer validateTransfer(uint256 transferId)
external
Approve a big transfer and immidiately transfer tokens during arbitrage
Requirements:
-
msg.sender should be an owner of schain
-
arbitrage of the transfer must be started
rejectTransfer rejectTransfer(uint256 transferId)
external
Reject a big transfer and transfer tokens to SKALE chain owner during arbitrage
Requirements:
-
msg.sender should be an owner of schain
-
arbitrage of the transfer must be started
doTransfer doTransfer(address token, address receiver, uint256 amount)
external
gasPayer gasPayer(bytes32 schainHash, address sender, bytes data) → address
external
Returns receiver of message.
Requirements:
-
Sender contract should be defined and schain name cannot be
Mainnet
.
getSchainToERC20 getSchainToERC20(string schainName, address erc20OnMainnet) → bool
external
Should return true if token was added by Schain owner or added automatically after sending to schain if whitelist was turned off.
getSchainToAllERC20Length getSchainToAllERC20Length(string schainName) → uint256
external
Should return length of a set of all mapped tokens which were added by Schain owner or added automatically after sending to schain if whitelist was turned off.
getSchainToAllERC20 getSchainToAllERC20(string schainName, uint256 from, uint256 to) → address[] tokensInRange
external
Should return an array of range of tokens were added by Schain owner or added automatically after sending to schain if whitelist was turned off.
getDelayedAmount getDelayedAmount(address receiver, address token) → uint256 value
external
Get amount of tokens that are delayed for specified receiver
getNextUnlockTimestamp getNextUnlockTimestamp(address receiver, address token) → uint256 unlockTimestamp
external
Get timestamp of next unlock of tokens that are delayed for specified receiver
getTrustedReceiversAmount getTrustedReceiversAmount(bytes32 schainHash) → uint256
external
Get amount of addresses that are added to the whitelist
getTrustedReceiver getTrustedReceiver(string schainName, uint256 index) → address
external
Get i-th address of the whitelist
getBigTransferThreshold getBigTransferThreshold(bytes32 schainHash, address token) → uint256
external
Get amount of tokens that are considered as a big transfer
getTimeDelay getTimeDelay(bytes32 schainHash) → uint256
external
Get time delay of big transfers
getArbitrageDuration getArbitrageDuration(bytes32 schainHash) → uint256
external
Get duration of an arbitrage
retrieveFor retrieveFor(address receiver)
public
Retrive tokens that were unlocked after delay for specified receiver
initialize initialize(contract IContractManager contractManagerOfSkaleManagerValue, contract ILinker linkerValue, contract IMessageProxyForMainnet messageProxyValue)
public
Creates a new DepositBoxERC20 contract.
depositERC20Direct depositERC20Direct(string schainName, address erc20OnMainnet, uint256 amount, address receiver)
public
Allows msg.sender
to send ERC20 token from mainnet to schain to specified receiver.
Requirements:
-
Schain name must not be
Mainnet
. -
Receiver account on schain cannot be null.
-
Schain that receives tokens should not be killed.
-
Receiver contract should be defined.
-
msg.sender
should approve their tokens for DepositBoxERC20 address.
isReceiverTrusted isReceiverTrusted(bytes32 schainHash, address receiver) → bool
public
Check if the receiver is in the delay whitelist
ERC20TokenAdded ERC20TokenAdded(string schainName, address contractOnMainnet)
event
Emitted when token is mapped in DepositBoxERC20.
ERC20TokenReady ERC20TokenReady(address contractOnMainnet, uint256 amount)
event
Emitted when token is received by DepositBox and is ready to be cloned or transferred on SKALE chain.
TransferDelayed TransferDelayed(uint256 id, address receiver, address token, uint256 amount)
event
Escalated Escalated(uint256 id)
event
TransferSkipped TransferSkipped(uint256 id)
event
Emitted when token transfer is skipped due to internal token error
BigTransferThresholdIsChanged BigTransferThresholdIsChanged(bytes32 schainHash, address token, uint256 oldValue, uint256 newValue)
event
Emitted when big transfer threshold is changed
BigTransferDelayIsChanged BigTransferDelayIsChanged(bytes32 schainHash, uint256 oldValue, uint256 newValue)
event
Emitted when big transfer delay is changed
ArbitrageDurationIsChanged ArbitrageDurationIsChanged(bytes32 schainHash, uint256 oldValue, uint256 newValue)
event
Emitted when arbitrage duration is changed