import * as _saturnbtcio_arch_sdk from '@saturnbtcio/arch-sdk'; import { UtxoMetaData, Pubkey, CreatedPdaAccount, SanitizedMessage } from '@saturnbtcio/arch-sdk'; import { Token, IdentifiableLiquidityPool, IdentifiableLiquidityPoolShard } from '@saturnbtcio/pool-serde-sdk'; import * as _saturnbtcio_psbt from '@saturnbtcio/psbt'; import { AddressTxsUtxo, Psbt, Network, InputType, OutputType, TransactionSizeCalculator, PsbtBuilder } from '@saturnbtcio/psbt'; import { SigHash, NETWORK } from '@scure/btc-signer'; type CollectionType = 'rune' | 'btc'; interface Wallet { address: string; balance: bigint; utxos: Array; } interface CollectionUtxo extends AddressTxsUtxo { collectionStatuses: Array; hasInscription: boolean; } interface Collection { id: string; type: CollectionType; } interface CollectionAmount extends Collection { amount: bigint; } type TxId = string; interface MempoolFee { ancestor: number; base: number; modified: number; } interface MempoolEntry { fees: MempoolFee; ancestorsCount: number; descendantsCount: number; ancestorsSize: number; descendantsSize: number; depends: string[]; spentby: string[]; } type MempoolInfoMap = Map; interface FeesRecommended { fastestFee: number; halfHourFee: number; hourFee: number; minimumFee: number; } interface IBitcoinProvider { getRecommendedFees(): Promise; getLatestBlockHeight(): Promise; getMempoolInfo(txIds: Array): Promise; getWallet(address: string): Promise; } interface ArchMessageRequest { feePayerPubkey: string; recentBlockhash: string; } interface BitcoinData { runeAddress: string; runePublicKey: string; paymentAddress: string | null; paymentPublicKey: string | undefined; } type BitcoinMessageRequest = BitcoinData & ArchMessageRequest; interface DecreaseLiquidityRequest { /** * The pubkey of the pool. */ poolId: string; /** * The pubkey of the position. */ positionPubKey: string; /** * The amount of liquidity to withdraw. */ liquidityAmount: bigint; /** * The minimum amount of the first token to withdraw. */ minToken0: bigint; /** * The minimum amount of the second token to withdraw. */ minToken1: bigint; /** * The address to withdraw the first token to. */ withdrawAddressToken0: string; /** * The address to withdraw the second token to. */ withdrawAddressToken1: string; /** * The fee rate for the transaction (in sats per byte). */ feeRate: bigint; } interface FindUtxoForDecreaseLiquidityRequest extends DecreaseLiquidityRequest { /** * User public key compatible with arch network. */ publicKey: string; } type DecreaseLiquidityPsbtRequest = DecreaseLiquidityRequest & BitcoinData; /** * Payment method for decrease liquidity operations */ type DecreaseLiquidityPaymentMethod = { type: 'fee_utxo'; feeUtxo: UtxoMetaData; } | { type: 'signed_psbt'; signedPsbt: string; } | { type: 'none'; }; type DecreaseLiquidityMessageRequest = DecreaseLiquidityRequest & BitcoinMessageRequest & { /** * The payment method for transaction fees */ paymentMethod: DecreaseLiquidityPaymentMethod; }; interface CanPoolCoverFeesResponse { /** * Whether the pool can cover the fees. */ canPoolCoverFees: boolean; /** * The total amount of fees that need to be paid. */ feesAmount: bigint; /** * The amount of fees that the pool can cover. */ poolCoveringFeesAmount: bigint; } interface IncreaseLiquidityRequest extends BitcoinData { feeRate: bigint; collectionAmount: bigint; btcAmount: bigint; includeAccountUtxo: boolean; poolId: string; } interface IncreaseLiquidityMessageWithMergeUtxoTxRequest extends BitcoinData { collectionAmount: bigint; btcAmount: bigint; feeRate: bigint; includeAccountUtxo: boolean; poolId: string; } interface IncreaseLiquidityMessageRequest extends BitcoinMessageRequest { signedPsbt: string; poolId: string; positionPubKey: string; feeRate: bigint; collectionAmount: bigint; btcAmount: bigint; mergeUtxoPsbt: string | undefined; maxAmount0: bigint; maxAmount1: bigint; } interface OpenPositionMessageRequest extends BitcoinMessageRequest { signedPsbt: string; poolId: string; feeRate: bigint; amount0: bigint; amount1: bigint; maxAmount0: bigint; maxAmount1: bigint; mergeUtxoPsbt: string | undefined; } interface AddPoolShardsMessageRequest extends BitcoinMessageRequest { feeRate: bigint; signedPsbt: string; poolId: string; shardsLength: number; } interface CreateAccountPsbtRequest extends BitcoinData { feeRate: bigint; shardsLength: number; } interface InitPoolCreateAccountPsbtRequest extends CreateAccountPsbtRequest { feeTier: number; token0: Token; token1: Token; } interface AddPoolShardsCreateAccountPsbtRequest extends CreateAccountPsbtRequest { poolId: string; } interface InitializePoolMessageRequest extends BitcoinMessageRequest { feeRate: bigint; signedPsbt: string; token0: string; token1: string; feeTier: number; minConfirmations: number; shardsLength: number; } interface BtcToRunePsbtRequest extends BitcoinData { feePayerPubkey: string; poolId: string; amountIn: bigint; amountOut: bigint; feeRate: bigint; } interface BtcToRuneSwapMessageRequest extends BitcoinMessageRequest { feeRate: bigint; poolId: string; amountIn: bigint; amountOut: bigint; exactIn: boolean; signedPsbt: string; shardPubkeys: string[]; mergeUtxoPsbt?: string; } interface BtcToRunePsbtResponse { tx: Psbt; shardPubkeys: string[]; mergeUtxoTx?: { psbt: Psbt; btcUtxo: CollectionUtxo; }; } declare enum PoolErrorType { PoolNotFound = "PoolNotFound", InsufficientLiquidity = "InsufficientLiquidity", ShardsUnavailable = "ShardsUnavailable", InvalidFeeRate = "InvalidFeeRate", InvalidAmountBelowMin = "InvalidAmountBelowMin", InvalidAmount = "InvalidAmount", InvalidToken = "InvalidToken", InvalidPsbt = "InvalidPsbt", InvalidUtxo = "InvalidUtxo", InvalidFeeTier = "InvalidFeeTier", InvalidSignature = "InvalidSignature", InvalidAssetPair = "InvalidAssetPair", InvalidRunestone = "InvalidRunestone", InvalidTxSize = "InvalidTxSize", InvalidPubkey = "InvalidPubkey", NotEnoughFunds = "NotEnoughFunds", NotEnoughFundsForSplittingRune = "NotEnoughFundsForSplittingRune", PoolAlreadyExists = "PoolAlreadyExists", FailedToSendArchTransaction = "FailedToSendArchTransaction", RequestExpired = "RequestExpired", InvalidNumericValue = "InvalidNumericValue", InvalidAddress = "InvalidAddress", ShardPubkeysRequired = "ShardPubkeysRequired" } interface CommonPoolError { type: PoolErrorType; message: string; } interface PoolNotFoundErrorByPoolId extends CommonPoolError { type: PoolErrorType.PoolNotFound; poolId: string; } interface PoolNotFoundErrorByToken extends CommonPoolError { type: PoolErrorType.PoolNotFound; token0: string; token1: string; feeTier?: number; } interface PoolAlreadyExistsError extends CommonPoolError { type: PoolErrorType.PoolAlreadyExists; poolId: string; } interface InvalidFeeRateError extends CommonPoolError { type: PoolErrorType.InvalidFeeRate; minFeeRate: number; } interface InsufficientLiquidityError extends CommonPoolError { type: PoolErrorType.InsufficientLiquidity; token: string; maxAmount: string; } interface ShardsUnavailableError extends CommonPoolError { type: PoolErrorType.ShardsUnavailable; reason: 'MempoolConstraints' | 'NoBalance'; token: string; } interface InvalidUtxoError extends CommonPoolError { type: PoolErrorType.InvalidUtxo; utxos: string[]; } interface InvalidTokenError extends CommonPoolError { type: PoolErrorType.InvalidToken; token: string; } interface NotEnoughFundsError extends CommonPoolError { type: PoolErrorType.NotEnoughFunds; maxAmount: string; minAmount: string; token: string; } interface NotEnoughFundsForSplittingRuneError extends CommonPoolError { type: PoolErrorType.NotEnoughFundsForSplittingRune; recommendedRuneAmount: string; currentSatsAmount: string; token: string; } interface InvalidPsbtError extends CommonPoolError { type: PoolErrorType.InvalidPsbt; } interface InvalidSignatureError extends CommonPoolError { type: PoolErrorType.InvalidSignature; } interface InvalidAmountBelowMinError extends CommonPoolError { type: PoolErrorType.InvalidAmountBelowMin; token: string; minAmount: string; } interface InvalidAmountError extends CommonPoolError { type: PoolErrorType.InvalidAmount; token: string; expectedAmount: string; actualAmount: string; } interface InvalidAssetPairError extends CommonPoolError { type: PoolErrorType.InvalidAssetPair; } interface InvalidFeeTierError extends CommonPoolError { type: PoolErrorType.InvalidFeeTier; feeTier: number; } interface InvalidPubkeyError extends CommonPoolError { type: PoolErrorType.InvalidPubkey; pubkey: string; } interface FailedToSendArchTransactionError extends CommonPoolError { type: PoolErrorType.FailedToSendArchTransaction; } interface RequestExpiredError extends CommonPoolError { type: PoolErrorType.RequestExpired; } interface InvalidRunestoneError extends CommonPoolError { type: PoolErrorType.InvalidRunestone; } interface InvalidTxSizeError extends CommonPoolError { type: PoolErrorType.InvalidTxSize; } interface InvalidNumericValue extends CommonPoolError { type: PoolErrorType.InvalidNumericValue; } interface InvalidAddress extends CommonPoolError { type: PoolErrorType.InvalidAddress; } interface ShardPubkeysRequiredError extends CommonPoolError { type: PoolErrorType.ShardPubkeysRequired; } type PoolError = PoolNotFoundErrorByPoolId | PoolNotFoundErrorByToken | PoolAlreadyExistsError | InvalidFeeRateError | InvalidUtxoError | InvalidTokenError | NotEnoughFundsError | NotEnoughFundsForSplittingRuneError | InvalidPsbtError | InvalidSignatureError | InvalidAmountBelowMinError | InvalidAmountError | InsufficientLiquidityError | ShardsUnavailableError | InvalidAssetPairError | InvalidFeeTierError | InvalidPubkeyError | InvalidRunestoneError | InvalidTxSizeError | InvalidNumericValue | InvalidAddress | FailedToSendArchTransactionError | RequestExpiredError | ShardPubkeysRequiredError; declare class PoolErrorException extends Error { error: PoolError; constructor(error: PoolError); getError(): PoolError; } interface GetSwapDetailsRequest { amount: bigint; token0Id: string; token1Id: string; feeRate: bigint; zeroToOne: boolean; exactIn: boolean; } interface SplitUtxoResponse { /** * The PSBT of the split rune. */ tx: Psbt; /** * The total amount of the split rune. */ totalAmount: string; /** * The amount of the split rune to receive. */ amountToReceive: string; } interface SplitRunePsbtRequest extends BitcoinData { paymentWallet: Wallet | undefined; collectionUtxos: Array; collection: Collection; amountIn: bigint; feeRate: bigint; runeToBtcTxVsize: number; } interface RuneToBtcPsbtRequest extends BitcoinData { amountIn: bigint; amountOut: bigint; exactIn: boolean; feeRate: bigint; poolId: string; splitRunePsbt: string | undefined; } interface RuneToBtcSwapMessageRequest extends BitcoinMessageRequest { feeRate: bigint; poolId: string; amountIn: bigint; amountOut: bigint; exactIn: boolean; signedPsbt: string; splitRunePsbt: string | undefined; } interface IArchProvider { getAccountAddress(pubkey: Pubkey): Promise; } interface IPoolIndexerProvider { getPoolById(poolId: string): Promise; getPoolsByTokenIds(token0Id: string, token1Id: string, feeTier?: number): Promise; getCollection(token: string): Promise; } declare class DecreaseLiquidity { private readonly config; constructor(config: SaturnSdkConfig); findUtxoReadyToPayFees(request: FindUtxoForDecreaseLiquidityRequest): Promise; canPoolCoverFees(request: DecreaseLiquidityRequest): Promise; createDecreaseLiquidityMessage(request: DecreaseLiquidityMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; private calculateDecreaseLiquidityFees; private getPoolAndPositionState; private getFeeForDecreaseLiquidityStateChange; private getFeeUtxo; } declare class IncreaseLiquidity { private readonly config; constructor(config: SaturnSdkConfig); buildPsbtToSendFundsToProgram(request: IncreaseLiquidityRequest): Promise<{ account: CreatedPdaAccount | undefined; tx: Psbt; txSizeIsSmallerThanMaxTxSize: boolean; }>; buildPsbtToSendFundsWithMergeUtxoTx(request: IncreaseLiquidityMessageWithMergeUtxoTxRequest): Promise<{ psbt: Psbt; mergeUtxoPsbt: Psbt; account: CreatedPdaAccount | undefined; }>; createIncreaseLiquidityMessage(request: IncreaseLiquidityMessageRequest): Promise<{ message: _saturnbtcio_arch_sdk.SanitizedMessage; utxosInfo: _saturnbtcio_arch_sdk.UtxoMetaData[]; }>; createOpenPositionMessage(request: OpenPositionMessageRequest): Promise<{ message: _saturnbtcio_arch_sdk.SanitizedMessage; utxosInfo: _saturnbtcio_arch_sdk.UtxoMetaData[]; }>; } declare class AddPoolShards { private readonly config; constructor(config: SaturnSdkConfig); addPoolShardsMessage(request: AddPoolShardsMessageRequest): Promise<{ message: _saturnbtcio_arch_sdk.SanitizedMessage; utxosInfo: _saturnbtcio_arch_sdk.UtxoMetaData[]; }>; } declare class CreateAccounts { private readonly config; constructor(config: SaturnSdkConfig); initPoolCreateAccountPsbt(request: InitPoolCreateAccountPsbtRequest): Promise<{ psbt: _saturnbtcio_psbt.Psbt<_saturnbtcio_psbt.AddressTxsUtxo>; }>; addPoolShardsCreateAccountPsbt(request: AddPoolShardsCreateAccountPsbtRequest): Promise<{ psbt: _saturnbtcio_psbt.Psbt<_saturnbtcio_psbt.AddressTxsUtxo>; }>; private handleErrorsInCreateAccountInstructions; } declare class InitializePool { private readonly config; constructor(config: SaturnSdkConfig); initializePoolMessage(request: InitializePoolMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; } declare class OneToZeroSwap { private readonly config; constructor(config: SaturnSdkConfig); private computeAdjustedRuneAmounts; private buildConsolidationTx; private addSwapOutputs; buildBtcToRunePsbt(request: BtcToRunePsbtRequest): Promise; swapMessage(request: BtcToRuneSwapMessageRequest): Promise<{ message: _saturnbtcio_arch_sdk.SanitizedMessage; utxosInfo: UtxoMetaData[]; splitRuneInputs: string[]; }>; } declare class SwapDetails { private readonly config; constructor(config: SaturnSdkConfig); getSwapDetails(request: GetSwapDetailsRequest): Promise<{ amountIn: bigint; amountOut: bigint; price: string; priceImpact: string; fees: { makers: bigint; network: bigint; }; poolId: string; }>; private getAmountsForPool; private getAmountOut; private getAmountIn; private getMinAmountForPool; private calculatePotentialTxSizeRuneToBtc; private calculatePotentialFeesBtcToRune; private comparePoolResponses; private calculatePriceImpact; private calculateFees; } declare class ZeroToOneSwap { private readonly config; constructor(config: SaturnSdkConfig); buildSplitRunePsbt(request: SplitRunePsbtRequest): Promise<{ tx: _saturnbtcio_psbt.Psbt<_saturnbtcio_psbt.AddressTxsUtxo>; utxo: CollectionUtxo; utxoMempoolEntry: MempoolEntry; totalAmount: bigint; amountToReceive: bigint; }>; buildRuneToBtcPsbt(request: RuneToBtcPsbtRequest): Promise<{ tx: _saturnbtcio_psbt.Psbt<_saturnbtcio_psbt.AddressTxsUtxo>; splitUtxoTx: SplitUtxoResponse | undefined; }>; swapMessage(request: RuneToBtcSwapMessageRequest): Promise<{ message: SanitizedMessage; utxosInfo: UtxoMetaData[]; splitRuneInputs: string[]; }>; } interface CollectProtocolFeesMessageRequest { runePublicKey: string; feePayerPubkey: string; poolId: string; withdrawAddressToken0: string; withdrawAddressToken1: string; recentBlockhash: string; feesUtxo?: UtxoMetaData; } declare class CollectProtocolFees { private readonly config; constructor(config: SaturnSdkConfig); collectProtocolFeesMessage(request: CollectProtocolFeesMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; } interface InitializeProtocolMessageRequest extends ArchMessageRequest { owner: string; } declare class InitializeProtocol { private readonly config; constructor(config: SaturnSdkConfig); initializeProtocolMessage(request: InitializeProtocolMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; } interface SetOwnerMessageRequest extends ArchMessageRequest { newOwner: string; } declare class SetOwner { private readonly config; constructor(config: SaturnSdkConfig); setOwnerMessage(request: SetOwnerMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; } interface SetFeeTiersMessageRequest extends ArchMessageRequest { feeTiers: Array; } declare class SetFeeTiers { private readonly config; constructor(config: SaturnSdkConfig); setFeeTiersMessage(request: SetFeeTiersMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; } interface TogglePausedMessageRequest extends ArchMessageRequest { paused: boolean; } declare class TogglePaused { private readonly config; constructor(config: SaturnSdkConfig); togglePausedMessage(request: TogglePausedMessageRequest): Promise<_saturnbtcio_arch_sdk.SanitizedMessage>; } interface SaturnSdkConfig { programAddress: string; network: Network; programAccount: string; mempoolInfoOracleAccount: string; feeRateOracleAccount: string; maxTxSize: number; indexerProvider: IPoolIndexerProvider; bitcoinProvider: IBitcoinProvider; archProvider: IArchProvider; } declare class SaturnSdk { readonly createAccounts: CreateAccounts; readonly addPoolShards: AddPoolShards; readonly initializePool: InitializePool; readonly increaseLiquidity: IncreaseLiquidity; readonly decreaseLiquidity: DecreaseLiquidity; readonly zeroToOneSwap: ZeroToOneSwap; readonly oneToZeroSwap: OneToZeroSwap; readonly swapDetails: SwapDetails; readonly collectProtocolFees: CollectProtocolFees; readonly initializeProtocol: InitializeProtocol; readonly setOwner: SetOwner; readonly setFeeTiers: SetFeeTiers; readonly togglePaused: TogglePaused; constructor(config: SaturnSdkConfig); } declare const getCalculatorForRuneToBtcTx: (userRuneInputType: InputType, userBtcOutputType: OutputType, pool: IdentifiableLiquidityPool, amountOut: bigint, mempoolInfo: MempoolInfoMap) => TransactionSizeCalculator; declare const getFeeForOpenOrIncreaseLiquidityStateChange: (hasRuneUtxo: boolean, hasBtcUtxo: boolean) => TransactionSizeCalculator; declare const getFeeForSwapBtcToRune: (txSizeCalculator: TransactionSizeCalculator, shards: number) => TransactionSizeCalculator; declare const findBtc: (wallet: Wallet, walletMempoolStatus: MempoolInfoMap, usedUtxos: Array, usedUtxosMempoolStatus: MempoolInfoMap, amount: bigint, feeRate: bigint, txBuilder: PsbtBuilder, sighashType: SigHash, publicKey: string, dustLimit: bigint) => { utxos: CollectionUtxo[]; amount: bigint; ancestorsSize: number; ancestorsFee: bigint; }; declare enum UpdateLiquidityBy { Liquidity = 0, BtcAmount = 1, RuneAmount = 2 } declare function selectBestShardsToRemoveFrom(pool: IdentifiableLiquidityPool, amountToRemove: bigint, removeBy: UpdateLiquidityBy, mempoolInfo: MempoolInfoMap): IdentifiableLiquidityPoolShard[]; declare const verifyBip322Signature: (signature: string, message: SanitizedMessage, pubkey: string, network: typeof NETWORK) => void; export { type AddPoolShardsCreateAccountPsbtRequest, type AddPoolShardsMessageRequest, type BtcToRunePsbtRequest, type BtcToRuneSwapMessageRequest, type Collection, type CollectionAmount, type CollectionType, type CollectionUtxo, type DecreaseLiquidityMessageRequest, type DecreaseLiquidityPaymentMethod, type DecreaseLiquidityPsbtRequest, type GetSwapDetailsRequest, type IArchProvider, type IBitcoinProvider, type IPoolIndexerProvider, type IncreaseLiquidityMessageRequest, type IncreaseLiquidityMessageWithMergeUtxoTxRequest, type IncreaseLiquidityRequest, type InitPoolCreateAccountPsbtRequest, type InitializePoolMessageRequest, type MempoolEntry, type MempoolFee, type MempoolInfoMap, type OpenPositionMessageRequest, type PoolError, PoolErrorException, PoolErrorType, type RuneToBtcPsbtRequest, type RuneToBtcSwapMessageRequest, SaturnSdk, type SplitRunePsbtRequest, type SplitUtxoResponse, UpdateLiquidityBy, type Wallet, findBtc, getCalculatorForRuneToBtcTx, getFeeForOpenOrIncreaseLiquidityStateChange, getFeeForSwapBtcToRune, selectBestShardsToRemoveFrom, verifyBip322Signature };