UNPKG

@ajna-finance/sdk

Version:

A typescript SDK that can be used to create Dapps in Ajna ecosystem.

107 lines (106 loc) 4.42 kB
import { BigNumber, Contract, Signer } from 'ethers'; import { Address, CallData, PoolInfoUtils, SignerOrProvider } from '../types'; import { Pool } from './Pool'; export interface BucketStatus { deposit: BigNumber; collateral: BigNumber; bucketLP: BigNumber; exchangeRate: BigNumber; } export interface Position { /** lender's LP balance of a particular bucket */ lpBalance: BigNumber; /** LP balance valued in quote token, limited by bucket balance */ depositRedeemable: BigNumber; /** LP balance valued in quote token, limited by bucket balance */ collateralRedeemable: BigNumber; /** estimated amount of deposit which may be withdrawn without pushing the LUP below HTP */ depositWithdrawable: BigNumber; } /** * Models a price bucket in a pool. */ export declare class Bucket { provider: SignerOrProvider; contractUtils: PoolInfoUtils; poolContract: Contract; pool: Pool; bucketName: string; index: number; price: BigNumber; /** * @param provider JSON-RPC endpoint. * @param pool Pool to which this bucket belongs. * @param index Price bucket index. */ constructor(provider: SignerOrProvider, pool: Pool, index: number); toString(): string; /** * Enables signer to bundle transactions together atomically in a single request. * @param signer consumer initiating transactions * @param callData array of transactions to sign and submit * @returns promise to transaction */ multicall(signer: Signer, callData: Array<CallData>): Promise<import("../types").WrappedTransaction>; /** * Retrieve current state of the bucket or by index if provided. * @returns {@link BucketStatus} */ getStatus(index?: number): Promise<BucketStatus>; /** * Deposits quote token into the bucket. * @param signer lender * @param amount amount to deposit * @param ttlSeconds revert if not processed in this amount of block time * @returns promise to transaction */ addQuoteToken(signer: Signer, amount: BigNumber, ttlSeconds?: number): Promise<import("../types").WrappedTransaction>; /** * Moves quote token from current bucket to another bucket. * @param signer lender * @param toIndex price bucket to which quote token should be deposited * @param maxAmountToMove optionally limits amount to move * @param ttlSeconds revert if not processed in this amount of time * @returns promise to transaction */ moveQuoteToken(signer: Signer, toIndex: number, maxAmountToMove?: BigNumber, ttlSeconds?: number): Promise<import("../types").WrappedTransaction>; /** * Removes quote token from the bucket. * @param signer lender * @param maxAmount optionally limits amount to remove * @returns promise to transaction */ removeQuoteToken(signer: Signer, maxAmount?: BigNumber): Promise<import("../types").WrappedTransaction>; /** * Shows a lender's position in a single bucket. * @returns {@link Position} */ getPosition(lenderAddress: Address): Promise<Position>; estimateDepositFeeRate(): Promise<BigNumber>; /** * Retrieves a lender's LP balance in a bucket. * @param lenderAddress lender * @param index fenwick index of the desired bucket * @returns LP balance */ lpBalance(lenderAddress: Address): Promise<BigNumber>; /** * Calculate how much quote token could currently be exchanged for LP. * @param lpBalance amount of LP to redeem for quote token * @returns The current amount of quote tokens that can be exchanged for the given LP, WAD units. */ lpToQuoteTokens: (lpTokens: BigNumber) => Promise<BigNumber>; /** * Calculate how much collateral could be exchanged for LP. * @param lpBalance amount of LP to redeem for collateral * @returns The exact amount of collateral that can be exchanged for the given LP, WAD units. */ lpToCollateral: (lpTokens: BigNumber) => Promise<BigNumber>; /** * Kick a loan with a lender's liquidity based on a LUP calculated as if they withdraw liquidity. * @param signer lender * @param limitIndex bucket in which lender has an LP balance * @returns promise to transaction */ lenderKick(signer: Signer, limitIndex?: number): Promise<import("../types").WrappedTransaction>; }