UNPKG

@faktoryfun/core-sdk

Version:

The official SDK for interacting with Faktory tokens and DEX contracts

300 lines (299 loc) 10.1 kB
import { AnchorMode, PostConditionMode } from "@stacks/transactions"; import type { UIntCV, ContractPrincipalCV } from "@stacks/transactions"; import type { FaktorySDKConfig, ReadResponse, TokenDeploymentInput, TokenDeploymentResponse, TokenTradesResponse, TransferVerification, VerifiedTokensResponse } from "./types"; import { NetworkType } from "./network-types"; export declare class FaktorySDK { SBTC_CONTRACT: Record<NetworkType, { address: string; name: string; assetName: string; }>; private readonly apiHost; private readonly apiKey; private readonly network; private readonly hiroApiKey?; constructor(config: FaktorySDKConfig); private fetch; getTokenDeployParams(input: TokenDeploymentInput): Promise<TokenDeploymentResponse>; getBuyParams({ dexContract, inAmount, // amount is in STX or BTC units senderAddress, slippage, }: { dexContract: string; inAmount: number; senderAddress: string; slippage?: number; }): Promise<{ contractAddress: string; contractName: string; functionName: string; functionArgs: Array<UIntCV | ContractPrincipalCV>; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; postConditions: ({ type: "ft-postcondition"; address: string; condition: "lte"; amount: string; asset: string; } | { type: "ft-postcondition"; address: string; condition: "gte"; amount: any; asset: string; })[]; } | { contractAddress: string; contractName: string; functionName: string; functionArgs: Array<UIntCV | ContractPrincipalCV>; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; postConditions: ({ type: "stx-postcondition"; address: string; condition: "lte"; amount: string; asset?: undefined; } | { type: "ft-postcondition"; address: string; condition: "gte"; amount: any; asset: string; } | { type: "stx-postcondition"; address: string; condition: "gte"; amount: string; asset?: undefined; })[]; }>; getSellParams({ dexContract, amount, // amount is in TOKEN units senderAddress, slippage, }: { dexContract: string; amount: number; senderAddress: string; slippage?: number; }): Promise<{ contractAddress: string; contractName: string; functionName: string; functionArgs: Array<UIntCV | ContractPrincipalCV>; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; postConditions: ({ type: "ft-postcondition"; address: string; condition: "lte"; amount: string; asset: string; } | { type: "ft-postcondition"; address: string; condition: "gte"; amount: string; asset: string; } | { type: "stx-postcondition"; address: string; condition: "gte"; amount: string; asset?: undefined; })[]; }>; private isExternalDex; getIn(dexContract: string, senderAddress: string, stx: number): Promise<ReadResponse>; getOut(dexContract: string, senderAddress: string, amount: number): Promise<ReadResponse>; getOpen(dexContract: string, senderAddress: string): Promise<ReadResponse>; getVerifiedTokens(options?: { search?: string; sortOrder?: string; page?: number; limit?: number; daoOnly?: boolean; }): Promise<VerifiedTokensResponse>; getDaoTokens(options?: { search?: string; sortOrder?: string; page?: number; limit?: number; }): Promise<VerifiedTokensResponse>; private getTokenInfo; verifyTransfer(tokenAddress: string): Promise<TransferVerification>; getToken(dexContract: string): Promise<{ success: boolean; data: { id: string; name: string; symbol: string; description: string; tokenContract: string; dexContract: string; txId: string | null; targetAmm: string; supply: number; decimals: number; targetStx: number; progress: number; price: number; price24hChanges: number; tradingVolume: number; holders: number; tokenToDex: string; tokenToDeployer: string; stxToDex: number; stxBuyFirstFee: number; logoUrl: string | null; mediaUrl: string | null; uri: string | null; twitter: string | null; website: string | null; telegram: string | null; discord: string | null; chatCount: number; txsCount: number; creatorAddress: string; deployedAt: string; tokenHash: string; tokenVerified: number; dexHash: string; dexVerified: number; tokenVerifiedAt: string; dexVerifiedAt: string; status: string; tokenChainhookUuid: string | null; tradingHookUuid: string | null; lastBuyHash: string | null; daoToken: boolean; priceUsd?: number; volumeUsd?: number; marketCap?: number; denomination: string; }; }>; getTokenTrades(tokenContract: string): Promise<TokenTradesResponse>; private getSeatPrice; private getSeatLimits; private detectContractTypeFromSeats; static detectContractType(prelaunchContract: string, tokenInfo?: any): "meme" | "dao" | "helico"; static getSeatPricing(contractType?: "meme" | "dao" | "helico"): { maxSeatsPerUser: number; usd: null; sats: number; btc: number; description: string; totalSeats: number; minUsers: number; contractType: "meme" | "dao" | "helico"; } | { maxSeatsPerUser: number; usd: null; sats: number; btc: number; description: string; totalSeats: number; minUsers: number; contractType: "meme" | "dao" | "helico"; } | { maxSeatsPerUser: number; usd: null; sats: number; btc: number; description: string; totalSeats: number; minUsers: number; contractType: "meme" | "dao" | "helico"; }; getBuySeatsParams({ prelaunchContract, seatCount, senderAddress, contractType, tokenInfo, }: { prelaunchContract: string; seatCount: number; senderAddress: string; contractType?: "meme" | "dao" | "helico"; tokenInfo?: { preHash?: string; daoToken?: boolean; [key: string]: any; }; }): Promise<{ contractAddress: string; contractName: string; functionName: string; functionArgs: UIntCV[]; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; postConditions: { type: "ft-postcondition"; address: string; condition: "lte" | "gte"; amount: string; asset: string; }[]; estimatedCost: number; currentSeats: number; maxAdditionalSeats: number; detectedType: "meme" | "dao" | "helico"; willCompleteLaunch: boolean; remainingSeats: number; }>; getRefundParams({ prelaunchContract, senderAddress, contractType, }: { prelaunchContract: string; senderAddress: string; contractType?: "meme" | "dao" | "helico"; }): Promise<{ contractAddress: string; contractName: string; functionName: string; functionArgs: never[]; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; postConditions: { type: "ft-postcondition"; address: string; condition: "lte"; amount: string; asset: string; }[]; refundAmount: number; seatsToRefund: number; }>; getPrelaunchStatus(prelaunchContract: string, senderAddress: string): Promise<{ status: any; userInfo: any; remainingSeats: any; maxSeatsAllowed: any; seatHolders: any; }>; getClaimParams({ prelaunchContract, tokenContract, senderAddress, }: { prelaunchContract: string; tokenContract: string; senderAddress: string; }): Promise<{ contractAddress: string; contractName: string; functionName: string; functionArgs: ContractPrincipalCV[]; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; claimableAmount: number; seatsOwned: number; }>; getTriggerFeeAirdropParams({ prelaunchContract, senderAddress, }: { prelaunchContract: string; senderAddress: string; }): Promise<{ contractAddress: string; contractName: string; functionName: string; functionArgs: never[]; network: import("@stacks/network").StacksNetwork; anchorMode: AnchorMode; postConditionMode: PostConditionMode; }>; isMarketOpen(prelaunchContract: string, senderAddress: string): Promise<any>; }