deBridge 백서

deBridge

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 31쪽 중 19쪽

is confirmed by min required amount of oracles. # IWethGate Source: https://docs.debridge.com/dmp-details/dev-guides/evm/interfaces/IWethGate IWethGate interface details - functions. ## Functions ### withdraw ```solidity theme={null} function withdraw( address receiver, uint256 wad ) external ``` Transfer assets to a receiver. **Parameters:** | Name | Type | Description | | ---------- | --------- | ------------------------------------- | | `receiver` | `address` | This address will receive a transfer. | | `wad` | `uint256` | Amount in wei | # introduction Source: https://docs.debridge.com/dmp-details/dev-guides/evm/introduction Method Parameters, AutoParams Structure, and Flags. # Interaction with deBridge Infrastructure Interaction with the deBridge infrastructure is as simple as calling the `send` method of the `debridgeGate` smart contract deployed on all supported blockchains. The method can be called by any arbitrary address — either EOA or smart contracts. ```solidity theme={null} function send( address _tokenAddress, uint256 _amount, uint256 _chainIdTo, bytes memory _receiver, bytes memory _permit, bool _useAssetFee, uint32 _referralCode, bytes calldata _autoParams ) external payable; ``` ## Method Parameters | Parameter Name | Type | Description | | --------------- | ------- | ------------------------------------------------------------------------------------------- | | `_tokenAddress` | address | Address of the token being sent (`address(0)` for chain base assets like ETH) | | `_amount` | uint256 | Token amount to be transferred | | `_chainIdTo` | uint256 | Id of the receiving chain | | `_receiver` | bytes | Address of the receiver | | `_permit` | bytes | [EIP-2612](https://eips.ethereum.org/EIPS/eip-2612) permit signature (if token supports it) | | `_useAssetFee` | bool | Should be set to `false`. Reserved for future governance usage | | `_referralCode` | uint32 | Your generated referral code | | `_autoParams` | bytes | Structure that enables passing arbitrary messages and call data | <Tip> If you integrate with or build applications on top of the deBridge infrastructure, make sure you specify your referral code that can be generated by pressing the INVITE FRIENDS button at [https://app.debridge.com/](https://app.debridge.com/). Governance may thank you later for being an early builder. </Tip> *** ## AutoParams Structure `_autoParams` allows passing arbitrary messages and call data to be executed as an external call to the receiver address on the destination chain. It also enables setting an `executionFee`, which rewards the wallet/keeper that completes the transaction. It enables a crypto-economic design where gas fees are paid from the blockchain where the transaction is initiated. The `_autoParams` field has the following structure: ```solidity theme={null} struct SubmissionAutoParamsTo { uint256 executionFee; uint256 flags; bytes fallbackAddress; bytes data; } ``` | Parameter Name | Type | Description | | ----------------- | ------- | ------------------------------------------------------------------------------------------------------ | | `executionFee` | uint256 | Suggested reward (in tokens) paid to executor on the destination chain | | `flags` | uint256 | Bitmask flags that define execution logic | | `fallbackAddress` | bytes | Address to receive tokens if external call fails | | `data` | bytes | Message/call data to be passed to the receiver on destination chain during the external call execution | *** ## Flags Flags are a bitmask that customize transaction execution flow on the destination chain. You can combine multiple flags by setting respective bits to `1` simultaneously. ```solidity theme={null} library Flags { uint256 public constant UNWRAP_ETH = 0; uint256 public constant REVERT_IF_EXTERNAL_FAIL = 1; uint256 public constant PROXY_WITH_SENDER = 2; uint256 public constant SEND_HASHED_DATA = 3; uint256 public constant SEND_EXTERNAL_CALL_GAS_LIMIT = 4; uint256 public constant MULTI_SEND = 5; } ``` | Flag Name | Value | Description | | ------------------------------ | ----- | --------------------------------------------------------------------------------------- | | `UNWRAP_ETH` | 0 | Automatically unwrap base asset (e.g., convert WETH to ETH) | | `REVERT_IF_EXTERNAL_FAIL` | 1 | Revert entire tx if external call fails | | `PROXY_WITH_SENDER` | 2 | Enforces sender validation via `submissionNativeSender` and `submissionChainIdFrom` | | `SEND_HASHED_DATA` | 3 | Only hashed data is passed; used to prevent unauthorized claims | | `SEND_EXTERNAL_CALL_GAS_LIMIT` | 4 | Specifies minimal gas limit for the external call (included in first 4 bytes of `data`) | | `MULTI_SEND` | 5 | Executes data via Gnosis Multisend implementation inside deBridge `callProxy` | *** `PROXY_WITH_SENDER` flag should be used if the receiving smart contract must validate that the message sender is trusted. When set, the deBridge protocol stores `submissionNativeSender` and `submissionChainIdFrom`, allowing the recipient contract to verify the sender. <img alt="External Call" /> The receiving smart contract can retrieve the `callProxy` address from the `debridgeGate` smart contract. Use [`onlyControllingAddress`](https://github.com/debridge-finance/debridge-twap-oracle/blob/f981f700d07108fce5509fabd2fd0f10157ae6d6/contracts/debridge-twap-oracle/BridgeAppBase.sol#L62) modifier or inherit from [`BridgeAppBase.sol`](https://github.com/debridge-finance/debridge-twap-oracle/blob/f981f700d07108fce5509fabd2fd0f10157ae6d6/contracts/debridge-twap-oracle/BridgeAppBase.sol) to implement this validation logic properly. # Flags Source: https://docs.debridge.com/dmp-details/dev-guides/evm/libraries/flags Flags library details - fields and functions. ## Variables ### UNWRAP\_ETH ```solidity theme={null} uint256 public constant UNWRAP_ETH; ``` Flag to unwrap ETH ### REVERT\_IF\_EXTERNAL\_FAIL ```solidity theme={null} uint256 public constant REVERT_IF_EXTERNAL_FAIL; ``` Flag to revert if external call fails ### PROXY\_WITH\_SENDER ```solidity theme={null} uint256 public constant PROXY_WITH_SENDER; ``` Flag to call proxy with a sender contract ### SEND\_HASHED\_DATA ```solidity theme={null} uint256 public constant SEND_HASHED_DATA; ``` Data is hash in DeBridgeGate send method *** ## Functions ### getFlag ```solidity theme={null} function getFlag( uint256 _packedFlags, uint256 _flag ) internal returns (bool) ``` Get flag #### Parameters: | Name | Type | Description | | ------------- | ------- | ----------------------- | | \_packedFlags | uint256 | Flags packed to uint256 | | \_flag | uint256 | Flag to check | *** ### setFlag ```solidity theme={null} function setFlag( uint256 _packedFlags, uint256 _flag, bool _value ) internal returns (uint256) ``` Set flag #### Parameters: | Name | Type | Description | | ------------- | ------- | ----------------------- | | \_packedFlags | uint256 | Flags packed to uint256 | | \_flag | uint256 | Flag to set | | \_value | bool | Is set or not set | # CallProxy Source: https://docs.debridge.com/dmp-details/dev-guides/evm/periphery/CallProxy CallProxy contract details - fields and functions. Proxy to execute the other contract calls. This contract is used when a user requests transfer with specific call of other contract. *** ## Variables ### DEBRIDGE\_GATE\_ROLE ```solidity theme={null} bytes32 public constant DEBRIDGE_GATE_ROLE; ``` Role allowed to withdraw fee ### submissionChainIdFrom ```solidity theme={null} uint256 public submissionChainIdFrom; ``` Chain from which the current submission is received ### submissionNativeSender ```solidity theme={null} bytes public submissionNativeSender; ``` Native sender of the current submission *** ## Functions ### initialize ```solidity theme={null} function initialize() public ``` ### call ```solidity theme={null} function call( address _reserveAddress, address _receiver, bytes _data, uint256 _flags, bytes _nativeSender, uint256 _chainIdFrom ) external returns (bool _result) ``` Used for calls where native asset transfer is involved. #### Parameters: | Name | Type | Description | | ---------------- | ------- | ------------------------------------------------------- | | \_reserveAddress | address | Receiver of the tokens if the call to \_receiver fails | | \_receiver | address | Contract to be called | | \_data | bytes | Call data | | \_flags | uint256 | Flags to change behavior; see Flags library for details | | \_nativeSender | bytes | Native sender | | \_chainIdFrom | uint256 | Id of a chain that originated the request | *** ### callERC20 ```solidity theme={null} function callERC20( address _token, address _reserveAddress, address _receiver, bytes _data, uint256 _flags, bytes _nativeSender, uint256 _chainIdFrom ) external returns (bool _result) ``` Used for calls where ERC20 transfer is involved. #### Parameters: | Name | Type | Description | | ---------------- | ------- | ------------------------------------------------------- | | \_token | address | Asset address | | \_reserveAddress | address | Receiver of the tokens if the call to \_receiver fails | | \_receiver | address | Contract to be called | | \_data | bytes | Call data | | \_flags | uint256 | Flags to change behavior; see Flags library for details | | \_nativeSender | bytes | Native sender | | \_chainIdFrom | uint256 | Id of a chain that originated the request | *** ### externalCall ```solidity theme={null} function externalCall( address destination, uint256 value, bytes data, bytes _nativeSender, uint256 _chainIdFrom, bool storeSender ) internal returns (bool result) ``` *** ### receive ```solidity theme={null} function receive() external ``` *** ### version ```solidity theme={null} function version() external returns (uint256) ``` Get this contract's version # DeBridgeToken Source: https://docs.debridge.com/dmp-details/dev-guides/evm/periphery/DeBridgeToken DeBridgeToken contract details - fields and functions. ERC20 token that is used as wrapped asset to represent the native token value on the other chains. *** ## Variables ### MINTER\_ROLE ```solidity theme={null} bytes32 public constant MINTER_ROLE; ``` Minter role identifier ### PAUSER\_ROLE ```solidity theme={null} bytes32 public constant PAUSER_ROLE; ``` Pauser role identifier ### DOMAIN\_SEPARATOR ```solidity theme={null} bytes32 public DOMAIN_SEPARATOR; ``` Domain separator as described in [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#rationale) ### PERMIT\_TYPEHASH ```solidity theme={null} bytes32 public constant PERMIT_TYPEHASH; ``` Typehash as described in [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#rationale). ``` typehash = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)") ``` ### nonces ```solidity theme={null} mapping(address => uint256) public nonces; ``` Transfers counter ### \_decimals ```solidity theme={null} uint8 internal _decimals; ``` Asset's decimals *** ## Functions ### initialize ```solidity theme={null} function initialize( string name_, string symbol_, uint8 decimals_, address admin, address[] minters ) public ``` Constructor that initializes the most important configurations. #### Parameters: | Name | Type | Description | | ---------- | ---------- | ---------------------------------------- | | name\_ | string | Asset's name. | | symbol\_ | string | Asset's symbol. | | decimals\_ | uint8 | Asset's decimals. | | admin | address | Address to set as asset's admin. | | minters | address\[] | The accounts allowed to mint new tokens. | *** ### mint ```solidity theme={null} function mint( address _receiver, uint256 _amount ) external ``` Issues new tokens. #### Parameters: | Name | Type | Description | | ---------- | ------- | -------------------- | | \_receiver | address | Token's receiver. | | \_amount | uint256 | Amount to be minted. | *** ### burn ```solidity theme={null} function burn( uint256 _amount ) external ``` Destroys existing tokens. #### Parameters: | Name | Type | Description | | -------- | ------- | ------------------- | | \_amount | uint256 | Amount to be burnt. | *** ### permit ```solidity theme={null} function permit( address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s ) external ``` Approves the spender by signature. #### Parameters: | Name | Type | Description | | ---------- | ------- | ----------------------- | | \_owner | address | Token's owner. | | \_spender | address | Account to be approved. | | \_value | uint256 | Amount to be approved. | | \_deadline | uint256 | The permit valid until. | | \_v | uint8 | Signature part. | | \_r | bytes32 | Signature part. | | \_s | bytes32 | Signature part. | *** ### decimals ```solidity theme={null} function decimals() public returns (uint8) ``` Asset's decimals *** ### pause ```solidity theme={null} function pause() public ``` Pauses all token transfers. The caller must have the `PAUSER_ROLE`. *** ### unpause ```solidity theme={null} function unpause() public ``` Unpauses all token transfers. The caller must have the `PAUSER_ROLE`. *** ### \_beforeTokenTransfer ```solidity theme={null} function _beforeTokenTransfer( address from, address to, uint256 amount ) internal ``` # DeBridgeTokenProxy Source: https://docs.debridge.com/dmp-details/dev-guides/evm/periphery/DeBridgeTokenProxy DeBridgeTokenProxy contract details - functions. This contract implements a proxy that gets the implementation address for each call from `DeBridgeTokenDeployer`. It's deployed by `DeBridgeTokenDeployer`. Implementation is `DeBridgeToken`. *** ## Functions ### constructor ```solidity theme={null} function constructor( address beacon, bytes data ) public ``` # SimpleFeeProxy Source: https://docs.debridge.com/dmp-details/dev-guides/evm/periphery/SimpleFeeProxy SimpleFeeProxy contract details - fields and functions. Helper to withdraw fees from DeBridgeGate and transfer them to a treasury. *** ## Variables ### debridgeGate ```solidity theme={null} contract IDeBridgeGate public debridgeGate; ``` DeBridgeGate address ### treasury ```solidity theme={null} address public treasury; ``` Treasury address *** ## Functions ### initialize ```solidity theme={null} function initialize( contract IDeBridgeGate _debridgeGate, address _treasury ) public ``` ### pause ```solidity theme={null} function pause() external ``` ### unpause ```solidity theme={null} function unpause() external ``` ### setDebridgeGate ```solidity theme={null} function setDebridgeGate( contract IDeBridgeGate _debridgeGate ) external ``` ### setTreasury ```solidity theme={null} function setTreasury( address _treasury ) external ``` ### withdrawFee ```solidity theme={null} function withdrawFee( address _tokenAddress ) external ``` Transfer collected fees for a token to the treasury. #### Parameters: | Name | Type | Description | | -------------- | ------- | --------------------------------------- | | \_tokenAddress | address | Address of a deToken on a current chain | *** ### withdrawNativeFee ```solidity theme={null} function withdrawNativeFee() external ``` Transfer collected fees for a native token to the treasury. ### receive ```solidity theme={null} function receive() external ``` ### getbDebridgeId ```solidity theme={null} function getbDebridgeId( uint256 _chainId, bytes _tokenAddress ) public returns (bytes32) ``` Calculates asset identifier. #### Parameters: | Name | Type | Description | | -------------- | ------- | ---------------------------------------- | | \_chainId | uint256 | Current chain id. | | \_tokenAddress | bytes | Address of the asset on the other chain. | *** ### getDebridgeId ```solidity theme={null} function getDebridgeId( uint256 _chainId, address _tokenAddress ) public returns (bytes32) ``` Calculates asset identifier. #### Parameters: | Name | Type | Description | | -------------- | ------- | ---------------------------------------- | | \_chainId | uint256 | Current chain id. | | \_tokenAddress | address | Address of the asset on the other chain. | *** ### getChainId ```solidity theme={null} function getChainId() public returns (uint256 cid) ``` Get current chain id. *** ### \_safeTransferETH ```solidity theme={null} function _safeTransferETH( address to, uint256 value ) internal ``` Transfer ETH to an address, revert if it fails. #### Parameters: | Name | Type | Description | | ----- | ------- | ------------------------- | | to | address | recipient of the transfer | | value | uint256 | the amount to send | *** ### version ```solidity theme={null} function version() external returns (uint256) ``` Get this contract's version # DeBridgeGate Source: https://docs.debridge.com/dmp-details/dev-guides/evm/transfers/DeBridgeGate DeBridgeGate contract details - fields and functions. 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 ```solidity theme={null} 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 ```solidity theme={null} bytes32 public constant GOVMONITORING_ROLE; ``` Role allowed to stop transfers ### SUBMISSION\_PREFIX ```solidity theme={null} uint256 public constant SUBMISSION_PREFIX; ``` Prefix to calculation `submissionId` ### DEPLOY\_PREFIX ```solidity theme={null} uint256 public constant DEPLOY_PREFIX; ``` Prefix to calculation `deployId` ### deBridgeTokenDeployer ```solidity theme={null} address public deBridgeTokenDeployer; ``` Address of `IDeBridgeTokenDeployer` contract ### signatureVerifier ```solidity theme={null} address public signatureVerifier; ``` Current signature verifier address to verify signatures. ### excessConfirmations ```solidity theme={null} uint8 public excessConfirmations; ``` Minimal required confirmations in case sent amount is big, has no effect if less than `SignatureVerifier.minConfirmations` ### flashFeeBps ```solidity theme={null} uint256 public flashFeeBps; ``` Flash loan fee in basis points (1/10000) ### nonce ```solidity theme={null} uint256 public nonce; ``` Outgoing submissions count ### getDebridge ```solidity theme={null} mapping(bytes32 => struct IDeBridgeGate.DebridgeInfo) public getDebridge; ``` Maps debridgeId (see `getDebridgeId`) => bridge-specific information. ### getDebridgeFeeInfo ```solidity theme={null} mapping(bytes32 => struct IDeBridgeGate.DebridgeFeeInfo) public getDebridgeFeeInfo; ``` Maps debridgeId (see `getDebridgeId`) => fee information ### isSubmissionUsed ```solidity theme={null} mapping(bytes32 => bool) public isSubmissionUsed; ``` Returns whether the transfer with the `submissionId` was claimed. ### isBlockedSubmission ```solidity theme={null} mapping(bytes32 => bool) public isBlockedSubmission; ``` Returns whether the transfer with the `submissionId` is blocked. ### getAmountThreshold ```solidity theme={null} 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 ```solidity theme={null} mapping(uint256 => struct IDeBridgeGate.ChainSupportInfo) public getChainToConfig; ``` Whether the chain for the asset is supported to send ### getChainFromConfig ```solidity theme={null} mapping(uint256 => struct IDeBridgeGate.ChainSupportInfo) public getChainFromConfig; ``` Whether the chain for the asset is supported to claim ### feeDiscount ```solidity theme={null} mapping(address =>
프로젝트로 돌아가기