UNPKG

fbonds-core

Version:

Banx protocol sdk

86 lines (85 loc) 4.64 kB
import { Bonds } from '../idls/bonds'; import { Sanctum } from './../idls/s_controller'; import { BondOfferV3, BondTradeTransactionV3, BondingCurveType, HadoMarket, OrderType } from './types'; import { Program } from '@coral-xyz/anchor'; import * as anchor from '@coral-xyz/anchor'; import { BN } from '@coral-xyz/anchor'; export declare enum ParseType { Number = "number", String = "string" } export declare const returnAnchorProgram: (connection: anchor.web3.Connection) => Program<Bonds>; type ReturnAnchorProgramSanctum = (programId: anchor.web3.PublicKey, connection: anchor.web3.Connection) => Program<Sanctum>; export declare const returnAnchorProgramSanctum: ReturnAnchorProgramSanctum; export declare const anchorRawBNsAndPubkeysToNumsAndStrings: (rawAccount: any) => any; export declare const anchorRawBNsAndPubkeysToNumsAndStringsWithType: (rawAccount: any, parseType: ParseType) => any; export interface CnftParams { dataHash: string; creatorHash: string; leafId: number; tree?: string; } type GetMetaplexEditionPda = (mintPubkey: anchor.web3.PublicKey) => anchor.web3.PublicKey; export declare const getMetaplexEditionPda: GetMetaplexEditionPda; type GetMetaplexMetadataPda = (mintPubkey: anchor.web3.PublicKey) => anchor.web3.PublicKey; export declare const getMetaplexMetadataPda: GetMetaplexMetadataPda; export declare const createDecodeEnum: <T extends string, D>(enumValue: T, decodedEnumType: D) => D; export declare const enumToAnchorEnumNew: <T extends string | number, E>(enumValue: T, enumObject: E) => { [K in keyof E]?: {}; } & { [K in T]: {}; }; export declare const nowInSeconds: () => number; export declare const enumToAnchorEnum: (anyEnum: any) => { [x: number]: {}; }; export declare const calculateNextSpotPriceBN: ({ orderType, spotPrice, delta, bondingCurveType, counter, }: { orderType: OrderType; spotPrice: BN; delta: BN; bondingCurveType: BondingCurveType; counter: BN; }) => BN; export declare const calculateNextSpotPrice: ({ orderType, spotPrice, delta, bondingCurveType, counter, }: { orderType: OrderType; spotPrice: number; delta: number; bondingCurveType: BondingCurveType; counter: number; }) => number; export declare const calculatePricesArray: ({ starting_spot_price, delta, amount, bondingCurveType, orderType, counter, }: { starting_spot_price: number; delta: number; amount: number; bondingCurveType: BondingCurveType; orderType: OrderType; counter: number; }) => { array: any; total: any; }; export declare const getMetaplexMetadata: (mintPubkey: anchor.web3.PublicKey) => anchor.web3.PublicKey; export declare const getRuleset: (mintPubkey: string, connection: anchor.web3.Connection) => Promise<anchor.web3.PublicKey | undefined>; export declare const findTokenRecordPda: (mint: anchor.web3.PublicKey, token: anchor.web3.PublicKey) => anchor.web3.PublicKey; export declare const findRuleSetPDA: (payer: anchor.web3.PublicKey, name: string) => anchor.web3.PublicKey; export declare function getAsset(assetId: any, rpcUrl: any): Promise<any>; export declare function getTreeCanopyDepth(treeAddress: anchor.web3.PublicKey, connection: anchor.web3.Connection): Promise<number>; export declare function getAssetProof(assetId: any, rpcUrl: any): Promise<any>; export declare const mapProof: (assetProof: { proof: string[]; }, canopyDepth?: number) => anchor.web3.AccountMeta[]; export declare function decode64(stuff: string): number[]; export declare function decode(stuff: string): number[]; export declare function bufferToArray(buffer: Buffer): number[]; export declare const getMaxLoanValueFromBondOfferBN: (bondOffer: BondOfferV3) => BN; export declare const calculatePriorityFees: (connection: anchor.web3.Connection) => Promise<number>; export declare const sortCompareBN: (a: BN, b: BN, order?: "desc" | "asc") => 0 | 1 | -1; export declare const getUpfrontFeeFromHadomarket: (hadoMarket: HadoMarket) => number; /** * @param amountOfBonds lender apr * @returns lenderApr + (lenderApr * REPAY_FEE_APR_TOKEN_PROTOCOL) */ export declare const calcBorrowerTokenAPR: (amountOfBonds: number, interestFeeFromHadoMarket: number, isSplFeature?: boolean) => number; /** * @param borrowAprRate borrow apr * @returns borrowAprRate / (1 + REPAY_FEE_APR_TOKEN_PROTOCOL / BASE_POINTS) */ export declare const calcLenderTokenApr: (borrowAprRate: number, interestFeeFromHadoMarket: number, isSplFeature?: boolean) => number; export declare const calcRepayFeeAprFromBondTradeTransaction: (bondTradeTransaction: BondTradeTransactionV3, hadoMarket: anchor.web3.PublicKey) => number; export {};