alkanesjs 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.mjs +4373 -19208
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.d.ts +290 -6
- package/dist/index.js +1086 -17155
- package/dist/index.js.map +4 -4
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as bitcoin from 'bitcoinjs-lib';
|
|
2
2
|
import { Network, Psbt, Transaction } from 'bitcoinjs-lib';
|
|
3
|
-
import {
|
|
3
|
+
import { BoxedResponse as BoxedResponse$1 } from 'bxrs';
|
|
4
4
|
import { BorshSchema, Infer } from 'borsher';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as ecpair from 'ecpair';
|
|
@@ -160,7 +160,7 @@ declare class WaitPacer {
|
|
|
160
160
|
interface ProviderConfig {
|
|
161
161
|
sandshrewUrl: string;
|
|
162
162
|
electrumApiUrl: string;
|
|
163
|
-
espoUrl
|
|
163
|
+
espoUrl?: string;
|
|
164
164
|
network: Network;
|
|
165
165
|
explorerUrl: string;
|
|
166
166
|
defaultFeeRate?: number;
|
|
@@ -182,7 +182,7 @@ type AlkanesParsedTraceResult = {
|
|
|
182
182
|
declare class Provider {
|
|
183
183
|
readonly sandshrewUrl: string;
|
|
184
184
|
readonly electrumApiUrl: string;
|
|
185
|
-
readonly espoUrl
|
|
185
|
+
readonly espoUrl?: string;
|
|
186
186
|
readonly network: Network;
|
|
187
187
|
readonly explorerUrl: string;
|
|
188
188
|
readonly pacerSettings: PacerSettings;
|
|
@@ -608,19 +608,303 @@ declare class RunesRpcProvider {
|
|
|
608
608
|
runes_getOutpoint(txidAndVout: string, blockHeight?: string): RpcCall<RunesOutpoint>;
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
type
|
|
612
|
-
|
|
611
|
+
type EspoAlkaneId = string;
|
|
612
|
+
type EspoOutpoint = string;
|
|
613
|
+
type EspoAmountString = string;
|
|
614
|
+
interface EspoOkResult {
|
|
615
|
+
ok: true;
|
|
616
|
+
}
|
|
617
|
+
interface EspoKeyValueItem {
|
|
618
|
+
key_hex: string;
|
|
619
|
+
key_str: string | null;
|
|
620
|
+
value_hex: string;
|
|
621
|
+
value_str: string | null;
|
|
622
|
+
value_u128: bigint | null;
|
|
623
|
+
last_txid: string | null;
|
|
624
|
+
}
|
|
625
|
+
interface EspoGetKeysParams {
|
|
626
|
+
alkane: EspoAlkaneId;
|
|
627
|
+
try_decode_utf8?: boolean;
|
|
628
|
+
keys?: string[];
|
|
629
|
+
limit?: number;
|
|
630
|
+
page?: number;
|
|
631
|
+
}
|
|
632
|
+
interface EspoGetKeysOk extends EspoOkResult {
|
|
633
|
+
alkane: EspoAlkaneId;
|
|
634
|
+
page: number;
|
|
635
|
+
limit: number;
|
|
636
|
+
total: number;
|
|
637
|
+
has_more: boolean;
|
|
638
|
+
items: Record<string, EspoKeyValueItem>;
|
|
639
|
+
}
|
|
640
|
+
type EspoGetKeys = DeepExpand<UnwrapEspoResult<EspoGetKeysOk>>;
|
|
641
|
+
interface EspoHolder {
|
|
642
|
+
address: string;
|
|
643
|
+
amount: number;
|
|
644
|
+
}
|
|
645
|
+
interface EspoGetHoldersParams {
|
|
646
|
+
alkane: EspoAlkaneId;
|
|
647
|
+
limit?: number;
|
|
648
|
+
page?: number;
|
|
649
|
+
}
|
|
650
|
+
interface EspoGetHoldersOk extends EspoOkResult {
|
|
651
|
+
alkane: EspoAlkaneId;
|
|
652
|
+
page: number;
|
|
653
|
+
limit: number;
|
|
654
|
+
total: number;
|
|
655
|
+
has_more: boolean;
|
|
656
|
+
items: EspoHolder[];
|
|
657
|
+
}
|
|
658
|
+
type EspoGetHolders = DeepExpand<UnwrapEspoResult<EspoGetHoldersOk>>;
|
|
659
|
+
interface EspoBalanceEntry {
|
|
660
|
+
alkane: EspoAlkaneId;
|
|
661
|
+
amount: number;
|
|
662
|
+
}
|
|
663
|
+
interface EspoOutpointBalance {
|
|
664
|
+
outpoint: EspoOutpoint;
|
|
665
|
+
entries: EspoBalanceEntry[];
|
|
666
|
+
}
|
|
667
|
+
interface EspoOutpointBalanceWithAddress extends EspoOutpointBalance {
|
|
668
|
+
address?: string;
|
|
669
|
+
}
|
|
670
|
+
interface EspoGetAddressBalancesOk extends EspoOkResult {
|
|
671
|
+
address: string;
|
|
672
|
+
balances: Record<EspoAlkaneId, number>;
|
|
673
|
+
outpoints?: EspoOutpointBalance[];
|
|
674
|
+
}
|
|
675
|
+
type EspoGetAddressBalances = DeepExpand<UnwrapEspoResult<EspoGetAddressBalancesOk>>;
|
|
676
|
+
interface EspoGetOutpointBalancesOk extends EspoOkResult {
|
|
677
|
+
outpoint: EspoOutpoint;
|
|
678
|
+
items: EspoOutpointBalanceWithAddress[];
|
|
679
|
+
}
|
|
680
|
+
type EspoGetOutpointBalances = DeepExpand<UnwrapEspoResult<EspoGetOutpointBalancesOk>>;
|
|
681
|
+
interface EspoGetHoldersCountOk extends EspoOkResult {
|
|
682
|
+
count: number;
|
|
683
|
+
}
|
|
684
|
+
type EspoGetHoldersCount = DeepExpand<UnwrapEspoResult<EspoGetHoldersCountOk>>;
|
|
685
|
+
interface EspoGetAddressOutpointsOk extends EspoOkResult {
|
|
686
|
+
address: string;
|
|
687
|
+
outpoints: EspoOutpointBalance[];
|
|
688
|
+
}
|
|
689
|
+
type EspoGetAddressOutpoints = DeepExpand<UnwrapEspoResult<EspoGetAddressOutpointsOk>>;
|
|
690
|
+
interface EspoCandle {
|
|
691
|
+
ts: number;
|
|
692
|
+
open: number;
|
|
693
|
+
high: number;
|
|
694
|
+
low: number;
|
|
695
|
+
close: number;
|
|
696
|
+
volume: number;
|
|
697
|
+
}
|
|
698
|
+
interface EspoGetCandlesParams {
|
|
699
|
+
pool: EspoAlkaneId;
|
|
700
|
+
timeframe?: "10m" | "1h" | "1d" | "1w" | "1M" | "m10" | "h1" | "d1" | "w1" | "m1";
|
|
701
|
+
side?: "base" | "quote";
|
|
702
|
+
limit?: number;
|
|
703
|
+
size?: number;
|
|
704
|
+
page?: number;
|
|
705
|
+
now?: number;
|
|
706
|
+
}
|
|
707
|
+
interface EspoGetCandlesOk extends EspoOkResult {
|
|
708
|
+
pool: EspoAlkaneId;
|
|
709
|
+
timeframe: string;
|
|
710
|
+
side: "base" | "quote";
|
|
711
|
+
page: number;
|
|
712
|
+
limit: number;
|
|
713
|
+
total: number;
|
|
714
|
+
has_more: boolean;
|
|
715
|
+
candles: EspoCandle[];
|
|
716
|
+
}
|
|
717
|
+
type EspoGetCandles = DeepExpand<UnwrapEspoResult<EspoGetCandlesOk>>;
|
|
718
|
+
type EspoTradeSide = "buy" | "sell" | "neutral";
|
|
719
|
+
interface EspoTrade {
|
|
720
|
+
timestamp: number;
|
|
721
|
+
txid: string;
|
|
722
|
+
address: string;
|
|
723
|
+
xpubkey: Uint8Array;
|
|
724
|
+
base_inflow: bigint;
|
|
725
|
+
quote_inflow: bigint;
|
|
726
|
+
side: EspoTradeSide;
|
|
727
|
+
amount: number;
|
|
728
|
+
}
|
|
729
|
+
interface EspoGetTradesParams {
|
|
730
|
+
pool: EspoAlkaneId;
|
|
731
|
+
limit?: number;
|
|
732
|
+
page?: number;
|
|
733
|
+
side?: "base" | "quote";
|
|
734
|
+
filter_side?: "buy" | "sell" | "all" | "a" | "b" | "s";
|
|
735
|
+
sort?: string;
|
|
736
|
+
dir?: "asc" | "desc" | "ascending" | "descending";
|
|
737
|
+
direction?: "asc" | "desc" | "ascending" | "descending";
|
|
738
|
+
}
|
|
739
|
+
interface EspoGetTradesOk extends EspoOkResult {
|
|
740
|
+
pool: EspoAlkaneId;
|
|
741
|
+
side: "base" | "quote";
|
|
742
|
+
filter_side: "all" | "buy" | "sell";
|
|
743
|
+
sort: string;
|
|
744
|
+
dir: "asc" | "desc";
|
|
745
|
+
page: number;
|
|
746
|
+
limit: number;
|
|
747
|
+
total: number;
|
|
748
|
+
has_more: boolean;
|
|
749
|
+
trades: EspoTrade[];
|
|
750
|
+
}
|
|
751
|
+
type EspoGetTrades = DeepExpand<UnwrapEspoResult<EspoGetTradesOk>>;
|
|
752
|
+
interface EspoPool {
|
|
753
|
+
base: EspoAlkaneId;
|
|
754
|
+
quote: EspoAlkaneId;
|
|
755
|
+
base_reserve: bigint;
|
|
756
|
+
quote_reserve: bigint;
|
|
757
|
+
source: "live";
|
|
758
|
+
}
|
|
759
|
+
interface EspoGetPoolsParams {
|
|
760
|
+
limit?: number;
|
|
761
|
+
page?: number;
|
|
762
|
+
}
|
|
763
|
+
interface EspoGetPoolsOk extends EspoOkResult {
|
|
764
|
+
page: number;
|
|
765
|
+
limit: number;
|
|
766
|
+
total: number;
|
|
767
|
+
has_more: boolean;
|
|
768
|
+
pools: Record<EspoAlkaneId, EspoPool>;
|
|
769
|
+
}
|
|
770
|
+
type EspoGetPools = DeepExpand<UnwrapEspoResult<EspoGetPoolsOk>>;
|
|
771
|
+
interface EspoSwapHop {
|
|
772
|
+
pool: EspoAlkaneId;
|
|
773
|
+
token_in: EspoAlkaneId;
|
|
774
|
+
token_out: EspoAlkaneId;
|
|
775
|
+
amount_in: bigint;
|
|
776
|
+
amount_out: bigint;
|
|
777
|
+
}
|
|
778
|
+
interface EspoFindBestSwapPathParams {
|
|
779
|
+
mode?: "exact_in" | "exact_out" | "implicit";
|
|
780
|
+
token_in: EspoAlkaneId;
|
|
781
|
+
token_out: EspoAlkaneId;
|
|
782
|
+
amount_in?: EspoAmountString | number;
|
|
783
|
+
amount_out_min?: EspoAmountString | number;
|
|
784
|
+
amount_out?: EspoAmountString | number;
|
|
785
|
+
amount_in_max?: EspoAmountString | number;
|
|
786
|
+
available_in?: EspoAmountString | number;
|
|
787
|
+
fee_bps?: number;
|
|
788
|
+
max_hops?: number;
|
|
789
|
+
}
|
|
790
|
+
interface EspoFindBestSwapPathOk extends EspoOkResult {
|
|
791
|
+
mode: string;
|
|
792
|
+
token_in: EspoAlkaneId;
|
|
793
|
+
token_out: EspoAlkaneId;
|
|
794
|
+
fee_bps: number;
|
|
795
|
+
max_hops: number;
|
|
796
|
+
amount_in: bigint;
|
|
797
|
+
amount_out: bigint;
|
|
798
|
+
hops: EspoSwapHop[];
|
|
799
|
+
}
|
|
800
|
+
type EspoFindBestSwapPath = DeepExpand<UnwrapEspoResult<EspoFindBestSwapPathOk>>;
|
|
801
|
+
interface EspoGetBestMevSwapOk extends EspoOkResult {
|
|
802
|
+
token: EspoAlkaneId;
|
|
803
|
+
fee_bps: number;
|
|
804
|
+
max_hops: number;
|
|
805
|
+
amount_in: bigint;
|
|
806
|
+
amount_out: bigint;
|
|
807
|
+
profit: bigint;
|
|
808
|
+
hops: EspoSwapHop[];
|
|
809
|
+
}
|
|
810
|
+
type EspoGetBestMevSwap = DeepExpand<UnwrapEspoResult<EspoGetBestMevSwapOk>>;
|
|
811
|
+
interface EspoTipHeight {
|
|
812
|
+
height: number;
|
|
813
|
+
}
|
|
814
|
+
type Keys = readonly PropertyKey[];
|
|
815
|
+
type Strip<T, K extends Keys> = Omit<T, Extract<K[number], keyof T>>;
|
|
816
|
+
type UnwrapEspoResult<T> = Strip<T, ["ok", "error", "hint"]>;
|
|
817
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
818
|
+
type DeepExpand<T> = T extends Primitive ? T : T extends Array<infer U> ? Array<DeepExpand<U>> : {
|
|
819
|
+
[K in keyof T]: DeepExpand<T[K]>;
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
type AmountLike = EspoAmountString | number | bigint;
|
|
823
|
+
type GetKeysOptions = Partial<Omit<EspoGetKeysParams, "alkane" | "try_decode_utf8">> & {
|
|
824
|
+
try_decode_utf8?: boolean;
|
|
825
|
+
tryDecodeUtf8?: boolean;
|
|
826
|
+
};
|
|
827
|
+
type GetHoldersOptions = Partial<Omit<EspoGetHoldersParams, "alkane">>;
|
|
828
|
+
type GetAddressBalancesOptions = {
|
|
829
|
+
include_outpoints?: boolean;
|
|
830
|
+
includeOutpoints?: boolean;
|
|
831
|
+
};
|
|
832
|
+
type GetCandlesOptions = Partial<Omit<EspoGetCandlesParams, "pool">>;
|
|
833
|
+
type GetTradesOptions = Partial<Omit<EspoGetTradesParams, "pool" | "filter_side">> & {
|
|
834
|
+
filter_side?: EspoGetTradesParams["filter_side"];
|
|
835
|
+
filterSide?: EspoGetTradesParams["filter_side"];
|
|
836
|
+
};
|
|
837
|
+
type GetPoolsOptions = Partial<EspoGetPoolsParams>;
|
|
838
|
+
interface FindBestSwapPathOptions {
|
|
839
|
+
mode?: EspoFindBestSwapPathParams["mode"];
|
|
840
|
+
amount_in?: AmountLike;
|
|
841
|
+
amountIn?: AmountLike;
|
|
842
|
+
amount_out_min?: AmountLike;
|
|
843
|
+
amountOutMin?: AmountLike;
|
|
844
|
+
amount_out?: AmountLike;
|
|
845
|
+
amountOut?: AmountLike;
|
|
846
|
+
amount_in_max?: AmountLike;
|
|
847
|
+
amountInMax?: AmountLike;
|
|
848
|
+
available_in?: AmountLike;
|
|
849
|
+
availableIn?: AmountLike;
|
|
850
|
+
fee_bps?: number;
|
|
851
|
+
feeBps?: number;
|
|
852
|
+
max_hops?: number;
|
|
853
|
+
maxHops?: number;
|
|
854
|
+
}
|
|
855
|
+
type GetBestMevSwapOptions = {
|
|
856
|
+
fee_bps?: number;
|
|
857
|
+
feeBps?: number;
|
|
858
|
+
max_hops?: number;
|
|
859
|
+
maxHops?: number;
|
|
860
|
+
};
|
|
861
|
+
declare class Espo {
|
|
862
|
+
rpc_url: string;
|
|
863
|
+
constructor(url: string);
|
|
864
|
+
private resultToBoxed;
|
|
865
|
+
private callAndUnbox;
|
|
866
|
+
private normalizeAmountLike;
|
|
867
|
+
private parseAmountString;
|
|
868
|
+
private normalizeBalanceEntry;
|
|
869
|
+
private hexStringToUint8Array;
|
|
870
|
+
private toBigIntAmount;
|
|
871
|
+
private toOptionalBigInt;
|
|
872
|
+
private normalizePool;
|
|
873
|
+
private normalizePoolsRecord;
|
|
874
|
+
private normalizeSwapHop;
|
|
875
|
+
private normalizeTrade;
|
|
876
|
+
private normalizeOutpointBalance;
|
|
877
|
+
private normalizeOutpointBalanceWithAddress;
|
|
878
|
+
private normalizeBalancesRecord;
|
|
879
|
+
ping(): Promise<BoxedResponse$1<"pong", string>>;
|
|
880
|
+
ammdataPing(): Promise<BoxedResponse$1<"pong", string>>;
|
|
881
|
+
getTipHeight(): Promise<BoxedResponse$1<UnwrapEspoResult<EspoTipHeight>, string>>;
|
|
882
|
+
getHoldersCount(alkane: EspoAlkaneId): Promise<BoxedResponse$1<EspoGetHoldersCount, string>>;
|
|
883
|
+
getKeys(alkane: EspoAlkaneId, options?: GetKeysOptions): Promise<BoxedResponse$1<EspoGetKeys, string>>;
|
|
884
|
+
getHolders(alkane: EspoAlkaneId, options?: GetHoldersOptions): Promise<BoxedResponse$1<EspoGetHolders, string>>;
|
|
885
|
+
getAddressBalances(address: string, options?: GetAddressBalancesOptions): Promise<BoxedResponse$1<EspoGetAddressBalances, string>>;
|
|
886
|
+
getOutpointBalances(outpoint: EspoOutpoint): Promise<BoxedResponse$1<EspoGetOutpointBalances, string>>;
|
|
887
|
+
getAddressOutpoints(address: string): Promise<BoxedResponse$1<EspoGetAddressOutpoints, string>>;
|
|
888
|
+
getCandles(pool: EspoAlkaneId, options?: GetCandlesOptions): Promise<BoxedResponse$1<EspoGetCandles, string>>;
|
|
889
|
+
getTrades(pool: EspoAlkaneId, options?: GetTradesOptions): Promise<BoxedResponse$1<EspoGetTrades, string>>;
|
|
890
|
+
getPools(options?: GetPoolsOptions): Promise<BoxedResponse$1<EspoGetPools, string>>;
|
|
891
|
+
findBestSwapPath(tokenIn: EspoAlkaneId, tokenOut: EspoAlkaneId, options?: FindBestSwapPathOptions): Promise<BoxedResponse$1<EspoFindBestSwapPath, string>>;
|
|
892
|
+
getBestMevSwap(token: EspoAlkaneId, options?: GetBestMevSwapOptions): Promise<BoxedResponse$1<EspoGetBestMevSwap, string>>;
|
|
893
|
+
}
|
|
894
|
+
|
|
613
895
|
declare class EspoRpcProvider extends Espo {
|
|
614
896
|
constructor(providerOrUrl: Provider | string);
|
|
615
897
|
}
|
|
616
898
|
|
|
617
899
|
declare class BaseRpcProvider {
|
|
900
|
+
private readonly coreProvider;
|
|
901
|
+
private espoProvider?;
|
|
618
902
|
readonly electrum: ElectrumApiProvider;
|
|
619
903
|
readonly ord: OrdRpcProvider;
|
|
620
904
|
readonly alkanes: AlkanesRpcProvider;
|
|
621
905
|
readonly sandshrew: SandshrewRpcProvider;
|
|
622
906
|
readonly runes: RunesRpcProvider;
|
|
623
|
-
|
|
907
|
+
get espo(): EspoRpcProvider;
|
|
624
908
|
constructor(coreProvider: Provider);
|
|
625
909
|
}
|
|
626
910
|
|