shift
  • Introduction
  • Underlying factors for developing shift
  • Get started
    • How to choose the Vault
    • How to deposit
    • How to withdraw
    • How to shuffle between Vault versions
    • How to track the balance
    • How to review transactions history
    • Emergency situation
  • SHIFT Products
    • Vault
    • DeFi strategy
    • Vault for Financial Institutes
  • Risk Management
    • Overview
    • Risk Assessment and Management Policy
    • Risk Mitigation
  • Developer Resources
    • Ecosystem overview
    • Vault contract
      • Position status logic
    • DEFII
      • Logic contract
      • LocalDefii contract
      • RemoteDefiiPrincipal contract
      • RemoteDefiiAgent contract
      • Instructions
    • OperatorRegistry contract
    • Emergency situations
    • Deployment addresses
  • Vaults
    • USD - Risk Level 3
  • FAQ
    • General
    • Fee terms
    • Platform design
    • Emergency
    • Utility
    • Security
    • Communication
  • Resources
    • Discord
    • Medium
    • Twitter
    • Telegram
    • Github
Powered by GitBook
On this page
  1. Developer Resources
  2. DEFII

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;
Parameter
Type
Definition

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);
Parameter
Type
Definition

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.

  1. Accepts notion tokens.

  2. 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.

  3. Returns the remaining amount to the depositor after executing the instructions.

function enter(
        uint256 amount,
        uint256 positionId,
        Instruction[] calldata instructions
    ) external payable
Parameter
Type
Definition

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
Parameter
Type
Definition

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:

  1. Takes tokens from FUNDS_HOLDER.

  2. Swaps tokens for notion.

  3. Sends the received tokens to the Vault.

function finishRemoteExit(
        address vault,
        uint256 positionId,
        address owner,
        IDefii.Instruction[] calldata instructions
    ) external payable operatorCheckApproval(owner)
Parameter
Type
Definition

vault

uint256

Vault address

positionId

uint256

Position ID in Vault

instructions

Instruction[]

Set of instructions

lzReceive

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
Parameter
Type
Definition

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
Parameter
Type
Definition

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
Parameter
Type
Definition

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
Parameter
Type
Definition

recipient

address

Recipient address

shares

uint256

Amount of shares to be withdrawn

instructions

Instruction[]

Set of instructions

Last updated 1 year ago

Function to support LayerZero. For additional integration, refer to the .

LayerZero integration page