DeBridgeGate
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

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

GOVMONITORING_ROLE

1
bytes32 public constant GOVMONITORING_ROLE;
Copied!
Role allowed to stop transfers

SUBMISSION_PREFIX

1
uint256 public constant SUBMISSION_PREFIX;
Copied!
prefix to calculation submissionId

DEPLOY_PREFIX

1
uint256 public constant DEPLOY_PREFIX;
Copied!
prefix to calculation deployId

deBridgeTokenDeployer

1
address public deBridgeTokenDeployer;
Copied!
Address of IDeBridgeTokenDeployer contract

signatureVerifier

1
address public signatureVerifier;
Copied!
Current signature verifier address to verify signatures.

excessConfirmations

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

flashFeeBps

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

nonce

1
uint256 public nonce;
Copied!
outgoing submissions count

getDebridge

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

getDebridgeFeeInfo

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

isSubmissionUsed

1
mapping(bytes32 => bool) public isSubmissionUsed;
Copied!
Returns whether the transfer with the submissionId was claimed. submissionId is generated in getSubmissionIdFrom

isBlockedSubmission

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

getAmountThreshold

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

getChainToConfig

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

getChainFromConfig

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

feeDiscount

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

getNativeInfo

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

defiController

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

feeProxy

1
address public feeProxy;
Copied!
Returns proxy to convert the collected fees and transfer to Ethereum network to treasury

callProxy

1
address public callProxy;
Copied!
Returns address of the proxy to execute user's calls.

weth

1
contract IWETH public weth;
Copied!
Returns contract for wrapped native token.

feeContractUpdater

1
address public feeContractUpdater;
Copied!
Contract address that can override globalFixedNativeFee

globalFixedNativeFee

1
uint256 public globalFixedNativeFee;
Copied!
Fallback fixed fee in native asset, used if a chain fixed fee is set to 0

globalTransferFeeBps

1
uint16 public globalTransferFeeBps;
Copied!
Fallback transfer fee in BPS, used if a chain transfer fee is set to 0

wethGate

1
contract IWethGate public wethGate;
Copied!
WethGate contract, that is used for weth withdraws affected by EIP1884

lockedClaim

1
uint256 public lockedClaim;
Copied!
Locker for claim method

Functions

initialize

1
function initialize(
2
uint8 _excessConfirmations,
3
contract IWETH _weth
4
) public
Copied!
Constructor that initializes the most important configurations.

Parameters:

Name
Type
Description
_excessConfirmations
uint8
minimal required confirmations in case of too many confirmations
_weth
contract IWETH
wrapped native token contract

send

1
function send(
2
address _tokenAddress,
3
uint256 _amount,
4
uint256 _chainIdTo,
5
bytes _receiver,
6
bytes _permit,
7
bool _useAssetFee,
8
uint32 _referralCode,
9
bytes _autoParams
10
) external
Copied!
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:

Name
Type
Description
_tokenAddress
address
Asset identifier.
_amount
uint256
Amount to be transferred (note: the fee can be applied).
_chainIdTo
uint256
Chain id of the target chain.
_receiver
bytes
Receiver address.
_permit
bytes
deadline + signature for approving the spender by signature.
_useAssetFee
bool
use assets fee for pay protocol fix (work only for specials token)
_referralCode
uint32
Referral code
_autoParams
bytes
Auto params for external call in target network

claim

1
function claim(
2
bytes32 _debridgeId,
3
uint256 _amount,
4
uint256 _chainIdFrom,
5
address _receiver,
6
uint256 _nonce,
7
bytes _signatures,
8
bytes _autoParams
9
) external
Copied!
Is used for transfers into the native chain to unlock the designated amount of asset from collateral and transfer it to the receiver.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_amount
uint256
Amount of the transferred asset (note: the fee can be applied).
_chainIdFrom
uint256
Chain where submission was sent
_receiver
address
Receiver address.
_nonce
uint256
Submission id.
_signatures
bytes
Validators signatures to confirm
_autoParams
bytes
Auto params for external call

flash

1
function flash(
2
address _tokenAddress,
3
address _receiver,
4
uint256 _amount,
5
bytes _data
6
) external
Copied!
Get a flash loan, msg.sender must implement IFlashCallback

Parameters:

