The LendingPool contract is a timelock-enabled ERC4626-compliant token vault designed to increase the utilisation of a liquid restaking token (LRT) through lending and borrowing activities. Users with LRT can become lenders by depositing their tokens in to the pool. The pool operator then lends the collected tokens or funds to borrowers through loan contracts. Lenders can withdraw from the scheme at any time, and the pool operator reserves the right to call the loans whenever necessary to ensure the required funds are available for returning to the lenders.
Using the SDK
You can use either the methods individually or by using the initialized AugustPools class. If you're using methods directly, you will be required to pass a the RPC URL so we recommend using a the class instead.
In these documentation examples, we will present the methods as if they're being used as a member of the exported AugustPools class (i.e. AugustPools.<METHOD_NAME>).
Installation
Install the package in your project directory with:
npm install @augustdigital/pools
Available Methods
Fetching Pool Data
Get All Lending Pools
Returns an array of of all August Digital lending pools including all relevant on-chain details about the pool.
Returns a list of all staked positions for a given wallet address across all Lending Pools for the given network in a way where the object contains all required parameters to pass to Pool.claim.
// @param address wallet address to query positions for// @param pools (optional) - array of pool data objectsasync getAllPositions(address: IAddress, pools?: IPoolWithUnderlying[])
[ {...pool: IPoolWithUnderlying; token: string; // token symbol position: string; // pool name status: "REDEEM"|"STAKED"|"PENDING"; availableRedemptions: IPoolAvailableRedemptions[], redeemable: INormalizedNumber; walletBalance: string; }...]
[]
Get Pool APR
Returns a pool's current or historical APR which is based on a weighted average of all deployed and active loans.
// @param pool - vault contract address// @param input params (optional) - object that if passed returns a historical list of objectsasync getPoolApr( pool: IAddress, { start: Date order?:'asc'|'desc'// default: desc --> descending interval?:// default: days --> day interval|'years'|'quarters'|'months'|'weeks'|'days'|'hours'|'minutes' })
{ timestamp: number; // unix timestamp value: INormalized; // APR amount at that unix time} | { // OR historical will be an array timestamp: number; value: INormalized; }[]
{"error":"Invalid request"}
Get Pool TVL
Returns a pool's current or historical TVL which is simply the total deposits subtracted by total withdraws.
// @param pool - vault contract address// @param input params (optional) - object that if passed returns a historical list of objectsasync getPoolTvl( pool: IAddress, { start: Date order?:'asc'|'desc'// default: desc --> descending interval?:// default: days --> day interval|'years'|'quarters'|'months'|'weeks'|'days'|'hours'|'minutes' })
{ timestamp: number; // unix timestamp value: INormalizedNumber; // TVL amount at that unix time} | { // OR historical will be an array timestamp: number; value: INormalizedNumber; }[]
undefined
Interacting with a Pool
Allowance
Returns the user wallet allowance for the inputted lending pool.
// @param pool - vault contract address// @param signer - ethers Signer object built from user walletasync allowance(pool: IAddress, signer: ISigner)
{ normalized: string; raw: bigint;}
{ normalized:'0'; raw:BigInt(0);}
Approve
Wrapper for the lending pool's ERC20.approve method.
// @param pool - vault contract address// @param signer - ethers Signer object built from user wallet// @param input params - object with amount to approve in any number typeasync approve(pool: IAddress, signer: Signer, { amount: string | number | bigint })
TransactionHash: string
undefined
Deposit
Wrapper for the lending pool's ERC4626.deposit method.
// @param pool - vault contract address// @param signer - ethers Signer object built from user wallet// @param input params - object with amount to approve in any number typeasync deposit(pool: IAddress, signer: Signer, { amount: string | number | bigint })
TransactionHash: string
undefined
Request Withdrawal
Wrapper for the lending pool's Pool.requestRedeem method.
// @param pool - vault contract address// @param signer - ethers Signer object built from user walletasync requestWithdrawal(pool: IAddress, signer: Signer)