OCPRouter
OCPRouter
poolFactory
contract IOCPoolFactory poolFactory
tokenManager
contract IOCPOmniTokenManager tokenManager
bridge
contract IOCPBridge bridge
weth
address weth
cachedMintLookup
mapping(uint16 => mapping(bytes => mapping(uint256 => struct Structs.CachedMint))) cachedMintLookup
CachedMint
event CachedMint(uint16 chainId, bytes srcAddress, uint256 nonce, address token, uint256 amount, address to, bytes payload, bytes reason)
constructor
constructor(address _poolFactory, address _tokenManager, address _bridge, address _weth) public
Initializes the contract setting the deployer as the initial owner.
Parameters
_poolFactory
address
The address of the pool factory contract.
_tokenManager
address
The address of the token manager contract.
_bridge
address
The address of the bridge contract.
_weth
address
The address of the WETH contract.
onlyBridge
modifier onlyBridge()
omniMint
function omniMint(uint16 _remoteChainId, address _token, uint256 _amountIn, address _to, bool _needDeploy, address payable _refundAddress, bytes _payload, struct Structs.LzTxObj _lzTxParams) external payable
_Transfers tokens from sender to receiver on the same chain.
If the getPool
is not deployed, it will be deployed.
If the getPool
is deployed, it will be used.
_token
cannot be the zero address and it will be transferred from sender to receiver.
_omniMint
will be called to mint the token on the receiver chain.
Requirements:
_token
cannot be the zero address._to
cannot be the zero address._amountIn
must be greater than 0._
Parameters
_remoteChainId
uint16
The chain id of the receiver.
_token
address
The address of the token to transfer.
_amountIn
uint256
The amount of tokens to transfer.
_to
address
The address of the receiver.
_needDeploy
bool
Whether the token needs to be deployed on the receiver chain.
_refundAddress
address payable
The address to refund the fee to.
_payload
bytes
The payload to send to the receiver.
_lzTxParams
struct Structs.LzTxObj
The layer zero transaction parameters.
_omniMint
function _omniMint(address _token, uint16 _remoteChainId, uint256 _amountIn, address _to, bool _needDeploy, address payable _refundAddress, bytes _payload, struct Structs.LzTxObj _lzTxParams, uint256 _msgFee) internal
_Transfers tokens from sender to receiver on the same chain.
If the _needDeploy
is true, the token will be deployed on the receiver chain and type
will be TYPE_DEPLOY_AND_MINT
.
If the _needDeploy
is false, the token will not be deployed on the receiver chain and type
will be TYPE_MINT
.
Requirements:
_token
cannot be the zero address._to
cannot be the zero address._amountIn
must be greater than 0._
Parameters
_token
address
The address of the token to transfer.
_remoteChainId
uint16
The chain id of the receiver.
_amountIn
uint256
The amount of tokens to transfer.
_to
address
The address of the receiver.
_needDeploy
bool
Whether the token needs to be deployed on the receiver chain.
_refundAddress
address payable
The address to refund the fee to.
_payload
bytes
The payload to send to the receiver.
_lzTxParams
struct Structs.LzTxObj
The layer zero transaction parameters.
_msgFee
uint256
The fee to send to the bridge.
_amountD18
function _amountD18(address _token, uint256 _amount) internal view returns (uint256)
return the amount of token for the given amount of token on the other chain.
Parameters
_token
address
The address of the token.
_amount
uint256
The amount of token.
Return Values
[0]
uint256
The amount of token on the other chain.
quoteLayerZeroFee
function quoteLayerZeroFee(uint16 _remoteChainId, uint8 _type, bytes _userPayload, struct Structs.LzTxObj _lzTxParams) external view returns (uint256, uint256)
_Transfers tokens from sender to receiver on the same chain.
Invoke the bridge
to get quote for the fee and amount of token on the other chain._
Parameters
_remoteChainId
uint16
The chain id of the receiver.
_type
uint8
The type of the transaction.
_userPayload
bytes
The payload to send to the receiver.
_lzTxParams
struct Structs.LzTxObj
The layer zero transaction parameters.
Return Values
[0]
uint256
The amount of token on the other chain and the fee to send to the bridge.
[1]
uint256
omniMintRemote
function omniMintRemote(uint16 _srcChainId, bytes _srcAddress, uint256 _nonce, bool _needDeploy, struct Structs.MintObj _mintParams, address _lzEndpoint, uint256 _dstGasForCall, bytes _payload) external
_Transfers tokens from sender to receiver on the same chain.
Requirements:
_token
cannot be the zero address._to
cannot be the zero address._amountIn
must be greater than 0.only the bridge can call this function._
Parameters
_srcChainId
uint16
The chain id of the sender.
_srcAddress
bytes
The address of the sender.
_nonce
uint256
The nonce of the transaction.
_needDeploy
bool
Whether the token needs to be deployed on the receiver chain.
_mintParams
struct Structs.MintObj
The mint parameters.
_lzEndpoint
address
The layer zero endpoint.
_dstGasForCall
uint256
The gas for the call.
_payload
bytes
The payload to send to the receiver.
updateBridge
function updateBridge(address _bridge) external
_update the bridge address.
Requirements:
only the owner can call this function._
Parameters
_bridge
address
The address of the bridge contract.