satsterminal-sdk
Version:
A TypeScript SDK for interacting with the SatsTerminal ecosystem.
255 lines (254 loc) • 5.71 kB
TypeScript
export interface SatsTerminalConfig {
apiKey: string;
baseUrl?: string;
}
export interface RequiredConfig {
apiKey: string;
}
export interface UTXO {
txid: string;
vout: number;
value: number;
status: {
confirmed: boolean;
};
}
export interface Order {
market: string;
id: string;
price: number;
fromTokenAmount?: string;
slippage?: number;
formattedAmount: number;
listingAmount?: number;
sellerAddress?: string;
tokenAmount?: string;
listingPrice?: string;
updatedAt?: string;
formattedUnitPrice?: string;
alkanesId?: string;
name?: string;
amount?: string;
}
export interface OrderMetrics {
averagePrice: number;
totalQuantity: number;
totalValue: number;
}
export interface OrderSummary {
marketplace: string;
selectedOrders: Order[];
totalFormattedAmount: string;
totalPrice: number;
metrics: OrderMetrics;
}
export interface SignedPSBT {
swapId?: string;
psbtHex?: string;
psbtBase64?: string;
}
export interface SearchParams {
query: string;
sell?: boolean;
protocol?: string;
}
export interface SearchResponse {
tokens: [];
}
export interface Token {
token_id: string;
token: string;
symbol: string;
icon: string;
is_verified: boolean;
}
export interface PopularTokensParams {
protocol?: string;
}
export interface PopularTokensResponse {
tokens: [];
}
export interface QuoteParams {
btcAmount: string;
runeName?: string;
address: string;
themeID?: string;
sell?: boolean;
marketplaces?: string[];
rbfProtection?: boolean;
fill?: boolean;
alkanesId?: string;
alkanesName?: string;
protocol?: string;
slippage?: number;
}
export interface QuoteResponse {
bestMarketplace: string;
selectedOrders: Order[];
totalFormattedAmount: string;
totalPrice: string;
metrics: Record<string, any>;
marketplaces: Record<string, any>;
error?: string;
}
export interface GetPSBTParams {
orders: Order[];
address: string;
publicKey: string;
paymentAddress: string;
paymentPublicKey: string;
utxos?: UTXO[];
feeRate?: number;
runeName: string;
slippage?: number;
themeID?: string;
sell?: boolean;
rbfProtection?: boolean;
protocol?: string;
alkanesId?: string;
alkanesName?: string;
}
export interface PSBTResponse {
swapId: string;
marketplace: string;
psbtBase64: string;
psbtHex: string;
inputs: number[];
rbfProtected: {
base64: string;
hex: string;
inputs: number[];
};
error?: string;
}
export interface ConfirmPSBTParams {
orders: Order[];
address: string;
publicKey: string;
paymentAddress: string;
paymentPublicKey: string;
signedPsbtBase64: string;
swapId: string;
runeName: string;
themeID?: string;
sell?: boolean;
marketplaces?: string[];
rbfProtection?: boolean;
signedRbfPsbtBase64?: string;
protocol?: string;
}
export interface ConfirmPSBTResponse {
marketplace: string;
txid: string;
rbfProtection: {
fundsPreparationTxId: string;
fulfillmentId: string;
};
isRbfTxid: boolean;
error?: string;
}
export interface SignInParams {
ord_address: string;
btc_address: string;
ord_public_key: string;
btc_public_key: string;
provider: string;
}
export interface SignInResponse {
id: number;
btc_address: string;
btc_public_key: string;
ord_address: string;
ord_public_key: string;
provider: string;
referral_code: string | null;
invitation_code: string | null;
total_points: number;
bind: {
binded: boolean;
};
}
export interface BindParams {
btcAddress: string;
nftAddress: string;
sign: string;
}
export interface BindResponse {
code: number;
msg: string;
}
export interface PointsParams {
ord_address: string;
}
export interface PointsResponse {
total_points: number;
}
export interface SwapV2QuoteParams {
amount: string;
fromToken: string;
toToken: string;
address: string;
params: Record<string, any>;
protocol: string;
marketplaces?: string[];
}
export interface SwapV2MarketplaceMetrics {
percentFulfilled: string;
totalReceived: string;
percentDifference: string;
averageUnitPrice: string;
}
export interface SwapV2Marketplace {
fromTokenAmount: string;
toTokenAmount: string;
swapId: string;
}
export interface SwapV2QuoteResponse {
bestMarketplace: string;
swapId: string;
fromTokenAmount: string;
toTokenAmount: string;
metrics: Record<string, SwapV2MarketplaceMetrics>;
marketplaces: Record<string, SwapV2Marketplace>;
}
export interface SwapV2PSBTParams {
marketplace: string;
swapId: string;
address: string;
publicKey: string;
paymentAddress: string;
paymentPublicKey: string;
feeRate: number;
slippage: number;
themeID?: string | null;
protocol: string;
}
export interface SwapV2PSBT {
base64: string;
hex: string;
inputs: number[];
}
export interface SwapV2PSBTResponse {
psbts: SwapV2PSBT[];
swapId: string;
}
export interface SwapV2SubmitParams {
marketplace: string;
swapId: string;
address: string;
publicKey: string;
paymentAddress: string;
paymentPublicKey: string;
protocol: string;
signedPsbts: string[];
}
export interface SwapV2SubmitResponse {
marketplace?: string;
txid: string;
rbfProtection?: {
fundsPreparationTxId: string;
fulfillmentId: string;
};
isRbfTxid?: boolean;
error?: string;
}