@permissionless-technologies/upd-sdk 0.1.0
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 +172 -0
- package/dist/chunk-4RBWWS2X.js +6616 -0
- package/dist/chunk-4RBWWS2X.js.map +1 -0
- package/dist/chunk-4VXNJTNQ.cjs +58 -0
- package/dist/chunk-4VXNJTNQ.cjs.map +1 -0
- package/dist/chunk-5NNXIJE4.js +16 -0
- package/dist/chunk-5NNXIJE4.js.map +1 -0
- package/dist/chunk-63FIKV36.js +49 -0
- package/dist/chunk-63FIKV36.js.map +1 -0
- package/dist/chunk-CZEDT3MS.cjs +62 -0
- package/dist/chunk-CZEDT3MS.cjs.map +1 -0
- package/dist/chunk-DF34ON56.cjs +18 -0
- package/dist/chunk-DF34ON56.cjs.map +1 -0
- package/dist/chunk-DJBU2OEB.js +57 -0
- package/dist/chunk-DJBU2OEB.js.map +1 -0
- package/dist/chunk-LNGWRYGY.js +3 -0
- package/dist/chunk-LNGWRYGY.js.map +1 -0
- package/dist/chunk-POBNO37G.cjs +4 -0
- package/dist/chunk-POBNO37G.cjs.map +1 -0
- package/dist/chunk-R64I3LAO.js +701 -0
- package/dist/chunk-R64I3LAO.js.map +1 -0
- package/dist/chunk-RIRT4JX6.js +1808 -0
- package/dist/chunk-RIRT4JX6.js.map +1 -0
- package/dist/chunk-WRPVPA7E.cjs +713 -0
- package/dist/chunk-WRPVPA7E.cjs.map +1 -0
- package/dist/chunk-ZDAHLZWC.cjs +1812 -0
- package/dist/chunk-ZDAHLZWC.cjs.map +1 -0
- package/dist/chunk-ZSWETUGH.cjs +6623 -0
- package/dist/chunk-ZSWETUGH.cjs.map +1 -0
- package/dist/constants-Bk2bGYfX.d.ts +64 -0
- package/dist/constants-BlOP_9dy.d.cts +64 -0
- package/dist/contracts/index.cjs +45 -0
- package/dist/contracts/index.cjs.map +1 -0
- package/dist/contracts/index.d.cts +6559 -0
- package/dist/contracts/index.d.ts +6559 -0
- package/dist/contracts/index.js +4 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/core/index.cjs +76 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +5 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/health-BUb4ItNt.d.ts +46 -0
- package/dist/health-DPxBqH7b.d.cts +46 -0
- package/dist/index-XNClksom.d.ts +415 -0
- package/dist/index-yRBqVOHV.d.cts +415 -0
- package/dist/index.cjs +138 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/oracle/index.cjs +30 -0
- package/dist/oracle/index.cjs.map +1 -0
- package/dist/oracle/index.d.cts +41 -0
- package/dist/oracle/index.d.ts +41 -0
- package/dist/oracle/index.js +5 -0
- package/dist/oracle/index.js.map +1 -0
- package/dist/react/index.cjs +383 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +339 -0
- package/dist/react/index.d.ts +339 -0
- package/dist/react/index.js +370 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types-DySv82My.d.cts +70 -0
- package/dist/types-DySv82My.d.ts +70 -0
- package/package.json +93 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { Address, Hash, Hex, WalletClient, PublicClient } from 'viem';
|
|
2
|
+
import { U as UPDClientConfig, C as CollateralInfo, a as StabilizerPosition, M as MintParams, B as BurnParams, S as SUPDInfo, b as StakeParams, c as UnstakeParams } from './types-DySv82My.cjs';
|
|
3
|
+
import { O as OracleClient } from './constants-BlOP_9dy.cjs';
|
|
4
|
+
import { S as SystemHealth } from './health-DPxBqH7b.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Deployment Configuration Loader
|
|
8
|
+
*
|
|
9
|
+
* Loads UPD contract addresses based on chain ID.
|
|
10
|
+
* JSON structure matches Forge deployment output exactly — no transformation needed.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface UPDDeploymentConfig {
|
|
14
|
+
chainId: number;
|
|
15
|
+
/** Proxy/final contract addresses — what integrators use */
|
|
16
|
+
contracts: {
|
|
17
|
+
UPDToken: Address;
|
|
18
|
+
PriceOracle: Address;
|
|
19
|
+
StabilizerNFT: Address;
|
|
20
|
+
OvercollateralizationReporter: Address;
|
|
21
|
+
InsuranceEscrow: Address;
|
|
22
|
+
BridgeEscrow?: Address;
|
|
23
|
+
sUPD?: Address;
|
|
24
|
+
};
|
|
25
|
+
/** UUPS implementation addresses — for upgrades only */
|
|
26
|
+
implementations: {
|
|
27
|
+
PriceOracle: Address;
|
|
28
|
+
StabilizerNFT: Address;
|
|
29
|
+
OvercollateralizationReporter: Address;
|
|
30
|
+
};
|
|
31
|
+
/** Externally deployed Solidity libraries */
|
|
32
|
+
libraries: {
|
|
33
|
+
LinkedListLib: Address;
|
|
34
|
+
CollateralMathLib: Address;
|
|
35
|
+
};
|
|
36
|
+
/** Clone template implementations (used by StabilizerNFT for escrow deployment) */
|
|
37
|
+
templates: {
|
|
38
|
+
StabilizerEscrow: Address;
|
|
39
|
+
PositionEscrow: Address;
|
|
40
|
+
};
|
|
41
|
+
/** Third-party / external addresses */
|
|
42
|
+
external: {
|
|
43
|
+
stETH: Address;
|
|
44
|
+
lido: Address;
|
|
45
|
+
oracleSigner: Address;
|
|
46
|
+
};
|
|
47
|
+
metadata: {
|
|
48
|
+
deployBlock: number;
|
|
49
|
+
deployTimestamp: number;
|
|
50
|
+
deployer: Address;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Get deployment config for a chain. Returns null if not found. */
|
|
54
|
+
declare function getDeployment(chainId: number): UPDDeploymentConfig | null;
|
|
55
|
+
/** Get deployment config or throw if not found. */
|
|
56
|
+
declare function getDeploymentOrThrow(chainId: number): UPDDeploymentConfig;
|
|
57
|
+
/** Check if a chain has a deployment. */
|
|
58
|
+
declare function hasDeployment(chainId: number): boolean;
|
|
59
|
+
/** Get all supported chain IDs. */
|
|
60
|
+
declare function getSupportedChainIds(): number[];
|
|
61
|
+
/** Get a specific contract address for a chain. */
|
|
62
|
+
declare function getContractAddress(chainId: number, contractName: keyof UPDDeploymentConfig['contracts']): Address | null;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* UPDClient — Main client for interacting with the UPD protocol.
|
|
66
|
+
*
|
|
67
|
+
* Read operations use publicClient only (no wallet needed).
|
|
68
|
+
* Write operations require a walletClient.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { createPublicClient, http } from 'viem'
|
|
73
|
+
* import { mainnet } from 'viem/chains'
|
|
74
|
+
* import { createUPDClient } from '@permissionless-technologies/upd-sdk'
|
|
75
|
+
*
|
|
76
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() })
|
|
77
|
+
* const client = createUPDClient({ publicClient, chainId: 1 })
|
|
78
|
+
*
|
|
79
|
+
* const balance = await client.getUPDBalance('0x...')
|
|
80
|
+
* const supply = await client.getTotalSupply()
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
declare class UPDClient {
|
|
85
|
+
readonly config: UPDClientConfig;
|
|
86
|
+
readonly deployment: UPDDeploymentConfig;
|
|
87
|
+
readonly oracle: OracleClient;
|
|
88
|
+
constructor(config: UPDClientConfig);
|
|
89
|
+
/** Get UPD token balance for an address. */
|
|
90
|
+
getUPDBalance(address: Address): Promise<bigint>;
|
|
91
|
+
/** Get total UPD supply. */
|
|
92
|
+
getTotalSupply(): Promise<bigint>;
|
|
93
|
+
/** Get system collateral info: total stETH collateral and total UPD supply. */
|
|
94
|
+
getCollateralInfo(): Promise<CollateralInfo>;
|
|
95
|
+
/** Get details for a specific stabilizer position. */
|
|
96
|
+
getStabilizerPosition(tokenId: bigint): Promise<StabilizerPosition>;
|
|
97
|
+
/**
|
|
98
|
+
* Mint UPD by sending ETH. Requires walletClient.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const attestation = createMockAttestation(2000n * 10n**18n)
|
|
103
|
+
* const hash = await client.mint({
|
|
104
|
+
* to: '0x...',
|
|
105
|
+
* ethAmount: parseEther('1'),
|
|
106
|
+
* priceAttestation: attestation,
|
|
107
|
+
* })
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
mint(params: MintParams): Promise<Hash>;
|
|
111
|
+
/**
|
|
112
|
+
* Burn UPD to receive stETH. Requires walletClient.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const attestation = createMockAttestation(2000n * 10n**18n)
|
|
117
|
+
* const hash = await client.burn({
|
|
118
|
+
* updAmount: parseUnits('2000', 18),
|
|
119
|
+
* priceAttestation: attestation,
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
burn(params: BurnParams): Promise<Hash>;
|
|
124
|
+
/** Get sUPD contract info: share value, APY, supply, liability. */
|
|
125
|
+
getSUPDInfo(): Promise<SUPDInfo>;
|
|
126
|
+
/** Stake UPD to receive sUPD shares. Requires walletClient. */
|
|
127
|
+
stakeUPD(params: StakeParams): Promise<Hash>;
|
|
128
|
+
/** Unstake sUPD shares to receive UPD. Requires walletClient. */
|
|
129
|
+
unstakeUPD(params: UnstakeParams): Promise<Hash>;
|
|
130
|
+
/**
|
|
131
|
+
* Mint UPD by sending ETH, automatically fetching a price attestation from the oracle.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const hash = await client.mintWithOracle({
|
|
136
|
+
* to: '0x...',
|
|
137
|
+
* ethAmount: parseEther('1'),
|
|
138
|
+
* })
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
mintWithOracle(params: {
|
|
142
|
+
to: Address;
|
|
143
|
+
ethAmount: bigint;
|
|
144
|
+
}): Promise<Hash>;
|
|
145
|
+
/**
|
|
146
|
+
* Burn UPD to receive stETH, automatically fetching a price attestation from the oracle.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const hash = await client.burnWithOracle({
|
|
151
|
+
* updAmount: parseUnits('2000', 18),
|
|
152
|
+
* })
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
burnWithOracle(params: {
|
|
156
|
+
updAmount: bigint;
|
|
157
|
+
}): Promise<Hash>;
|
|
158
|
+
/**
|
|
159
|
+
* Get system health metrics by combining on-chain collateral data with oracle price.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const health = await client.getSystemHealth()
|
|
164
|
+
* console.log(`System ratio: ${health.systemCollateralRatioBps} bps`)
|
|
165
|
+
* console.log(`Healthy: ${health.isHealthy}`)
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
getSystemHealth(): Promise<SystemHealth>;
|
|
169
|
+
/** Stake UPD, fetching oracle attestation automatically. */
|
|
170
|
+
stakeUPDWithOracle(params: {
|
|
171
|
+
updAmount: bigint;
|
|
172
|
+
}): Promise<Hash>;
|
|
173
|
+
/** Unstake sUPD, fetching oracle attestation automatically. */
|
|
174
|
+
unstakeUPDWithOracle(params: {
|
|
175
|
+
shares: bigint;
|
|
176
|
+
}): Promise<Hash>;
|
|
177
|
+
private _requireWallet;
|
|
178
|
+
private _toSolidityAttestation;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Create a UPD client instance.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* import { createPublicClient, http } from 'viem'
|
|
186
|
+
* import { mainnet } from 'viem/chains'
|
|
187
|
+
* import { createUPDClient } from '@permissionless-technologies/upd-sdk'
|
|
188
|
+
*
|
|
189
|
+
* const client = createUPDClient({
|
|
190
|
+
* publicClient: createPublicClient({ chain: mainnet, transport: http() }),
|
|
191
|
+
* chainId: 1,
|
|
192
|
+
* })
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
declare function createUPDClient(config: UPDClientConfig): UPDClient;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* UPD Quote Functions — Pure math for estimating mint/burn amounts.
|
|
199
|
+
*
|
|
200
|
+
* These functions require no blockchain calls. They mirror the Solidity
|
|
201
|
+
* CollateralMathLib logic so integrators can show users expected amounts
|
|
202
|
+
* before submitting a transaction.
|
|
203
|
+
*/
|
|
204
|
+
/**
|
|
205
|
+
* Estimate how much UPD a user will receive for a given ETH amount.
|
|
206
|
+
*
|
|
207
|
+
* @param ethAmount - ETH to deposit (in wei)
|
|
208
|
+
* @param ethUsdPrice - ETH/USD price (18 decimals, e.g. 2000e18 = $2000)
|
|
209
|
+
* @returns Expected UPD amount (18 decimals)
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const upd = quoteMintUPD(parseEther('1'), 2000n * 10n**18n)
|
|
214
|
+
* // → 2000000000000000000000n (2000 UPD)
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
declare function quoteMintUPD(ethAmount: bigint, ethUsdPrice: bigint): bigint;
|
|
218
|
+
/**
|
|
219
|
+
* Estimate how much stETH a user will receive for burning UPD.
|
|
220
|
+
*
|
|
221
|
+
* @param updAmount - UPD to burn (18 decimals)
|
|
222
|
+
* @param ethUsdPrice - ETH/USD price (18 decimals)
|
|
223
|
+
* @returns Expected stETH amount (in wei)
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* const stEth = quoteBurnUPD(parseUnits('2000', 18), 2000n * 10n**18n)
|
|
228
|
+
* // → 1000000000000000000n (1 stETH)
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare function quoteBurnUPD(updAmount: bigint, ethUsdPrice: bigint): bigint;
|
|
232
|
+
/**
|
|
233
|
+
* Calculate the stabilizer stETH needed for a given user ETH deposit.
|
|
234
|
+
*
|
|
235
|
+
* @param userEth - User's ETH amount (in wei)
|
|
236
|
+
* @param minCollateralRatioBps - Minimum collateral ratio in basis points (e.g. 12500 = 125%)
|
|
237
|
+
* @returns Stabilizer stETH required (in wei)
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* const needed = stabilizerStEthNeeded(parseEther('10'), 12500n)
|
|
242
|
+
* // → 2500000000000000000n (2.5 ETH worth of stETH at 125% ratio)
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare function stabilizerStEthNeeded(userEth: bigint, minCollateralRatioBps: bigint): bigint;
|
|
246
|
+
/**
|
|
247
|
+
* Calculate the collateralization ratio from stETH balance, price, and UPD liability.
|
|
248
|
+
*
|
|
249
|
+
* @param stEthBalance - stETH held in escrow (in wei)
|
|
250
|
+
* @param ethUsdPrice - ETH/USD price (18 decimals)
|
|
251
|
+
* @param backedUPDAmount - UPD liability (18 decimals)
|
|
252
|
+
* @returns Collateralization ratio in basis points (e.g. 12500 = 125%)
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* const ratio = collateralizationRatio(parseEther('1.25'), 2000n * 10n**18n, parseUnits('2000', 18))
|
|
257
|
+
* // → 12500n (125%)
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
/**
|
|
261
|
+
* Estimate sUPD shares received for staking UPD.
|
|
262
|
+
*
|
|
263
|
+
* Mirrors sUPD.sol line 136: shares = updAmount * SHARE_PRECISION / shareValue
|
|
264
|
+
*
|
|
265
|
+
* @param updAmount - UPD to stake (18 decimals)
|
|
266
|
+
* @param shareValue - Current sUPD share value (18 decimals, e.g. 1.05e18 = $1.05/share)
|
|
267
|
+
* @returns Expected sUPD shares (18 decimals)
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* const shares = quoteStakeUPD(parseUnits('1000', 18), 1050000000000000000n)
|
|
272
|
+
* // → ~952.38e18 shares (1000 UPD at $1.05/share)
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
declare function quoteStakeUPD(updAmount: bigint, shareValue: bigint): bigint;
|
|
276
|
+
/**
|
|
277
|
+
* Estimate UPD received for unstaking sUPD shares.
|
|
278
|
+
*
|
|
279
|
+
* Mirrors sUPD.sol line 173: updOwed = shares * shareValue / SHARE_PRECISION
|
|
280
|
+
*
|
|
281
|
+
* @param shares - sUPD shares to unstake (18 decimals)
|
|
282
|
+
* @param shareValue - Current sUPD share value (18 decimals)
|
|
283
|
+
* @returns Expected UPD amount (18 decimals)
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```ts
|
|
287
|
+
* const upd = quoteUnstakeUPD(parseUnits('952.38', 18), 1050000000000000000n)
|
|
288
|
+
* // → ~1000e18 UPD
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
declare function quoteUnstakeUPD(shares: bigint, shareValue: bigint): bigint;
|
|
292
|
+
declare function collateralizationRatio(stEthBalance: bigint, ethUsdPrice: bigint, backedUPDAmount: bigint): bigint;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* EIP-3009 Transfer Authorization helpers for UPD.
|
|
296
|
+
*
|
|
297
|
+
* Pure signing functions — no blockchain calls. Generate off-chain EIP-712
|
|
298
|
+
* signatures that can be submitted by any relayer or facilitator (e.g., x402).
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* import { signTransferAuthorization } from '@permissionless-technologies/upd-sdk'
|
|
303
|
+
*
|
|
304
|
+
* const auth = await signTransferAuthorization({
|
|
305
|
+
* walletClient,
|
|
306
|
+
* tokenAddress: '0x...',
|
|
307
|
+
* from: '0xAlice...',
|
|
308
|
+
* to: '0xBob...',
|
|
309
|
+
* value: parseUnits('100', 18),
|
|
310
|
+
* validAfter: 0n,
|
|
311
|
+
* validBefore: BigInt(Math.floor(Date.now() / 1000) + 3600),
|
|
312
|
+
* })
|
|
313
|
+
*
|
|
314
|
+
* // Submit via relayer, x402 facilitator, or directly
|
|
315
|
+
* await publicClient.writeContract({
|
|
316
|
+
* address: tokenAddress,
|
|
317
|
+
* abi: UPD_TOKEN_ABI,
|
|
318
|
+
* functionName: 'transferWithAuthorization',
|
|
319
|
+
* args: [auth.from, auth.to, auth.value, auth.validAfter, auth.validBefore, auth.nonce, auth.v, auth.r, auth.s],
|
|
320
|
+
* })
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
interface TransferAuthorizationParams {
|
|
325
|
+
walletClient: WalletClient;
|
|
326
|
+
tokenAddress: Address;
|
|
327
|
+
from: Address;
|
|
328
|
+
to: Address;
|
|
329
|
+
value: bigint;
|
|
330
|
+
validAfter?: bigint;
|
|
331
|
+
validBefore?: bigint;
|
|
332
|
+
nonce?: Hex;
|
|
333
|
+
}
|
|
334
|
+
interface TransferAuthorization {
|
|
335
|
+
from: Address;
|
|
336
|
+
to: Address;
|
|
337
|
+
value: bigint;
|
|
338
|
+
validAfter: bigint;
|
|
339
|
+
validBefore: bigint;
|
|
340
|
+
nonce: Hex;
|
|
341
|
+
v: number;
|
|
342
|
+
r: Hex;
|
|
343
|
+
s: Hex;
|
|
344
|
+
}
|
|
345
|
+
interface CancelAuthorizationParams {
|
|
346
|
+
walletClient: WalletClient;
|
|
347
|
+
tokenAddress: Address;
|
|
348
|
+
authorizer: Address;
|
|
349
|
+
nonce: Hex;
|
|
350
|
+
}
|
|
351
|
+
interface CancelAuthorization {
|
|
352
|
+
authorizer: Address;
|
|
353
|
+
nonce: Hex;
|
|
354
|
+
v: number;
|
|
355
|
+
r: Hex;
|
|
356
|
+
s: Hex;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Sign a TransferWithAuthorization (EIP-3009).
|
|
360
|
+
*
|
|
361
|
+
* Generates a random nonce if none is provided. Default time window: now → +1 hour.
|
|
362
|
+
* The returned object contains all arguments needed for `transferWithAuthorization()`.
|
|
363
|
+
*/
|
|
364
|
+
declare function signTransferAuthorization(params: TransferAuthorizationParams, tokenName?: string): Promise<TransferAuthorization>;
|
|
365
|
+
/**
|
|
366
|
+
* Sign a ReceiveWithAuthorization (EIP-3009).
|
|
367
|
+
*
|
|
368
|
+
* Same as transferWithAuthorization but the resulting signature can only be
|
|
369
|
+
* submitted by the `to` address (prevents front-running).
|
|
370
|
+
*/
|
|
371
|
+
declare function signReceiveAuthorization(params: TransferAuthorizationParams, tokenName?: string): Promise<TransferAuthorization>;
|
|
372
|
+
/**
|
|
373
|
+
* Sign a CancelAuthorization (EIP-3009).
|
|
374
|
+
*
|
|
375
|
+
* Cancels a previously signed authorization before it's been used.
|
|
376
|
+
*/
|
|
377
|
+
declare function signCancelAuthorization(params: CancelAuthorizationParams, tokenName?: string): Promise<CancelAuthorization>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* UPD Deployment Verification — Check on-chain state matches deployment config.
|
|
381
|
+
*
|
|
382
|
+
* Verifies:
|
|
383
|
+
* 1. Bytecode exists at all deployed addresses
|
|
384
|
+
* 2. UUPS proxy implementation slots point to correct implementations
|
|
385
|
+
* 3. Critical storage values are initialized correctly
|
|
386
|
+
* 4. Access control roles are granted properly
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
interface VerificationCheck {
|
|
390
|
+
name: string;
|
|
391
|
+
passed: boolean;
|
|
392
|
+
expected?: string;
|
|
393
|
+
actual?: string;
|
|
394
|
+
}
|
|
395
|
+
interface VerificationResult {
|
|
396
|
+
chainId: number;
|
|
397
|
+
checks: VerificationCheck[];
|
|
398
|
+
passed: number;
|
|
399
|
+
failed: number;
|
|
400
|
+
allPassed: boolean;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Verify that a UPD deployment matches its on-chain state.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* const result = await verifyDeployment(publicClient, deployment)
|
|
408
|
+
* if (!result.allPassed) {
|
|
409
|
+
* console.error('Deployment verification failed:', result.checks.filter(c => !c.passed))
|
|
410
|
+
* }
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
declare function verifyDeployment(publicClient: PublicClient, deployment: UPDDeploymentConfig): Promise<VerificationResult>;
|
|
414
|
+
|
|
415
|
+
export { type CancelAuthorization as C, type TransferAuthorization as T, UPDClient as U, type VerificationCheck as V, type CancelAuthorizationParams as a, type TransferAuthorizationParams as b, type UPDDeploymentConfig as c, type VerificationResult as d, collateralizationRatio as e, createUPDClient as f, getContractAddress as g, getDeployment as h, getDeploymentOrThrow as i, getSupportedChainIds as j, hasDeployment as k, quoteMintUPD as l, quoteStakeUPD as m, quoteUnstakeUPD as n, signReceiveAuthorization as o, signTransferAuthorization as p, quoteBurnUPD as q, stabilizerStEthNeeded as r, signCancelAuthorization as s, verifyDeployment as v };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWRPVPA7E_cjs = require('./chunk-WRPVPA7E.cjs');
|
|
4
|
+
require('./chunk-POBNO37G.cjs');
|
|
5
|
+
var chunkDF34ON56_cjs = require('./chunk-DF34ON56.cjs');
|
|
6
|
+
var chunkZDAHLZWC_cjs = require('./chunk-ZDAHLZWC.cjs');
|
|
7
|
+
var chunk4VXNJTNQ_cjs = require('./chunk-4VXNJTNQ.cjs');
|
|
8
|
+
var chunkZSWETUGH_cjs = require('./chunk-ZSWETUGH.cjs');
|
|
9
|
+
var chunkCZEDT3MS_cjs = require('./chunk-CZEDT3MS.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "UPDClient", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkWRPVPA7E_cjs.UPDClient; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createUPDClient", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkWRPVPA7E_cjs.createUPDClient; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "getContractAddress", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkWRPVPA7E_cjs.getContractAddress; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "getDeployment", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkWRPVPA7E_cjs.getDeployment; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "getDeploymentOrThrow", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunkWRPVPA7E_cjs.getDeploymentOrThrow; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "getSupportedChainIds", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return chunkWRPVPA7E_cjs.getSupportedChainIds; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "hasDeployment", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return chunkWRPVPA7E_cjs.hasDeployment; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "signCancelAuthorization", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return chunkWRPVPA7E_cjs.signCancelAuthorization; }
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "signReceiveAuthorization", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return chunkWRPVPA7E_cjs.signReceiveAuthorization; }
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "signTransferAuthorization", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () { return chunkWRPVPA7E_cjs.signTransferAuthorization; }
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "verifyDeployment", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return chunkWRPVPA7E_cjs.verifyDeployment; }
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "createMockAttestation", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return chunkDF34ON56_cjs.createMockAttestation; }
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "BRIDGE_ESCROW_ABI", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return chunkZDAHLZWC_cjs.BRIDGE_ESCROW_ABI; }
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, "INSURANCE_ESCROW_ABI", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return chunkZDAHLZWC_cjs.INSURANCE_ESCROW_ABI; }
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "PRICE_ORACLE_ABI", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return chunkZDAHLZWC_cjs.PRICE_ORACLE_ABI; }
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "DEFAULT_MIN_RATIO_BPS", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () { return chunk4VXNJTNQ_cjs.DEFAULT_MIN_RATIO_BPS; }
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "collateralizationRatio", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return chunk4VXNJTNQ_cjs.collateralizationRatio; }
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "computeSystemHealth", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return chunk4VXNJTNQ_cjs.computeSystemHealth; }
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "quoteBurnUPD", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () { return chunk4VXNJTNQ_cjs.quoteBurnUPD; }
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "quoteMintUPD", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () { return chunk4VXNJTNQ_cjs.quoteMintUPD; }
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "quoteStakeUPD", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () { return chunk4VXNJTNQ_cjs.quoteStakeUPD; }
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "quoteUnstakeUPD", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () { return chunk4VXNJTNQ_cjs.quoteUnstakeUPD; }
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "stabilizerStEthNeeded", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () { return chunk4VXNJTNQ_cjs.stabilizerStEthNeeded; }
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "OVERCOLLATERALIZATION_REPORTER_ABI", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () { return chunkZSWETUGH_cjs.OVERCOLLATERALIZATION_REPORTER_ABI; }
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "POSITION_ESCROW_ABI", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () { return chunkZSWETUGH_cjs.POSITION_ESCROW_ABI; }
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "STABILIZER_ESCROW_ABI", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () { return chunkZSWETUGH_cjs.STABILIZER_ESCROW_ABI; }
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "STABILIZER_NFT_ABI", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () { return chunkZSWETUGH_cjs.STABILIZER_NFT_ABI; }
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, "SUPD_ABI", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () { return chunkZSWETUGH_cjs.SUPD_ABI; }
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "UPD_TOKEN_ABI", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () { return chunkZSWETUGH_cjs.UPD_TOKEN_ABI; }
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(exports, "ETH_USD_ASSET_PAIR", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () { return chunkCZEDT3MS_cjs.ETH_USD_ASSET_PAIR; }
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, "createOracleClient", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () { return chunkCZEDT3MS_cjs.createOracleClient; }
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=index.cjs.map
|
|
138
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { C as CancelAuthorization, a as CancelAuthorizationParams, T as TransferAuthorization, b as TransferAuthorizationParams, U as UPDClient, c as UPDDeploymentConfig, V as VerificationCheck, d as VerificationResult, e as collateralizationRatio, f as createUPDClient, g as getContractAddress, h as getDeployment, i as getDeploymentOrThrow, j as getSupportedChainIds, k as hasDeployment, q as quoteBurnUPD, l as quoteMintUPD, m as quoteStakeUPD, n as quoteUnstakeUPD, s as signCancelAuthorization, o as signReceiveAuthorization, p as signTransferAuthorization, r as stabilizerStEthNeeded, v as verifyDeployment } from './index-yRBqVOHV.cjs';
|
|
2
|
+
export { B as BurnParams, C as CollateralInfo, M as MintParams, P as PriceAttestationQuery, S as SUPDInfo, a as StabilizerPosition, b as StakeParams, T as TransactionHash, U as UPDClientConfig, c as UnstakeParams } from './types-DySv82My.cjs';
|
|
3
|
+
export { E as ETH_USD_ASSET_PAIR, O as OracleClient, a as OracleClientConfig, c as createMockAttestation } from './constants-BlOP_9dy.cjs';
|
|
4
|
+
export { D as DEFAULT_MIN_RATIO_BPS, S as SystemHealth, c as computeSystemHealth } from './health-DPxBqH7b.cjs';
|
|
5
|
+
export { createOracleClient } from './oracle/index.cjs';
|
|
6
|
+
export { BRIDGE_ESCROW_ABI, INSURANCE_ESCROW_ABI, OVERCOLLATERALIZATION_REPORTER_ABI, POSITION_ESCROW_ABI, PRICE_ORACLE_ABI, STABILIZER_ESCROW_ABI, STABILIZER_NFT_ABI, SUPD_ABI, UPD_TOKEN_ABI } from './contracts/index.cjs';
|
|
7
|
+
import 'viem';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { C as CancelAuthorization, a as CancelAuthorizationParams, T as TransferAuthorization, b as TransferAuthorizationParams, U as UPDClient, c as UPDDeploymentConfig, V as VerificationCheck, d as VerificationResult, e as collateralizationRatio, f as createUPDClient, g as getContractAddress, h as getDeployment, i as getDeploymentOrThrow, j as getSupportedChainIds, k as hasDeployment, q as quoteBurnUPD, l as quoteMintUPD, m as quoteStakeUPD, n as quoteUnstakeUPD, s as signCancelAuthorization, o as signReceiveAuthorization, p as signTransferAuthorization, r as stabilizerStEthNeeded, v as verifyDeployment } from './index-XNClksom.js';
|
|
2
|
+
export { B as BurnParams, C as CollateralInfo, M as MintParams, P as PriceAttestationQuery, S as SUPDInfo, a as StabilizerPosition, b as StakeParams, T as TransactionHash, U as UPDClientConfig, c as UnstakeParams } from './types-DySv82My.js';
|
|
3
|
+
export { E as ETH_USD_ASSET_PAIR, O as OracleClient, a as OracleClientConfig, c as createMockAttestation } from './constants-Bk2bGYfX.js';
|
|
4
|
+
export { D as DEFAULT_MIN_RATIO_BPS, S as SystemHealth, c as computeSystemHealth } from './health-BUb4ItNt.js';
|
|
5
|
+
export { createOracleClient } from './oracle/index.js';
|
|
6
|
+
export { BRIDGE_ESCROW_ABI, INSURANCE_ESCROW_ABI, OVERCOLLATERALIZATION_REPORTER_ABI, POSITION_ESCROW_ABI, PRICE_ORACLE_ABI, STABILIZER_ESCROW_ABI, STABILIZER_NFT_ABI, SUPD_ABI, UPD_TOKEN_ABI } from './contracts/index.js';
|
|
7
|
+
import 'viem';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { UPDClient, createUPDClient, getContractAddress, getDeployment, getDeploymentOrThrow, getSupportedChainIds, hasDeployment, signCancelAuthorization, signReceiveAuthorization, signTransferAuthorization, verifyDeployment } from './chunk-R64I3LAO.js';
|
|
2
|
+
import './chunk-LNGWRYGY.js';
|
|
3
|
+
export { createMockAttestation } from './chunk-5NNXIJE4.js';
|
|
4
|
+
export { BRIDGE_ESCROW_ABI, INSURANCE_ESCROW_ABI, PRICE_ORACLE_ABI } from './chunk-RIRT4JX6.js';
|
|
5
|
+
export { DEFAULT_MIN_RATIO_BPS, collateralizationRatio, computeSystemHealth, quoteBurnUPD, quoteMintUPD, quoteStakeUPD, quoteUnstakeUPD, stabilizerStEthNeeded } from './chunk-63FIKV36.js';
|
|
6
|
+
export { OVERCOLLATERALIZATION_REPORTER_ABI, POSITION_ESCROW_ABI, STABILIZER_ESCROW_ABI, STABILIZER_NFT_ABI, SUPD_ABI, UPD_TOKEN_ABI } from './chunk-4RBWWS2X.js';
|
|
7
|
+
export { ETH_USD_ASSET_PAIR, createOracleClient } from './chunk-DJBU2OEB.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../chunk-POBNO37G.cjs');
|
|
4
|
+
var chunkDF34ON56_cjs = require('../chunk-DF34ON56.cjs');
|
|
5
|
+
var chunkCZEDT3MS_cjs = require('../chunk-CZEDT3MS.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "createMockAttestation", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkDF34ON56_cjs.createMockAttestation; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "DEFAULT_ORACLE_URL", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkCZEDT3MS_cjs.DEFAULT_ORACLE_URL; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_TIMEOUT", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkCZEDT3MS_cjs.DEFAULT_TIMEOUT; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "ETH_USD_ASSET_PAIR", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkCZEDT3MS_cjs.ETH_USD_ASSET_PAIR; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "createOracleClient", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkCZEDT3MS_cjs.createOracleClient; }
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
30
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { a as OracleClientConfig, O as OracleClient } from '../constants-BlOP_9dy.cjs';
|
|
2
|
+
export { D as DEFAULT_ORACLE_URL, b as DEFAULT_TIMEOUT, E as ETH_USD_ASSET_PAIR, d as OracleResponse, c as createMockAttestation } from '../constants-BlOP_9dy.cjs';
|
|
3
|
+
import '../types-DySv82My.cjs';
|
|
4
|
+
import 'viem';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Oracle HTTP Client — Fetches signed price attestations from an oracle service.
|
|
8
|
+
*
|
|
9
|
+
* The oracle service returns signed ETH/USD prices in the exact format
|
|
10
|
+
* that PriceOracle.sol expects. The client deserializes the response
|
|
11
|
+
* into a PriceAttestationQuery that can be passed directly to
|
|
12
|
+
* UPDClient.mint() or UPDClient.burn().
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { createOracleClient } from '@permissionless-technologies/upd-sdk/oracle'
|
|
17
|
+
*
|
|
18
|
+
* const oracle = createOracleClient()
|
|
19
|
+
* const attestation = await oracle.getEthUsdAttestation()
|
|
20
|
+
*
|
|
21
|
+
* // Pass directly to mint
|
|
22
|
+
* await updClient.mint({ to: '0x...', ethAmount: parseEther('1'), priceAttestation: attestation })
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Custom oracle URL (e.g. local development)
|
|
28
|
+
* const oracle = createOracleClient({ oracleUrl: 'http://localhost:3000' })
|
|
29
|
+
* const { price } = await oracle.getEthUsdPrice()
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create an oracle client that fetches signed price attestations.
|
|
35
|
+
*
|
|
36
|
+
* @param config - Optional configuration (URL, timeout, custom fetch)
|
|
37
|
+
* @returns An OracleClient instance
|
|
38
|
+
*/
|
|
39
|
+
declare function createOracleClient(config?: OracleClientConfig): OracleClient;
|
|
40
|
+
|
|
41
|
+
export { OracleClient, OracleClientConfig, createOracleClient };
|