Contract for assets transfers. The user can transfer the asset to any of the approved chains. The admin manages the assets, fees and other important protocol parameters.

Variables

BPS_DENOMINATOR

uint256 public constant BPS_DENOMINATOR;
Basis points or bps, set to 10,000 (equal to 1/10000). Used to express relative values (fees)

GOVMONITORING_ROLE

bytes32 public constant GOVMONITORING_ROLE;
Role allowed to stop transfers

SUBMISSION_PREFIX

uint256 public constant SUBMISSION_PREFIX;
Prefix to calculation submissionId

DEPLOY_PREFIX

uint256 public constant DEPLOY_PREFIX;
Prefix to calculation deployId

deBridgeTokenDeployer

address public deBridgeTokenDeployer;
Address of IDeBridgeTokenDeployer contract

signatureVerifier

address public signatureVerifier;
Current signature verifier address to verify signatures.

excessConfirmations

uint8 public excessConfirmations;
Minimal required confirmations in case sent amount is big, has no effect if less than SignatureVerifier.minConfirmations

flashFeeBps

uint256 public flashFeeBps;
Flash loan fee in basis points (1/10000)

nonce

uint256 public nonce;
Outgoing submissions count

getDebridge

mapping(bytes32 => struct IDeBridgeGate.DebridgeInfo) public getDebridge;
Maps debridgeId (see getDebridgeId) => bridge-specific information.

getDebridgeFeeInfo

mapping(bytes32 => struct IDeBridgeGate.DebridgeFeeInfo) public getDebridgeFeeInfo;
Maps debridgeId (see getDebridgeId) => fee information

isSubmissionUsed

mapping(bytes32 => bool) public isSubmissionUsed;
Returns whether the transfer with the submissionId was claimed.

isBlockedSubmission

mapping(bytes32 => bool) public isBlockedSubmission;
Returns whether the transfer with the submissionId is blocked.

getAmountThreshold

mapping(bytes32 => uint256) public getAmountThreshold;
Maps debridgeId (see getDebridgeId) to threshold amount after which Math.max(excessConfirmations,SignatureVerifier.minConfirmations) is used instead of SignatureVerifier.minConfirmations

getChainToConfig

mapping(uint256 => struct IDeBridgeGate.ChainSupportInfo) public getChainToConfig;
Whether the chain for the asset is supported to send

getChainFromConfig

mapping(uint256 => struct IDeBridgeGate.ChainSupportInfo) public getChainFromConfig;
Whether the chain for the asset is supported to claim

feeDiscount

mapping(address => struct IDeBridgeGate.DiscountInfo) public feeDiscount;
Fee discount for address

getNativeInfo

mapping(address => struct IDeBridgeGate.TokenInfo) public getNativeInfo;
Returns native token info by wrapped token address

defiController

address public defiController;
DefiController that can supply liquidity to staking strategies (AAVE, Compound, etc.)

feeProxy

address public feeProxy;
Proxy to convert collected fees and transfer to Ethereum treasury

callProxy

address public callProxy;
Address of the proxy to execute user’s calls.

weth

contract IWETH public weth;
Wrapped native token contract

feeContractUpdater

address public feeContractUpdater;
Contract that can override globalFixedNativeFee

globalFixedNativeFee

uint256 public globalFixedNativeFee;
Fallback fixed fee in native asset (used if chain fixed fee is 0)

globalTransferFeeBps

uint16 public globalTransferFeeBps;
Fallback transfer fee in BPS (used if chain transfer fee is 0)

wethGate

contract IWethGate public wethGate;
WethGate contract used for WETH withdraws affected by EIP1884

lockedClaim

uint256 public lockedClaim;
Locker for claim method

Functions

initialize

function initialize(
  uint8 _excessConfirmations,
  contract IWETH _weth
) public
Constructor that initializes the most important configurations.

Parameters:

NameTypeDescription
_excessConfirmationsuint8Minimal required confirmations in case of too many confirmations
_wethcontract IWETHWrapped native token contract

send