Name
Type
Description
_tokenAddress
address
An asset to loan
_receiver
address
Where funds should be sent
_amount
uint256
Amount to loan
_data
bytes
Data to pass to sender's flashCallback function

deployNewAsset

1
function deployNewAsset(
2
bytes _nativeTokenAddress,
3
uint256 _nativeChainId,
4
string _name,
5
string _symbol,
6
uint8 _decimals,
7
bytes _signatures
8
) external
Copied!
Deploy a deToken(DeBridgeTokenProxy) for an asset

Parameters:

Name
Type
Description
_nativeTokenAddress
bytes
A token address on a native chain
_nativeChainId
uint256
The token native chain's id
_name
string
The token's name
_symbol
string
The token's symbol
_decimals
uint8
The token's decimals
_signatures
bytes
Validators' signatures

autoUpdateFixedNativeFee

1
function autoUpdateFixedNativeFee(
2
uint256 _globalFixedNativeFee
3
) external
Copied!
Update native fix fee. Called by our fee update contract

Parameters:

Name
Type
Description
_globalFixedNativeFee
uint256
new value

updateChainSupport

1
function updateChainSupport(
2
uint256[] _chainIds,
3
struct IDeBridgeGate.ChainSupportInfo[] _chainSupportInfo,
4
bool _isChainFrom
5
) external
Copied!
Update asset's fees.

Parameters:

Name
Type
Description
_chainIds
uint256[]
Chain identifiers.
_chainSupportInfo
struct IDeBridgeGate.ChainSupportInfo[]
Chain support info.
_isChainFrom
bool
is true for editing getChainFromConfig.

updateGlobalFee

1
function updateGlobalFee(
2
uint256 _globalFixedNativeFee,
3
uint16 _globalTransferFeeBps
4
) external
Copied!
Update fallbacks for fixed fee in native asset and transfer fee

Parameters:

Name
Type
Description
_globalFixedNativeFee
uint256
Fallback fixed fee in native asset, used if a chain fixed fee is set to 0
_globalTransferFeeBps
uint16
Fallback transfer fee in BPS, used if a chain transfer fee is set to 0

updateAssetFixedFees

1
function updateAssetFixedFees(
2
bytes32 _debridgeId,
3
uint256[] _supportedChainIds,
4
uint256[] _assetFeesInfo
5
) external
Copied!
Update asset's fees.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_supportedChainIds
uint256[]
Chain identifiers.
_assetFeesInfo
uint256[]
Chain support info.

updateExcessConfirmations

1
function updateExcessConfirmations(
2
uint8 _excessConfirmations
3
) external
Copied!
Update minimal amount of required signatures, must be > SignatureVerifier.minConfirmations to have an effect

Parameters:

Name
Type
Description
_excessConfirmations
uint8
Minimal amount of required signatures

setChainSupport

1
function setChainSupport(
2
uint256 _chainId,
3
bool _isSupported,
4
bool _isChainFrom
5
) external
Copied!
Set support for the chains where the token can be transferred.

Parameters:

Name
Type
Description
_chainId
uint256
Chain id where tokens are sent.
_isSupported
bool
Whether the token is transferable to the other chain.
_isChainFrom
bool
is true for editing getChainFromConfig.

setCallProxy

1
function setCallProxy(
2
address _callProxy
3
) external
Copied!
Set address of the call proxy.

Parameters:

Name
Type
Description
_callProxy
address
Address of the proxy that executes external calls.

updateAsset

1
function updateAsset(
2
bytes32 _debridgeId,
3
uint256 _maxAmount,
4
uint16 _minReservesBps,
5
uint256 _amountThreshold
6
) external
Copied!
Update specific asset's bridge parameters.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_maxAmount
uint256
Maximum amount of current chain token to be wrapped.
_minReservesBps
uint16
Minimal reserve ration in BPS.
_amountThreshold
uint256
Threshold amount after which Math.max(excessConfirmations,SignatureVerifier.minConfirmations) is used instead of SignatureVerifier.minConfirmations

setSignatureVerifier

1
function setSignatureVerifier(
2
address _verifier
3
) external
Copied!
Set signature verifier address.

Parameters:

Name
Type
Description
_verifier
address
Signature verifier address.

setDeBridgeTokenDeployer

