@ajna-finance/sdk
Version:
A typescript SDK that can be used to create Dapps in Ajna ecosystem.
94 lines (93 loc) • 4.93 kB
TypeScript
import { BigNumber } from 'ethers';
import { Address, Signer, SignerOrProvider } from '../types';
import { NonfungibleBucket } from './NonfungibleBucket';
import { Pool } from './Pool';
declare class NonfungiblePool extends Pool {
isSubset: boolean;
constructor(provider: SignerOrProvider, poolAddress: Address, ajnaAddress: Address);
initialize(): Promise<void>;
toString(): string;
/**
* Approve this pool to transfer an NFT.
* @param signer pool user
* @param tokenId NFT token id
* @returns promise to transaction
*/
collateralApprove(signer: Signer, tokenId: number): Promise<import("../types").WrappedTransaction>;
/**
* Approve this pool to transfer multiple NFTs.
* @param signer pool user
* @returns promise to transaction
*/
collateralApproveAll(signer: Signer): Promise<import("../types").WrappedTransaction>;
/**
* Deposit one or more NFTs into a bucket (not for borrowers).
* @param signer address to be awarded LP
* @param bucketIndex identifies the price bucket
* @param tokenIdsToAdd identifies NFTs to deposit
* @param ttlSeconds revert if not processed in this amount of time
* @returns promise to transaction
*/
addCollateral(signer: Signer, bucketIndex: number, tokenIdsToAdd: Array<number>, ttlSeconds?: number): Promise<import("../types").WrappedTransaction>;
/**
* Merge collateral accross a number of buckets, `removalIndexes` reconstitute an `NFT`.
* @param signer address to merge LPB and potentially remove whole NFTs
* @param removalIndexes Array of bucket indexes to remove all collateral that the caller has ownership over.
* @param noOfNFTsToRemove Intergral number of `NFT`s to remove if collateral amount is met `noOfNFTsToRemove`, else merge at bucket index, `toIndex`.
* @param toIndex The bucket index to which merge collateral into.
* @returns promise to transaction
*/
mergeOrRemoveCollateral(signer: Signer, removalIndexes: Array<number>, noOfNFTsToRemove: number, toIndex: 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, noOfNFTsToRemove: number): Promise<import("../types").WrappedTransaction>;
/**
* Pledges collateral and draws debt.
* @param signer borrower
* @param amountToBorrow new debt to draw
* @param tokenIdsToPledge identifies NFTs to deposit as collateral
* @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, tokenIdsToPledge: Array<number>, 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 noOfNFTsToPull number of NFTs 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, noOfNFTsToPull: number, limitIndex?: number): Promise<import("../types").WrappedTransaction>;
/**
* @param bucketIndex fenwick index of the desired bucket
* @returns {@link NonfungibleBucket} modeling bucket at specified index
*/
getBucketByIndex(bucketIndex: number): NonfungibleBucket;
/**
* @param price price within range supported by Ajna
* @returns {@link NonfungibleBucket} modeling bucket at nearest to specified price
*/
getBucketByPrice(price: BigNumber): NonfungibleBucket;
/**
* @param minPrice lowest desired price
* @param maxPrice highest desired price
* @returns array of {@link NonfungibleBucket}s between specified prices
*/
getBucketsByPriceRange(minPrice: BigNumber, maxPrice: BigNumber): NonfungibleBucket[];
totalBorrowerTokens(borrower: Address): Promise<number>;
totalBucketTokens(borrower: Address): Promise<number>;
/**
* 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>;
}
export { NonfungiblePool };