function send(
    address _tokenAddress,
    uint256 _amount,
    uint256 _chainIdTo,
    bytes _receiver,
    bytes _permit,
    bool _useAssetFee,
    uint32 _referralCode,
    bytes _autoParams
) external
This method is used for the transfer of assets from the native chain. It locks an asset in the smart contract in the native chain and enables minting of deAsset on the secondary chain. Parameters:
NameTypeDescription
_tokenAddressaddressAsset identifier.
_amountuint256Amount to be transferred (note: the fee can be applied).
_chainIdTouint256Chain id of the target chain.
_receiverbytesReceiver address.
_permitbytesdeadline + signature for approving the spender by signature.
_useAssetFeebooluse assets fee for pay protocol fix (work only for specials token)
_referralCodeuint32Referral code
_autoParamsbytesAuto params for external call in target network

claim

function claim(
    bytes32 _debridgeId,
    uint256 _amount,
    uint256 _chainIdFrom,
    address _receiver,
    uint256 _nonce,
    bytes _signatures,
    bytes _autoParams
) external
Is used for transfers into the native chain to unlock the designated amount of asset from collateral and transfer it to the receiver. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_amountuint256Amount of the transferred asset (note: the fee can be applied).
_chainIdFromuint256Chain where submission was sent
_receiveraddressReceiver address.
_nonceuint256Submission id.
_signaturesbytesValidators signatures to confirm
_autoParamsbytesAuto params for external call

flash

function flash(
    address _tokenAddress,
    address _receiver,
    uint256 _amount,
    bytes _data
) external
Get a flash loan, msg.sender must implement IFlashCallback. Parameters:
NameTypeDescription
_tokenAddressaddressAn asset to loan
_receiveraddressWhere funds should be sent
_amountuint256Amount to loan
_databytesData to pass to sender’s flashCallback function

deployNewAsset

function deployNewAsset(
    bytes _nativeTokenAddress,
    uint256 _nativeChainId,
    string _name,
    string _symbol,
    uint8 _decimals,
    bytes _signatures
) external
Deploy a deToken(DeBridgeTokenProxy) for an asset. Parameters:
NameTypeDescription
_nativeTokenAddressbytesA token address on a native chain
_nativeChainIduint256The token native chain’s id
_namestringThe token’s name
_symbolstringThe token’s symbol
_decimalsuint8The token’s decimals
_signaturesbytesValidators’ signatures

autoUpdateFixedNativeFee

function autoUpdateFixedNativeFee(
    uint256 _globalFixedNativeFee
) external
Update native fix fee. Called by our fee update contract. Parameters:
NameTypeDescription
_globalFixedNativeFeeuint256new value

updateChainSupport

function updateChainSupport(
    uint256[] _chainIds,
    struct IDeBridgeGate.ChainSupportInfo[] _chainSupportInfo,
    bool _isChainFrom
) external
Update asset’s fees. Parameters:
NameTypeDescription
_chainIdsuint256[]Chain identifiers.
_chainSupportInfostruct IDeBridgeGate.ChainSupportInfo[]Chain support info.
_isChainFromboolis true for editing getChainFromConfig.

updateGlobalFee

function updateGlobalFee(
    uint256 _globalFixedNativeFee,
    uint16 _globalTransferFeeBps
) external
Update fallbacks for fixed fee in native asset and transfer fee. Parameters:
NameTypeDescription
_globalFixedNativeFeeuint256Fallback fixed fee in native asset, used if a chain fixed fee is set to 0
_globalTransferFeeBpsuint16Fallback transfer fee in BPS, used if a chain transfer fee is set to 0

updateAssetFixedFees

function updateAssetFixedFees(
    bytes32 _debridgeId,
    uint256[] _supportedChainIds,
    uint256[] _assetFeesInfo
) external
Update asset’s fees. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_supportedChainIdsuint256[]Chain identifiers.
_assetFeesInfouint256[]Chain support info.

updateExcessConfirmations

function updateExcessConfirmations(
    uint8 _excessConfirmations
) external
Update minimal amount of required signatures, must be > SignatureVerifier.minConfirmations to have an effect. Parameters:
NameTypeDescription
_excessConfirmationsuint8Minimal amount of required signatures

setChainSupport

function setChainSupport(
    uint256 _chainId,
    bool _isSupported,
    bool _isChainFrom
) external
Set support for the chains where the token can be transferred. Parameters:
NameTypeDescription
_chainIduint256Chain id where tokens are sent.
_isSupportedboolWhether the token is transferable to other chain.
_isChainFromboolIs true for editing getChainFromConfig.

