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

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

_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

_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

Return Values

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

Return Values

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

updateBridge

function updateBridge(address _bridge) external

_update the bridge address.

Requirements:

  • only the owner can call this function._

Parameters