@permissionless-technologies/upd-sdk 0.1.0 → 0.2.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/dist/chunk-3V62JGJY.js +192 -0
- package/dist/chunk-3V62JGJY.js.map +1 -0
- package/dist/{chunk-ZSWETUGH.cjs → chunk-7BP37BGO.cjs} +359 -31
- package/dist/chunk-7BP37BGO.cjs.map +1 -0
- package/dist/{chunk-R64I3LAO.js → chunk-AGPBQ56J.js} +81 -155
- package/dist/chunk-AGPBQ56J.js.map +1 -0
- package/dist/chunk-KSGUFTW3.cjs +206 -0
- package/dist/chunk-KSGUFTW3.cjs.map +1 -0
- package/dist/{chunk-WRPVPA7E.cjs → chunk-LECDXCSW.cjs} +105 -184
- package/dist/chunk-LECDXCSW.cjs.map +1 -0
- package/dist/{chunk-4RBWWS2X.js → chunk-PS6EIE5E.js} +359 -32
- package/dist/chunk-PS6EIE5E.js.map +1 -0
- package/dist/{chunk-RIRT4JX6.js → chunk-TYRBIJVF.js} +3 -228
- package/dist/chunk-TYRBIJVF.js.map +1 -0
- package/dist/{chunk-ZDAHLZWC.cjs → chunk-VZZN3BR3.cjs} +2 -228
- package/dist/chunk-VZZN3BR3.cjs.map +1 -0
- package/dist/contracts/index.cjs +13 -13
- package/dist/contracts/index.d.cts +104 -24
- package/dist/contracts/index.d.ts +104 -24
- package/dist/contracts/index.js +2 -2
- package/dist/core/index.cjs +17 -17
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +3 -3
- package/dist/{index-XNClksom.d.ts → index-BMgIlGvW.d.ts} +11 -3
- package/dist/{index-yRBqVOHV.d.cts → index-D6VgT_bZ.d.cts} +11 -3
- package/dist/index.cjs +50 -50
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/react/index.cjs +145 -22
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +112 -1
- package/dist/react/index.d.ts +112 -1
- package/dist/react/index.js +126 -5
- package/dist/react/index.js.map +1 -1
- package/package.json +3 -1
- package/dist/chunk-4RBWWS2X.js.map +0 -1
- package/dist/chunk-4VXNJTNQ.cjs +0 -58
- package/dist/chunk-4VXNJTNQ.cjs.map +0 -1
- package/dist/chunk-63FIKV36.js +0 -49
- package/dist/chunk-63FIKV36.js.map +0 -1
- package/dist/chunk-R64I3LAO.js.map +0 -1
- package/dist/chunk-RIRT4JX6.js.map +0 -1
- package/dist/chunk-WRPVPA7E.cjs.map +0 -1
- package/dist/chunk-ZDAHLZWC.cjs.map +0 -1
- package/dist/chunk-ZSWETUGH.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { UPDClient, createUPDClient,
|
|
1
|
+
export { UPDClient, createUPDClient, signCancelAuthorization, signReceiveAuthorization, signTransferAuthorization, verifyDeployment } from './chunk-AGPBQ56J.js';
|
|
2
2
|
import './chunk-LNGWRYGY.js';
|
|
3
3
|
export { createMockAttestation } from './chunk-5NNXIJE4.js';
|
|
4
|
-
export { BRIDGE_ESCROW_ABI,
|
|
5
|
-
export { DEFAULT_MIN_RATIO_BPS, collateralizationRatio, computeSystemHealth, quoteBurnUPD, quoteMintUPD, quoteStakeUPD, quoteUnstakeUPD, stabilizerStEthNeeded } from './chunk-
|
|
6
|
-
export { OVERCOLLATERALIZATION_REPORTER_ABI, POSITION_ESCROW_ABI, STABILIZER_ESCROW_ABI, STABILIZER_NFT_ABI, SUPD_ABI, UPD_TOKEN_ABI } from './chunk-
|
|
4
|
+
export { BRIDGE_ESCROW_ABI, PRICE_ORACLE_ABI } from './chunk-TYRBIJVF.js';
|
|
5
|
+
export { DEFAULT_MIN_RATIO_BPS, collateralizationRatio, computeSystemHealth, getContractAddress, getDeployment, getDeploymentOrThrow, getSupportedChainIds, hasDeployment, quoteBurnUPD, quoteMintUPD, quoteStakeUPD, quoteUnstakeUPD, stabilizerStEthNeeded } from './chunk-3V62JGJY.js';
|
|
6
|
+
export { INSURANCE_ESCROW_ABI, OVERCOLLATERALIZATION_REPORTER_ABI, POSITION_ESCROW_ABI, STABILIZER_ESCROW_ABI, STABILIZER_NFT_ABI, SUPD_ABI, UPD_TOKEN_ABI } from './chunk-PS6EIE5E.js';
|
|
7
7
|
export { ETH_USD_ASSET_PAIR, createOracleClient } from './chunk-DJBU2OEB.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../chunk-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
require('../chunk-VZZN3BR3.cjs');
|
|
4
|
+
var chunkKSGUFTW3_cjs = require('../chunk-KSGUFTW3.cjs');
|
|
5
|
+
var chunk7BP37BGO_cjs = require('../chunk-7BP37BGO.cjs');
|
|
6
6
|
var chunkCZEDT3MS_cjs = require('../chunk-CZEDT3MS.cjs');
|
|
7
7
|
var wagmi = require('wagmi');
|
|
8
8
|
var reactQuery = require('@tanstack/react-query');
|
|
@@ -12,14 +12,14 @@ function useUPD(config) {
|
|
|
12
12
|
const { tokenAddress, userAddress } = config;
|
|
13
13
|
const { data: balance, isLoading: balanceLoading } = wagmi.useReadContract({
|
|
14
14
|
address: tokenAddress,
|
|
15
|
-
abi:
|
|
15
|
+
abi: chunk7BP37BGO_cjs.UPD_TOKEN_ABI,
|
|
16
16
|
functionName: "balanceOf",
|
|
17
17
|
args: userAddress ? [userAddress] : void 0,
|
|
18
18
|
query: { enabled: !!userAddress }
|
|
19
19
|
});
|
|
20
20
|
const { data: totalSupply, isLoading: supplyLoading } = wagmi.useReadContract({
|
|
21
21
|
address: tokenAddress,
|
|
22
|
-
abi:
|
|
22
|
+
abi: chunk7BP37BGO_cjs.UPD_TOKEN_ABI,
|
|
23
23
|
functionName: "totalSupply"
|
|
24
24
|
});
|
|
25
25
|
return {
|
|
@@ -32,12 +32,12 @@ function useCollateral(config) {
|
|
|
32
32
|
const { reporterAddress, tokenAddress } = config;
|
|
33
33
|
const { data: totalStEthCollateral, isLoading: collateralLoading } = wagmi.useReadContract({
|
|
34
34
|
address: reporterAddress,
|
|
35
|
-
abi:
|
|
36
|
-
functionName: "
|
|
35
|
+
abi: chunk7BP37BGO_cjs.OVERCOLLATERALIZATION_REPORTER_ABI,
|
|
36
|
+
functionName: "getTotalStEthCollateral"
|
|
37
37
|
});
|
|
38
38
|
const { data: totalUPDSupply, isLoading: supplyLoading } = wagmi.useReadContract({
|
|
39
39
|
address: tokenAddress,
|
|
40
|
-
abi:
|
|
40
|
+
abi: chunk7BP37BGO_cjs.UPD_TOKEN_ABI,
|
|
41
41
|
functionName: "totalSupply"
|
|
42
42
|
});
|
|
43
43
|
return {
|
|
@@ -50,14 +50,14 @@ function useStabilizer(config) {
|
|
|
50
50
|
const { stabilizerNFTAddress, tokenId } = config;
|
|
51
51
|
const { data: positionEscrow, isLoading: posLoading } = wagmi.useReadContract({
|
|
52
52
|
address: stabilizerNFTAddress,
|
|
53
|
-
abi:
|
|
53
|
+
abi: chunk7BP37BGO_cjs.STABILIZER_NFT_ABI,
|
|
54
54
|
functionName: "positionEscrows",
|
|
55
55
|
args: tokenId !== void 0 ? [tokenId] : void 0,
|
|
56
56
|
query: { enabled: tokenId !== void 0 }
|
|
57
57
|
});
|
|
58
58
|
const { data: stabilizerEscrow, isLoading: stabLoading } = wagmi.useReadContract({
|
|
59
59
|
address: stabilizerNFTAddress,
|
|
60
|
-
abi:
|
|
60
|
+
abi: chunk7BP37BGO_cjs.STABILIZER_NFT_ABI,
|
|
61
61
|
functionName: "stabilizerEscrows",
|
|
62
62
|
args: tokenId !== void 0 ? [tokenId] : void 0,
|
|
63
63
|
query: { enabled: tokenId !== void 0 }
|
|
@@ -108,7 +108,7 @@ function useMintQuote(ethAmount, config) {
|
|
|
108
108
|
});
|
|
109
109
|
const updAmount = react.useMemo(() => {
|
|
110
110
|
if (price === void 0 || ethAmount === 0n) return void 0;
|
|
111
|
-
return
|
|
111
|
+
return chunkKSGUFTW3_cjs.quoteMintUPD(ethAmount, price);
|
|
112
112
|
}, [ethAmount, price]);
|
|
113
113
|
return {
|
|
114
114
|
updAmount,
|
|
@@ -123,7 +123,7 @@ function useBurnQuote(updAmount, config) {
|
|
|
123
123
|
});
|
|
124
124
|
const stEthAmount = react.useMemo(() => {
|
|
125
125
|
if (price === void 0 || updAmount === 0n) return void 0;
|
|
126
|
-
return
|
|
126
|
+
return chunkKSGUFTW3_cjs.quoteBurnUPD(updAmount, price);
|
|
127
127
|
}, [updAmount, price]);
|
|
128
128
|
return {
|
|
129
129
|
stEthAmount,
|
|
@@ -149,7 +149,7 @@ function useMintUPD(config) {
|
|
|
149
149
|
function mint(params) {
|
|
150
150
|
writeContract({
|
|
151
151
|
address: stabilizerNFTAddress,
|
|
152
|
-
abi:
|
|
152
|
+
abi: chunk7BP37BGO_cjs.STABILIZER_NFT_ABI,
|
|
153
153
|
functionName: "mintUPD",
|
|
154
154
|
args: [
|
|
155
155
|
params.to,
|
|
@@ -192,7 +192,7 @@ function useBurnUPD(config) {
|
|
|
192
192
|
function burn(params) {
|
|
193
193
|
writeContract({
|
|
194
194
|
address: stabilizerNFTAddress,
|
|
195
|
-
abi:
|
|
195
|
+
abi: chunk7BP37BGO_cjs.STABILIZER_NFT_ABI,
|
|
196
196
|
functionName: "burnUPD",
|
|
197
197
|
args: [
|
|
198
198
|
params.updAmount,
|
|
@@ -237,7 +237,7 @@ function useSystemHealth(config) {
|
|
|
237
237
|
if (totalStEthCollateral === void 0 || totalUPDSupply === void 0 || ethUsdPrice === void 0) {
|
|
238
238
|
return void 0;
|
|
239
239
|
}
|
|
240
|
-
return
|
|
240
|
+
return chunkKSGUFTW3_cjs.computeSystemHealth(
|
|
241
241
|
{ totalStEthCollateral, totalUPDSupply },
|
|
242
242
|
ethUsdPrice,
|
|
243
243
|
config.minRatioBps
|
|
@@ -252,29 +252,29 @@ function useSUPD(config) {
|
|
|
252
252
|
const { supdAddress, userAddress } = config;
|
|
253
253
|
const { data: balance, isLoading: balLoading } = wagmi.useReadContract({
|
|
254
254
|
address: supdAddress,
|
|
255
|
-
abi:
|
|
255
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
256
256
|
functionName: "balanceOf",
|
|
257
257
|
args: userAddress ? [userAddress] : void 0,
|
|
258
258
|
query: { enabled: !!userAddress }
|
|
259
259
|
});
|
|
260
260
|
const { data: totalSupply, isLoading: supplyLoading } = wagmi.useReadContract({
|
|
261
261
|
address: supdAddress,
|
|
262
|
-
abi:
|
|
262
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
263
263
|
functionName: "totalSupply"
|
|
264
264
|
});
|
|
265
265
|
const { data: shareValue, isLoading: svLoading } = wagmi.useReadContract({
|
|
266
266
|
address: supdAddress,
|
|
267
|
-
abi:
|
|
267
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
268
268
|
functionName: "currentShareValue"
|
|
269
269
|
});
|
|
270
270
|
const { data: annualYieldBps, isLoading: apyLoading } = wagmi.useReadContract({
|
|
271
271
|
address: supdAddress,
|
|
272
|
-
abi:
|
|
272
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
273
273
|
functionName: "annualYieldBps"
|
|
274
274
|
});
|
|
275
275
|
const { data: totalLiabilityUSD, isLoading: liabLoading } = wagmi.useReadContract({
|
|
276
276
|
address: supdAddress,
|
|
277
|
-
abi:
|
|
277
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
278
278
|
functionName: "totalLiabilityUSD"
|
|
279
279
|
});
|
|
280
280
|
return {
|
|
@@ -302,7 +302,7 @@ function useStakeUPD(config) {
|
|
|
302
302
|
function stake(params) {
|
|
303
303
|
writeContract({
|
|
304
304
|
address: supdAddress,
|
|
305
|
-
abi:
|
|
305
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
306
306
|
functionName: "stakeUPD",
|
|
307
307
|
args: [
|
|
308
308
|
params.updAmount,
|
|
@@ -342,7 +342,7 @@ function useUnstakeUPD(config) {
|
|
|
342
342
|
function unstake(params) {
|
|
343
343
|
writeContract({
|
|
344
344
|
address: supdAddress,
|
|
345
|
-
abi:
|
|
345
|
+
abi: chunk7BP37BGO_cjs.SUPD_ABI,
|
|
346
346
|
functionName: "unstakeToUPD",
|
|
347
347
|
args: [
|
|
348
348
|
params.shares,
|
|
@@ -366,6 +366,127 @@ function useUnstakeUPD(config) {
|
|
|
366
366
|
reset
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
+
function useSwapEthToUPD(config) {
|
|
370
|
+
const deployment = chunkKSGUFTW3_cjs.getDeployment(config.chainId);
|
|
371
|
+
const stabilizerNFTAddress = deployment?.contracts.StabilizerNFT;
|
|
372
|
+
const {
|
|
373
|
+
price,
|
|
374
|
+
priceFormatted,
|
|
375
|
+
attestation,
|
|
376
|
+
isLoading: priceLoading,
|
|
377
|
+
error: priceError
|
|
378
|
+
} = useEthUsdPrice(config.oracle);
|
|
379
|
+
const {
|
|
380
|
+
writeContract,
|
|
381
|
+
data: txHash,
|
|
382
|
+
isPending,
|
|
383
|
+
error: writeError,
|
|
384
|
+
reset
|
|
385
|
+
} = wagmi.useWriteContract();
|
|
386
|
+
const {
|
|
387
|
+
isLoading: isConfirming,
|
|
388
|
+
isSuccess: isConfirmed
|
|
389
|
+
} = wagmi.useWaitForTransactionReceipt({ hash: txHash });
|
|
390
|
+
const quote = react.useMemo(() => {
|
|
391
|
+
return (ethAmount) => {
|
|
392
|
+
if (price === void 0 || ethAmount === 0n) return void 0;
|
|
393
|
+
return chunkKSGUFTW3_cjs.quoteMintUPD(ethAmount, price);
|
|
394
|
+
};
|
|
395
|
+
}, [price]);
|
|
396
|
+
function mint(params) {
|
|
397
|
+
if (!stabilizerNFTAddress || !attestation) return;
|
|
398
|
+
writeContract({
|
|
399
|
+
address: stabilizerNFTAddress,
|
|
400
|
+
abi: chunk7BP37BGO_cjs.STABILIZER_NFT_ABI,
|
|
401
|
+
functionName: "mintUPD",
|
|
402
|
+
args: [
|
|
403
|
+
params.to,
|
|
404
|
+
{
|
|
405
|
+
price: attestation.price,
|
|
406
|
+
decimals: attestation.decimals,
|
|
407
|
+
dataTimestamp: attestation.dataTimestamp,
|
|
408
|
+
assetPair: attestation.assetPair,
|
|
409
|
+
signature: attestation.signature
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
value: params.ethAmount
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
quote,
|
|
417
|
+
mint,
|
|
418
|
+
price,
|
|
419
|
+
priceFormatted,
|
|
420
|
+
priceLoading,
|
|
421
|
+
isPending,
|
|
422
|
+
txHash,
|
|
423
|
+
isConfirming,
|
|
424
|
+
isConfirmed,
|
|
425
|
+
error: writeError ?? priceError,
|
|
426
|
+
reset,
|
|
427
|
+
isReady: !!stabilizerNFTAddress && !!attestation
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function useSwapUPDToStETH(config) {
|
|
431
|
+
const deployment = chunkKSGUFTW3_cjs.getDeployment(config.chainId);
|
|
432
|
+
const stabilizerNFTAddress = deployment?.contracts.StabilizerNFT;
|
|
433
|
+
const {
|
|
434
|
+
price,
|
|
435
|
+
priceFormatted,
|
|
436
|
+
attestation,
|
|
437
|
+
isLoading: priceLoading,
|
|
438
|
+
error: priceError
|
|
439
|
+
} = useEthUsdPrice(config.oracle);
|
|
440
|
+
const {
|
|
441
|
+
writeContract,
|
|
442
|
+
data: txHash,
|
|
443
|
+
isPending,
|
|
444
|
+
error: writeError,
|
|
445
|
+
reset
|
|
446
|
+
} = wagmi.useWriteContract();
|
|
447
|
+
const {
|
|
448
|
+
isLoading: isConfirming,
|
|
449
|
+
isSuccess: isConfirmed
|
|
450
|
+
} = wagmi.useWaitForTransactionReceipt({ hash: txHash });
|
|
451
|
+
const quote = react.useMemo(() => {
|
|
452
|
+
return (updAmount) => {
|
|
453
|
+
if (price === void 0 || updAmount === 0n) return void 0;
|
|
454
|
+
return chunkKSGUFTW3_cjs.quoteBurnUPD(updAmount, price);
|
|
455
|
+
};
|
|
456
|
+
}, [price]);
|
|
457
|
+
function burn(params) {
|
|
458
|
+
if (!stabilizerNFTAddress || !attestation) return;
|
|
459
|
+
writeContract({
|
|
460
|
+
address: stabilizerNFTAddress,
|
|
461
|
+
abi: chunk7BP37BGO_cjs.STABILIZER_NFT_ABI,
|
|
462
|
+
functionName: "burnUPD",
|
|
463
|
+
args: [
|
|
464
|
+
params.updAmount,
|
|
465
|
+
{
|
|
466
|
+
price: attestation.price,
|
|
467
|
+
decimals: attestation.decimals,
|
|
468
|
+
dataTimestamp: attestation.dataTimestamp,
|
|
469
|
+
assetPair: attestation.assetPair,
|
|
470
|
+
signature: attestation.signature
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
quote,
|
|
477
|
+
burn,
|
|
478
|
+
price,
|
|
479
|
+
priceFormatted,
|
|
480
|
+
priceLoading,
|
|
481
|
+
isPending,
|
|
482
|
+
txHash,
|
|
483
|
+
isConfirming,
|
|
484
|
+
isConfirmed,
|
|
485
|
+
error: writeError ?? priceError,
|
|
486
|
+
reset,
|
|
487
|
+
isReady: !!stabilizerNFTAddress && !!attestation
|
|
488
|
+
};
|
|
489
|
+
}
|
|
369
490
|
|
|
370
491
|
exports.useBurnQuote = useBurnQuote;
|
|
371
492
|
exports.useBurnUPD = useBurnUPD;
|
|
@@ -376,6 +497,8 @@ exports.useMintUPD = useMintUPD;
|
|
|
376
497
|
exports.useSUPD = useSUPD;
|
|
377
498
|
exports.useStabilizer = useStabilizer;
|
|
378
499
|
exports.useStakeUPD = useStakeUPD;
|
|
500
|
+
exports.useSwapEthToUPD = useSwapEthToUPD;
|
|
501
|
+
exports.useSwapUPDToStETH = useSwapUPDToStETH;
|
|
379
502
|
exports.useSystemHealth = useSystemHealth;
|
|
380
503
|
exports.useUPD = useUPD;
|
|
381
504
|
exports.useUnstakeUPD = useUnstakeUPD;
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/use-upd.ts","../../src/react/use-collateral.ts","../../src/react/use-stabilizer.ts","../../src/react/use-eth-usd-price.ts","../../src/react/use-mint-quote.ts","../../src/react/use-burn-quote.ts","../../src/react/use-mint-upd.ts","../../src/react/use-burn-upd.ts","../../src/react/use-system-health.ts","../../src/react/use-supd.ts","../../src/react/use-stake-upd.ts","../../src/react/use-unstake-upd.ts"],"names":["useReadContract","UPD_TOKEN_ABI","OVERCOLLATERALIZATION_REPORTER_ABI","STABILIZER_NFT_ABI","createOracleClient","useQuery","useMemo","quoteMintUPD","quoteBurnUPD","useWriteContract","useWaitForTransactionReceipt","computeSystemHealth","SUPD_ABI"],"mappings":";;;;;;;;;;AAeO,SAAS,OAAO,MAAA,EAAoC;AACzD,EAAA,MAAM,EAAE,YAAA,EAAc,WAAA,EAAY,GAAI,MAAA;AAEtC,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,SAAA,EAAW,cAAA,KAAmBA,qBAAA,CAAgB;AAAA,IACnE,OAAA,EAAS,YAAA;AAAA,IACT,GAAA,EAAKC,+BAAA;AAAA,IACL,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,WAAA,GAAc,CAAC,WAAW,CAAA,GAAI,MAAA;AAAA,IACpC,KAAA,EAAO,EAAE,OAAA,EAAS,CAAC,CAAC,WAAA;AAAY,GACjC,CAAA;AAED,EAAA,MAAM,EAAE,IAAA,EAAM,WAAA,EAAa,SAAA,EAAW,aAAA,KAAkBD,qBAAA,CAAgB;AAAA,IACtE,OAAA,EAAS,YAAA;AAAA,IACT,GAAA,EAAKC,+BAAA;AAAA,IACL,YAAA,EAAc;AAAA,GACf,CAAA;AAED,EAAA,OAAO;AAAA,IACL,OAA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,aAAA,EAAe,OAAO,WAAA,CAAY,aAAA;AAAA,UAClC,SAAA,EAAW,OAAO,WAAA,CAAY,SAAA;AAAA,UAC9B,SAAA,EAAW,OAAO,WAAA,CAAY;AAAA;AAChC;AACF,KACD,CAAA;AAAA,EACH;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,KAAA,EAAO,UAAA;AAAA,IACP;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { UPD_TOKEN_ABI } from '../contracts/index.js'\n\nexport interface UseUPDConfig {\n tokenAddress: Address\n userAddress?: Address\n}\n\nexport interface UseUPDReturn {\n balance: bigint | undefined\n totalSupply: bigint | undefined\n isLoading: boolean\n}\n\nexport function useUPD(config: UseUPDConfig): UseUPDReturn {\n const { tokenAddress, userAddress } = config\n\n const { data: balance, isLoading: balanceLoading } = useReadContract({\n address: tokenAddress,\n abi: UPD_TOKEN_ABI,\n functionName: 'balanceOf',\n args: userAddress ? [userAddress] : undefined,\n query: { enabled: !!userAddress },\n })\n\n const { data: totalSupply, isLoading: supplyLoading } = useReadContract({\n address: tokenAddress,\n abi: UPD_TOKEN_ABI,\n functionName: 'totalSupply',\n })\n\n return {\n balance: balance as bigint | undefined,\n totalSupply: totalSupply as bigint | undefined,\n isLoading: balanceLoading || supplyLoading,\n }\n}\n","import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { OVERCOLLATERALIZATION_REPORTER_ABI } from '../contracts/index.js'\nimport { UPD_TOKEN_ABI } from '../contracts/index.js'\n\nexport interface UseCollateralConfig {\n reporterAddress: Address\n tokenAddress: Address\n}\n\nexport interface UseCollateralReturn {\n totalStEthCollateral: bigint | undefined\n totalUPDSupply: bigint | undefined\n isLoading: boolean\n}\n\nexport function useCollateral(config: UseCollateralConfig): UseCollateralReturn {\n const { reporterAddress, tokenAddress } = config\n\n const { data: totalStEthCollateral, isLoading: collateralLoading } =\n useReadContract({\n address: reporterAddress,\n abi: OVERCOLLATERALIZATION_REPORTER_ABI,\n functionName: 'totalStEthCollateral',\n })\n\n const { data: totalUPDSupply, isLoading: supplyLoading } = useReadContract({\n address: tokenAddress,\n abi: UPD_TOKEN_ABI,\n functionName: 'totalSupply',\n })\n\n return {\n totalStEthCollateral: totalStEthCollateral as bigint | undefined,\n totalUPDSupply: totalUPDSupply as bigint | undefined,\n isLoading: collateralLoading || supplyLoading,\n }\n}\n","import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseStabilizerConfig {\n stabilizerNFTAddress: Address\n tokenId?: bigint\n}\n\nexport interface UseStabilizerReturn {\n positionEscrowAddress: Address | undefined\n stabilizerEscrowAddress: Address | undefined\n isLoading: boolean\n}\n\nexport function useStabilizer(\n config: UseStabilizerConfig,\n): UseStabilizerReturn {\n const { stabilizerNFTAddress, tokenId } = config\n\n const { data: positionEscrow, isLoading: posLoading } = useReadContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'positionEscrows',\n args: tokenId !== undefined ? [tokenId] : undefined,\n query: { enabled: tokenId !== undefined },\n })\n\n const { data: stabilizerEscrow, isLoading: stabLoading } = useReadContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'stabilizerEscrows',\n args: tokenId !== undefined ? [tokenId] : undefined,\n query: { enabled: tokenId !== undefined },\n })\n\n return {\n positionEscrowAddress: positionEscrow as Address | undefined,\n stabilizerEscrowAddress: stabilizerEscrow as Address | undefined,\n isLoading: posLoading || stabLoading,\n }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { createOracleClient } from '../oracle/client.js'\nimport type { PriceAttestationQuery } from '../core/types.js'\n\nexport interface UseEthUsdPriceConfig {\n /** Oracle service URL. Defaults to oracle.upd.io. */\n oracleUrl?: string\n /** Refetch interval in milliseconds. Defaults to 10000 (10s). */\n refetchInterval?: number\n /** Whether to enable the query. Defaults to true. */\n enabled?: boolean\n}\n\nexport interface UseEthUsdPriceReturn {\n /** Raw price in 18 decimals (e.g. 2000e18 = $2000). */\n price: bigint | undefined\n /** Human-readable formatted price string (e.g. \"$2,000.00\"). */\n priceFormatted: string\n /** Full signed attestation, ready to pass to mint/burn. */\n attestation: PriceAttestationQuery | undefined\n /** Whether the initial fetch is loading. */\n isLoading: boolean\n /** Error from the most recent fetch, if any. */\n error: Error | null\n /** Manually trigger a refetch. */\n refetch: () => void\n}\n\nfunction formatUsdPrice(price: bigint | undefined): string {\n if (price === undefined) return '--'\n const priceFloat = Number(price) / 1e18\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(priceFloat)\n}\n\nexport function useEthUsdPrice(config?: UseEthUsdPriceConfig): UseEthUsdPriceReturn {\n const oracleUrl = config?.oracleUrl\n const refetchInterval = config?.refetchInterval ?? 10_000\n const enabled = config?.enabled ?? true\n\n const oracle = createOracleClient({ oracleUrl })\n\n const { data, isLoading, error, refetch } = useQuery({\n queryKey: ['upd-oracle-eth-usd', oracleUrl],\n queryFn: () => oracle.getEthUsdAttestation(),\n refetchInterval,\n enabled,\n staleTime: 5_000,\n })\n\n return {\n price: data?.price,\n priceFormatted: formatUsdPrice(data?.price),\n attestation: data,\n isLoading,\n error: error as Error | null,\n refetch: () => { refetch() },\n }\n}\n","import { useMemo } from 'react'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { quoteMintUPD } from '../core/quote.js'\n\nexport interface UseMintQuoteConfig extends UseEthUsdPriceConfig {}\n\nexport interface UseMintQuoteReturn {\n /** Expected UPD amount for the given ETH input (18 decimals). */\n updAmount: bigint | undefined\n /** Current ETH/USD price used for the quote (18 decimals). */\n ethUsdPrice: bigint | undefined\n /** Whether the price is still loading. */\n isLoading: boolean\n}\n\n/**\n * Real-time mint quote hook — composes oracle price + pure math.\n *\n * @param ethAmount - ETH amount to quote (in wei). Pass 0n to disable.\n * @param config - Optional oracle configuration.\n *\n * @example\n * ```tsx\n * const { updAmount, isLoading } = useMintQuote(parseEther('1'))\n * // updAmount ≈ 2000e18 (at $2000/ETH)\n * ```\n */\nexport function useMintQuote(\n ethAmount: bigint,\n config?: UseMintQuoteConfig,\n): UseMintQuoteReturn {\n const { price, isLoading } = useEthUsdPrice({\n ...config,\n enabled: ethAmount > 0n && (config?.enabled ?? true),\n })\n\n const updAmount = useMemo(() => {\n if (price === undefined || ethAmount === 0n) return undefined\n return quoteMintUPD(ethAmount, price)\n }, [ethAmount, price])\n\n return {\n updAmount,\n ethUsdPrice: price,\n isLoading,\n }\n}\n","import { useMemo } from 'react'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { quoteBurnUPD } from '../core/quote.js'\n\nexport interface UseBurnQuoteConfig extends UseEthUsdPriceConfig {}\n\nexport interface UseBurnQuoteReturn {\n /** Expected stETH amount for the given UPD input (in wei). */\n stEthAmount: bigint | undefined\n /** Current ETH/USD price used for the quote (18 decimals). */\n ethUsdPrice: bigint | undefined\n /** Whether the price is still loading. */\n isLoading: boolean\n}\n\n/**\n * Real-time burn quote hook — composes oracle price + pure math.\n *\n * @param updAmount - UPD amount to quote (18 decimals). Pass 0n to disable.\n * @param config - Optional oracle configuration.\n *\n * @example\n * ```tsx\n * const { stEthAmount, isLoading } = useBurnQuote(parseUnits('2000', 18))\n * // stEthAmount ≈ 1e18 (at $2000/ETH)\n * ```\n */\nexport function useBurnQuote(\n updAmount: bigint,\n config?: UseBurnQuoteConfig,\n): UseBurnQuoteReturn {\n const { price, isLoading } = useEthUsdPrice({\n ...config,\n enabled: updAmount > 0n && (config?.enabled ?? true),\n })\n\n const stEthAmount = useMemo(() => {\n if (price === undefined || updAmount === 0n) return undefined\n return quoteBurnUPD(updAmount, price)\n }, [updAmount, price])\n\n return {\n stEthAmount,\n ethUsdPrice: price,\n isLoading,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseMintUPDConfig {\n /** Address of the StabilizerNFT contract. */\n stabilizerNFTAddress: Address\n}\n\nexport interface UseMintUPDReturn {\n /** Execute the mint transaction. */\n mint: (params: {\n to: Address\n ethAmount: bigint\n attestation: PriceAttestationQuery\n }) => void\n /** Whether the transaction is being sent. */\n isPending: boolean\n /** Transaction hash once submitted. */\n txHash: Hash | undefined\n /** Whether we're waiting for confirmation. */\n isConfirming: boolean\n /** Whether the transaction is confirmed. */\n isConfirmed: boolean\n /** Error from the transaction, if any. */\n error: Error | null\n /** Reset the mutation state. */\n reset: () => void\n}\n\n/**\n * Write hook for minting UPD by depositing ETH.\n *\n * @example\n * ```tsx\n * const { mint, isPending, isConfirmed, error } = useMintUPD({\n * stabilizerNFTAddress: deployment.contracts.StabilizerNFT,\n * })\n *\n * // Use with useEthUsdPrice to get attestation\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => mint({ to: userAddress, ethAmount: parseEther('1'), attestation })}>\n * Mint UPD\n * </button>\n * ```\n */\nexport function useMintUPD(config: UseMintUPDConfig): UseMintUPDReturn {\n const { stabilizerNFTAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({\n hash: txHash,\n })\n\n function mint(params: {\n to: Address\n ethAmount: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'mintUPD',\n args: [\n params.to,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n value: params.ethAmount,\n })\n }\n\n return {\n mint,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseBurnUPDConfig {\n /** Address of the StabilizerNFT contract. */\n stabilizerNFTAddress: Address\n}\n\nexport interface UseBurnUPDReturn {\n /** Execute the burn transaction. */\n burn: (params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) => void\n /** Whether the transaction is being sent. */\n isPending: boolean\n /** Transaction hash once submitted. */\n txHash: Hash | undefined\n /** Whether we're waiting for confirmation. */\n isConfirming: boolean\n /** Whether the transaction is confirmed. */\n isConfirmed: boolean\n /** Error from the transaction, if any. */\n error: Error | null\n /** Reset the mutation state. */\n reset: () => void\n}\n\n/**\n * Write hook for burning UPD to receive stETH.\n *\n * @example\n * ```tsx\n * const { burn, isPending, isConfirmed } = useBurnUPD({\n * stabilizerNFTAddress: deployment.contracts.StabilizerNFT,\n * })\n *\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => burn({ updAmount: parseUnits('1000', 18), attestation })}>\n * Burn 1000 UPD\n * </button>\n * ```\n */\nexport function useBurnUPD(config: UseBurnUPDConfig): UseBurnUPDReturn {\n const { stabilizerNFTAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({\n hash: txHash,\n })\n\n function burn(params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'burnUPD',\n args: [\n params.updAmount,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n })\n }\n\n return {\n burn,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useMemo } from 'react'\nimport type { Address } from 'viem'\nimport { useCollateral, type UseCollateralConfig } from './use-collateral.js'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { computeSystemHealth, type SystemHealth } from '../core/health.js'\n\nexport interface UseSystemHealthConfig {\n /** Address of the OvercollateralizationReporter contract. */\n reporterAddress: Address\n /** Address of the UPD token. */\n tokenAddress: Address\n /** Oracle service URL. */\n oracleUrl?: string\n /** Minimum collateral ratio in basis points (default: 12500 = 125%). */\n minRatioBps?: bigint\n}\n\nexport interface UseSystemHealthReturn {\n /** Computed system health metrics, or undefined if still loading. */\n health: SystemHealth | undefined\n /** Whether any underlying data is still loading. */\n isLoading: boolean\n}\n\n/**\n * System health hook — composes useCollateral + useEthUsdPrice + computeSystemHealth.\n *\n * @example\n * ```tsx\n * const { health, isLoading } = useSystemHealth({\n * reporterAddress: deployment.contracts.OvercollateralizationReporter,\n * tokenAddress: deployment.contracts.UPDToken,\n * })\n *\n * if (health && !health.isHealthy) {\n * return <Alert>System undercollateralized: {health.systemCollateralRatioBps} bps</Alert>\n * }\n * ```\n */\nexport function useSystemHealth(config: UseSystemHealthConfig): UseSystemHealthReturn {\n const collateralConfig: UseCollateralConfig = {\n reporterAddress: config.reporterAddress,\n tokenAddress: config.tokenAddress,\n }\n\n const priceConfig: UseEthUsdPriceConfig = {\n oracleUrl: config.oracleUrl,\n }\n\n const {\n totalStEthCollateral,\n totalUPDSupply,\n isLoading: collateralLoading,\n } = useCollateral(collateralConfig)\n\n const {\n price: ethUsdPrice,\n isLoading: priceLoading,\n } = useEthUsdPrice(priceConfig)\n\n const health = useMemo(() => {\n if (\n totalStEthCollateral === undefined ||\n totalUPDSupply === undefined ||\n ethUsdPrice === undefined\n ) {\n return undefined\n }\n\n return computeSystemHealth(\n { totalStEthCollateral, totalUPDSupply },\n ethUsdPrice,\n config.minRatioBps,\n )\n }, [totalStEthCollateral, totalUPDSupply, ethUsdPrice, config.minRatioBps])\n\n return {\n health,\n isLoading: collateralLoading || priceLoading,\n }\n}\n","import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { SUPD_ABI } from '../contracts/index.js'\n\nexport interface UseSUPDConfig {\n /** Address of the sUPD contract. */\n supdAddress: Address\n /** User address to read balance for (optional). */\n userAddress?: Address\n}\n\nexport interface UseSUPDReturn {\n /** User's sUPD balance (18 decimals). */\n balance: bigint | undefined\n /** Total sUPD shares outstanding. */\n totalSupply: bigint | undefined\n /** Current share value with accrued yield (18 decimals). */\n shareValue: bigint | undefined\n /** Annual yield in basis points (e.g. 800 = 8%). */\n annualYieldBps: bigint | undefined\n /** Total USD liability of all outstanding sUPD. */\n totalLiabilityUSD: bigint | undefined\n /** Whether any read is still loading. */\n isLoading: boolean\n}\n\n/**\n * Read hook for sUPD — share value, APY, balances, and total liability.\n *\n * @example\n * ```tsx\n * const { balance, shareValue, annualYieldBps, isLoading } = useSUPD({\n * supdAddress: deployment.contracts.sUPD,\n * userAddress: account.address,\n * })\n * ```\n */\nexport function useSUPD(config: UseSUPDConfig): UseSUPDReturn {\n const { supdAddress, userAddress } = config\n\n const { data: balance, isLoading: balLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'balanceOf',\n args: userAddress ? [userAddress] : undefined,\n query: { enabled: !!userAddress },\n })\n\n const { data: totalSupply, isLoading: supplyLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'totalSupply',\n })\n\n const { data: shareValue, isLoading: svLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'currentShareValue',\n })\n\n const { data: annualYieldBps, isLoading: apyLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'annualYieldBps',\n })\n\n const { data: totalLiabilityUSD, isLoading: liabLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'totalLiabilityUSD',\n })\n\n return {\n balance: balance as bigint | undefined,\n totalSupply: totalSupply as bigint | undefined,\n shareValue: shareValue as bigint | undefined,\n annualYieldBps: annualYieldBps as bigint | undefined,\n totalLiabilityUSD: totalLiabilityUSD as bigint | undefined,\n isLoading: balLoading || supplyLoading || svLoading || apyLoading || liabLoading,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { SUPD_ABI } from '../contracts/index.js'\n\nexport interface UseStakeUPDConfig {\n /** Address of the sUPD contract. */\n supdAddress: Address\n}\n\nexport interface UseStakeUPDReturn {\n /** Execute the stake transaction. User must approve UPD transfer to sUPD first. */\n stake: (params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) => void\n isPending: boolean\n txHash: Hash | undefined\n isConfirming: boolean\n isConfirmed: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Write hook for staking UPD → sUPD.\n *\n * Note: The user must first approve the sUPD contract to spend their UPD tokens\n * (via UPDToken.approve or EIP-3009 transferWithAuthorization).\n *\n * @example\n * ```tsx\n * const { stake, isPending } = useStakeUPD({\n * supdAddress: deployment.contracts.sUPD,\n * })\n *\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => stake({ updAmount: parseUnits('1000', 18), attestation })}>\n * Stake 1000 UPD\n * </button>\n * ```\n */\nexport function useStakeUPD(config: UseStakeUPDConfig): UseStakeUPDReturn {\n const { supdAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({ hash: txHash })\n\n function stake(params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'stakeUPD',\n args: [\n params.updAmount,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n })\n }\n\n return {\n stake,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { SUPD_ABI } from '../contracts/index.js'\n\nexport interface UseUnstakeUPDConfig {\n /** Address of the sUPD contract. */\n supdAddress: Address\n}\n\nexport interface UseUnstakeUPDReturn {\n /** Execute the unstake transaction (unstakeToUPD — full redemption). */\n unstake: (params: {\n shares: bigint\n attestation: PriceAttestationQuery\n }) => void\n isPending: boolean\n txHash: Hash | undefined\n isConfirming: boolean\n isConfirmed: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Write hook for unstaking sUPD → UPD.\n *\n * Calls `unstakeToUPD(shares, priceQuery)` which gathers stETH from sUPD's\n * stabilizer escrows and mints fresh UPD to the caller.\n *\n * For advanced unstake variants (pro-rata, queued, with-extra-UPD), use the\n * contract ABI directly.\n *\n * @example\n * ```tsx\n * const { unstake, isPending } = useUnstakeUPD({\n * supdAddress: deployment.contracts.sUPD,\n * })\n *\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => unstake({ shares: myShares, attestation })}>\n * Unstake\n * </button>\n * ```\n */\nexport function useUnstakeUPD(config: UseUnstakeUPDConfig): UseUnstakeUPDReturn {\n const { supdAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({ hash: txHash })\n\n function unstake(params: {\n shares: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'unstakeToUPD',\n args: [\n params.shares,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n })\n }\n\n return {\n unstake,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/react/use-upd.ts","../../src/react/use-collateral.ts","../../src/react/use-stabilizer.ts","../../src/react/use-eth-usd-price.ts","../../src/react/use-mint-quote.ts","../../src/react/use-burn-quote.ts","../../src/react/use-mint-upd.ts","../../src/react/use-burn-upd.ts","../../src/react/use-system-health.ts","../../src/react/use-supd.ts","../../src/react/use-stake-upd.ts","../../src/react/use-unstake-upd.ts","../../src/react/use-swap-eth-to-upd.ts","../../src/react/use-swap-upd-to-steth.ts"],"names":["useReadContract","UPD_TOKEN_ABI","OVERCOLLATERALIZATION_REPORTER_ABI","STABILIZER_NFT_ABI","createOracleClient","useQuery","useMemo","quoteMintUPD","quoteBurnUPD","useWriteContract","useWaitForTransactionReceipt","computeSystemHealth","SUPD_ABI","getDeployment"],"mappings":";;;;;;;;;;AAeO,SAAS,OAAO,MAAA,EAAoC;AACzD,EAAA,MAAM,EAAE,YAAA,EAAc,WAAA,EAAY,GAAI,MAAA;AAEtC,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,SAAA,EAAW,cAAA,KAAmBA,qBAAA,CAAgB;AAAA,IACnE,OAAA,EAAS,YAAA;AAAA,IACT,GAAA,EAAKC,+BAAA;AAAA,IACL,YAAA,EAAc,WAAA;AAAA,IACd,IAAA,EAAM,WAAA,GAAc,CAAC,WAAW,CAAA,GAAI,MAAA;AAAA,IACpC,KAAA,EAAO,EAAE,OAAA,EAAS,CAAC,CAAC,WAAA;AAAY,GACjC,CAAA;AAED,EAAA,MA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A,IAAA;AAAA,IACA,KAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAQ,UAAA,IAAc,UAAA;AAAA,IACtB,KAAA;AAAA,IACA,OAAA,EAAS,CAAC,CAAC,oBAAA,IAAwB,CAAC,CAAC;AAAA,GACvC;AACF","file":"index.cjs","sourcesContent":["import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { UPD_TOKEN_ABI } from '../contracts/index.js'\n\nexport interface UseUPDConfig {\n tokenAddress: Address\n userAddress?: Address\n}\n\nexport interface UseUPDReturn {\n balance: bigint | undefined\n totalSupply: bigint | undefined\n isLoading: boolean\n}\n\nexport function useUPD(config: UseUPDConfig): UseUPDReturn {\n const { tokenAddress, userAddress } = config\n\n const { data: balance, isLoading: balanceLoading } = useReadContract({\n address: tokenAddress,\n abi: UPD_TOKEN_ABI,\n functionName: 'balanceOf',\n args: userAddress ? [userAddress] : undefined,\n query: { enabled: !!userAddress },\n })\n\n const { data: totalSupply, isLoading: supplyLoading } = useReadContract({\n address: tokenAddress,\n abi: UPD_TOKEN_ABI,\n functionName: 'totalSupply',\n })\n\n return {\n balance: balance as bigint | undefined,\n totalSupply: totalSupply as bigint | undefined,\n isLoading: balanceLoading || supplyLoading,\n }\n}\n","import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { OVERCOLLATERALIZATION_REPORTER_ABI } from '../contracts/index.js'\nimport { UPD_TOKEN_ABI } from '../contracts/index.js'\n\nexport interface UseCollateralConfig {\n reporterAddress: Address\n tokenAddress: Address\n}\n\nexport interface UseCollateralReturn {\n totalStEthCollateral: bigint | undefined\n totalUPDSupply: bigint | undefined\n isLoading: boolean\n}\n\nexport function useCollateral(config: UseCollateralConfig): UseCollateralReturn {\n const { reporterAddress, tokenAddress } = config\n\n const { data: totalStEthCollateral, isLoading: collateralLoading } =\n useReadContract({\n address: reporterAddress,\n abi: OVERCOLLATERALIZATION_REPORTER_ABI,\n functionName: 'getTotalStEthCollateral',\n })\n\n const { data: totalUPDSupply, isLoading: supplyLoading } = useReadContract({\n address: tokenAddress,\n abi: UPD_TOKEN_ABI,\n functionName: 'totalSupply',\n })\n\n return {\n totalStEthCollateral: totalStEthCollateral as bigint | undefined,\n totalUPDSupply: totalUPDSupply as bigint | undefined,\n isLoading: collateralLoading || supplyLoading,\n }\n}\n","import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseStabilizerConfig {\n stabilizerNFTAddress: Address\n tokenId?: bigint\n}\n\nexport interface UseStabilizerReturn {\n positionEscrowAddress: Address | undefined\n stabilizerEscrowAddress: Address | undefined\n isLoading: boolean\n}\n\nexport function useStabilizer(\n config: UseStabilizerConfig,\n): UseStabilizerReturn {\n const { stabilizerNFTAddress, tokenId } = config\n\n const { data: positionEscrow, isLoading: posLoading } = useReadContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'positionEscrows',\n args: tokenId !== undefined ? [tokenId] : undefined,\n query: { enabled: tokenId !== undefined },\n })\n\n const { data: stabilizerEscrow, isLoading: stabLoading } = useReadContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'stabilizerEscrows',\n args: tokenId !== undefined ? [tokenId] : undefined,\n query: { enabled: tokenId !== undefined },\n })\n\n return {\n positionEscrowAddress: positionEscrow as Address | undefined,\n stabilizerEscrowAddress: stabilizerEscrow as Address | undefined,\n isLoading: posLoading || stabLoading,\n }\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { createOracleClient } from '../oracle/client.js'\nimport type { PriceAttestationQuery } from '../core/types.js'\n\nexport interface UseEthUsdPriceConfig {\n /** Oracle service URL. Defaults to oracle.upd.io. */\n oracleUrl?: string\n /** Refetch interval in milliseconds. Defaults to 10000 (10s). */\n refetchInterval?: number\n /** Whether to enable the query. Defaults to true. */\n enabled?: boolean\n}\n\nexport interface UseEthUsdPriceReturn {\n /** Raw price in 18 decimals (e.g. 2000e18 = $2000). */\n price: bigint | undefined\n /** Human-readable formatted price string (e.g. \"$2,000.00\"). */\n priceFormatted: string\n /** Full signed attestation, ready to pass to mint/burn. */\n attestation: PriceAttestationQuery | undefined\n /** Whether the initial fetch is loading. */\n isLoading: boolean\n /** Error from the most recent fetch, if any. */\n error: Error | null\n /** Manually trigger a refetch. */\n refetch: () => void\n}\n\nfunction formatUsdPrice(price: bigint | undefined): string {\n if (price === undefined) return '--'\n const priceFloat = Number(price) / 1e18\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(priceFloat)\n}\n\nexport function useEthUsdPrice(config?: UseEthUsdPriceConfig): UseEthUsdPriceReturn {\n const oracleUrl = config?.oracleUrl\n const refetchInterval = config?.refetchInterval ?? 10_000\n const enabled = config?.enabled ?? true\n\n const oracle = createOracleClient({ oracleUrl })\n\n const { data, isLoading, error, refetch } = useQuery({\n queryKey: ['upd-oracle-eth-usd', oracleUrl],\n queryFn: () => oracle.getEthUsdAttestation(),\n refetchInterval,\n enabled,\n staleTime: 5_000,\n })\n\n return {\n price: data?.price,\n priceFormatted: formatUsdPrice(data?.price),\n attestation: data,\n isLoading,\n error: error as Error | null,\n refetch: () => { refetch() },\n }\n}\n","import { useMemo } from 'react'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { quoteMintUPD } from '../core/quote.js'\n\nexport interface UseMintQuoteConfig extends UseEthUsdPriceConfig {}\n\nexport interface UseMintQuoteReturn {\n /** Expected UPD amount for the given ETH input (18 decimals). */\n updAmount: bigint | undefined\n /** Current ETH/USD price used for the quote (18 decimals). */\n ethUsdPrice: bigint | undefined\n /** Whether the price is still loading. */\n isLoading: boolean\n}\n\n/**\n * Real-time mint quote hook — composes oracle price + pure math.\n *\n * @param ethAmount - ETH amount to quote (in wei). Pass 0n to disable.\n * @param config - Optional oracle configuration.\n *\n * @example\n * ```tsx\n * const { updAmount, isLoading } = useMintQuote(parseEther('1'))\n * // updAmount ≈ 2000e18 (at $2000/ETH)\n * ```\n */\nexport function useMintQuote(\n ethAmount: bigint,\n config?: UseMintQuoteConfig,\n): UseMintQuoteReturn {\n const { price, isLoading } = useEthUsdPrice({\n ...config,\n enabled: ethAmount > 0n && (config?.enabled ?? true),\n })\n\n const updAmount = useMemo(() => {\n if (price === undefined || ethAmount === 0n) return undefined\n return quoteMintUPD(ethAmount, price)\n }, [ethAmount, price])\n\n return {\n updAmount,\n ethUsdPrice: price,\n isLoading,\n }\n}\n","import { useMemo } from 'react'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { quoteBurnUPD } from '../core/quote.js'\n\nexport interface UseBurnQuoteConfig extends UseEthUsdPriceConfig {}\n\nexport interface UseBurnQuoteReturn {\n /** Expected stETH amount for the given UPD input (in wei). */\n stEthAmount: bigint | undefined\n /** Current ETH/USD price used for the quote (18 decimals). */\n ethUsdPrice: bigint | undefined\n /** Whether the price is still loading. */\n isLoading: boolean\n}\n\n/**\n * Real-time burn quote hook — composes oracle price + pure math.\n *\n * @param updAmount - UPD amount to quote (18 decimals). Pass 0n to disable.\n * @param config - Optional oracle configuration.\n *\n * @example\n * ```tsx\n * const { stEthAmount, isLoading } = useBurnQuote(parseUnits('2000', 18))\n * // stEthAmount ≈ 1e18 (at $2000/ETH)\n * ```\n */\nexport function useBurnQuote(\n updAmount: bigint,\n config?: UseBurnQuoteConfig,\n): UseBurnQuoteReturn {\n const { price, isLoading } = useEthUsdPrice({\n ...config,\n enabled: updAmount > 0n && (config?.enabled ?? true),\n })\n\n const stEthAmount = useMemo(() => {\n if (price === undefined || updAmount === 0n) return undefined\n return quoteBurnUPD(updAmount, price)\n }, [updAmount, price])\n\n return {\n stEthAmount,\n ethUsdPrice: price,\n isLoading,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseMintUPDConfig {\n /** Address of the StabilizerNFT contract. */\n stabilizerNFTAddress: Address\n}\n\nexport interface UseMintUPDReturn {\n /** Execute the mint transaction. */\n mint: (params: {\n to: Address\n ethAmount: bigint\n attestation: PriceAttestationQuery\n }) => void\n /** Whether the transaction is being sent. */\n isPending: boolean\n /** Transaction hash once submitted. */\n txHash: Hash | undefined\n /** Whether we're waiting for confirmation. */\n isConfirming: boolean\n /** Whether the transaction is confirmed. */\n isConfirmed: boolean\n /** Error from the transaction, if any. */\n error: Error | null\n /** Reset the mutation state. */\n reset: () => void\n}\n\n/**\n * Write hook for minting UPD by depositing ETH.\n *\n * @example\n * ```tsx\n * const { mint, isPending, isConfirmed, error } = useMintUPD({\n * stabilizerNFTAddress: deployment.contracts.StabilizerNFT,\n * })\n *\n * // Use with useEthUsdPrice to get attestation\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => mint({ to: userAddress, ethAmount: parseEther('1'), attestation })}>\n * Mint UPD\n * </button>\n * ```\n */\nexport function useMintUPD(config: UseMintUPDConfig): UseMintUPDReturn {\n const { stabilizerNFTAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({\n hash: txHash,\n })\n\n function mint(params: {\n to: Address\n ethAmount: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'mintUPD',\n args: [\n params.to,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n value: params.ethAmount,\n })\n }\n\n return {\n mint,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseBurnUPDConfig {\n /** Address of the StabilizerNFT contract. */\n stabilizerNFTAddress: Address\n}\n\nexport interface UseBurnUPDReturn {\n /** Execute the burn transaction. */\n burn: (params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) => void\n /** Whether the transaction is being sent. */\n isPending: boolean\n /** Transaction hash once submitted. */\n txHash: Hash | undefined\n /** Whether we're waiting for confirmation. */\n isConfirming: boolean\n /** Whether the transaction is confirmed. */\n isConfirmed: boolean\n /** Error from the transaction, if any. */\n error: Error | null\n /** Reset the mutation state. */\n reset: () => void\n}\n\n/**\n * Write hook for burning UPD to receive stETH.\n *\n * @example\n * ```tsx\n * const { burn, isPending, isConfirmed } = useBurnUPD({\n * stabilizerNFTAddress: deployment.contracts.StabilizerNFT,\n * })\n *\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => burn({ updAmount: parseUnits('1000', 18), attestation })}>\n * Burn 1000 UPD\n * </button>\n * ```\n */\nexport function useBurnUPD(config: UseBurnUPDConfig): UseBurnUPDReturn {\n const { stabilizerNFTAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({\n hash: txHash,\n })\n\n function burn(params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'burnUPD',\n args: [\n params.updAmount,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n })\n }\n\n return {\n burn,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useMemo } from 'react'\nimport type { Address } from 'viem'\nimport { useCollateral, type UseCollateralConfig } from './use-collateral.js'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { computeSystemHealth, type SystemHealth } from '../core/health.js'\n\nexport interface UseSystemHealthConfig {\n /** Address of the OvercollateralizationReporter contract. */\n reporterAddress: Address\n /** Address of the UPD token. */\n tokenAddress: Address\n /** Oracle service URL. */\n oracleUrl?: string\n /** Minimum collateral ratio in basis points (default: 12500 = 125%). */\n minRatioBps?: bigint\n}\n\nexport interface UseSystemHealthReturn {\n /** Computed system health metrics, or undefined if still loading. */\n health: SystemHealth | undefined\n /** Whether any underlying data is still loading. */\n isLoading: boolean\n}\n\n/**\n * System health hook — composes useCollateral + useEthUsdPrice + computeSystemHealth.\n *\n * @example\n * ```tsx\n * const { health, isLoading } = useSystemHealth({\n * reporterAddress: deployment.contracts.OvercollateralizationReporter,\n * tokenAddress: deployment.contracts.UPDToken,\n * })\n *\n * if (health && !health.isHealthy) {\n * return <Alert>System undercollateralized: {health.systemCollateralRatioBps} bps</Alert>\n * }\n * ```\n */\nexport function useSystemHealth(config: UseSystemHealthConfig): UseSystemHealthReturn {\n const collateralConfig: UseCollateralConfig = {\n reporterAddress: config.reporterAddress,\n tokenAddress: config.tokenAddress,\n }\n\n const priceConfig: UseEthUsdPriceConfig = {\n oracleUrl: config.oracleUrl,\n }\n\n const {\n totalStEthCollateral,\n totalUPDSupply,\n isLoading: collateralLoading,\n } = useCollateral(collateralConfig)\n\n const {\n price: ethUsdPrice,\n isLoading: priceLoading,\n } = useEthUsdPrice(priceConfig)\n\n const health = useMemo(() => {\n if (\n totalStEthCollateral === undefined ||\n totalUPDSupply === undefined ||\n ethUsdPrice === undefined\n ) {\n return undefined\n }\n\n return computeSystemHealth(\n { totalStEthCollateral, totalUPDSupply },\n ethUsdPrice,\n config.minRatioBps,\n )\n }, [totalStEthCollateral, totalUPDSupply, ethUsdPrice, config.minRatioBps])\n\n return {\n health,\n isLoading: collateralLoading || priceLoading,\n }\n}\n","import { useReadContract } from 'wagmi'\nimport type { Address } from 'viem'\nimport { SUPD_ABI } from '../contracts/index.js'\n\nexport interface UseSUPDConfig {\n /** Address of the sUPD contract. */\n supdAddress: Address\n /** User address to read balance for (optional). */\n userAddress?: Address\n}\n\nexport interface UseSUPDReturn {\n /** User's sUPD balance (18 decimals). */\n balance: bigint | undefined\n /** Total sUPD shares outstanding. */\n totalSupply: bigint | undefined\n /** Current share value with accrued yield (18 decimals). */\n shareValue: bigint | undefined\n /** Annual yield in basis points (e.g. 800 = 8%). */\n annualYieldBps: bigint | undefined\n /** Total USD liability of all outstanding sUPD. */\n totalLiabilityUSD: bigint | undefined\n /** Whether any read is still loading. */\n isLoading: boolean\n}\n\n/**\n * Read hook for sUPD — share value, APY, balances, and total liability.\n *\n * @example\n * ```tsx\n * const { balance, shareValue, annualYieldBps, isLoading } = useSUPD({\n * supdAddress: deployment.contracts.sUPD,\n * userAddress: account.address,\n * })\n * ```\n */\nexport function useSUPD(config: UseSUPDConfig): UseSUPDReturn {\n const { supdAddress, userAddress } = config\n\n const { data: balance, isLoading: balLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'balanceOf',\n args: userAddress ? [userAddress] : undefined,\n query: { enabled: !!userAddress },\n })\n\n const { data: totalSupply, isLoading: supplyLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'totalSupply',\n })\n\n const { data: shareValue, isLoading: svLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'currentShareValue',\n })\n\n const { data: annualYieldBps, isLoading: apyLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'annualYieldBps',\n })\n\n const { data: totalLiabilityUSD, isLoading: liabLoading } = useReadContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'totalLiabilityUSD',\n })\n\n return {\n balance: balance as bigint | undefined,\n totalSupply: totalSupply as bigint | undefined,\n shareValue: shareValue as bigint | undefined,\n annualYieldBps: annualYieldBps as bigint | undefined,\n totalLiabilityUSD: totalLiabilityUSD as bigint | undefined,\n isLoading: balLoading || supplyLoading || svLoading || apyLoading || liabLoading,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { SUPD_ABI } from '../contracts/index.js'\n\nexport interface UseStakeUPDConfig {\n /** Address of the sUPD contract. */\n supdAddress: Address\n}\n\nexport interface UseStakeUPDReturn {\n /** Execute the stake transaction. User must approve UPD transfer to sUPD first. */\n stake: (params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) => void\n isPending: boolean\n txHash: Hash | undefined\n isConfirming: boolean\n isConfirmed: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Write hook for staking UPD → sUPD.\n *\n * Note: The user must first approve the sUPD contract to spend their UPD tokens\n * (via UPDToken.approve or EIP-3009 transferWithAuthorization).\n *\n * @example\n * ```tsx\n * const { stake, isPending } = useStakeUPD({\n * supdAddress: deployment.contracts.sUPD,\n * })\n *\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => stake({ updAmount: parseUnits('1000', 18), attestation })}>\n * Stake 1000 UPD\n * </button>\n * ```\n */\nexport function useStakeUPD(config: UseStakeUPDConfig): UseStakeUPDReturn {\n const { supdAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({ hash: txHash })\n\n function stake(params: {\n updAmount: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'stakeUPD',\n args: [\n params.updAmount,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n })\n }\n\n return {\n stake,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport type { PriceAttestationQuery } from '../core/types.js'\nimport { SUPD_ABI } from '../contracts/index.js'\n\nexport interface UseUnstakeUPDConfig {\n /** Address of the sUPD contract. */\n supdAddress: Address\n}\n\nexport interface UseUnstakeUPDReturn {\n /** Execute the unstake transaction (unstakeToUPD — full redemption). */\n unstake: (params: {\n shares: bigint\n attestation: PriceAttestationQuery\n }) => void\n isPending: boolean\n txHash: Hash | undefined\n isConfirming: boolean\n isConfirmed: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Write hook for unstaking sUPD → UPD.\n *\n * Calls `unstakeToUPD(shares, priceQuery)` which gathers stETH from sUPD's\n * stabilizer escrows and mints fresh UPD to the caller.\n *\n * For advanced unstake variants (pro-rata, queued, with-extra-UPD), use the\n * contract ABI directly.\n *\n * @example\n * ```tsx\n * const { unstake, isPending } = useUnstakeUPD({\n * supdAddress: deployment.contracts.sUPD,\n * })\n *\n * const { attestation } = useEthUsdPrice()\n *\n * <button onClick={() => unstake({ shares: myShares, attestation })}>\n * Unstake\n * </button>\n * ```\n */\nexport function useUnstakeUPD(config: UseUnstakeUPDConfig): UseUnstakeUPDReturn {\n const { supdAddress } = config\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({ hash: txHash })\n\n function unstake(params: {\n shares: bigint\n attestation: PriceAttestationQuery\n }) {\n writeContract({\n address: supdAddress,\n abi: SUPD_ABI,\n functionName: 'unstakeToUPD',\n args: [\n params.shares,\n {\n price: params.attestation.price,\n decimals: params.attestation.decimals,\n dataTimestamp: params.attestation.dataTimestamp,\n assetPair: params.attestation.assetPair,\n signature: params.attestation.signature,\n },\n ],\n })\n }\n\n return {\n unstake,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: writeError as Error | null,\n reset,\n }\n}\n","import { useMemo } from 'react'\nimport { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Address, Hash } from 'viem'\nimport { getDeployment } from '../deployments/index.js'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { quoteMintUPD } from '../core/quote.js'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseSwapEthToUPDConfig {\n /** Chain ID — contract addresses resolved automatically from deployment config. */\n chainId: number\n /** Oracle configuration (optional). */\n oracle?: UseEthUsdPriceConfig\n}\n\nexport interface UseSwapEthToUPDReturn {\n /** Compute expected UPD amount for a given ETH input. */\n quote: (ethAmount: bigint) => bigint | undefined\n /** Execute the mint: sends ETH, receives UPD. Oracle attestation handled internally. */\n mint: (params: { to: Address; ethAmount: bigint }) => void\n /** Current ETH/USD price (18 decimals). */\n price: bigint | undefined\n /** Formatted price string (e.g. \"$2,000.00\"). */\n priceFormatted: string\n /** Whether the oracle price is still loading. */\n priceLoading: boolean\n /** Whether the mint transaction is pending. */\n isPending: boolean\n /** Transaction hash once submitted. */\n txHash: Hash | undefined\n /** Whether we're waiting for on-chain confirmation. */\n isConfirming: boolean\n /** Whether the transaction is confirmed. */\n isConfirmed: boolean\n /** Error from oracle or transaction. */\n error: Error | null\n /** Reset the transaction state. */\n reset: () => void\n /** Whether the hook is ready (deployment exists + oracle loaded). */\n isReady: boolean\n}\n\n/**\n * One-stop hook for swapping ETH → UPD.\n *\n * Internally composes oracle price feed, quote computation, and StabilizerNFT.mintUPD.\n * Contract addresses are resolved from the deployment config — no manual wiring needed.\n *\n * @example\n * ```tsx\n * const { quote, mint, price, priceFormatted, isPending, isConfirmed } = useSwapEthToUPD({\n * chainId: 11155111,\n * })\n *\n * const expectedUPD = quote(parseEther('1'))\n *\n * <button onClick={() => mint({ to: address, ethAmount: parseEther('1') })}>\n * Mint {expectedUPD ? formatUnits(expectedUPD, 18) : '...'} UPD\n * </button>\n * ```\n */\nexport function useSwapEthToUPD(config: UseSwapEthToUPDConfig): UseSwapEthToUPDReturn {\n const deployment = getDeployment(config.chainId)\n const stabilizerNFTAddress = deployment?.contracts.StabilizerNFT\n\n const {\n price,\n priceFormatted,\n attestation,\n isLoading: priceLoading,\n error: priceError,\n } = useEthUsdPrice(config.oracle)\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({ hash: txHash })\n\n const quote = useMemo(() => {\n return (ethAmount: bigint): bigint | undefined => {\n if (price === undefined || ethAmount === 0n) return undefined\n return quoteMintUPD(ethAmount, price)\n }\n }, [price])\n\n function mint(params: { to: Address; ethAmount: bigint }) {\n if (!stabilizerNFTAddress || !attestation) return\n writeContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'mintUPD',\n args: [\n params.to,\n {\n price: attestation.price,\n decimals: attestation.decimals,\n dataTimestamp: attestation.dataTimestamp,\n assetPair: attestation.assetPair,\n signature: attestation.signature,\n },\n ],\n value: params.ethAmount,\n })\n }\n\n return {\n quote,\n mint,\n price,\n priceFormatted,\n priceLoading,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: (writeError ?? priceError) as Error | null,\n reset,\n isReady: !!stabilizerNFTAddress && !!attestation,\n }\n}\n","import { useMemo } from 'react'\nimport { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'\nimport type { Hash } from 'viem'\nimport { getDeployment } from '../deployments/index.js'\nimport { useEthUsdPrice, type UseEthUsdPriceConfig } from './use-eth-usd-price.js'\nimport { quoteBurnUPD } from '../core/quote.js'\nimport { STABILIZER_NFT_ABI } from '../contracts/index.js'\n\nexport interface UseSwapUPDToStETHConfig {\n /** Chain ID — contract addresses resolved automatically from deployment config. */\n chainId: number\n /** Oracle configuration (optional). */\n oracle?: UseEthUsdPriceConfig\n}\n\nexport interface UseSwapUPDToStETHReturn {\n /** Compute expected stETH amount for a given UPD input. */\n quote: (updAmount: bigint) => bigint | undefined\n /** Execute the burn: sends UPD, receives stETH. Oracle attestation handled internally. */\n burn: (params: { updAmount: bigint }) => void\n /** Current ETH/USD price (18 decimals). */\n price: bigint | undefined\n /** Formatted price string (e.g. \"$2,000.00\"). */\n priceFormatted: string\n /** Whether the oracle price is still loading. */\n priceLoading: boolean\n /** Whether the burn transaction is pending. */\n isPending: boolean\n /** Transaction hash once submitted. */\n txHash: Hash | undefined\n /** Whether we're waiting for on-chain confirmation. */\n isConfirming: boolean\n /** Whether the transaction is confirmed. */\n isConfirmed: boolean\n /** Error from oracle or transaction. */\n error: Error | null\n /** Reset the transaction state. */\n reset: () => void\n /** Whether the hook is ready (deployment exists + oracle loaded). */\n isReady: boolean\n}\n\n/**\n * One-stop hook for swapping UPD → stETH (burn).\n *\n * Internally composes oracle price feed, quote computation, and StabilizerNFT.burnUPD.\n * Contract addresses are resolved from the deployment config — no manual wiring needed.\n *\n * @example\n * ```tsx\n * const { quote, burn, priceFormatted, isPending, isConfirmed } = useSwapUPDToStETH({\n * chainId: 11155111,\n * })\n *\n * const expectedStETH = quote(parseUnits('1000', 18))\n *\n * <button onClick={() => burn({ updAmount: parseUnits('1000', 18) })}>\n * Burn for {expectedStETH ? formatUnits(expectedStETH, 18) : '...'} stETH\n * </button>\n * ```\n */\nexport function useSwapUPDToStETH(config: UseSwapUPDToStETHConfig): UseSwapUPDToStETHReturn {\n const deployment = getDeployment(config.chainId)\n const stabilizerNFTAddress = deployment?.contracts.StabilizerNFT\n\n const {\n price,\n priceFormatted,\n attestation,\n isLoading: priceLoading,\n error: priceError,\n } = useEthUsdPrice(config.oracle)\n\n const {\n writeContract,\n data: txHash,\n isPending,\n error: writeError,\n reset,\n } = useWriteContract()\n\n const {\n isLoading: isConfirming,\n isSuccess: isConfirmed,\n } = useWaitForTransactionReceipt({ hash: txHash })\n\n const quote = useMemo(() => {\n return (updAmount: bigint): bigint | undefined => {\n if (price === undefined || updAmount === 0n) return undefined\n return quoteBurnUPD(updAmount, price)\n }\n }, [price])\n\n function burn(params: { updAmount: bigint }) {\n if (!stabilizerNFTAddress || !attestation) return\n writeContract({\n address: stabilizerNFTAddress,\n abi: STABILIZER_NFT_ABI,\n functionName: 'burnUPD',\n args: [\n params.updAmount,\n {\n price: attestation.price,\n decimals: attestation.decimals,\n dataTimestamp: attestation.dataTimestamp,\n assetPair: attestation.assetPair,\n signature: attestation.signature,\n },\n ],\n })\n }\n\n return {\n quote,\n burn,\n price,\n priceFormatted,\n priceLoading,\n isPending,\n txHash,\n isConfirming,\n isConfirmed,\n error: (writeError ?? priceError) as Error | null,\n reset,\n isReady: !!stabilizerNFTAddress && !!attestation,\n }\n}\n"]}
|
package/dist/react/index.d.cts
CHANGED
|
@@ -336,4 +336,115 @@ interface UseUnstakeUPDReturn {
|
|
|
336
336
|
*/
|
|
337
337
|
declare function useUnstakeUPD(config: UseUnstakeUPDConfig): UseUnstakeUPDReturn;
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
interface UseSwapEthToUPDConfig {
|
|
340
|
+
/** Chain ID — contract addresses resolved automatically from deployment config. */
|
|
341
|
+
chainId: number;
|
|
342
|
+
/** Oracle configuration (optional). */
|
|
343
|
+
oracle?: UseEthUsdPriceConfig;
|
|
344
|
+
}
|
|
345
|
+
interface UseSwapEthToUPDReturn {
|
|
346
|
+
/** Compute expected UPD amount for a given ETH input. */
|
|
347
|
+
quote: (ethAmount: bigint) => bigint | undefined;
|
|
348
|
+
/** Execute the mint: sends ETH, receives UPD. Oracle attestation handled internally. */
|
|
349
|
+
mint: (params: {
|
|
350
|
+
to: Address;
|
|
351
|
+
ethAmount: bigint;
|
|
352
|
+
}) => void;
|
|
353
|
+
/** Current ETH/USD price (18 decimals). */
|
|
354
|
+
price: bigint | undefined;
|
|
355
|
+
/** Formatted price string (e.g. "$2,000.00"). */
|
|
356
|
+
priceFormatted: string;
|
|
357
|
+
/** Whether the oracle price is still loading. */
|
|
358
|
+
priceLoading: boolean;
|
|
359
|
+
/** Whether the mint transaction is pending. */
|
|
360
|
+
isPending: boolean;
|
|
361
|
+
/** Transaction hash once submitted. */
|
|
362
|
+
txHash: Hash | undefined;
|
|
363
|
+
/** Whether we're waiting for on-chain confirmation. */
|
|
364
|
+
isConfirming: boolean;
|
|
365
|
+
/** Whether the transaction is confirmed. */
|
|
366
|
+
isConfirmed: boolean;
|
|
367
|
+
/** Error from oracle or transaction. */
|
|
368
|
+
error: Error | null;
|
|
369
|
+
/** Reset the transaction state. */
|
|
370
|
+
reset: () => void;
|
|
371
|
+
/** Whether the hook is ready (deployment exists + oracle loaded). */
|
|
372
|
+
isReady: boolean;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* One-stop hook for swapping ETH → UPD.
|
|
376
|
+
*
|
|
377
|
+
* Internally composes oracle price feed, quote computation, and StabilizerNFT.mintUPD.
|
|
378
|
+
* Contract addresses are resolved from the deployment config — no manual wiring needed.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```tsx
|
|
382
|
+
* const { quote, mint, price, priceFormatted, isPending, isConfirmed } = useSwapEthToUPD({
|
|
383
|
+
* chainId: 11155111,
|
|
384
|
+
* })
|
|
385
|
+
*
|
|
386
|
+
* const expectedUPD = quote(parseEther('1'))
|
|
387
|
+
*
|
|
388
|
+
* <button onClick={() => mint({ to: address, ethAmount: parseEther('1') })}>
|
|
389
|
+
* Mint {expectedUPD ? formatUnits(expectedUPD, 18) : '...'} UPD
|
|
390
|
+
* </button>
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
declare function useSwapEthToUPD(config: UseSwapEthToUPDConfig): UseSwapEthToUPDReturn;
|
|
394
|
+
|
|
395
|
+
interface UseSwapUPDToStETHConfig {
|
|
396
|
+
/** Chain ID — contract addresses resolved automatically from deployment config. */
|
|
397
|
+
chainId: number;
|
|
398
|
+
/** Oracle configuration (optional). */
|
|
399
|
+
oracle?: UseEthUsdPriceConfig;
|
|
400
|
+
}
|
|
401
|
+
interface UseSwapUPDToStETHReturn {
|
|
402
|
+
/** Compute expected stETH amount for a given UPD input. */
|
|
403
|
+
quote: (updAmount: bigint) => bigint | undefined;
|
|
404
|
+
/** Execute the burn: sends UPD, receives stETH. Oracle attestation handled internally. */
|
|
405
|
+
burn: (params: {
|
|
406
|
+
updAmount: bigint;
|
|
407
|
+
}) => void;
|
|
408
|
+
/** Current ETH/USD price (18 decimals). */
|
|
409
|
+
price: bigint | undefined;
|
|
410
|
+
/** Formatted price string (e.g. "$2,000.00"). */
|
|
411
|
+
priceFormatted: string;
|
|
412
|
+
/** Whether the oracle price is still loading. */
|
|
413
|
+
priceLoading: boolean;
|
|
414
|
+
/** Whether the burn transaction is pending. */
|
|
415
|
+
isPending: boolean;
|
|
416
|
+
/** Transaction hash once submitted. */
|
|
417
|
+
txHash: Hash | undefined;
|
|
418
|
+
/** Whether we're waiting for on-chain confirmation. */
|
|
419
|
+
isConfirming: boolean;
|
|
420
|
+
/** Whether the transaction is confirmed. */
|
|
421
|
+
isConfirmed: boolean;
|
|
422
|
+
/** Error from oracle or transaction. */
|
|
423
|
+
error: Error | null;
|
|
424
|
+
/** Reset the transaction state. */
|
|
425
|
+
reset: () => void;
|
|
426
|
+
/** Whether the hook is ready (deployment exists + oracle loaded). */
|
|
427
|
+
isReady: boolean;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* One-stop hook for swapping UPD → stETH (burn).
|
|
431
|
+
*
|
|
432
|
+
* Internally composes oracle price feed, quote computation, and StabilizerNFT.burnUPD.
|
|
433
|
+
* Contract addresses are resolved from the deployment config — no manual wiring needed.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```tsx
|
|
437
|
+
* const { quote, burn, priceFormatted, isPending, isConfirmed } = useSwapUPDToStETH({
|
|
438
|
+
* chainId: 11155111,
|
|
439
|
+
* })
|
|
440
|
+
*
|
|
441
|
+
* const expectedStETH = quote(parseUnits('1000', 18))
|
|
442
|
+
*
|
|
443
|
+
* <button onClick={() => burn({ updAmount: parseUnits('1000', 18) })}>
|
|
444
|
+
* Burn for {expectedStETH ? formatUnits(expectedStETH, 18) : '...'} stETH
|
|
445
|
+
* </button>
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
declare function useSwapUPDToStETH(config: UseSwapUPDToStETHConfig): UseSwapUPDToStETHReturn;
|
|
449
|
+
|
|
450
|
+
export { type UseBurnQuoteConfig, type UseBurnQuoteReturn, type UseBurnUPDConfig, type UseBurnUPDReturn, type UseCollateralConfig, type UseCollateralReturn, type UseEthUsdPriceConfig, type UseEthUsdPriceReturn, type UseMintQuoteConfig, type UseMintQuoteReturn, type UseMintUPDConfig, type UseMintUPDReturn, type UseSUPDConfig, type UseSUPDReturn, type UseStabilizerConfig, type UseStabilizerReturn, type UseStakeUPDConfig, type UseStakeUPDReturn, type UseSwapEthToUPDConfig, type UseSwapEthToUPDReturn, type UseSwapUPDToStETHConfig, type UseSwapUPDToStETHReturn, type UseSystemHealthConfig, type UseSystemHealthReturn, type UseUPDConfig, type UseUPDReturn, type UseUnstakeUPDConfig, type UseUnstakeUPDReturn, useBurnQuote, useBurnUPD, useCollateral, useEthUsdPrice, useMintQuote, useMintUPD, useSUPD, useStabilizer, useStakeUPD, useSwapEthToUPD, useSwapUPDToStETH, useSystemHealth, useUPD, useUnstakeUPD };
|