1
function setDeBridgeTokenDeployer(
2
address _deBridgeTokenDeployer
3
) external
Copied!
Set asset deployer address.

Parameters:

Name
Type
Description
_deBridgeTokenDeployer
address
Asset deployer address.

setDefiController

1
function setDefiController(
2
address _defiController
3
) external
Copied!
Set defi controller.

Parameters:

Name
Type
Description
_defiController
address
Defi controller address.

setFeeContractUpdater

1
function setFeeContractUpdater(
2
address _value
3
) external
Copied!
Set fee contract updater, that can update fix native fee

Parameters:

Name
Type
Description
_value
address
new contract address.

setWethGate

1
function setWethGate(
2
contract IWethGate _wethGate
3
) external
Copied!
Set wethGate contract, that uses for weth withdraws affected by EIP1884

Parameters:

Name
Type
Description
_wethGate
contract IWethGate
address of new wethGate contract.

pause

1
function pause(
2
) external
Copied!
Stop all transfers.

unpause

1
function unpause(
2
) external
Copied!
Allow transfers.

withdrawFee

1
function withdrawFee(
2
bytes32 _debridgeId
3
) external
Copied!
Withdraw collected fees to feeProxy

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.

requestReserves

1
function requestReserves(
2
address _tokenAddress,
3
uint256 _amount
4
) external
Copied!
Request the assets to be used in DeFi protocol.

Parameters:

Name
Type
Description
_tokenAddress
address
Asset address.
_amount
uint256
Amount of tokens to request.

returnReserves

1
function returnReserves(
2
address _tokenAddress,
3
uint256 _amount
4
) external
Copied!
Return the assets that were used in DeFi protocol.

Parameters:

Name
Type
Description
_tokenAddress
address
Asset address.
_amount
uint256
Amount of tokens to claim.

setFeeProxy

1
function setFeeProxy(
2
address _feeProxy
3
) external
Copied!
Set fee converter proxy.

Parameters:

Name
Type
Description
_feeProxy
address
Fee proxy address.

blockSubmission

1
function blockSubmission(
2
bytes32[] _submissionIds,
3
bool isBlocked
4
) external
Copied!
Block or unblock a list of submissions

Parameters:

Name
Type
Description
_submissionIds
bytes32[]
Ids of submissions to block/unblock
isBlocked
bool
True to block, false to unblock

updateFlashFee

1
function updateFlashFee(
2
uint256 _flashFeeBps
3
) external
Copied!
Update flash fees.

Parameters:

Name
Type
Description
_flashFeeBps
uint256
new fee in BPS

updateFeeDiscount

1
function updateFeeDiscount(
2
address _address,
3
uint16 _discountFixBps,
4
uint16 _discountTransferBps
5
) external
Copied!
Update discount.

Parameters:

Name
Type
Description
_address
address
customer address
_discountFixBps
uint16
fix discount in BPS
_discountTransferBps
uint16
transfer % discount in BPS

receive

1
function receive(
2
) external
Copied!

_checkConfirmations

1
function _checkConfirmations(
2
bytes32 _submissionId,
3
bytes32 _debridgeId,
4
uint256 _amount,
5
bytes _signatures
6
) internal
Copied!

_addAsset

1
function _addAsset(
2
bytes32 _debridgeId,
3
address _tokenAddress,
4
bytes _nativeAddress,
5
uint256 _nativeChainId
6
) internal
Copied!
Add support for the asset.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_tokenAddress
address
Address of the asset on the current chain.
_nativeAddress
bytes
Address of the asset on the native chain.
_nativeChainId
uint256
Native chain id.

_send

1
function _send(
2
bytes _amount,
3
address _chainIdTo,
4
uint256 _permit
5
) internal returns (uint256 amountAfterFee, bytes32 debridgeId, struct IDeBridgeGate.FeeParams feeParams)
Copied!
Locks asset on the chain and enables minting on the other chain.

Parameters:

Name
Type
Description
_amount
bytes
Amount to be transferred (note: the fee can be applied).
_chainIdTo
address
Chain id of the target chain.
_permit
uint256
deadline + signature for approving the spender by signature.

_publishSubmission

