WrappedTokenBridge

The WrappedTokenBridge enables users to wrap a token and transfer it to another chain in a single transaction using CCIP. Additonally it can receive a CCIP token transfer from another chain and automatically unwrap tokens before sending them to their final destination.

This contract is used to handle stLINK <-> wstLINK transfers between the primary chain and secondary chains.

View Functions

getRouter

Returns the current CCIP router

function getRouter() public view returns (address)

Return Values

NameTypeDescription

router

address

router address

linkToken

Returns the address of the LINK token

function linkToken() external view returns (address)

Return Values

NameTypeDescription

linkToken

address

address of LINK token

token

Returns the address of the underlying token bridged by this contract

function token() external view returns (address)

Return Values

NameTypeDescription

underlyingToken

address

address of underlying token

wrappedToken

Returns the address of the wrapped token bridged by this contract

function wrappedToken() external view returns (address)

Return Values

NameTypeDescription

wrappedToken

address

address of wrapped token

getFee

Returns the current fee for a token transfer

function getFee(uint64 _destinationChainSelector, uint256 _amount, bool _payNative) external view returns (uint256)

Parameters

NameTypeDescription

_destinationChainSelector

uint64

id of destination chain

_amount

uint256

amount of tokens to transfer

_payNative

bool

whether fee should be paid natively or with LINK

Return Values

NameTypeDescription

fee

uint256

current fee

Write Functions

setRouter

Sets the CCIP router

function setRouter(address _router) external

Parameters

NameTypeDescription

_router

address

router address

onTokenTransfer

ERC677 implementation to receive a token transfer to be wrapped and sent to a destination chain

function onTokenTransfer(address _sender, uint256 _value, bytes _calldata) external

Parameters

NameTypeDescription

_sender

address

address of sender

_value

uint256

amount of tokens transferred

_calldata

bytes

encoded calldata consisting of destinationChainSelector (uint64), receiver (address), maxLINKFee (uint256)

transferTokens

Wraps and transfers tokens to a destination chain

function transferTokens(uint64 _destinationChainSelector, address _receiver, uint256 _amount, bool _payNative, uint256 _maxLINKFee) external payable returns (bytes32 messageId)

Parameters

NameTypeDescription

_destinationChainSelector

uint64

id of destination chain

_receiver

address

address to receive tokens on destination chain

_amount

uint256

amount of tokens to transfer

_payNative

bool

whether fee should be paid natively or with LINK

_maxLINKFee

uint256

call will revert if LINK fee exceeds this value

recoverTokens

Withdraws tokens held by this contract

function recoverTokens(address[] _tokens, uint256[] _amounts, address _receiver) external

Parameters

NameTypeDescription

_tokens

address[]

list of tokens to withdraw

_amounts

uint256[]

list of corresponding amounts to withdraw

_receiver

address

address to receive tokens

Last updated