@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.
Files changed (68) hide show
  1. package/README.md +172 -0
  2. package/dist/chunk-4RBWWS2X.js +6616 -0
  3. package/dist/chunk-4RBWWS2X.js.map +1 -0
  4. package/dist/chunk-4VXNJTNQ.cjs +58 -0
  5. package/dist/chunk-4VXNJTNQ.cjs.map +1 -0
  6. package/dist/chunk-5NNXIJE4.js +16 -0
  7. package/dist/chunk-5NNXIJE4.js.map +1 -0
  8. package/dist/chunk-63FIKV36.js +49 -0
  9. package/dist/chunk-63FIKV36.js.map +1 -0
  10. package/dist/chunk-CZEDT3MS.cjs +62 -0
  11. package/dist/chunk-CZEDT3MS.cjs.map +1 -0
  12. package/dist/chunk-DF34ON56.cjs +18 -0
  13. package/dist/chunk-DF34ON56.cjs.map +1 -0
  14. package/dist/chunk-DJBU2OEB.js +57 -0
  15. package/dist/chunk-DJBU2OEB.js.map +1 -0
  16. package/dist/chunk-LNGWRYGY.js +3 -0
  17. package/dist/chunk-LNGWRYGY.js.map +1 -0
  18. package/dist/chunk-POBNO37G.cjs +4 -0
  19. package/dist/chunk-POBNO37G.cjs.map +1 -0
  20. package/dist/chunk-R64I3LAO.js +701 -0
  21. package/dist/chunk-R64I3LAO.js.map +1 -0
  22. package/dist/chunk-RIRT4JX6.js +1808 -0
  23. package/dist/chunk-RIRT4JX6.js.map +1 -0
  24. package/dist/chunk-WRPVPA7E.cjs +713 -0
  25. package/dist/chunk-WRPVPA7E.cjs.map +1 -0
  26. package/dist/chunk-ZDAHLZWC.cjs +1812 -0
  27. package/dist/chunk-ZDAHLZWC.cjs.map +1 -0
  28. package/dist/chunk-ZSWETUGH.cjs +6623 -0
  29. package/dist/chunk-ZSWETUGH.cjs.map +1 -0
  30. package/dist/constants-Bk2bGYfX.d.ts +64 -0
  31. package/dist/constants-BlOP_9dy.d.cts +64 -0
  32. package/dist/contracts/index.cjs +45 -0
  33. package/dist/contracts/index.cjs.map +1 -0
  34. package/dist/contracts/index.d.cts +6559 -0
  35. package/dist/contracts/index.d.ts +6559 -0
  36. package/dist/contracts/index.js +4 -0
  37. package/dist/contracts/index.js.map +1 -0
  38. package/dist/core/index.cjs +76 -0
  39. package/dist/core/index.cjs.map +1 -0
  40. package/dist/core/index.d.cts +5 -0
  41. package/dist/core/index.d.ts +5 -0
  42. package/dist/core/index.js +7 -0
  43. package/dist/core/index.js.map +1 -0
  44. package/dist/health-BUb4ItNt.d.ts +46 -0
  45. package/dist/health-DPxBqH7b.d.cts +46 -0
  46. package/dist/index-XNClksom.d.ts +415 -0
  47. package/dist/index-yRBqVOHV.d.cts +415 -0
  48. package/dist/index.cjs +138 -0
  49. package/dist/index.cjs.map +1 -0
  50. package/dist/index.d.cts +7 -0
  51. package/dist/index.d.ts +7 -0
  52. package/dist/index.js +9 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/oracle/index.cjs +30 -0
  55. package/dist/oracle/index.cjs.map +1 -0
  56. package/dist/oracle/index.d.cts +41 -0
  57. package/dist/oracle/index.d.ts +41 -0
  58. package/dist/oracle/index.js +5 -0
  59. package/dist/oracle/index.js.map +1 -0
  60. package/dist/react/index.cjs +383 -0
  61. package/dist/react/index.cjs.map +1 -0
  62. package/dist/react/index.d.cts +339 -0
  63. package/dist/react/index.d.ts +339 -0
  64. package/dist/react/index.js +370 -0
  65. package/dist/react/index.js.map +1 -0
  66. package/dist/types-DySv82My.d.cts +70 -0
  67. package/dist/types-DySv82My.d.ts +70 -0
  68. package/package.json +93 -0