1
function _publishSubmission(
2
bytes32 _debridgeId,
3
uint256 _chainIdTo,
4
uint256 _amount,
5
bytes _receiver,
6
struct IDeBridgeGate.FeeParams feeParams,
7
uint32 _referralCode,
8
struct IDeBridgeGate.SubmissionAutoParamsTo autoParams,
9
bool hasAutoParams
10
) internal
Copied!

_applyDiscount

1
function _applyDiscount(
2
uint256 amount,
3
uint16 discountBps
4
) internal returns (uint256)
Copied!

_validateToken

1
function _validateToken(
2
address _token
3
) internal
Copied!

_claim

1
function _claim(
2
bytes32 _debridgeId,
3
bytes32 _receiver,
4
address _amount
5
) internal returns (bool isNativeToken)
Copied!
Unlock the asset on the current chain and transfer to receiver.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_receiver
bytes32
Receiver address.
_amount
address
Amount of the transfered asset (note: the fee can be applyed).

_mintOrTransfer

1
function _mintOrTransfer(
2
address _token,
3
address _receiver,
4
uint256 _amount,
5
bool isNativeToken
6
) internal
Copied!

_safeTransferETH

1
function _safeTransferETH(
2
address to,
3
uint256 value
4
) internal
Copied!

_withdrawWeth

1
function _withdrawWeth(
2
address _receiver,
3
uint256 _amount
4
) internal
Copied!

_normalizeTokenAmount

1
function _normalizeTokenAmount(
2
address _token,
3
uint256 _amount
4
) internal returns (uint256)
Copied!

getDefiAvaliableReserves

1
function getDefiAvaliableReserves(
2
address _tokenAddress
3
) external returns (uint256)
Copied!
Get reserves of a token available to use in defi

Parameters:

Name
Type
Description
_tokenAddress
address
Token address

getDebridgeId

1
function getDebridgeId(
2
uint256 _chainId,
3
address _tokenAddress
4
) public returns (bytes32)
Copied!
Calculates asset identifier.

Parameters:

Name
Type
Description
_chainId
uint256
Current chain id.
_tokenAddress
address
Address of the asset on the other chain.

getbDebridgeId

1
function getbDebridgeId(
2
uint256 _chainId,
3
bytes _tokenAddress
4
) public returns (bytes32)
Copied!
Calculates asset identifier.

Parameters:

Name
Type
Description
_chainId
uint256
Current chain id.
_tokenAddress
bytes
Address of the asset on the other chain.

getDebridgeChainAssetFixedFee

1
function getDebridgeChainAssetFixedFee(
2
bytes32 _debridgeId,
3
uint256 _chainId
4
) external returns (uint256)
Copied!
Returns asset fixed fee value for specified debridge and chainId.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_chainId
uint256
Chain id.

getSubmissionIdFrom

1
function getSubmissionIdFrom(
2
bytes32 _debridgeId,
3
uint256 _chainIdFrom,
4
uint256 _amount,
5
address _receiver,
6
uint256 _nonce,
7
struct IDeBridgeGate.SubmissionAutoParamsFrom _autoParams,
8
bool _hasAutoParams,
9
address _sender
10
) public returns (bytes32)
Copied!
Calculate submission id for auto claimable transfer.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Asset identifier.
_chainIdFrom
uint256
Chain identifier of the chain where tokens are sent from.
_amount
uint256
Amount of the transferred asset (note: the fee can be applied).
_receiver
address
Receiver address.
_nonce
uint256
Submission id.
_autoParams
struct IDeBridgeGate.SubmissionAutoParamsFrom
Auto params for external call
_hasAutoParams
bool
True if auto params are provided
_sender
address
Address that will call claim

getDeployId

1
function getDeployId(
2
bytes32 _debridgeId,
3
string _name,
4
string _symbol,
5
uint8 _decimals
6
) public returns (bytes32)
Copied!
Calculates asset identifier for deployment.

Parameters:

Name
Type
Description
_debridgeId
bytes32
Id of an asset, see getDebridgeId.
_name
string
Asset's name.
_symbol
string
Asset's symbol.
_decimals
uint8
Asset's decimals.

getChainId

1
function getChainId(
2
) public returns (uint256 cid)
Copied!
Get current chain id

version

1
function version(
2
) external returns (uint256)
Copied!
Get this contract's version