Nest
AppXDiscordTelegram
  • Welcome to Nest
  • Nest Overview
    • Core Mechanics
    • Protocol
    • Flow of Funds
  • Vaults
    • nRWA
      • LiquidStone
      • Mansa
      • Whinfell
      • Mineral Vault
      • Blackstone SRLN ETF
      • OpenTrade T-Bills
      • $M
      • USDM
    • nTBILL
      • Anemoy Liquid Treasury Fund
      • $M
      • USDM
    • nELIXIR
      • Elixir deUSD
  • Media Kit
  • Community
  • Audits & Diligence
  • Developer Guide
    • API Specification
    • Smart Contracts
    • Boring Vaults
    • Nest Vault Implementation
  • Geographic Restrictions
Powered by GitBook
On this page
  • Balance Tab
  • Deposit Tab
  • Withdraw Tab
  • Miscellaneous
  1. Developer Guide

Nest Vault Implementation

How to implement Nest Vaults on your site.

PreviousBoring VaultsNextGeographic Restrictions

Last updated 7 days ago

Balance Tab

Nest Balance Tab

Our balance tab supports the following features:

  • Balance

  • Position Value

  • Bridge

Balance

At its core, Nest Tokens are just ERC20 tokens. To determine the balance of Nest Tokens a user has, you just need to call the balanceOf function of the Boring Vault contract to get a users balance. Of course, the result will be with respect to the value of the decimals function.

Position Value

The position value of a user's holdings is just the user’s balance multiplied by the Rate of the token. To get the rate of the token, you will need to call the getRate function on the Accountant contract associated with the Boring Vault.

Bridge

The bridge feature allows users to bridge their tokens from one chain to another. At this time, our application only supports migrating from Ethereum to Plume and not Plume to Ethereum. To bridge your Nest token, you will need to call the bridge function on the Teller contract associated with the Boring Vault.

Deposit Tab

Our deposit tab supports the following features:

  • Compliance Check

  • Exchange Rate

  • Withdrawal Conditions

  • Approve

  • Slippage

  • Deposit

  • Deposit and Bridge

Compliance Check

Before we load the deposit tab, you need to check that the connected user is compliant. You can do this by making an API call to the compliance endpoint.

TODO: Add details of the compliance endpoint

Exchange Rate

The exchange rate is the rate for which you would receive Nest Tokens given you deposit a particular asset token. You can get this by calling the getRateInQuoteSafe function on the Accountant contract associated with the Boring Vault. Be sure to invert it if you need to.

Withdrawal Conditions

Withdrawal conditions are different per token and per network. This is not specified on chain and instead is configured by the off-chain infrastructure. Typically, the withdrawal processor runs once a day on Ethereum mainnet and once every 15 minutes on Plume mainnet.

Slippage

In the event that the price of the asset token is changing, we can provide a slippage tolerance. We are hard coding this per token for now, but you can allow the user to set it. If you set this, you should change the minimumMint parameter to account for this.

Approve

Before you deposit, you will need to approve the Predicate Proxy contract associated to the Boring Vault to be able to transfer tokens on behalf of the user. You will do that by calling the approve function on the asset token for the amount that is being deposited.

Predicate Message

Before you can deposit into Nest Vaults, you will need to acquire a Predicate Message that ensures that the user that is depositing meets compliance requirements. You can do this by making an API call to the compliance endpoint.

TODO: Add details of the compliance endpoint.

Deposit

In the event that the chain that the user is connected to is the same as the destination chain, you can deposit your asset token into the vault in exchange for Nest Tokens. To initiate a deposit, you call the deposit function on the Predicate Proxy contract associated with the Boring Vault.

Prior to depositing, you will need to get a Predicate Message.

The deposit function takes the following parameters:

  • depositTokenContractAddress - The contract address of the asset token that is getting deposited.

  • depositAmount - The amount of the asset token that is getting deposited.

  • minimumMint - The amount of the vault token the user should receive at minimum. This should be the rate with slippage applied.

  • predicateMessage - The predicate message returned from the API.

Deposit and Bridge

In the event that the chain that the user is connected to is different as the destination chain, you can deposit your asset token into the vault in exchange for Nest Tokens on the destination chain. To initiate a deposit and bridge, you call the depositAndBridge function on the Predicate Proxy contract associated with the Boring Vault.

Prior to depositing, you will need to get a Predicate Message.

The depositAndBridge function takes the following parameters:

  • depositTokenContractAddress - The contract address of the asset token that is getting deposited.

  • depositAmount - The amount of the asset token that is getting deposited.

  • minimumMint - The amount of the vault token the user should receive at minimum. This should be the rate with slippage applied.

  • data

    • chainSelector - The LayerZero Endpoint ID for the destination chain.

    • destinationChainReciever - The address who should receive the tokens on the destination chain

    • bridgeFeeToken - 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE (always)

    • messageGas - 100000n (always)

    • data - 0x (always)

  • predicateMessage - The predicate message returned from the API.

Withdraw Tab

Our withdrawal tab supports the following features:

  • Exchange Rate

  • Slippage

  • Deadline

  • Approve

  • Withdraw

Exchange Rate

The exchange rate is the rate for which you would receive a particular asset token in exchange for your Nest Tokens. You can get this by calling the getRateInQuoteSafe function on the Accountant contract associated with the Boring Vault. No need to invert it this time.

Slippage

In the event that the price of the asset token is changing, we can provide a slippage tolerance. We are hard coding this per token for now, but you can allow the user to set it. If you set this, you should change the atomicPrice parameter to account for this.

Deadline

Since the withdraw function is asynchronous, you will need to supply a deadline. We are hard coding this value per token to account for the off-chain processing rules. This directly correlates to the Withdrawal Conditions in the Deposit tab.

Approve

Before you withdraw, you will need to approve the AtomicQueue contract associated to the network to be able to transfer tokens on behalf of the user. You will do that by calling the approve function on the Nest Token for the amount that is being withdrawn.

Withdraw

Withdraws for Nest Tokens happen asynchronously. So, you will submit a withdraw request to the AtomicQueue on behalf of the user. That request will be fulfilled based on the rules mentioned in the Withdrawal Conditions. In order to submit a withdrawal request, you need to call the withdraw function on the AtomicQueue contract for the network.

The withdraw function takes the following parameters:

  • offerTokenContractAddress - The contract address of the Nest Token.

  • wantTokenContractAddress - The contract address of the asset token.

  • atomicRequest

    • deadline - The deadline that the request should be fulfilled by.

    • atomicPrice - The rate with the slippage supplied.

    • offerAmount - The amount of Nest Tokens you wish to withdraw.

    • inSolve - false (always)

Miscellaneous

Things not mentioned here that we can add:

  • Transaction history

  • Vault details

  • APY

  • TVL

Helpers

Nest Deposit Tab
Nest Withdraw Tab

The Nucleus Team provides to help with these functions.

an SDK