@@ -0,0 +1,4 @@
1
+ export { BRIDGE_ESCROW_ABI, INSURANCE_ESCROW_ABI, PRICE_ORACLE_ABI } from '../chunk-RIRT4JX6.js';
2
+ export { OVERCOLLATERALIZATION_REPORTER_ABI, POSITION_ESCROW_ABI, STABILIZER_ESCROW_ABI, STABILIZER_NFT_ABI, SUPD_ABI, UPD_TOKEN_ABI } from '../chunk-4RBWWS2X.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var chunkWRPVPA7E_cjs = require('../chunk-WRPVPA7E.cjs');
4
+ var chunkDF34ON56_cjs = require('../chunk-DF34ON56.cjs');
5
+ var chunk4VXNJTNQ_cjs = require('../chunk-4VXNJTNQ.cjs');
6
+ require('../chunk-ZSWETUGH.cjs');
7
+ var chunkCZEDT3MS_cjs = require('../chunk-CZEDT3MS.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "UPDClient", {
12
+ enumerable: true,
13
+ get: function () { return chunkWRPVPA7E_cjs.UPDClient; }
14
+ });
15
+ Object.defineProperty(exports, "createUPDClient", {
16
+ enumerable: true,
17
+ get: function () { return chunkWRPVPA7E_cjs.createUPDClient; }
18
+ });
19
+ Object.defineProperty(exports, "signCancelAuthorization", {
20
+ enumerable: true,
21
+ get: function () { return chunkWRPVPA7E_cjs.signCancelAuthorization; }
22
+ });
23
+ Object.defineProperty(exports, "signReceiveAuthorization", {
24
+ enumerable: true,
25
+ get: function () { return chunkWRPVPA7E_cjs.signReceiveAuthorization; }
26
+ });
27
+ Object.defineProperty(exports, "signTransferAuthorization", {
28
+ enumerable: true,
29
+ get: function () { return chunkWRPVPA7E_cjs.signTransferAuthorization; }
30
+ });
31
+ Object.defineProperty(exports, "verifyDeployment", {
32
+ enumerable: true,
33
+ get: function () { return chunkWRPVPA7E_cjs.verifyDeployment; }
34
+ });
35
+ Object.defineProperty(exports, "createMockAttestation", {
36
+ enumerable: true,
37
+ get: function () { return chunkDF34ON56_cjs.createMockAttestation; }
38
+ });
39
+ Object.defineProperty(exports, "DEFAULT_MIN_RATIO_BPS", {
40
+ enumerable: true,
41
+ get: function () { return chunk4VXNJTNQ_cjs.DEFAULT_MIN_RATIO_BPS; }
42
+ });
43
+ Object.defineProperty(exports, "collateralizationRatio", {
44
+ enumerable: true,
45
+ get: function () { return chunk4VXNJTNQ_cjs.collateralizationRatio; }
46
+ });
47
+ Object.defineProperty(exports, "computeSystemHealth", {
48
+ enumerable: true,
49
+ get: function () { return chunk4VXNJTNQ_cjs.computeSystemHealth; }
50
+ });
51
+ Object.defineProperty(exports, "quoteBurnUPD", {
52
+ enumerable: true,
53
+ get: function () { return chunk4VXNJTNQ_cjs.quoteBurnUPD; }
54
+ });
55
+ Object.defineProperty(exports, "quoteMintUPD", {
56
+ enumerable: true,
57
+ get: function () { return chunk4VXNJTNQ_cjs.quoteMintUPD; }
58
+ });
59
+ Object.defineProperty(exports, "quoteStakeUPD", {
60
+ enumerable: true,
61
+ get: function () { return chunk4VXNJTNQ_cjs.quoteStakeUPD; }
62
+ });
63
+ Object.defineProperty(exports, "quoteUnstakeUPD", {
64
+ enumerable: true,
65
+ get: function () { return chunk4VXNJTNQ_cjs.quoteUnstakeUPD; }
66
+ });
67
+ Object.defineProperty(exports, "stabilizerStEthNeeded", {
68
+ enumerable: true,
69
+ get: function () { return chunk4VXNJTNQ_cjs.stabilizerStEthNeeded; }
70
+ });
71
+ Object.defineProperty(exports, "ETH_USD_ASSET_PAIR", {
72
+ enumerable: true,
73
+ get: function () { return chunkCZEDT3MS_cjs.ETH_USD_ASSET_PAIR; }
74
+ });
75
+ //# sourceMappingURL=index.cjs.map
76
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,5 @@
1
+ export { C as CancelAuthorization, a as CancelAuthorizationParams, T as TransferAuthorization, b as TransferAuthorizationParams, U as UPDClient, V as VerificationCheck, d as VerificationResult, e as collateralizationRatio, f as createUPDClient, 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, 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
+ import 'viem';
@@ -0,0 +1,5 @@
1
+ export { C as CancelAuthorization, a as CancelAuthorizationParams, T as TransferAuthorization, b as TransferAuthorizationParams, U as UPDClient, V as VerificationCheck, d as VerificationResult, e as collateralizationRatio, f as createUPDClient, 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, 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
+ import 'viem';
@@ -0,0 +1,7 @@
1
+ export { UPDClient, createUPDClient, signCancelAuthorization, signReceiveAuthorization, signTransferAuthorization, verifyDeployment } from '../chunk-R64I3LAO.js';
2
+ export { createMockAttestation } from '../chunk-5NNXIJE4.js';
3
+ export { DEFAULT_MIN_RATIO_BPS, collateralizationRatio, computeSystemHealth, quoteBurnUPD, quoteMintUPD, quoteStakeUPD, quoteUnstakeUPD, stabilizerStEthNeeded } from '../chunk-63FIKV36.js';
4
+ import '../chunk-4RBWWS2X.js';
5
+ export { ETH_USD_ASSET_PAIR } from '../chunk-DJBU2OEB.js';
6
+ //# sourceMappingURL=index.js.map
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,46 @@
1
+ import { C as CollateralInfo } from './types-DySv82My.js';
2
+
3
+ /**
4
+ * System Health — Pure functions for computing UPD system health metrics.
5
+ *
6
+ * These functions take pre-fetched data (from UPDClient or React hooks) and
7
+ * compute derived health metrics. No blockchain calls — composable with
8
+ * any data source.
9
+ */
10
+
11
+ /** Default minimum system collateral ratio: 125% (12500 bps). */
12
+ declare const DEFAULT_MIN_RATIO_BPS = 12500n;
13
+ interface SystemHealth {
14
+ /** System-wide collateralization ratio in basis points (e.g. 12500 = 125%). */
15
+ systemCollateralRatioBps: bigint;
16
+ /** Whether the system is at or above the minimum collateral threshold. */
17
+ isHealthy: boolean;
18
+ /** USD value of total stETH collateral (18 decimals). */
19
+ collateralValueUsd: bigint;
20
+ /** Total UPD supply (18 decimals). */
21
+ totalUPDSupply: bigint;
22
+ /** Overcollateralization buffer in USD (collateral - supply). Can be negative. */
23
+ bufferUsd: bigint;
24
+ }
25
+ /**
26
+ * Compute system health from collateral info and current ETH/USD price.
27
+ *
28
+ * @param collateral - Total stETH collateral and UPD supply (from getCollateralInfo)
29
+ * @param ethUsdPrice - Current ETH/USD price in 18 decimals
30
+ * @param minRatioBps - Minimum healthy ratio in basis points (default: 12500 = 125%)
31
+ * @returns Computed system health metrics
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const info = await client.getCollateralInfo()
36
+ * const { price } = await oracle.getEthUsdPrice()
37
+ * const health = computeSystemHealth(info, price)
38
+ *
39
+ * if (!health.isHealthy) {
40
+ * console.warn(`System undercollateralized: ${health.systemCollateralRatioBps} bps`)
41
+ * }
42
+ * ```
43
+ */
44
+ declare function computeSystemHealth(collateral: CollateralInfo, ethUsdPrice: bigint, minRatioBps?: bigint): SystemHealth;
45
+
46
+ export { DEFAULT_MIN_RATIO_BPS as D, type SystemHealth as S, computeSystemHealth as c };
@@ -0,0 +1,46 @@
1
+ import { C as CollateralInfo } from './types-DySv82My.cjs';
2
+
3
+ /**
4
+ * System Health — Pure functions for computing UPD system health metrics.
5
+ *
6
+ * These functions take pre-fetched data (from UPDClient or React hooks) and
7
+ * compute derived health metrics. No blockchain calls — composable with
8
+ * any data source.
9
+ */
10
+
11
+ /** Default minimum system collateral ratio: 125% (12500 bps). */
12
+ declare const DEFAULT_MIN_RATIO_BPS = 12500n;
13
+ interface SystemHealth {
14
+ /** System-wide collateralization ratio in basis points (e.g. 12500 = 125%). */
15
+ systemCollateralRatioBps: bigint;
16
+ /** Whether the system is at or above the minimum collateral threshold. */
17
+ isHealthy: boolean;
18
+ /** USD value of total stETH collateral (18 decimals). */
19
+ collateralValueUsd: bigint;
20
+ /** Total UPD supply (18 decimals). */
21
+ totalUPDSupply: bigint;
22
+ /** Overcollateralization buffer in USD (collateral - supply). Can be negative. */
23
+ bufferUsd: bigint;
24
+ }
25
+ /**
26
+ * Compute system health from collateral info and current ETH/USD price.
27
+ *
28
+ * @param collateral - Total stETH collateral and UPD supply (from getCollateralInfo)
29
+ * @param ethUsdPrice - Current ETH/USD price in 18 decimals
30
+ * @param minRatioBps - Minimum healthy ratio in basis points (default: 12500 = 125%)
31
+ * @returns Computed system health metrics
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const info = await client.getCollateralInfo()
36
+ * const { price } = await oracle.getEthUsdPrice()
37
+ * const health = computeSystemHealth(info, price)
38
+ *
39
+ * if (!health.isHealthy) {
40
+ * console.warn(`System undercollateralized: ${health.systemCollateralRatioBps} bps`)
41
+ * }
42
+ * ```
43
+ */
44
+ declare function computeSystemHealth(collateral: CollateralInfo, ethUsdPrice: bigint, minRatioBps?: bigint): SystemHealth;
45
+
46
+ export { DEFAULT_MIN_RATIO_BPS as D, type SystemHealth as S, computeSystemHealth as c };
@@ -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.js';
3
+ import { O as OracleClient } from './constants-Bk2bGYfX.js';
4
+ import { S as SystemHealth } from './health-BUb4ItNt.js';
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 };