@secondlayer/stacks 0.0.1
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/README.md +92 -0
- package/dist/shared/stacks-02actsrx.cjs +17 -0
- package/dist/shared/stacks-02actsrx.cjs.map +10 -0
- package/dist/shared/stacks-1aqm7c2h.cjs +110 -0
- package/dist/shared/stacks-1aqm7c2h.cjs.map +11 -0
- package/dist/shared/stacks-24h5k94q.cjs +74 -0
- package/dist/shared/stacks-24h5k94q.cjs.map +11 -0
- package/dist/shared/stacks-2ar4prfz.cjs +328 -0
- package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
- package/dist/shared/stacks-4py5pm0r.cjs +237 -0
- package/dist/shared/stacks-4py5pm0r.cjs.map +10 -0
- package/dist/shared/stacks-5tprhns9.cjs +54 -0
- package/dist/shared/stacks-5tprhns9.cjs.map +11 -0
- package/dist/shared/stacks-61rvzkz1.cjs +132 -0
- package/dist/shared/stacks-61rvzkz1.cjs.map +17 -0
- package/dist/shared/stacks-709tra19.js +30 -0
- package/dist/shared/stacks-709tra19.js.map +10 -0
- package/dist/shared/stacks-74k8cxgb.cjs +567 -0
- package/dist/shared/stacks-74k8cxgb.cjs.map +13 -0
- package/dist/shared/stacks-8m9byk2j.js +7 -0
- package/dist/shared/stacks-8m9byk2j.js.map +9 -0
- package/dist/shared/stacks-8yykgdww.js +125 -0
- package/dist/shared/stacks-8yykgdww.js.map +11 -0
- package/dist/shared/stacks-9g0jhab3.cjs +40 -0
- package/dist/shared/stacks-9g0jhab3.cjs.map +10 -0
- package/dist/shared/stacks-an5k8n4t.cjs +291 -0
- package/dist/shared/stacks-an5k8n4t.cjs.map +23 -0
- package/dist/shared/stacks-b008c3w8.cjs +214 -0
- package/dist/shared/stacks-b008c3w8.cjs.map +11 -0
- package/dist/shared/stacks-bnvfmt7y.cjs +31 -0
- package/dist/shared/stacks-bnvfmt7y.cjs.map +9 -0
- package/dist/shared/stacks-bycy6t9k.js +22 -0
- package/dist/shared/stacks-bycy6t9k.js.map +10 -0
- package/dist/shared/stacks-d1fmkv3p.js +258 -0
- package/dist/shared/stacks-d1fmkv3p.js.map +13 -0
- package/dist/shared/stacks-dr5en54r.cjs +119 -0
- package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
- package/dist/shared/stacks-dxhntr76.js +278 -0
- package/dist/shared/stacks-dxhntr76.js.map +10 -0
- package/dist/shared/stacks-evnzth1q.cjs +35 -0
- package/dist/shared/stacks-evnzth1q.cjs.map +10 -0
- package/dist/shared/stacks-f3tk2k5s.js +27 -0
- package/dist/shared/stacks-f3tk2k5s.js.map +9 -0
- package/dist/shared/stacks-f7wdrzs3.js +285 -0
- package/dist/shared/stacks-f7wdrzs3.js.map +11 -0
- package/dist/shared/stacks-fcaefc5b.cjs +16 -0
- package/dist/shared/stacks-fcaefc5b.cjs.map +10 -0
- package/dist/shared/stacks-g9mcjcqg.cjs +3 -0
- package/dist/shared/stacks-g9mcjcqg.cjs.map +9 -0
- package/dist/shared/stacks-gck1sq7h.cjs +28 -0
- package/dist/shared/stacks-gck1sq7h.cjs.map +10 -0
- package/dist/shared/stacks-gjvbq6w7.js +46 -0
- package/dist/shared/stacks-gjvbq6w7.js.map +10 -0
- package/dist/shared/stacks-j2cy7qtt.js +237 -0
- package/dist/shared/stacks-j2cy7qtt.js.map +11 -0
- package/dist/shared/stacks-k08tgzyp.cjs +232 -0
- package/dist/shared/stacks-k08tgzyp.cjs.map +13 -0
- package/dist/shared/stacks-k2p5tv6x.js +37 -0
- package/dist/shared/stacks-k2p5tv6x.js.map +10 -0
- package/dist/shared/stacks-k58k970n.js +234 -0
- package/dist/shared/stacks-k58k970n.js.map +10 -0
- package/dist/shared/stacks-n2g56wgg.js +338 -0
- package/dist/shared/stacks-n2g56wgg.js.map +23 -0
- package/dist/shared/stacks-nqytwfcc.js +243 -0
- package/dist/shared/stacks-nqytwfcc.js.map +11 -0
- package/dist/shared/stacks-qcae5852.js +19 -0
- package/dist/shared/stacks-qcae5852.js.map +10 -0
- package/dist/shared/stacks-qt8ehebn.js +76 -0
- package/dist/shared/stacks-qt8ehebn.js.map +11 -0
- package/dist/shared/stacks-qvg7c24g.cjs +232 -0
- package/dist/shared/stacks-qvg7c24g.cjs.map +10 -0
- package/dist/shared/stacks-r1t6g3c3.cjs +241 -0
- package/dist/shared/stacks-r1t6g3c3.cjs.map +11 -0
- package/dist/shared/stacks-tjxmrssa.js +282 -0
- package/dist/shared/stacks-tjxmrssa.js.map +11 -0
- package/dist/shared/stacks-v9jqcpd4.js +18 -0
- package/dist/shared/stacks-v9jqcpd4.js.map +10 -0
- package/dist/shared/stacks-vdfag81a.cjs +121 -0
- package/dist/shared/stacks-vdfag81a.cjs.map +10 -0
- package/dist/shared/stacks-vdfs3e5v.js +134 -0
- package/dist/shared/stacks-vdfs3e5v.js.map +10 -0
- package/dist/shared/stacks-y3dh7hv1.js +60 -0
- package/dist/shared/stacks-y3dh7hv1.js.map +11 -0
- package/dist/shared/stacks-ya3x01yd.cjs +16 -0
- package/dist/shared/stacks-ya3x01yd.cjs.map +10 -0
- package/dist/shared/stacks-yfgsm6ap.js +599 -0
- package/dist/shared/stacks-yfgsm6ap.js.map +13 -0
- package/dist/shared/stacks-yfveb68e.js +121 -0
- package/dist/shared/stacks-yfveb68e.js.map +10 -0
- package/dist/shared/stacks-zm0b3tgy.js +160 -0
- package/dist/shared/stacks-zm0b3tgy.js.map +17 -0
- package/dist/shared/stacks-zyv9qqme.cjs +249 -0
- package/dist/shared/stacks-zyv9qqme.cjs.map +11 -0
- package/dist/src/accounts/index.cjs +90 -0
- package/dist/src/accounts/index.cjs.map +12 -0
- package/dist/src/accounts/index.d.cts +47 -0
- package/dist/src/accounts/index.d.ts +47 -0
- package/dist/src/accounts/index.js +104 -0
- package/dist/src/accounts/index.js.map +12 -0
- package/dist/src/actions/index.cjs +36 -0
- package/dist/src/actions/index.cjs.map +9 -0
- package/dist/src/actions/index.d.cts +886 -0
- package/dist/src/actions/index.d.ts +886 -0
- package/dist/src/actions/index.js +81 -0
- package/dist/src/actions/index.js.map +9 -0
- package/dist/src/bns/index.cjs +590 -0
- package/dist/src/bns/index.cjs.map +15 -0
- package/dist/src/bns/index.d.cts +241 -0
- package/dist/src/bns/index.d.ts +241 -0
- package/dist/src/bns/index.js +611 -0
- package/dist/src/bns/index.js.map +15 -0
- package/dist/src/chains/index.cjs +13 -0
- package/dist/src/chains/index.cjs.map +9 -0
- package/dist/src/chains/index.d.cts +53 -0
- package/dist/src/chains/index.d.ts +53 -0
- package/dist/src/chains/index.js +18 -0
- package/dist/src/chains/index.js.map +9 -0
- package/dist/src/clarity/index.cjs +3 -0
- package/dist/src/clarity/index.cjs.map +9 -0
- package/dist/src/clarity/index.d.cts +821 -0
- package/dist/src/clarity/index.d.ts +821 -0
- package/dist/src/clarity/index.js +145 -0
- package/dist/src/clarity/index.js.map +9 -0
- package/dist/src/connect/index.cjs +480 -0
- package/dist/src/connect/index.cjs.map +19 -0
- package/dist/src/connect/index.d.cts +110 -0
- package/dist/src/connect/index.d.ts +110 -0
- package/dist/src/connect/index.js +448 -0
- package/dist/src/connect/index.js.map +19 -0
- package/dist/src/connect/walletconnect/index.cjs +1322 -0
- package/dist/src/connect/walletconnect/index.cjs.map +18 -0
- package/dist/src/connect/walletconnect/index.d.cts +132 -0
- package/dist/src/connect/walletconnect/index.d.ts +132 -0
- package/dist/src/connect/walletconnect/index.js +1290 -0
- package/dist/src/connect/walletconnect/index.js.map +18 -0
- package/dist/src/index.cjs +557 -0
- package/dist/src/index.cjs.map +21 -0
- package/dist/src/index.d.cts +847 -0
- package/dist/src/index.d.ts +847 -0
- package/dist/src/index.js +629 -0
- package/dist/src/index.js.map +21 -0
- package/dist/src/postconditions/index.cjs +3 -0
- package/dist/src/postconditions/index.cjs.map +9 -0
- package/dist/src/postconditions/index.d.cts +91 -0
- package/dist/src/postconditions/index.d.ts +91 -0
- package/dist/src/postconditions/index.js +12 -0
- package/dist/src/postconditions/index.js.map +9 -0
- package/dist/src/pox/index.cjs +860 -0
- package/dist/src/pox/index.cjs.map +15 -0
- package/dist/src/pox/index.d.cts +244 -0
- package/dist/src/pox/index.d.ts +244 -0
- package/dist/src/pox/index.js +877 -0
- package/dist/src/pox/index.js.map +15 -0
- package/dist/src/stackingdao/index.cjs +300 -0
- package/dist/src/stackingdao/index.cjs.map +13 -0
- package/dist/src/stackingdao/index.d.cts +179 -0
- package/dist/src/stackingdao/index.d.ts +179 -0
- package/dist/src/stackingdao/index.js +318 -0
- package/dist/src/stackingdao/index.js.map +13 -0
- package/dist/src/subscriptions/index.cjs +14 -0
- package/dist/src/subscriptions/index.cjs.map +9 -0
- package/dist/src/subscriptions/index.d.cts +250 -0
- package/dist/src/subscriptions/index.d.ts +250 -0
- package/dist/src/subscriptions/index.js +21 -0
- package/dist/src/subscriptions/index.js.map +9 -0
- package/dist/src/transactions/index.cjs +50 -0
- package/dist/src/transactions/index.cjs.map +9 -0
- package/dist/src/transactions/index.d.cts +412 -0
- package/dist/src/transactions/index.d.ts +412 -0
- package/dist/src/transactions/index.js +101 -0
- package/dist/src/transactions/index.js.map +9 -0
- package/dist/src/utils/index.cjs +168 -0
- package/dist/src/utils/index.cjs.map +11 -0
- package/dist/src/utils/index.d.cts +140 -0
- package/dist/src/utils/index.d.ts +140 -0
- package/dist/src/utils/index.js +222 -0
- package/dist/src/utils/index.js.map +11 -0
- package/package.json +105 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/** Full chain descriptor used by clients and transports for network-aware operations. */
|
|
2
|
+
type StacksChain = {
|
|
3
|
+
/** Chain ID (e.g. 0x00000001 for mainnet) */
|
|
4
|
+
id: number
|
|
5
|
+
/** Human-readable name */
|
|
6
|
+
name: string
|
|
7
|
+
/** Network type */
|
|
8
|
+
network: "mainnet" | "testnet"
|
|
9
|
+
/** Transaction version byte for serialization */
|
|
10
|
+
transactionVersion: number
|
|
11
|
+
/** Peer network ID for P2P broadcasting */
|
|
12
|
+
peerNetworkId: number
|
|
13
|
+
/** Address version bytes */
|
|
14
|
+
addressVersion: {
|
|
15
|
+
singleSig: number
|
|
16
|
+
multiSig: number
|
|
17
|
+
}
|
|
18
|
+
/** Magic bytes for network identification */
|
|
19
|
+
magicBytes: string
|
|
20
|
+
/** Boot address (system contracts deployer) */
|
|
21
|
+
bootAddress: string
|
|
22
|
+
/** Native currency info */
|
|
23
|
+
nativeCurrency: {
|
|
24
|
+
name: string
|
|
25
|
+
symbol: string
|
|
26
|
+
decimals: number
|
|
27
|
+
}
|
|
28
|
+
/** Default RPC URLs */
|
|
29
|
+
rpcUrls: {
|
|
30
|
+
default: {
|
|
31
|
+
http: string[]
|
|
32
|
+
ws?: string[]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Block explorer URLs */
|
|
36
|
+
blockExplorers?: {
|
|
37
|
+
default: {
|
|
38
|
+
name: string
|
|
39
|
+
url: string
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** Function that sends an HTTP request to a Stacks node API path. */
|
|
44
|
+
type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
|
|
45
|
+
/** Options for a transport-level HTTP request. */
|
|
46
|
+
type RequestOptions = {
|
|
47
|
+
method?: "GET" | "POST" | "PUT" | "DELETE"
|
|
48
|
+
body?: unknown
|
|
49
|
+
headers?: Record<string, string>
|
|
50
|
+
};
|
|
51
|
+
/** Shared configuration for all transport types. */
|
|
52
|
+
type TransportConfig = {
|
|
53
|
+
url?: string
|
|
54
|
+
timeout?: number
|
|
55
|
+
retryCount?: number
|
|
56
|
+
retryDelay?: number
|
|
57
|
+
fetchOptions?: RequestInit
|
|
58
|
+
apiKey?: string
|
|
59
|
+
};
|
|
60
|
+
/** A resolved transport instance with a bound request function. */
|
|
61
|
+
type Transport = {
|
|
62
|
+
type: string
|
|
63
|
+
request: RequestFn
|
|
64
|
+
config: TransportConfig
|
|
65
|
+
destroy?: () => void
|
|
66
|
+
};
|
|
67
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
68
|
+
type LocalAccount = {
|
|
69
|
+
type: "local"
|
|
70
|
+
address: string
|
|
71
|
+
/** Compressed public key (hex) */
|
|
72
|
+
publicKey: string
|
|
73
|
+
/** Raw ECDSA sign over a hash */
|
|
74
|
+
sign(hash: Uint8Array): Uint8Array
|
|
75
|
+
/** Sign a structured message (SIP-018) */
|
|
76
|
+
signMessage(message: string | Uint8Array): string
|
|
77
|
+
};
|
|
78
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
79
|
+
type CustomAccount = {
|
|
80
|
+
type: "custom"
|
|
81
|
+
address: string
|
|
82
|
+
publicKey: string
|
|
83
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
84
|
+
};
|
|
85
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
86
|
+
type StacksProvider = {
|
|
87
|
+
request(method: string, params?: any): Promise<any>
|
|
88
|
+
};
|
|
89
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
90
|
+
type ProviderAccount = {
|
|
91
|
+
type: "provider"
|
|
92
|
+
address: string
|
|
93
|
+
publicKey: string
|
|
94
|
+
provider: StacksProvider
|
|
95
|
+
};
|
|
96
|
+
/** Union of all supported account types (local key, custom signer, or browser provider). */
|
|
97
|
+
type Account = LocalAccount | CustomAccount | ProviderAccount;
|
|
98
|
+
/**
|
|
99
|
+
* Core client instance that holds chain context, transport, and extensible actions.
|
|
100
|
+
* Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}.
|
|
101
|
+
*/
|
|
102
|
+
type Client<TExtended extends Record<string, unknown> = Record<string, unknown>> = {
|
|
103
|
+
chain?: StacksChain
|
|
104
|
+
account?: Account
|
|
105
|
+
transport: Transport
|
|
106
|
+
request: RequestFn
|
|
107
|
+
extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
|
|
108
|
+
} & TExtended;
|
|
109
|
+
interface DepositParams {
|
|
110
|
+
amount: bigint;
|
|
111
|
+
referrer?: string;
|
|
112
|
+
pool?: string;
|
|
113
|
+
}
|
|
114
|
+
interface InitWithdrawParams {
|
|
115
|
+
ststxAmount: bigint;
|
|
116
|
+
}
|
|
117
|
+
interface WithdrawParams {
|
|
118
|
+
nftId: bigint;
|
|
119
|
+
}
|
|
120
|
+
interface WithdrawIdleParams {
|
|
121
|
+
ststxAmount: bigint;
|
|
122
|
+
}
|
|
123
|
+
interface ExchangeRateInfo {
|
|
124
|
+
stxPerStstx: bigint;
|
|
125
|
+
ststxSupply: bigint;
|
|
126
|
+
totalStx: bigint;
|
|
127
|
+
}
|
|
128
|
+
interface WithdrawalInfo {
|
|
129
|
+
ststxAmount: bigint;
|
|
130
|
+
stxAmount: bigint;
|
|
131
|
+
unlockBurnHeight: bigint;
|
|
132
|
+
}
|
|
133
|
+
interface FeeInfo {
|
|
134
|
+
stackFee: bigint;
|
|
135
|
+
unstackFee: bigint;
|
|
136
|
+
withdrawIdleFee: bigint;
|
|
137
|
+
}
|
|
138
|
+
declare const STACKINGDAO_CONTRACTS: {
|
|
139
|
+
readonly core: {
|
|
140
|
+
readonly name: "stacking-dao-core-v6"
|
|
141
|
+
}
|
|
142
|
+
readonly ststxToken: {
|
|
143
|
+
readonly name: "ststx-token"
|
|
144
|
+
}
|
|
145
|
+
readonly withdrawNft: {
|
|
146
|
+
readonly name: "ststx-withdraw-nft-v2"
|
|
147
|
+
}
|
|
148
|
+
readonly reserve: {
|
|
149
|
+
readonly name: "reserve-v1"
|
|
150
|
+
}
|
|
151
|
+
readonly dataCore: {
|
|
152
|
+
readonly name: "data-core-v3"
|
|
153
|
+
}
|
|
154
|
+
readonly dataCoreV1: {
|
|
155
|
+
readonly name: "data-core-v1"
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
/** Trait contracts auto-passed to core functions — users never need these. */
|
|
159
|
+
declare const TRAIT_CONTRACTS: {};
|
|
160
|
+
/**
|
|
161
|
+
* StackingDAO liquid staking extension.
|
|
162
|
+
* Deposit STX → receive stSTX. Auto-compounding stacking rewards.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* import { createWalletClient, http, mainnet } from "stacks";
|
|
166
|
+
* import { stackingDao } from "stacks/stackingdao";
|
|
167
|
+
*
|
|
168
|
+
* const client = createWalletClient({ ... }).extend(stackingDao());
|
|
169
|
+
*
|
|
170
|
+
* // Deposit STX for stSTX
|
|
171
|
+
* await client.stackingDao.deposit({ amount: 100_000_000_000n });
|
|
172
|
+
*
|
|
173
|
+
* // Check exchange rate
|
|
174
|
+
* const rate = await client.stackingDao.getExchangeRate();
|
|
175
|
+
*/
|
|
176
|
+
declare function stackingDao(): (client: Client) => {
|
|
177
|
+
stackingDao: {}
|
|
178
|
+
};
|
|
179
|
+
export { stackingDao, WithdrawalInfo, WithdrawParams, WithdrawIdleParams, TRAIT_CONTRACTS, STACKINGDAO_CONTRACTS, InitWithdrawParams, FeeInfo, ExchangeRateInfo, DepositParams };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/** Full chain descriptor used by clients and transports for network-aware operations. */
|
|
2
|
+
type StacksChain = {
|
|
3
|
+
/** Chain ID (e.g. 0x00000001 for mainnet) */
|
|
4
|
+
id: number
|
|
5
|
+
/** Human-readable name */
|
|
6
|
+
name: string
|
|
7
|
+
/** Network type */
|
|
8
|
+
network: "mainnet" | "testnet"
|
|
9
|
+
/** Transaction version byte for serialization */
|
|
10
|
+
transactionVersion: number
|
|
11
|
+
/** Peer network ID for P2P broadcasting */
|
|
12
|
+
peerNetworkId: number
|
|
13
|
+
/** Address version bytes */
|
|
14
|
+
addressVersion: {
|
|
15
|
+
singleSig: number
|
|
16
|
+
multiSig: number
|
|
17
|
+
}
|
|
18
|
+
/** Magic bytes for network identification */
|
|
19
|
+
magicBytes: string
|
|
20
|
+
/** Boot address (system contracts deployer) */
|
|
21
|
+
bootAddress: string
|
|
22
|
+
/** Native currency info */
|
|
23
|
+
nativeCurrency: {
|
|
24
|
+
name: string
|
|
25
|
+
symbol: string
|
|
26
|
+
decimals: number
|
|
27
|
+
}
|
|
28
|
+
/** Default RPC URLs */
|
|
29
|
+
rpcUrls: {
|
|
30
|
+
default: {
|
|
31
|
+
http: string[]
|
|
32
|
+
ws?: string[]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Block explorer URLs */
|
|
36
|
+
blockExplorers?: {
|
|
37
|
+
default: {
|
|
38
|
+
name: string
|
|
39
|
+
url: string
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** Function that sends an HTTP request to a Stacks node API path. */
|
|
44
|
+
type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
|
|
45
|
+
/** Options for a transport-level HTTP request. */
|
|
46
|
+
type RequestOptions = {
|
|
47
|
+
method?: "GET" | "POST" | "PUT" | "DELETE"
|
|
48
|
+
body?: unknown
|
|
49
|
+
headers?: Record<string, string>
|
|
50
|
+
};
|
|
51
|
+
/** Shared configuration for all transport types. */
|
|
52
|
+
type TransportConfig = {
|
|
53
|
+
url?: string
|
|
54
|
+
timeout?: number
|
|
55
|
+
retryCount?: number
|
|
56
|
+
retryDelay?: number
|
|
57
|
+
fetchOptions?: RequestInit
|
|
58
|
+
apiKey?: string
|
|
59
|
+
};
|
|
60
|
+
/** A resolved transport instance with a bound request function. */
|
|
61
|
+
type Transport = {
|
|
62
|
+
type: string
|
|
63
|
+
request: RequestFn
|
|
64
|
+
config: TransportConfig
|
|
65
|
+
destroy?: () => void
|
|
66
|
+
};
|
|
67
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
68
|
+
type LocalAccount = {
|
|
69
|
+
type: "local"
|
|
70
|
+
address: string
|
|
71
|
+
/** Compressed public key (hex) */
|
|
72
|
+
publicKey: string
|
|
73
|
+
/** Raw ECDSA sign over a hash */
|
|
74
|
+
sign(hash: Uint8Array): Uint8Array
|
|
75
|
+
/** Sign a structured message (SIP-018) */
|
|
76
|
+
signMessage(message: string | Uint8Array): string
|
|
77
|
+
};
|
|
78
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
79
|
+
type CustomAccount = {
|
|
80
|
+
type: "custom"
|
|
81
|
+
address: string
|
|
82
|
+
publicKey: string
|
|
83
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
84
|
+
};
|
|
85
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
86
|
+
type StacksProvider = {
|
|
87
|
+
request(method: string, params?: any): Promise<any>
|
|
88
|
+
};
|
|
89
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
90
|
+
type ProviderAccount = {
|
|
91
|
+
type: "provider"
|
|
92
|
+
address: string
|
|
93
|
+
publicKey: string
|
|
94
|
+
provider: StacksProvider
|
|
95
|
+
};
|
|
96
|
+
/** Union of all supported account types (local key, custom signer, or browser provider). */
|
|
97
|
+
type Account = LocalAccount | CustomAccount | ProviderAccount;
|
|
98
|
+
/**
|
|
99
|
+
* Core client instance that holds chain context, transport, and extensible actions.
|
|
100
|
+
* Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}.
|
|
101
|
+
*/
|
|
102
|
+
type Client<TExtended extends Record<string, unknown> = Record<string, unknown>> = {
|
|
103
|
+
chain?: StacksChain
|
|
104
|
+
account?: Account
|
|
105
|
+
transport: Transport
|
|
106
|
+
request: RequestFn
|
|
107
|
+
extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
|
|
108
|
+
} & TExtended;
|
|
109
|
+
interface DepositParams {
|
|
110
|
+
amount: bigint;
|
|
111
|
+
referrer?: string;
|
|
112
|
+
pool?: string;
|
|
113
|
+
}
|
|
114
|
+
interface InitWithdrawParams {
|
|
115
|
+
ststxAmount: bigint;
|
|
116
|
+
}
|
|
117
|
+
interface WithdrawParams {
|
|
118
|
+
nftId: bigint;
|
|
119
|
+
}
|
|
120
|
+
interface WithdrawIdleParams {
|
|
121
|
+
ststxAmount: bigint;
|
|
122
|
+
}
|
|
123
|
+
interface ExchangeRateInfo {
|
|
124
|
+
stxPerStstx: bigint;
|
|
125
|
+
ststxSupply: bigint;
|
|
126
|
+
totalStx: bigint;
|
|
127
|
+
}
|
|
128
|
+
interface WithdrawalInfo {
|
|
129
|
+
ststxAmount: bigint;
|
|
130
|
+
stxAmount: bigint;
|
|
131
|
+
unlockBurnHeight: bigint;
|
|
132
|
+
}
|
|
133
|
+
interface FeeInfo {
|
|
134
|
+
stackFee: bigint;
|
|
135
|
+
unstackFee: bigint;
|
|
136
|
+
withdrawIdleFee: bigint;
|
|
137
|
+
}
|
|
138
|
+
declare const STACKINGDAO_CONTRACTS: {
|
|
139
|
+
readonly core: {
|
|
140
|
+
readonly name: "stacking-dao-core-v6"
|
|
141
|
+
}
|
|
142
|
+
readonly ststxToken: {
|
|
143
|
+
readonly name: "ststx-token"
|
|
144
|
+
}
|
|
145
|
+
readonly withdrawNft: {
|
|
146
|
+
readonly name: "ststx-withdraw-nft-v2"
|
|
147
|
+
}
|
|
148
|
+
readonly reserve: {
|
|
149
|
+
readonly name: "reserve-v1"
|
|
150
|
+
}
|
|
151
|
+
readonly dataCore: {
|
|
152
|
+
readonly name: "data-core-v3"
|
|
153
|
+
}
|
|
154
|
+
readonly dataCoreV1: {
|
|
155
|
+
readonly name: "data-core-v1"
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
/** Trait contracts auto-passed to core functions — users never need these. */
|
|
159
|
+
declare const TRAIT_CONTRACTS: {};
|
|
160
|
+
/**
|
|
161
|
+
* StackingDAO liquid staking extension.
|
|
162
|
+
* Deposit STX → receive stSTX. Auto-compounding stacking rewards.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* import { createWalletClient, http, mainnet } from "stacks";
|
|
166
|
+
* import { stackingDao } from "stacks/stackingdao";
|
|
167
|
+
*
|
|
168
|
+
* const client = createWalletClient({ ... }).extend(stackingDao());
|
|
169
|
+
*
|
|
170
|
+
* // Deposit STX for stSTX
|
|
171
|
+
* await client.stackingDao.deposit({ amount: 100_000_000_000n });
|
|
172
|
+
*
|
|
173
|
+
* // Check exchange rate
|
|
174
|
+
* const rate = await client.stackingDao.getExchangeRate();
|
|
175
|
+
*/
|
|
176
|
+
declare function stackingDao(): (client: Client) => {
|
|
177
|
+
stackingDao: {}
|
|
178
|
+
};
|
|
179
|
+
export { stackingDao, WithdrawalInfo, WithdrawParams, WithdrawIdleParams, TRAIT_CONTRACTS, STACKINGDAO_CONTRACTS, InitWithdrawParams, FeeInfo, ExchangeRateInfo, DepositParams };
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SIP010_ABI
|
|
3
|
+
} from "../../shared/stacks-k58k970n.js";
|
|
4
|
+
import {
|
|
5
|
+
getContract
|
|
6
|
+
} from "../../shared/stacks-vdfs3e5v.js";
|
|
7
|
+
import"../../shared/stacks-zm0b3tgy.js";
|
|
8
|
+
import"../../shared/stacks-709tra19.js";
|
|
9
|
+
import"../../shared/stacks-d1fmkv3p.js";
|
|
10
|
+
import {
|
|
11
|
+
Pc
|
|
12
|
+
} from "../../shared/stacks-yfveb68e.js";
|
|
13
|
+
import"../../shared/stacks-f7wdrzs3.js";
|
|
14
|
+
import"../../shared/stacks-yfgsm6ap.js";
|
|
15
|
+
import"../../shared/stacks-j2cy7qtt.js";
|
|
16
|
+
import"../../shared/stacks-8yykgdww.js";
|
|
17
|
+
import"../../shared/stacks-v9jqcpd4.js";
|
|
18
|
+
import"../../shared/stacks-bycy6t9k.js";
|
|
19
|
+
import"../../shared/stacks-gjvbq6w7.js";
|
|
20
|
+
import"../../shared/stacks-nqytwfcc.js";
|
|
21
|
+
import"../../shared/stacks-8m9byk2j.js";
|
|
22
|
+
|
|
23
|
+
// src/stackingdao/abi.ts
|
|
24
|
+
var withdrawTuple = {
|
|
25
|
+
tuple: [
|
|
26
|
+
{ name: "stx-fee-amount", type: "uint128" },
|
|
27
|
+
{ name: "stx-user-amount", type: "uint128" }
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
var STACKING_DAO_CORE_ABI = {
|
|
31
|
+
functions: [
|
|
32
|
+
{
|
|
33
|
+
name: "deposit",
|
|
34
|
+
access: "public",
|
|
35
|
+
args: [
|
|
36
|
+
{ name: "reserve", type: "trait_reference" },
|
|
37
|
+
{ name: "commission-contract", type: "trait_reference" },
|
|
38
|
+
{ name: "staking-contract", type: "trait_reference" },
|
|
39
|
+
{ name: "direct-helpers", type: "trait_reference" },
|
|
40
|
+
{ name: "stx-amount", type: "uint128" },
|
|
41
|
+
{ name: "referrer", type: { optional: "principal" } },
|
|
42
|
+
{ name: "pool", type: { optional: "principal" } }
|
|
43
|
+
],
|
|
44
|
+
outputs: { response: { ok: "uint128", error: "uint128" } }
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "init-withdraw",
|
|
48
|
+
access: "public",
|
|
49
|
+
args: [
|
|
50
|
+
{ name: "reserve", type: "trait_reference" },
|
|
51
|
+
{ name: "direct-helpers", type: "trait_reference" },
|
|
52
|
+
{ name: "ststx-amount", type: "uint128" }
|
|
53
|
+
],
|
|
54
|
+
outputs: { response: { ok: "uint128", error: "uint128" } }
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "withdraw",
|
|
58
|
+
access: "public",
|
|
59
|
+
args: [
|
|
60
|
+
{ name: "reserve", type: "trait_reference" },
|
|
61
|
+
{ name: "commission-contract", type: "trait_reference" },
|
|
62
|
+
{ name: "staking-contract", type: "trait_reference" },
|
|
63
|
+
{ name: "nft-id", type: "uint128" }
|
|
64
|
+
],
|
|
65
|
+
outputs: { response: { ok: withdrawTuple, error: "uint128" } }
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "withdraw-idle",
|
|
69
|
+
access: "public",
|
|
70
|
+
args: [
|
|
71
|
+
{ name: "reserve", type: "trait_reference" },
|
|
72
|
+
{ name: "direct-helpers", type: "trait_reference" },
|
|
73
|
+
{ name: "commission-contract", type: "trait_reference" },
|
|
74
|
+
{ name: "staking-contract", type: "trait_reference" },
|
|
75
|
+
{ name: "ststx-amount", type: "uint128" }
|
|
76
|
+
],
|
|
77
|
+
outputs: { response: { ok: withdrawTuple, error: "uint128" } }
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "get-stack-fee",
|
|
81
|
+
access: "read-only",
|
|
82
|
+
args: [],
|
|
83
|
+
outputs: "uint128"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "get-unstack-fee",
|
|
87
|
+
access: "read-only",
|
|
88
|
+
args: [],
|
|
89
|
+
outputs: "uint128"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "get-withdraw-idle-fee",
|
|
93
|
+
access: "read-only",
|
|
94
|
+
args: [],
|
|
95
|
+
outputs: "uint128"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "get-shutdown-deposits",
|
|
99
|
+
access: "read-only",
|
|
100
|
+
args: [],
|
|
101
|
+
outputs: "bool"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
var DATA_CORE_V1_ABI = {
|
|
106
|
+
functions: [
|
|
107
|
+
{
|
|
108
|
+
name: "get-withdrawals-by-nft",
|
|
109
|
+
access: "read-only",
|
|
110
|
+
args: [{ name: "nft-id", type: "uint128" }],
|
|
111
|
+
outputs: {
|
|
112
|
+
tuple: [
|
|
113
|
+
{ name: "ststx-amount", type: "uint128" },
|
|
114
|
+
{ name: "stx-amount", type: "uint128" },
|
|
115
|
+
{ name: "unlock-burn-height", type: "uint128" }
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
var DATA_CORE_V3_ABI = {
|
|
122
|
+
functions: [
|
|
123
|
+
{
|
|
124
|
+
name: "get-stx-per-ststx-helper",
|
|
125
|
+
access: "read-only",
|
|
126
|
+
args: [{ name: "stx-amount", type: "uint128" }],
|
|
127
|
+
outputs: "uint128"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
var RESERVE_V1_ABI = {
|
|
132
|
+
functions: [
|
|
133
|
+
{
|
|
134
|
+
name: "get-total-stx",
|
|
135
|
+
access: "read-only",
|
|
136
|
+
args: [],
|
|
137
|
+
outputs: { response: { ok: "uint128", error: "none" } }
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// src/stackingdao/constants.ts
|
|
143
|
+
var DEPLOYER = "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG";
|
|
144
|
+
var STACKINGDAO_CONTRACTS = {
|
|
145
|
+
core: { address: DEPLOYER, name: "stacking-dao-core-v6" },
|
|
146
|
+
ststxToken: { address: DEPLOYER, name: "ststx-token" },
|
|
147
|
+
withdrawNft: { address: DEPLOYER, name: "ststx-withdraw-nft-v2" },
|
|
148
|
+
reserve: { address: DEPLOYER, name: "reserve-v1" },
|
|
149
|
+
dataCore: { address: DEPLOYER, name: "data-core-v3" },
|
|
150
|
+
dataCoreV1: { address: DEPLOYER, name: "data-core-v1" }
|
|
151
|
+
};
|
|
152
|
+
var TRAIT_CONTRACTS = {
|
|
153
|
+
reserve: `${DEPLOYER}.reserve-v1`,
|
|
154
|
+
commission: `${DEPLOYER}.commission-v2`,
|
|
155
|
+
directHelpers: `${DEPLOYER}.direct-helpers-v4`,
|
|
156
|
+
staking: `${DEPLOYER}.staking-v0`
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/stackingdao/actions.ts
|
|
160
|
+
function assertMainnet(client) {
|
|
161
|
+
if (!client.chain) {
|
|
162
|
+
throw new Error("Client must have a chain configured");
|
|
163
|
+
}
|
|
164
|
+
if (client.chain.network !== "mainnet") {
|
|
165
|
+
throw new Error("StackingDAO is only available on mainnet");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function getCoreContract(client) {
|
|
169
|
+
assertMainnet(client);
|
|
170
|
+
const c = STACKINGDAO_CONTRACTS.core;
|
|
171
|
+
return getContract({ client, address: c.address, name: c.name, abi: STACKING_DAO_CORE_ABI });
|
|
172
|
+
}
|
|
173
|
+
function getStstxToken(client) {
|
|
174
|
+
assertMainnet(client);
|
|
175
|
+
const c = STACKINGDAO_CONTRACTS.ststxToken;
|
|
176
|
+
return getContract({ client, address: c.address, name: c.name, abi: SIP010_ABI });
|
|
177
|
+
}
|
|
178
|
+
function getDataCoreV1(client) {
|
|
179
|
+
assertMainnet(client);
|
|
180
|
+
const c = STACKINGDAO_CONTRACTS.dataCoreV1;
|
|
181
|
+
return getContract({ client, address: c.address, name: c.name, abi: DATA_CORE_V1_ABI });
|
|
182
|
+
}
|
|
183
|
+
function getDataCoreV3(client) {
|
|
184
|
+
assertMainnet(client);
|
|
185
|
+
const c = STACKINGDAO_CONTRACTS.dataCore;
|
|
186
|
+
return getContract({ client, address: c.address, name: c.name, abi: DATA_CORE_V3_ABI });
|
|
187
|
+
}
|
|
188
|
+
function getReserveContract(client) {
|
|
189
|
+
assertMainnet(client);
|
|
190
|
+
const c = STACKINGDAO_CONTRACTS.reserve;
|
|
191
|
+
return getContract({ client, address: c.address, name: c.name, abi: RESERVE_V1_ABI });
|
|
192
|
+
}
|
|
193
|
+
var traits = {
|
|
194
|
+
reserve: TRAIT_CONTRACTS.reserve,
|
|
195
|
+
commissionContract: TRAIT_CONTRACTS.commission,
|
|
196
|
+
stakingContract: TRAIT_CONTRACTS.staking,
|
|
197
|
+
directHelpers: TRAIT_CONTRACTS.directHelpers
|
|
198
|
+
};
|
|
199
|
+
async function deposit(client, params) {
|
|
200
|
+
const core = getCoreContract(client);
|
|
201
|
+
return core.call.deposit({
|
|
202
|
+
...traits,
|
|
203
|
+
stxAmount: params.amount,
|
|
204
|
+
referrer: params.referrer ?? null,
|
|
205
|
+
pool: params.pool ?? null
|
|
206
|
+
}, {
|
|
207
|
+
postConditions: [
|
|
208
|
+
Pc.principal(client.account.address).willSendEq(params.amount).ustx()
|
|
209
|
+
]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async function initWithdraw(client, params) {
|
|
213
|
+
const core = getCoreContract(client);
|
|
214
|
+
const ststx = STACKINGDAO_CONTRACTS.ststxToken;
|
|
215
|
+
return core.call["init-withdraw"]({
|
|
216
|
+
reserve: traits.reserve,
|
|
217
|
+
directHelpers: traits.directHelpers,
|
|
218
|
+
ststxAmount: params.ststxAmount
|
|
219
|
+
}, {
|
|
220
|
+
postConditions: [
|
|
221
|
+
Pc.principal(client.account.address).willSendEq(params.ststxAmount).ft(`${ststx.address}.${ststx.name}`, "ststx")
|
|
222
|
+
]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async function withdraw(client, params) {
|
|
226
|
+
const core = getCoreContract(client);
|
|
227
|
+
return core.call.withdraw({
|
|
228
|
+
reserve: traits.reserve,
|
|
229
|
+
commissionContract: traits.commissionContract,
|
|
230
|
+
stakingContract: traits.stakingContract,
|
|
231
|
+
nftId: params.nftId
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
async function withdrawIdle(client, params) {
|
|
235
|
+
const core = getCoreContract(client);
|
|
236
|
+
const ststx = STACKINGDAO_CONTRACTS.ststxToken;
|
|
237
|
+
return core.call["withdraw-idle"]({
|
|
238
|
+
reserve: traits.reserve,
|
|
239
|
+
directHelpers: traits.directHelpers,
|
|
240
|
+
commissionContract: traits.commissionContract,
|
|
241
|
+
stakingContract: traits.stakingContract,
|
|
242
|
+
ststxAmount: params.ststxAmount
|
|
243
|
+
}, {
|
|
244
|
+
postConditions: [
|
|
245
|
+
Pc.principal(client.account.address).willSendEq(params.ststxAmount).ft(`${ststx.address}.${ststx.name}`, "ststx")
|
|
246
|
+
]
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async function getStSTXBalance(client, address) {
|
|
250
|
+
const token = getStstxToken(client);
|
|
251
|
+
return await token.read["get-balance"]({ account: address });
|
|
252
|
+
}
|
|
253
|
+
async function getExchangeRate(client) {
|
|
254
|
+
const reserve = getReserveContract(client);
|
|
255
|
+
const dataV3 = getDataCoreV3(client);
|
|
256
|
+
const [totalStx, ststxSupply] = await Promise.all([
|
|
257
|
+
reserve.read["get-total-stx"]({}),
|
|
258
|
+
getTotalSupply(client)
|
|
259
|
+
]);
|
|
260
|
+
const stxPerStstx = await dataV3.read["get-stx-per-ststx-helper"]({
|
|
261
|
+
stxAmount: totalStx
|
|
262
|
+
});
|
|
263
|
+
return { stxPerStstx, ststxSupply, totalStx };
|
|
264
|
+
}
|
|
265
|
+
async function getTotalSupply(client) {
|
|
266
|
+
const token = getStstxToken(client);
|
|
267
|
+
return await token.read["get-total-supply"]({});
|
|
268
|
+
}
|
|
269
|
+
async function getWithdrawalInfo(client, nftId) {
|
|
270
|
+
const dataV1 = getDataCoreV1(client);
|
|
271
|
+
return await dataV1.read["get-withdrawals-by-nft"]({
|
|
272
|
+
nftId
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
async function getFees(client) {
|
|
276
|
+
const core = getCoreContract(client);
|
|
277
|
+
const [stackFee, unstackFee, withdrawIdleFee] = await Promise.all([
|
|
278
|
+
core.read["get-stack-fee"]({}),
|
|
279
|
+
core.read["get-unstack-fee"]({}),
|
|
280
|
+
core.read["get-withdraw-idle-fee"]({})
|
|
281
|
+
]);
|
|
282
|
+
return { stackFee, unstackFee, withdrawIdleFee };
|
|
283
|
+
}
|
|
284
|
+
async function getReserveBalance(client) {
|
|
285
|
+
const reserve = getReserveContract(client);
|
|
286
|
+
return await reserve.read["get-total-stx"]({});
|
|
287
|
+
}
|
|
288
|
+
async function getShutdownDeposits(client) {
|
|
289
|
+
const core = getCoreContract(client);
|
|
290
|
+
return await core.read["get-shutdown-deposits"]({});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/stackingdao/index.ts
|
|
294
|
+
function stackingDao() {
|
|
295
|
+
return (client) => ({
|
|
296
|
+
stackingDao: {
|
|
297
|
+
deposit: (params) => deposit(client, params),
|
|
298
|
+
initWithdraw: (params) => initWithdraw(client, params),
|
|
299
|
+
withdraw: (params) => withdraw(client, params),
|
|
300
|
+
withdrawIdle: (params) => withdrawIdle(client, params),
|
|
301
|
+
getStSTXBalance: (address) => getStSTXBalance(client, address),
|
|
302
|
+
getExchangeRate: () => getExchangeRate(client),
|
|
303
|
+
getTotalSupply: () => getTotalSupply(client),
|
|
304
|
+
getWithdrawalInfo: (nftId) => getWithdrawalInfo(client, nftId),
|
|
305
|
+
getFees: () => getFees(client),
|
|
306
|
+
getReserveBalance: () => getReserveBalance(client),
|
|
307
|
+
getShutdownDeposits: () => getShutdownDeposits(client)
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
export {
|
|
312
|
+
stackingDao,
|
|
313
|
+
TRAIT_CONTRACTS,
|
|
314
|
+
STACKINGDAO_CONTRACTS
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
//# debugId=2E26299092479C8C64756E2164756E21
|
|
318
|
+
//# sourceMappingURL=index.js.map
|