setCallProxy

function setCallProxy(
    address _callProxy
) external
Set address of the call proxy. Parameters:
NameTypeDescription
_callProxyaddressAddress of the proxy that executes calls.

updateAsset

function updateAsset(
    bytes32 _debridgeId,
    uint256 _maxAmount,
    uint16 _minReservesBps,
    uint256 _amountThreshold
) external
Update specific asset’s bridge parameters. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_maxAmountuint256Maximum amount of current chain token to be wrapped.
_minReservesBpsuint16Minimal reserve ratio in BPS.
_amountThresholduint256Threshold amount after which Math.max(excessConfirmations,SignatureVerifier.minConfirmations) is used instead of SignatureVerifier.minConfirmations

setSignatureVerifier

function setSignatureVerifier(
    address _verifier
) external
Set signature verifier address. Parameters:
NameTypeDescription
_verifieraddressSignature verifier address.

setDeBridgeTokenDeployer

function setDeBridgeTokenDeployer(
    address _deBridgeTokenDeployer
) external
Set asset deployer address. Parameters:
NameTypeDescription
_deBridgeTokenDeployeraddressAsset deployer address.

setDefiController

function setDefiController(
    address _defiController
) external
Set defi controller. Parameters:
NameTypeDescription
_defiControlleraddressDefi controller address.

setFeeContractUpdater

function setFeeContractUpdater(
    address _value
) external
Set fee contract updater, that can update fix native fee. Parameters:
NameTypeDescription
_valueaddressNew contract address.

setWethGate

function setWethGate(
    contract IWethGate _wethGate
) external
Set wethGate contract, used for weth withdrawals affected by EIP1884. Parameters:
NameTypeDescription
_wethGatecontract IWethGateAddress of new wethGate contract.

pause

function pause() external
Stop all transfers.

unpause

function unpause() external
Allow transfers again.

withdrawFee

function withdrawFee(
    bytes32 _debridgeId
) external
Withdraw collected fees to feeProxy. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.

requestReserves

function requestReserves(
    address _tokenAddress,
    uint256 _amount
) external
Request the assets to be used in DeFi protocol. Parameters:
NameTypeDescription
_tokenAddressaddressAsset address.
_amountuint256Amount to request.

returnReserves

function returnReserves(
    address _tokenAddress,
    uint256 _amount
) external
Return the assets that were used in DeFi protocol. Parameters:
NameTypeDescription
_tokenAddressaddressAsset address.
_amountuint256Amount of tokens to claim.

setFeeProxy

function setFeeProxy(
    address _feeProxy
) external
Set fee converter proxy. Parameters:
NameTypeDescription
_feeProxyaddressFee proxy address.

blockSubmission

function blockSubmission(
    bytes32[] _submissionIds,
    bool isBlocked
) external
Block or unblock a list of submissions. Parameters:
NameTypeDescription
_submissionIdsbytes32[]IDs of submissions to modify.
isBlockedboolTrue to block, false to unblock.

updateFlashFee

function updateFlashFee(
    uint256 _flashFeeBps
) external
Update flash fees. Parameters:
NameTypeDescription
_flashFeeBpsuint256New fee in BPS.

updateFeeDiscount

function updateFeeDiscount(
    address _address,
    uint16 _discountFixBps,
    uint16 _discountTransferBps
) external
Update discount settings. Parameters:
NameTypeDescription
_addressaddressCustomer address.
_discountFixBpsuint16Fix discount in BPS.
_discountTransferBpsuint16Transfer % discount in BPS.

receive

function receive() external

_checkConfirmations

function _checkConfirmations(
    bytes32 _submissionId,
    bytes32 _debridgeId,
    uint256 _amount,
    bytes _signatures
) internal

_addAsset

function _addAsset(
    bytes32 _debridgeId,
    address _tokenAddress,
    bytes _nativeAddress,
    uint256 _nativeChainId
) internal
Add support for the asset. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_tokenAddressaddressAddress of the asset on this chain.
_nativeAddressbytesAddress of asset on native chain.
_nativeChainIduint256Native chain ID.

_send

