Yearn
The Yearn
class from @moonup/moon-api
provides a convenient way to interact with the Yearn Finance protocol. This API allows you to perform various operations related to adding liquidity, removing liquidity, and managing your Yearn vaults.
Here's a detailed documentation for the Yearn
class:
Initialization
To use the Yearn
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Yearn API.
Here's an example of how to create an instance of the Yearn
class:
Class: Yearn
Methods
addLiquidity(name: string, data: InputBody, params?: RequestParams)
This method is used to add liquidity to a Yearn vault.
Parameters:
name
: The name of the Yearn vault.data
: An object containing the input data for adding liquidity.params
: Optional request parameters.
Returns: A promise that resolves to the result of the liquidity addition.
Example:
addLiquidityWeth(name: string, data: InputBody, params?: RequestParams)
This method is used to add WETH liquidity to a Yearn vault.
Parameters:
name
: The name of the Yearn vault.data
: An object containing the input data for adding WETH liquidity.params
: Optional request parameters.
Returns: A promise that resolves to the data of the WETH liquidity addition.
Example:
removeLiquidity(name: string, data: InputBody, params?: RequestParams)
This method is used to remove liquidity from a Yearn vault.
Parameters:
name
: The name of the Yearn vault.data
: An object containing the input data for removing liquidity.params
: Optional request parameters.
Returns: A promise that resolves to the result of the liquidity removal.
Example:
removeLiquidityWeth(name: string, data: InputBody, params?: RequestParams)
This method is used to remove WETH liquidity from a Yearn vault.
Parameters:
name
: The name of the Yearn vault.data
: An object containing the input data for removing WETH liquidity.params
: Optional request parameters.
Returns: A promise that resolves to the data of the WETH liquidity removal.
Example:
Usage
To use the Yearn
class, you need to create an instance of it with a configured HttpClient
. The HttpClient
is responsible for making HTTP requests to the Yearn API.
You can then use the yearn
instance to call the various methods of the Yearn
class. Make sure to handle any potential errors that may occur during the API calls using try-catch
blocks.
Last updated