View functions

To retrieve important details about the vaults, such as TVR (Total Value Ratio), APY (Annual Percentage Yield), investment strategies, and risk scores, as well as to check user balances, utilize the functions provided below:

const viewYelay = async () => {

  const vaultAddress = 'vaultAddress'
  const userAddress = 'user_address'
  const networkName = 'mainnet'
}

Where 'networkName' is 'mainnet', 'arbitrum' or 'sepolia'.

Protocol discovery functions

Use the following functions to retrieve an array containing information about the Vaults deployed on the Yelay platform. This array will include essential details for each Vault, such as its address, names, associated asset groups, strategies it employs, and the address of the risk score provider responsible for assessing its risk level.

For reference, you can explore the Vaults currently active on Yelay by visiting: https://app.spool.fi/smart-vaults

testResult = await yelaySDK.listVaults({limit: 10, offset: 0});

Returns an array of VaultInfo objects:

VaultInfo {
  address: string;
  name: string;
  assetGroup: AssetGroup;
  smartVaultStrategies: SmartVaultStrategy[];
  riskProviderAddress: string | undefined;
}

Where SmartVaultStrategy is:

SmartVaultStrategy {
  address: string;
  name: string;
  lastDoHardWorkIndex: number;
  lastDoHardWorkTime: number;
  isGhost: boolean;
  index: number;
  apy: string;
  isRemoved: boolean;
  riskScore: number;
  allocation: string;
}

Use the following function to fetch an array of strategies currently deployed on the Yelay platform. This array will provide comprehensive information about each strategy, including its contract address, name, Annual Percentage Yield (APY), risk score, and the timestamp of the most recent DoHardWork execution. Use the following link to explore the strategies currently active on Yelay: https://app.spool.fi/strategies.

testResult = await yelaySDK.listStrategies({limit: 10, offset: 0});

Returns array of strategy info objects:

StrategyInfo {
  address: string;
  name: string;
  lastDoHardWorkIndex: number;
  lastDoHardWorkTime: number;
  isGhost: boolean;
  index: number;
  apy: string;
  riskScores: RiskScore[];
} 

Where risk scores are:

RiskScore {
  riskProvider: string;
  riskScore: number;
  strategyAddress: string;
}

Use the following function to retrieve an array of risk score providers that are integrated with the Yelay platform. For more details about the risk score providers, use the following link: https://docs.spool.fi/technical-reference/understanding-the-protocol/understanding-a-risk-model

testResult = await yelaySDK.listRiskProviders({limit: 10, offset: 0});

Returns an array of Risk providers:

RiskProvider {
  address: string;
  riskScores: RiskScore[];
} 

RiskScores structure can be seen above

To obtain an array of asset groups currently configured on the Yelay platform, use the following function. For more details about the asset groups, see here: https://docs.spool.fi/technical-reference/technical-implementation/smart-vaults/supported-asset-groups

testResult = await yelaySDK.listAssetGroups({limit: 10, offset: 0});

Returns an array of Asset group:

AssetGroup {
  id: string;
  tokens: TokenInfo[];
}

Where TokenInfo is:

TokenInfo {
  address: string;
  name: string;
  decimals: number;
  symbol: string;
}

Vault details functions

Retrieve essential information about a specific Vault using this function. Please note that this method does not include Annual Percentage Yield (APY) details, which can be obtained through a getVaultAPY function (see below).

testResult = await yelaySDK.getVaultDetails(vaultAddress);

Returns the same as ListVaults - VaultInfo object, but only for one vault.

VaultInfo {
  address: string;
  name: string;
  assetGroup: AssetGroup;
  smartVaultStrategies: SmartVaultStrategy[];
  riskProviderAddress: string | undefined;
}

To determine the total supply of shares (SVTs) for a particular Vault, employ the following function:

testResult = await yelaySDK.getSVTTotalSupply(vaultAddress);

Returns a BigNumber of SVT amounts in decimals.

Calculate the total balance within a Vault, denominated in the Vault's native asset, by utilizing this method. Keep in mind that this function only accounts for deposits that have been processed by the 'DoHardWork' mechanism.

testResult = await yelaySDK.getSmartVaultAssetBalances(
        vaultAddress,
        false
    );

Returns an array of BigNumbers representing the amount the vault has of each asset in the asset group. If asset group is [dai] it will return [amountOfDai], if [dai, usdc] it will return [amountOfDai, amountOfUsdc]

Use the provided function to retrieve the balance within a Vault, nominated in the Vault’s assets. This method is particularly useful for Vaults that support multiple assets:

testResult = await yelaySDK.getVaultTVRInVaultAsset(vaultAddress);

Returns a map of each asset in vault and int’s amount Record<string, BigNumber>

The above methods also have a batch option

    const vaults = {
        vaultAddresses: ["0xbf54929b5c7e76e7382acc199513b7028aef24c6", "0x435859758743bef5b85f5208b02c56921e250725"]
    }
    const res = await yelaySDK.getVaultTVRInSVTBatch(vaults)
    const res2 = await yelaySDK.getVaultTVRInUSDBatch(vaults)
    const res3 = await yelaySDK.getVaultTVRInVaultAssetBatch(vaults)

in which case the results are arrays, matched by index to vaults sent as parameters.

These batch functions have been added in v1.0.15.

Obtain comprehensive APY details for a Vault, including yield APY, incentives APY, and a breakdown of associated fees, by leveraging the following function:

