@ajna-finance/sdk
Version:
A typescript SDK that can be used to create Dapps in Ajna ecosystem.
78 lines (77 loc) • 3.88 kB
TypeScript
import { BigNumber, Signer } from 'ethers';
import { Address, SignerOrProvider } from '../types';
import { FungibleBucket } from './FungibleBucket';
import { Pool } from './Pool';
/**
* Models a pool with ERC-20 collateral.
*/
export declare class FungiblePool extends Pool {
constructor(provider: SignerOrProvider, poolAddress: Address, ajnaAddress: Address);
initialize(): Promise<void>;
toString(): string;
/**
* Approve this pool to manage collateral token.
* @param signer pool user
* @param allowance normalized approval amount (or MaxUint256)
* @returns promise to transaction
*/
collateralApprove(signer: Signer, allowance: BigNumber): Promise<import("../types").WrappedTransaction>;
/**
* Pledges collateral and draws debt.
* @param signer borrower
* @param amountToBorrow new debt to draw
* @param collateralToPledge new collateral to deposit
* @param limitIndex revert if loan would drop LUP below this bucket (or pass MAX_FENWICK_INDEX)
* @returns promise to transaction
*/
drawDebt(signer: Signer, amountToBorrow: BigNumber, collateralToPledge: BigNumber, limitIndex?: number): Promise<import("../types").WrappedTransaction>;
/**
* Repays debt and pulls collateral.
* @param signer borrower
* @param maxQuoteTokenAmountToRepay amount for partial repayment, MaxUint256 for full repayment, 0 for no repayment
* @param collateralAmountToPull amount of collateral to withdraw after repayment
* @param limitIndex revert if LUP has moved below this bucket by the time the transaction is processed
* @returns promise to transaction
*/
repayDebt(signer: Signer, maxQuoteTokenAmountToRepay: BigNumber, collateralAmountToPull: BigNumber, limitIndex?: number): Promise<import("../types").WrappedTransaction>;
/**
* Deposit collateral token into a bucket (not for borrowers).
* @param signer address to be awarded LP
* @param collateralAmountToAdd deposit amount
* @param bucketIndex identifies the price bucket
* @param ttlSeconds revert if not processed in this amount of time
* @returns promise to transaction
*/
addCollateral(signer: Signer, bucketIndex: number, collateralAmountToAdd: BigNumber, ttlSeconds?: number): Promise<import("../types").WrappedTransaction>;
/**
* Withdraw collateral from a bucket (not for borrowers).
* @param signer address to redeem LP
* @param bucketIndex identifies the price bucket
* @param maxAmount optionally limits amount to remove
* @returns promise to transaction
*/
removeCollateral(signer: Signer, bucketIndex: number, maxAmount?: BigNumber): Promise<import("../types").WrappedTransaction>;
/**
* @param bucketIndex fenwick index of the desired bucket
* @returns {@link FungibleBucket} modeling bucket at specified index
*/
getBucketByIndex(bucketIndex: number): FungibleBucket;
/**
* @param price price within range supported by Ajna
* @returns {@link FungibleBucket} modeling bucket at nearest to specified price
*/
getBucketByPrice(price: BigNumber): FungibleBucket;
/**
* @param minPrice lowest desired price
* @param maxPrice highest desired price
* @returns array of {@link FungibleBucket}s between specified prices
*/
getBucketsByPriceRange(minPrice: BigNumber, maxPrice: BigNumber): FungibleBucket[];
/**
* Withdraw all available liquidity from the given buckets using multicall transaction (first quote token, then - collateral if LP is left).
* @param signer address to redeem LP
* @param bucketIndices array of bucket indices to withdraw liquidity from
* @returns promise to transaction
*/
withdrawLiquidity(signer: Signer, bucketIndices: Array<number>): Promise<import("../types").WrappedTransaction>;
}