BridgeETH

link to BridgeETH source code (will update when protocol goes live)

BridgeETH contract is the Ethereum part of the K9-owned bridge. This bridge is used only by K9 Finance DAO for the platform purposes to transfer knBONE tokens from Ethereum to Shibarium and backwards.

Variables

bytes32 public constant DAO_ROLE = keccak256("DAO_ROLE"); - dao role identifier bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE"); - bridge validator role identifier bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE"); - pauser role identifier bytes32 public constant UNPAUSE_ROLE = keccak256("UNPAUSE_ROLE"); - unpauser role identifier uint256 public minSignatures; - minimum number of signatures from validators to accept a transaction uint256 public nextTransactionIDFromThisNetwork; - the next transactionID that will be assigned to a transaction of this network IKnBONE public knBONE - knBONE contract interface address public feeReceiver; - bridging fee receiver address mapping(uint256 => mapping(uint256 => bool)) public processedTransaction; - for each network, for each in and out transaction , it shows whether it was processed or not

Events

event Deposit(uint256 indexed transactionID, address indexed from, address indexed to, uint256 amount); - upon depositForUser call (when user submits) event Execute(uint256 indexed chainID, uint256 indexed transactionID, uint8 indexed withdrawStatus); - upon execute call (processing an incoming transaction)

Methods

initialize

function initialize(
           address _dao, 
           address _feeReceiver, 
           IKnBONE _knBONE, 
           address[] calldata _validators, 
           uint256 _minSignatures) 
     external initializer

Initializer function, not called after initialization

depositForUser

function depositForUser(address receiver, uint256 amount) 
     external 
     whenNotPaused 
     nonReentrant

When user have done the deposit to protocol, claims the knBONE amount of the associated deposit to further transfer it from Ethereum to Shibarium.

execute

function execute(
           uint256 chainID, 
           uint256 transactionID, 
           address receiver, 
           uint256 amountToReceive, 
           uint256 feeAmount, 
           uint256 _instantPoolAmount, 
           uint256 _requestWithdrawAmount, 
           bytes[] calldata signatures) 
           external 
     whenNotPaused 
     nonReentrant

Processes the incoming transaction of deposit or withdrawal.

If the _instantPoolAmount or/and _requestWithdrawAmount values are not zero, then it means that user wants to unstake from the protocol, so this function tries to unstake from knBONE contract with the specified parameters on behalf of the receiver. If zero, then user's deposit is processed.

It is necessary that there are at least minimum minSignatures signatures from unique addresses having VALIDATOR_ROLE in the signatures array.

simulateExecute

function simulateExecute(uint256 chainID, 
           uint256 transactionID, 
           address receiver, 
           uint256 amountToReceive, 
           uint256 feeAmount, 
           uint256 _instantPoolAmount, 
           uint256 _requestWithdrawAmount) 
     external 
     whenNotPaused 
     nonReentrant

Does the same as execute() only without signatures - needed for simulation to check if the execute() will work on user call. Any chainID and transactionID may be specified.

Available only when the sender is a zero address.

setMinSignatures

function setMinSignatures(uint256 _minSignatures) external onlyRole(DAO_ROLE)

Sets minSignatures, cannot be set to 0.

setFeeReceiver

function setFeeReceiver(address _feeReceiver) external onlyRole(DAO_ROLE)

Sets feeReceiver, cannot be set to 0 address.

pause

function pause() external onlyRole(PAUSE_ROLE)

Pauses the BridgeETH contract.

unpause

function unpause() external onlyRole(UNPAUSE_ROLE)

Unpauses the BridgeETH contract.

Last updated