Comment on page
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.
uint256 public constant BPS_DENOMINATOR;
Basis points or bps, set to 10 000 (equal to 1/10000). Used to express relative values (fees)
bytes32 public constant GOVMONITORING_ROLE;
Role allowed to stop transfers
uint256 public constant SUBMISSION_PREFIX;
prefix to calculation submissionId
uint256 public constant DEPLOY_PREFIX;
prefix to calculation deployId
address public deBridgeTokenDeployer;
Address of IDeBridgeTokenDeployer contract
address public signatureVerifier;
Current signature verifier address to verify signatures.
uint8 public excessConfirmations;
Minimal required confirmations in case sent amount is big, have no effect if less than SignatureVerifier.minConfirmations
uint256 public flashFeeBps;
Flash loan fee in basis points (1/10000)
uint256 public nonce;
outgoing submissions count
mapping(bytes32 => struct IDeBridgeGate.DebridgeInfo) public getDebridge;
Maps debridgeId (see getDebridgeId) => bridge-specific information.
mapping(bytes32 => struct IDeBridgeGate.DebridgeFeeInfo) public getDebridgeFeeInfo;
Maps debridgeId (see getDebridgeId) => fee information
mapping(bytes32 => bool) public isSubmissionUsed;
Returns whether the transfer with the submissionId was claimed. submissionId is generated in getSubmissionIdFrom
mapping(bytes32 => bool) public isBlockedSubmission;
Returns whether the transfer with the submissionId is blocked.
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
mapping(uint256 => struct IDeBridgeGate.ChainSupportInfo) public getChainToConfig;
Whether the chain for the asset is supported to send
mapping(uint256 => struct IDeBridgeGate.ChainSupportInfo) public getChainFromConfig;
Whether the chain for the asset is supported to claim
mapping(address => struct IDeBridgeGate.DiscountInfo) public feeDiscount;
Fee discount for address
mapping(address => struct IDeBridgeGate.TokenInfo) public getNativeInfo;
Returns native token info by wrapped token address
address public defiController;
Return DefiController that can supply liquidity to staking strategies (AAVE, Compound, etc.)
address public feeProxy;
Returns proxy to convert the collected fees and transfer to Ethereum network to treasury
address public callProxy;
Returns address of the proxy to execute user's calls.
contract IWETH public weth;
Returns contract for wrapped native token.
address public feeContractUpdater;
Contract address that can override globalFixedNativeFee
uint256 public globalFixedNativeFee;
Fallback fixed fee in native asset, used if a chain fixed fee is set to 0
uint16 public globalTransferFeeBps;
Fallback transfer fee in BPS, used if a chain transfer fee is set to 0
contract IWethGate public wethGate;
WethGate contract, that is used for weth withdraws affected by EIP1884
uint256 public lockedClaim;
Locker for claim method
function initialize(
uint8 _excessConfirmations,
contract IWETH _weth
) public
Constructor that initializes the most important configurations.
Name | Type | Description |
---|---|---|
_excessConfirmations | uint8 | minimal required confirmations in case of too many confirmations |
_weth | contract IWETH | wrapped native token contract |
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.
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 |
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.
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 |
function flash(
address _tokenAddress,
address _receiver,
uint256 _amount,
bytes _data
) external
Get a flash loan, msg.sender must implement IFlashCallback
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 |
function deployNewAsset(
bytes _nativeTokenAddress,
uint256 _nativeChainId,
string _name,
string _symbol,
uint8 _decimals,
bytes _signatures
) external
Deploy a deToken(DeBridgeTokenProxy) for an asset
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 |
function autoUpdateFixedNativeFee(
uint256 _globalFixedNativeFee
) external
Update native fix fee. Called by our fee update contract
Name | Type | Description |
---|---|---|
_globalFixedNativeFee | uint256 | new value |
function updateChainSupport(
uint256[] _chainIds,
struct IDeBridgeGate.ChainSupportInfo[] _chainSupportInfo,
bool _isChainFrom
) external
Update asset's fees.
Name | Type | Description |
---|---|---|
_chainIds | uint256[] | Chain identifiers. |
_chainSupportInfo | struct IDeBridgeGate.ChainSupportInfo[] | Chain support info. |
_isChainFrom | bool | is true for editing getChainFromConfig. |
function updateGlobalFee(
uint256 _globalFixedNativeFee,
uint16 _globalTransferFeeBps
) external
Update fallbacks for fixed fee in native asset and transfer fee
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 |
function updateAssetFixedFees(
bytes32 _debridgeId,
uint256[] _supportedChainIds,
uint256[] _assetFeesInfo
) external
Update asset's fees.
Name | Type | Description |
---|---|---|
_debridgeId | bytes32 | Asset identifier. |
_supportedChainIds | uint256[] | Chain identifiers. |
_assetFeesInfo | uint256[] | Chain support info. |
function updateExcessConfirmations(
uint8 _excessConfirmations
) external
Update minimal amount of required signatures, must be > SignatureVerifier.minConfirmations to have an effect
Name | Type | Description |
---|---|---|
_excessConfirmations | uint8 | Minimal amount of required signatures |
function setChainSupport(
uint256 _chainId,
bool _isSupported,
bool _isChainFrom
) external
Set support for the chains where the token can be transferred.
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. |
function setCallProxy(
address _callProxy
) external
Set address of the call proxy.
Name | Type | Description |
---|---|---|
_callProxy | address | Address of the proxy that executes external calls. |
function updateAsset(
bytes32 _debridgeId,
uint256 _maxAmount,
uint16 _minReservesBps,
uint256 _amountThreshold
) external
Update specific asset's bridge 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 |
function setSignatureVerifier(
address _verifier
) external
Set signature verifier address.
Name | Type | Description |
---|---|---|
_verifier | address | Signature verifier address. |
function setDeBridgeTokenDeployer(
address _deBridgeTokenDeployer
) external
Set asset deployer address.
Name | Type | Description |
---|---|---|
_deBridgeTokenDeployer | address | Asset deployer address. |
function setDefiController(
address _defiController
) external
Set defi controller.
Name | Type | Description |
---|---|---|
_defiController | address | Defi controller address. |
function setFeeContractUpdater(
address _value
) external
Set fee contract updater, that can update fix native fee
Name | Type | Description |
---|---|---|
_value | address | new contract address. |
function setWethGate(
contract IWethGate _wethGate
) external
Set wethGate contract, that uses for weth withdraws affected by EIP1884
Name | Type | Description |
---|---|---|
_wethGate | contract IWethGate | address of new wethGate contract. |
function pause(
) external
Stop all transfers.
function unpause(
) external
Allow transfers.
function withdrawFee(
bytes32 _debridgeId
) external
Withdraw collected fees to feeProxy
Name | Type | Description |
---|---|---|
_debridgeId | bytes32 | Asset identifier. |
function requestReserves(
address _tokenAddress,
uint256 _amount
) external
Request the assets to be used in DeFi protocol.
Name | Type | Description |
---|---|---|
_tokenAddress | address | Asset address. |
_amount | uint256 | Amount of tokens to request. |
function returnReserves(
address _tokenAddress,
uint256 _amount
) external
Return the assets that were used in DeFi protocol.
Name | Type | Description |
---|---|---|
_tokenAddress | address | Asset address. |
_amount | uint256 | Amount of tokens to claim. |
function setFeeProxy(
address _feeProxy
) external
Set fee converter proxy.
Name | Type | Description |
---|---|---|
_feeProxy | address | Fee proxy address. |
function blockSubmission(
bytes32[] _submissionIds,
bool isBlocked
) external
Block or unblock a list of submissions
Name | Type | Description |
---|---|---|
_submissionIds | bytes32[] | Ids of submissions to block/unblock |
isBlocked | bool | True to block, false to unblock |
function updateFlashFee(
uint256 _flashFeeBps
) external
Update flash fees.
Name | Type | Description |
---|---|---|
_flashFeeBps | uint256 | new fee in BPS |
function updateFeeDiscount(
address _address,
uint16 _discountFixBps,
uint16 _discountTransferBps
) external
Update discount.
Name | Type | Description |
---|---|---|
_address | address | customer address |
_discountFixBps | uint16 | fix discount in BPS |
_discountTransferBps | uint16 | transfer % discount in BPS |
function receive(
) external
function _checkConfirmations(
bytes32 _submissionId,
bytes32 _debridgeId,
uint256 _amount,
bytes _signatures
) internal