RemoteDefiiPrincipal contract
The RemoteDefiiPrincipal contract is responsible for interacting with the Vault and managing user liquidity. This contract is deployed on the same chain as the Vault. RemoteDefiiPrincipal is an ERC20 token that represents the share of liquidity in DEFII. Contract mints DEFII LP token.
The contract interacts with RemoteDefiiAgent using LayerZero. The contract can exchange messages with RemoteDefiiAgent and bridge liquidity deposited through the Vault.
Read Functions
FUNDS_HOLDER
Returns the address of the FundsHolder smart contract where liquidity is stored for cross-chain interactions.
FundsHolder public immutable FUNDS_HOLDER;
OPERATOR_REGISTRY
Returns the address of the OperatorRegistry smart contract where user approvals for operators are stored.
IOperatorRegistry public immutable OPERATOR_REGISTRY;
REMOTE_CHAIN_ID
The identifier of the chain on which RemoteDefiiPrincipal operates.
uint256 public immutable REMOTE_CHAIN_ID;
notion
Returns the address of the notion token.
function notion() external view returns (address)
defiiType
Returns the defiiType. For RemoteDefii, this is always 1.
function defiiType() external pure returns (Type)
positionBalance
Returns the balance of the owner's position in the Vault.
mapping(address vault => mapping(uint256 positionId => mapping(address owner => mapping(address token => uint256 balance))))
public positionBalance;
vault
address
Vault address
positionId
uint256
Position ID in Vault
owner
address
Position owner
token
address
Token address
quoteLayerZeroFee
Calculates the LayerZero fee for cross-chain message transmission.
function quoteLayerZeroFee(
bytes calldata calldata_,
bool payInZRO,
bytes calldata lzAdapterParams
) external view returns (uint256 nativeFee, uint256 zroFee);
calldata
bytes
Message calldata
payInZRO
bool
Always false
lzAdapterParams
bytes
LayerZero adapter parameters
remoteCallType
Message broker type. Currently, only LayerZero is supported.
function remoteCallType() external pure override returns (RemoteCallsType);
supportedTokens
Tokens supported by DEFII. The list of tokens is determined during the deployment of the LocalDefii smart contract.
function supportedTokens() public view virtual returns (address[] memory t);
Write Functions
enter
Initiates entry into DEFII.
Accepts notion tokens.
Executes the BRIDGE or SWAP_BRIDGE instruction. Tokens are sent to the remote chain with a message that the remoteChainAgent should initiate entry into the third-party protocol.
Returns the remaining amount to the depositor after executing the instructions.
function enter(
uint256 amount,
uint256 positionId,
Instruction[] calldata instructions
) external payable
amount
uint256
Amount of notion tokens for deposit
positionId
uint256
Position ID in Vault
instructions
Instruction[]
Set of instructions
exit
Initiates an exit from DEFII. Burns DEFII LP and sends a command to remoteDefiiAgent to credit DEFII LP tokens to the owner. (clarification is needed)
function exit(
uint256 shares,
uint256 positionId,
Instruction[] calldata instructions
) external payable
shares
uint256
Amount of shares
positionId
uint256
Position ID in Vault
instructions
Instruction[]
Set of instructions
finishRemoteExit
Completes the withdrawal of funds from remoteDefii. It is expected that the output tokens have already arrived at FUNDS_HOLDER. The following actions are performed:
Takes tokens from FUNDS_HOLDER.
Swaps tokens for notion.
Sends the received tokens to the Vault.
function finishRemoteExit(
address vault,
uint256 positionId,
address owner,
IDefii.Instruction[] calldata instructions
) external payable operatorCheckApproval(owner)
vault
uint256
Vault address
positionId
uint256
Position ID in Vault
instructions
Instruction[]
Set of instructions
lzReceive
Function to support LayerZero. For additional integration, refer to the LayerZero integration page.
function lzReceive(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64,
bytes calldata _payload
) external
mintShares
Mints DEFII LP tokens after a successful entry into remoteDefii. Can only be called by remoteDefiiPrincipal itself after receiving a command from remoteDefiiAgent.
function mintShares(
address vault,
uint256 positionId,
uint256 shares
) external remoteFn
vault
uint256
Vault address
positionId
uint256
Position ID in Vault
shares
uint256
Amount of share to be minted
receiveTokenWithMessage
Takes tokens from msg.sender and transfers them to FUNDS_HOLDER for further movement to the remote chain.
function receiveTokenWithMessage(
address token,
uint256 amount,
bytes calldata message
) external
token
address
Token address
amount
uint256
Amount of tokens
message
bytes
Message received from the message broker.
withdrawFunds
Withdraws tokens to the address of msg.sender.
function withdrawFunds(
address vault,
uint256 positionId,
address token,
uint256 amount
) external
vault
uint256
Vault address
positionId
uint256
Position ID in Vault
token
address
Token amount
amount
uint256
Amount of token
withdrawLiquidity
Initiates the withdrawal of liquidity to the recipient's address and burns their DEFII LP tokens.
function withdrawLiquidity(
address recipient,
uint256 shares,
Instruction[] calldata instructions
) external payable
recipient
address
Recipient address
shares
uint256
Amount of shares to be withdrawn
instructions
Instruction[]
Set of instructions
Last updated