Function: sgReceive(uint16 _chainId, byte[] _srcAddress, uint256 _nonce, address _token, uint256 amountLD, byte[] _payload)
Allows to receive tokens from another chain. Only stargateRelayer (Router) can call this function. The native token will be transferred to this contract before triggering this function.
Inputs
_chainIdConstraints: N/A.
Impact: Not used.
_srcAddressConstraints: N/A.
Impact: Not used.
_nonceConstraints: N/A.
Impact: Not used.
_tokenConstraints: No checks.
Impact: The address of token will be deposited to the vault. This address is received from
pool.
amountLDConstraints: This value is not controlled by the user who initiated the token transfer between chains. This value is a result of swap.
Impact: The amount of tokens received. This amount of
_tokenwill be deposited to the vault and thereceiverToVaultToIdToAmountfor the receiver will be increased byamountLDvalue.
_payloadConstraints:
vaultAddressshould be whitelisted.Impact: Contains this data ---
receiver,id, andvaultAddress.
Branches and code coverage (including function calls)
Intended branches
Deposit in case
token == sgEth.Deposit in case
token != sgEth.
Negative behavior
msg.senderis notstargateRelayerorstargateRelayerEth.vaultAddressis not whitelisted.
Function call analysis
_stageRefund(receiver, _token, amountLD)What is controllable?
receiver,_token, andamountLD.If return value controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters, or does other unusual control flow? The function increments the global
eligibleRefund[receiver][_token]by aamountLDvalue. ThiseligibleRefundvalue is used in theclaimRefund->_claimRefundfunction.
_depositToVault(id, amountLD, _token, vaultAddress)What is controllable?
id,amountLD,_token, andvaultAddress.If return value controllable, how is it used and how can it go wrong? Returns a boolean value, successfully or unsuccessfully the external call of
depositfunction was executed.What happens if it reverts, reenters, or does other unusual control flow? the function deposits funds to the vaultAddress contract.