Yelay V3 SDK Docs
  • Intro
  • Main entities
  • Setting up your account
  • Initialization
  • Deposit
  • Withdrawals
  • Tracking balance and TVL
  • Yield tracking and claiming
  • Supportive methods
  • Deposits with timelock
  • Yelay's yield farming sources
Powered by GitBook
On this page

Yield tracking and claiming

In Yelay V3, all earned yield is collected in the YieldExtractor contract. The yield is then becoming available to be claimed for clients and end users on a daily basis.

Fetch aggregated yield accrual info

Use this method to retrieve aggregated yield data for specified vaults, pools, and users within a given timeframe:

const aggregatedYieldData = await sdk.yields.getYields([vaults], [poolIds], [users], timeframe);

Where:

  • vaults – Array of vault addresses to filter results.

  • poolIds – Array of pool IDs to filter results.

  • users – Array of user addresses to filter results.

  • timeframe – Timeframe to limit results within a specific period.

Fetch yield and APY per vault

Fetch yield info and APY per specific vault per given timeframe:

const aggregatedYieldData = const vaultYieldData = await sdk.yields.getVaultsYield([vaults], {fromTimestamp, toTimestamp});await sdk.yields.getYields([vaults], [poolIds], [users], timeframe);

The method returns a response of the following structure:

[{ vault: '0x39dac87be293dc855b60fedd89667364865378cc',
startBlock: 22629951,
finishBlock: 22637089,
startTimestamp: 1749024047,
finishTimestamp: 1749110483,
yield: '336925898',
apy: '9.22'}]

Get claimable yield

Retrieve the amount of claimable yield for the user, optionally filtering by specific pool IDs and vault addresses:

// Get all claimable yield for the user
const claimable = await sdk.yields.getClaimableYield({
	user: '0xUSER_ADDRESS',
});

// Filter by pools and vaults
const claimableFullyFiltered = await sdk.yields.getClaimableYield({
	user: '0xUSER_ADDRESS',
	poolIds: [1, 2, 3],
	vaultAddresses: ['0xVAULT_ADDRESS1'],
});

console.log(claimable);

Claim yield

Once you have retrieved claimable yield using getClaimableYield, you can claim it using the claimYield method:

// First, get the claimable yield to obtain claim requests
const claimableYield = await sdk.yields.getClaimableYield({
	user: '0xUSER_ADDRESS',
});

// Extract the claim requests from the claimable yield
const claimRequests = claimableYield.map(item => item.claimRequest);

// Submit the transaction to claim the yield
const claimTx = await sdk.yields.claimYield(claimRequests);

// Wait for the transaction to be mined
await claimTx.wait();

The claimYield method sends a transaction to the blockchain to claim yield based on the provided claim requests. It requires a valid signer with sufficient gas to execute the transaction. You can optionally provide gas overrides to customize the transaction parameters.

PreviousTracking balance and TVLNextSupportive methods

Last updated 9 days ago