BaseXVSProxyOFT
BaseXVSProxyOFT
Section titled “BaseXVSProxyOFT”BaseXVSProxyOFT at token-bridge v2.7.0 is the shared abstract LayerZero OFT V2 base. It is not an upgradeable proxy or a standalone deployment. The concrete source and destination contracts fix the token, shared decimals, LayerZero V1 endpoint, and ResilientOracle in their constructors.
In addition to the Venus-specific functions below, the concrete ABI inherits OFT/LzApp functions such as sendFrom, estimateSendFee, retryMessage, trusted-remote and messaging-library configuration, ownership, and packet state. Those inherited functions use LayerZero V1 uint16 endpoint IDs, named chain IDs in the ABI. Administrative calls should normally be routed through XVSBridgeAdmin and checked against its function registry and AccessControlManager permissions.
The BaseXVSProxyOFT contract is tailored for facilitating cross-chain transactions with an ERC20 token.
It manages transaction limits of a single and daily transactions.
This contract inherits key functionalities from other contracts, including pausing capabilities and error handling.
It holds state variables for the inner token and maps for tracking transaction limits and statistics across various chains and addresses.
The contract owner can configure bridge state directly at the Solidity level, but production ownership is assigned to XVSBridgeAdmin, which applies its own registry and AccessControlManager checks.
Internal functions conduct eligibility check of transactions, making the contract a fundamental component for cross-chain token management.
Solidity API
Section titled “Solidity API”oracle
Section titled “oracle”The address of ResilientOracle contract wrapped in its interface.
contract ResilientOracleInterface oraclechainIdToMaxSingleTransactionLimit
Section titled “chainIdToMaxSingleTransactionLimit”Maximum limit for a single transaction in USD(scaled with 18 decimals) from local chain.
mapping(uint16 => uint256) chainIdToMaxSingleTransactionLimitchainIdToMaxDailyLimit
Section titled “chainIdToMaxDailyLimit”Maximum daily limit for transactions in USD(scaled with 18 decimals) from local chain.
mapping(uint16 => uint256) chainIdToMaxDailyLimitchainIdToLast24HourTransferred
Section titled “chainIdToLast24HourTransferred”Total sent amount in USD(scaled with 18 decimals) within the last 24-hour window from local chain.
mapping(uint16 => uint256) chainIdToLast24HourTransferredchainIdToLast24HourWindowStart
Section titled “chainIdToLast24HourWindowStart”Timestamp when the last 24-hour window started from local chain.
mapping(uint16 => uint256) chainIdToLast24HourWindowStartchainIdToMaxSingleReceiveTransactionLimit
Section titled “chainIdToMaxSingleReceiveTransactionLimit”Maximum limit for a single receive transaction in USD(scaled with 18 decimals) from remote chain.
mapping(uint16 => uint256) chainIdToMaxSingleReceiveTransactionLimitchainIdToMaxDailyReceiveLimit
Section titled “chainIdToMaxDailyReceiveLimit”Maximum daily limit for receiving transactions in USD(scaled with 18 decimals) from remote chain.
mapping(uint16 => uint256) chainIdToMaxDailyReceiveLimitchainIdToLast24HourReceived
Section titled “chainIdToLast24HourReceived”Total received amount in USD(scaled with 18 decimals) within the last 24-hour window from remote chain.
mapping(uint16 => uint256) chainIdToLast24HourReceivedchainIdToLast24HourReceiveWindowStart
Section titled “chainIdToLast24HourReceiveWindowStart”Timestamp when the last 24-hour window started from remote chain.
mapping(uint16 => uint256) chainIdToLast24HourReceiveWindowStartwhitelist
Section titled “whitelist”Address on which cap check and bound limit is not applicable.
mapping(address => bool) whitelistsetOracle
Section titled “setOracle”Set the address of the ResilientOracle contract.
function setOracle(address oracleAddress_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| oracleAddress_ | address | The new address of the ResilientOracle contract. |
📅 Events
Section titled “📅 Events”- Emits OracleChanged with old and new oracle address.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
setMaxSingleTransactionLimit
Section titled “setMaxSingleTransactionLimit”Sets the limit of single transaction amount.
function setMaxSingleTransactionLimit(uint16 chainId_, uint256 limit_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| chainId_ | uint16 | Destination chain id. |
| limit_ | uint256 | Amount in USD(scaled with 18 decimals). |
📅 Events
Section titled “📅 Events”- Emits SetMaxSingleTransactionLimit with old and new limit associated with chain id.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
setMaxDailyLimit
Section titled “setMaxDailyLimit”Sets the limit of daily (24 Hour) transactions amount.
function setMaxDailyLimit(uint16 chainId_, uint256 limit_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| chainId_ | uint16 | Destination chain id. |
| limit_ | uint256 | Amount in USD(scaled with 18 decimals). |
📅 Events
Section titled “📅 Events”- Emits setMaxDailyLimit with old and new limit associated with chain id.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
setMaxSingleReceiveTransactionLimit
Section titled “setMaxSingleReceiveTransactionLimit”Sets the maximum limit for a single receive transaction.
function setMaxSingleReceiveTransactionLimit(uint16 chainId_, uint256 limit_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| chainId_ | uint16 | The destination chain ID. |
| limit_ | uint256 | The new maximum limit in USD(scaled with 18 decimals). |
📅 Events
Section titled “📅 Events”- Emits setMaxSingleReceiveTransactionLimit with old and new limit associated with chain id.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
setMaxDailyReceiveLimit
Section titled “setMaxDailyReceiveLimit”Sets the maximum daily limit for receiving transactions.
function setMaxDailyReceiveLimit(uint16 chainId_, uint256 limit_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| chainId_ | uint16 | The destination chain ID. |
| limit_ | uint256 | The new maximum daily limit in USD(scaled with 18 decimals). |
📅 Events
Section titled “📅 Events”- Emits setMaxDailyReceiveLimit with old and new limit associated with chain id.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
setWhitelist
Section titled “setWhitelist”Sets the whitelist address to skip checks on transaction limit.
function setWhitelist(address user_, bool val_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| user_ | address | Address to be add in whitelist. |
| val_ | bool | Boolean to be set (true for user_ address is whitelisted). |
📅 Events
Section titled “📅 Events”- Emits setWhitelist.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
Triggers stopped state of the bridge.
function pause() external⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
unpause
Section titled “unpause”Triggers resume state of the bridge.
function unpause() external⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
sweepToken
Section titled “sweepToken”A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to user
function sweepToken(contract IERC20 token_, address to_, uint256 amount_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| token_ | contract IERC20 | The address of the ERC-20 token to sweep |
| to_ | address | The address of the recipient |
| amount_ | uint256 | The amount of tokens needs to transfer |
📅 Events
Section titled “📅 Events”- Emits SweepToken event
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only Owner
❌ Errors
Section titled “❌ Errors”- Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract
removeTrustedRemote
Section titled “removeTrustedRemote”Remove trusted remote from storage.
function removeTrustedRemote(uint16 remoteChainId_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| remoteChainId_ | uint16 | The chain’s id corresponds to setting the trusted remote to empty. |
📅 Events
Section titled “📅 Events”- Emits TrustedRemoteRemoved once chain id is removed from trusted remote.
⛔️ Access Requirements
Section titled “⛔️ Access Requirements”- Only owner.
updateSendAndCallEnabled
Section titled “updateSendAndCallEnabled”It enables or disables sendAndCall functionality for the bridge.
function updateSendAndCallEnabled(bool enabled_) externalParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| enabled_ | bool | Boolean indicating whether the sendAndCall function should be enabled or disabled. |
isEligibleToSend
Section titled “isEligibleToSend”Checks the eligibility of a sender to initiate a cross-chain token transfer.
function isEligibleToSend(address from_, uint16 dstChainId_, uint256 amount_) external view returns (bool eligibleToSend, uint256 maxSingleTransactionLimit, uint256 maxDailyLimit, uint256 amountInUsd, uint256 transferredInWindow, uint256 last24HourWindowStart, bool isWhiteListedUser)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| from_ | address | The sender’s address initiating the transfer. |
| dstChainId_ | uint16 | Indicates destination chain. |
| amount_ | uint256 | The quantity of tokens to be transferred. |
Return Values
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| eligibleToSend | bool | A boolean indicating whether the sender is eligible to transfer the tokens. |
| maxSingleTransactionLimit | uint256 | The maximum limit for a single transaction. |
| maxDailyLimit | uint256 | The maximum daily limit for transactions. |
| amountInUsd | uint256 | The equivalent amount in USD based on the oracle price. |
| transferredInWindow | uint256 | The total amount transferred in the current 24-hour window. |
| last24HourWindowStart | uint256 | The timestamp when the current 24-hour window started. |
| isWhiteListedUser | bool | A boolean indicating whether the sender is whitelisted. |
sendAndCall
Section titled “sendAndCall”Initiates a cross-chain token transfer and triggers a call on the destination chain.
function sendAndCall(address from_, uint16 dstChainId_, bytes32 toAddress_, uint256 amount_, bytes payload_, uint64 dstGasForCall_, struct ICommonOFT.LzCallParams callparams_) public payableParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| from_ | address | Address from which tokens will be debited. |
| dstChainId_ | uint16 | Destination chain id on which tokens will be send. |
| toAddress_ | bytes32 | Address on which tokens will be credited on destination chain. |
| amount_ | uint256 | Amount of tokens that will be transferred. |
| payload_ | bytes | Additional data payload for the call on the destination chain. |
| dstGasForCall_ | uint64 | The amount of gas allocated for the call on the destination chain. |
| callparams_ | struct ICommonOFT.LzCallParams | Additional parameters, including refund address, ZRO payment address, and adapter params. |
retryMessage
Section titled “retryMessage”Retries a stored failed LayerZero V1 message after requiring the supplied source path to equal the contract’s current nonempty trusted remote. Anyone can submit the retry transaction, but the payload must match the stored failed-message hash.
function retryMessage(uint16 srcChainId_, bytes srcAddress_, uint64 nonce_, bytes payload_) public payablerenounceOwnership
Section titled “renounceOwnership”Empty implementation of renounce ownership to avoid any mishappening.
function renounceOwnership() publicReturn’s the address of the inner token of this bridge.
function token() public view returns (address)Return Values
Section titled “Return Values”| Name | Type | Description |
|---|---|---|
| [0] | address | Address of the inner token of this bridge. |