core staking contracts
WrappedTokenBridge Contract: Cross-Chain wstLINK via CCIP
The WrappedTokenBridge enables users to wrap a token and transfer it to another chain in a single transaction using CCIP. Additionally 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
Section titled “View Functions”getRouter
Section titled “getRouter”Returns the current CCIP router
function getRouter() public view returns (address)Return Values
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| router | address | router address |
linkToken
Section titled “linkToken”Returns the address of the LINK token
function linkToken() external view returns (address)Return Values
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| linkToken | address | address of LINK token |
Returns the address of the underlying token bridged by this contract
function token() external view returns (address)Return Values
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| underlyingToken | address | address of underlying token |
wrappedToken
Section titled “wrappedToken”Returns the address of the wrapped token bridged by this contract
function wrappedToken() external view returns (address)Return Values
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| wrappedToken | address | address of wrapped token |
getFee
Section titled “getFee”Returns the current fee for a token transfer
function getFee(uint64 _destinationChainSelector, uint256 _amount, bool _payNative) external view returns (uint256)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| _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
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| fee | uint256 | current fee |
Write Functions
Section titled “Write Functions”setRouter
Section titled “setRouter”Sets the CCIP router
function setRouter(address _router) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| _router | address | router address |
onTokenTransfer
Section titled “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) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| _sender | address | address of sender |
| _value | uint256 | amount of tokens transferred |
| _calldata | bytes | encoded calldata consisting of destinationChainSelector (uint64), receiver (address), maxLINKFee (uint256) |
transferTokens
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| _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
Section titled “recoverTokens”Withdraws tokens held by this contract
function recoverTokens(address[] _tokens, uint256[] _amounts, address _receiver) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| _tokens | address[] | list of tokens to withdraw |
| _amounts | uint256[] | list of corresponding amounts to withdraw |
| _receiver | address | address to receive tokens |