testResult = await yelaySDK.getVaultAPY({
        vaultAddressList: [vaultAddress],
        networkName
    });

Returns a record for each given vault containing it’s fees and APYs [vaultAddress]:

        {
          totalApy: (newApy * Math.pow(10, 18)) + rewardAPYs[vaultAddress],
          rewardsApy: rewardAPYs[vaultAddress],
          baseApyNum: (newApy * Math.pow(10, 18)),
          managementFee: managementFee,
          performanceFee: performanceFee,
          depositFee: depositFee
        }

Base vault’s APY is the weighted average of 7-days historical APYs of the underlying strategies.

To fetch a Vault's total asset value denominated in USD, use the following method:

testResult = await yelaySDK.getVaultTVRInUSD(vaultAddress);

Returns a number representing the usd value of assets in vault

To return a breakdown of fees per vault, use the following:

testResult = await yelaySDK.getVaultFeesInUSD(vaultDetailsQuery2);

Returns a vault fee struct:

interface VaultFeesStruct {
  performanceFees: number;
  managementFees: number;
  depositFees: number;
}

To return all users of the specified vaults, use the method getVaultUsers:

const query= {
    vaultAddresses: ["vault_address1", "vault_address2"]
}

const vaultUsers = await yelaySDK.getVaultUsers(query);

The method returns a record for each vault from the query, containing an array where each object represents a user. The object contains their address, dNFTs and wNFTs for that smart vault, along with the actual smart vault data:

{
    'vault_address1': [
        {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
            {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
        ...
    ],
    'vault_address2': [
        {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
            {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
        ...
    ],
}

To return all vaults the user or a list of user interacted with, use the method getUserVaults:

const query= {
    userAddresses: ["user_address1", "user_address2"]
}

const userVaults = await yelaySDK.getUserVaults(query);

The method returns a record for each user from the query, containing an array where each object represents a vault. The object contains the vault details, dNFTs and wNFTs of the user for that smart vault, along with the user address:

{
    'user_address1': [
        {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
            {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
        ...
    ],
    'user_address2': [
        {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
            {
            smartVault: VaultInfo
            dnfts: EnrichedDNFT[]
            wnfts: EnrichedWNFT[]
            userAddress: string
        },
        ...
    ],
}

User balance functions

To obtain the user's balance within a specific Vault, denominated in the Vault's native asset, utilize the following function:

testResult = await yelaySDK.getUserVaultBalance(
{vaultAddress, 
userAddress}
); 

returns an array of user balances corresponding to the asset group of the vault. Returns BigNumber[].

To obtain the user's balance of Vault shares (SVTs), excluding shares for which a withdrawal has already been initiated, use the following method:

 testResult = await yelaySDK.getUserSVTBalance(
        vaultAddress,
        userAddress
    );

Returns a BigNumber with the svt amounts. Includes all D-NFTs.

To calculate the user's total balance in a specific Vault, taking into account both processed and unprocessed deposits, use the provided function:

testResult = await yelaySDK.getEnrichedUserDNFTForVault({
        vaultAddress,
        userAddress
    });

Returns an array of D-NFT objects:

export interface EnrichedNFT {
  nftId: BigNumber;
  shares: BigNumber;
  isBurned: boolean;
  isFlushExecuted: boolean;
  isSynced: boolean;
  isDHWFinished: boolean;
}

export interface EnrichedDNFT extends EnrichedNFT {
  assets: number[];
}
  • shares are the amounts of NFT still available, up to 1,000,000

  • isBurned is true if the user has exchange this nft, either for SVTs (in case of D-NFTs) or for the underlying assets (in case of W-NFTs)

  • isFlushExecuted tells us if this nft is included in next DoHardWork

  • isSynced is irrelevant

  • isDhw finished lets us know if this nft has been processed

  • The assets array of the D-NFTs is filled at it’s creation and includes the assets that will be routed into the vault

To fetch the user's balance in Withdrawal NFTs (W-NFTs), representing the total amount of assets pending withdrawal, use the following function:

testResult = await yelaySDK.getEnrichedUserWNFTForVault({
        vaultAddress,
        userAddress
    });

Returns an array of W-NFT objects:

export interface EnrichedWNFT extends EnrichedNFT {
  blockNumber: number,
  svtWithdrawn: string,
  assets: {
    amount: number;
    contractAddress: string;
    name: string
  }[];
}

This includes both W-NFTs that represent withdrawal request and are awaiting DoHardWork as well as those that are already ready to be claimed to be withdrawn.

Please note that the 'assets' property of a W-NFT is only populated after the NFT is burned, which occurs when the user claims the associated assets. Additionally, each W-NFT contains an 'svtWithdrawn' property, which indicates the number of SVTs being withdrawn through that specific W-NFT.

When dealing with multi-asset Vaults, employ the following function prior to initiating a deposit:

testResult = await yelaySDK.getDepositRatio(vaultAddress);

Result is an array of BigNumbers. This method is used to determine deposit bags for multi asset vaults. It tells us what the ratio of the deposits should be when depositing.

To avoid calculating the values for the redeem bag used when withdrawing, getMaxRedeemBag method can be used:

const query = {
  userAddress: "user_address",
  vaultAddress: "vault_address"
}

const maxRedeemBag = await yelaySDK.getMaxRedeemBag(query)

The method returns a RedeemBagStruct, which can then be directly used in the redeem or redeemFast method parameters.

Last updated