function _send(
    bytes _amount,
    address _chainIdTo,
    uint256 _permit
) internal returns (uint256 amountAfterFee, bytes32 debridgeId, struct IDeBridgeGate.FeeParams feeParams)
Locks asset on the chain and enables minting on the other chain. Parameters:
NameTypeDescription
_amountbytesAmount to be transferred (fee can be applied).
_chainIdToaddressTarget chain ID.
_permituint256Deadline + signature for permit.

_publishSubmission

function _publishSubmission(
    bytes32 _debridgeId,
    uint256 _chainIdTo,
    uint256 _amount,
    bytes _receiver,
    struct IDeBridgeGate.FeeParams feeParams,
    uint32 _referralCode,
    struct IDeBridgeGate.SubmissionAutoParamsTo autoParams,
    bool hasAutoParams
) internal

_applyDiscount

function _applyDiscount(
    uint256 amount,
    uint16 discountBps
) internal returns (uint256)

_validateToken

function _validateToken(
    address _token
) internal

_claim

function _claim(
    bytes32 _debridgeId,
    bytes32 _receiver,
    address _amount
) internal returns (bool isNativeToken)
Unlock the asset on the current chain and transfer to receiver. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_receiverbytes32Receiver address.
_amountaddressAmount of the transferred asset (note: fee can be applied).

_mintOrTransfer

function _mintOrTransfer(
    address _token,
    address _receiver,
    uint256 _amount,
    bool isNativeToken
) internal

_safeTransferETH

function _safeTransferETH(
    address to,
    uint256 value
) internal

_withdrawWeth

function _withdrawWeth(
    address _receiver,
    uint256 _amount
) internal

_normalizeTokenAmount

function _normalizeTokenAmount(
    address _token,
    uint256 _amount
) internal returns (uint256)

getDefiAvaliableReserves

function getDefiAvaliableReserves(
    address _tokenAddress
) external returns (uint256)
Get reserves of a token available to use in DeFi. Parameters:
NameTypeDescription
_tokenAddressaddressToken address.

getDebridgeId

function getDebridgeId(
    uint256 _chainId,
    address _tokenAddress
) public returns (bytes32)
Calculates asset identifier. Parameters:
NameTypeDescription
_chainIduint256Current chain id.
_tokenAddressaddressAddress of the asset on other chain.

getbDebridgeId

function getbDebridgeId(
    uint256 _chainId,
    bytes _tokenAddress
) public returns (bytes32)
Calculates asset identifier. Parameters:
NameTypeDescription
_chainIduint256Current chain id.
_tokenAddressbytesAddress of the asset on other chain.

getDebridgeChainAssetFixedFee

function getDebridgeChainAssetFixedFee(
    bytes32 _debridgeId,
    uint256 _chainId
) external returns (uint256)
Returns asset fixed fee value for specified debridge and chainId. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_chainIduint256Chain id.

getSubmissionIdFrom

function getSubmissionIdFrom(
    bytes32 _debridgeId,
    uint256 _chainIdFrom,
    uint256 _amount,
    address _receiver,
    uint256 _nonce,
    struct IDeBridgeGate.SubmissionAutoParamsFrom _autoParams,
    bool _hasAutoParams,
    address _sender
) public returns (bytes32)
Calculate submission id for auto claimable transfer. Parameters:
NameTypeDescription
_debridgeIdbytes32Asset identifier.
_chainIdFromuint256Chain identifier of the chain where tokens are sent from.
_amountuint256Amount of the transferred asset (note: the fee can be applied).
_receiveraddressReceiver address.
_nonceuint256Submission id.
_autoParamsstruct IDeBridgeGate.SubmissionAutoParamsFromAuto params for external call.
_hasAutoParamsboolTrue if auto params are provided.
_senderaddressAddress that will call claim.

getDeployId

function getDeployId(
    bytes32 _debridgeId,
    string _name,
    string _symbol,
    uint8 _decimals
) public returns (bytes32)
Calculates asset identifier for deployment. Parameters:
NameTypeDescription
_debridgeIdbytes32Id of an asset, see getDebridgeId.
_namestringAsset’s name.
_symbolstringAsset’s symbol.
_decimalsuint8Asset’s decimals.

getChainId

function getChainId() public returns (uint256 cid)
Get current chain id.

version

function version() external returns (uint256)
Get this contract’s version.