Skip to content

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.

The address of ResilientOracle contract wrapped in its interface.

contract ResilientOracleInterface oracle

Maximum limit for a single transaction in USD(scaled with 18 decimals) from local chain.

mapping(uint16 => uint256) chainIdToMaxSingleTransactionLimit

Maximum daily limit for transactions in USD(scaled with 18 decimals) from local chain.

mapping(uint16 => uint256) chainIdToMaxDailyLimit

Total sent amount in USD(scaled with 18 decimals) within the last 24-hour window from local chain.

mapping(uint16 => uint256) chainIdToLast24HourTransferred

Timestamp when the last 24-hour window started from local chain.

mapping(uint16 => uint256) chainIdToLast24HourWindowStart

Maximum limit for a single receive transaction in USD(scaled with 18 decimals) from remote chain.

mapping(uint16 => uint256) chainIdToMaxSingleReceiveTransactionLimit

Maximum daily limit for receiving transactions in USD(scaled with 18 decimals) from remote chain.

mapping(uint16 => uint256) chainIdToMaxDailyReceiveLimit

Total received amount in USD(scaled with 18 decimals) within the last 24-hour window from remote chain.

mapping(uint16 => uint256) chainIdToLast24HourReceived

Timestamp when the last 24-hour window started from remote chain.

mapping(uint16 => uint256) chainIdToLast24HourReceiveWindowStart

Address on which cap check and bound limit is not applicable.

mapping(address => bool) whitelist

Set the address of the ResilientOracle contract.

function setOracle(address oracleAddress_) external
NameTypeDescription
oracleAddress_addressThe new address of the ResilientOracle contract.
  • Emits OracleChanged with old and new oracle address.
  • Only owner.

Sets the limit of single transaction amount.

function setMaxSingleTransactionLimit(uint16 chainId_, uint256 limit_) external
NameTypeDescription
chainId_uint16Destination chain id.
limit_uint256Amount in USD(scaled with 18 decimals).
  • Emits SetMaxSingleTransactionLimit with old and new limit associated with chain id.
  • Only owner.

Sets the limit of daily (24 Hour) transactions amount.

function setMaxDailyLimit(uint16 chainId_, uint256 limit_) external
NameTypeDescription
chainId_uint16Destination chain id.
limit_uint256Amount in USD(scaled with 18 decimals).
  • Emits setMaxDailyLimit with old and new limit associated with chain id.
  • Only owner.

Sets the maximum limit for a single receive transaction.

function setMaxSingleReceiveTransactionLimit(uint16 chainId_, uint256 limit_) external
NameTypeDescription
chainId_uint16The destination chain ID.
limit_uint256The new maximum limit in USD(scaled with 18 decimals).
  • Emits setMaxSingleReceiveTransactionLimit with old and new limit associated with chain id.
  • Only owner.

Sets the maximum daily limit for receiving transactions.

function setMaxDailyReceiveLimit(uint16 chainId_, uint256 limit_) external
NameTypeDescription
chainId_uint16The destination chain ID.
limit_uint256The new maximum daily limit in USD(scaled with 18 decimals).
  • Emits setMaxDailyReceiveLimit with old and new limit associated with chain id.
  • Only owner.

Sets the whitelist address to skip checks on transaction limit.

function setWhitelist(address user_, bool val_) external
NameTypeDescription
user_addressAddress to be add in whitelist.
val_boolBoolean to be set (true for user_ address is whitelisted).
  • Emits setWhitelist.
  • Only owner.

Triggers stopped state of the bridge.

function pause() external
  • Only owner.

Triggers resume state of the bridge.

function unpause() external
  • Only owner.

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_) external
NameTypeDescription
token_contract IERC20The address of the ERC-20 token to sweep
to_addressThe address of the recipient
amount_uint256The amount of tokens needs to transfer
  • Emits SweepToken event
  • Only Owner
  • Throw InsufficientBalance if amount_ is greater than the available balance of the token in the contract

Remove trusted remote from storage.

function removeTrustedRemote(uint16 remoteChainId_) external
NameTypeDescription
remoteChainId_uint16The chain’s id corresponds to setting the trusted remote to empty.
  • Emits TrustedRemoteRemoved once chain id is removed from trusted remote.
  • Only owner.

It enables or disables sendAndCall functionality for the bridge.

function updateSendAndCallEnabled(bool enabled_) external
NameTypeDescription
enabled_boolBoolean indicating whether the sendAndCall function should be enabled or disabled.

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)
NameTypeDescription
from_addressThe sender’s address initiating the transfer.
dstChainId_uint16Indicates destination chain.
amount_uint256The quantity of tokens to be transferred.
NameTypeDescription
eligibleToSendboolA boolean indicating whether the sender is eligible to transfer the tokens.
maxSingleTransactionLimituint256The maximum limit for a single transaction.
maxDailyLimituint256The maximum daily limit for transactions.
amountInUsduint256The equivalent amount in USD based on the oracle price.
transferredInWindowuint256The total amount transferred in the current 24-hour window.
last24HourWindowStartuint256The timestamp when the current 24-hour window started.
isWhiteListedUserboolA boolean indicating whether the sender is whitelisted.

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 payable
NameTypeDescription
from_addressAddress from which tokens will be debited.
dstChainId_uint16Destination chain id on which tokens will be send.
toAddress_bytes32Address on which tokens will be credited on destination chain.
amount_uint256Amount of tokens that will be transferred.
payload_bytesAdditional data payload for the call on the destination chain.
dstGasForCall_uint64The amount of gas allocated for the call on the destination chain.
callparams_struct ICommonOFT.LzCallParamsAdditional parameters, including refund address, ZRO payment address, and adapter params.

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 payable

Empty implementation of renounce ownership to avoid any mishappening.

function renounceOwnership() public

Return’s the address of the inner token of this bridge.

function token() public view returns (address)
NameTypeDescription
[0]addressAddress of the inner token of this bridge.