BridgeSHIB

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

BridgeSHIB contract is the Shibarium part of the K9-owned bridge. This bridge is used only by K9 Finance DAO for the platform purposes to transfer knBONE tokens from Shibarium to Ethereum 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 ACCEPTOR_ROLE = keccak256("ACCEPTOR_ROLE"); - role identifier of the recipient of the transaction 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 leaving this network IKnBONESHIB knBONE; - knBONE contract interface mapping(uint256 => bool) public acceptedSignature; - for each nonce of an outgoing transaction, it shows whether it was accepted or not, this is necessary as protection against signature replay of transaction receivers 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 amountToReceive, uint256 feeAmount, uint256 _instantPoolAmount, uint256 _requestWithdrawAmount); - upon depositForUserOrUnstake call (when user submits or unstakes) event Execute(uint256 indexed chainID, uint256 indexed transactionID); - upon execute call (processing an incoming transaction)

Methods

initialize

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

Initializer function, not called after initialization.

depositForUserOrUnstake

function depositForUserOrUnstake(
            address receiver, 
            uint256 amountToReceive, 
            uint256 feeAmount, 
            uint256 _instantPoolAmount, 
            uint256 _requestWithdrawAmount, 
            uint256 signatureNonce, 
            uint256 signatureDeadline, 
            bytes calldata signature) 
     external 
     whenNotPaused 
     nonReentrant

Allows the user to transfer tokens from Shibarium to Ethereum or transfer and unstake.

If transfer and unstake, the receiver must match the sender of the transaction.

The transaction receiver signature is required.

execute

function execute(
           uint256 chainID, 
           uint256 transactionID, 
           address receiver, 
           uint256 amount, bytes[] 
           calldata signatures) 
     external 
     whenNotPaused 
     nonReentrant

Executes a transaction from the origin network.

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

setMinSignatures

function setMinSignatures(uint256 minSignatures) 
     external 
     onlyRole(DAO_ROLE)

Sets minSignatures, cannot be set to 0.

pause

function pause() external onlyRole(PAUSE_ROLE)

Pauses the BridgeSHIB contract.

unpause

function unpause() external onlyRole(UNPAUSE_ROLE)

Unpauses the BridgeSHIB contract.

Last updated