@huma-finance/widgets 0.0.80-beta.1081 → 0.0.80-beta.1085
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/API.md +39 -0
- package/dist/index.js +256 -61
- package/dist/src/components/Lend/stellarWithdraw/1-Confirm.d.ts +9 -0
- package/dist/src/components/Lend/stellarWithdraw/2-Transfer.d.ts +9 -0
- package/dist/src/components/Lend/stellarWithdraw/3-Done.d.ts +11 -0
- package/dist/src/components/Lend/stellarWithdraw/index.d.ts +19 -0
- package/dist/src/index.d.ts +12 -0
- package/package.json +5 -5
- package/src/components/Lend/stellarWithdraw/1-Confirm.tsx +60 -0
- package/src/components/Lend/stellarWithdraw/2-Transfer.tsx +67 -0
- package/src/components/Lend/stellarWithdraw/3-Done.tsx +38 -0
- package/src/components/Lend/stellarWithdraw/index.tsx +170 -0
- package/src/index.tsx +26 -0
package/API.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
<dl>
|
|
4
4
|
<dt><a href="#StellarLendAddRedemption">StellarLendAddRedemption()</a></dt>
|
|
5
5
|
<dd><p>Stellar add redemption props – request to withdraw (redeem) shares from a tranche.</p></dd>
|
|
6
|
+
<dt><a href="#StellarLendWithdraw">StellarLendWithdraw()</a></dt>
|
|
7
|
+
<dd><p>Stellar lend pool withdraw props – disburse (pool open) or withdraw after pool closure.</p></dd>
|
|
6
8
|
<dt><a href="#InvoiceFactoringBorrowWidget">InvoiceFactoringBorrowWidget(props)</a> ⇒</dt>
|
|
7
9
|
<dd><p>Invoice factoring borrow widget</p></dd>
|
|
8
10
|
<dt><a href="#InvoiceFactoringPaymentWidget">InvoiceFactoringPaymentWidget(props)</a> ⇒</dt>
|
|
@@ -56,6 +58,8 @@ To be used when re-enabling autopay and other pool actions that require allowanc
|
|
|
56
58
|
<dd><p>Lend pool supply widget for Stellar pools</p></dd>
|
|
57
59
|
<dt><a href="#StellarLendAddRedemptionWidget">StellarLendAddRedemptionWidget(props)</a></dt>
|
|
58
60
|
<dd><p>Lend pool add redemption widget for Stellar pools</p></dd>
|
|
61
|
+
<dt><a href="#StellarLendWithdrawWidget">StellarLendWithdrawWidget(props)</a></dt>
|
|
62
|
+
<dd><p>Lend pool withdraw widget for Stellar pools (disburse when pool open, withdraw_after_pool_closure when closed)</p></dd>
|
|
59
63
|
<dt><a href="#StellarBorrowWidget">StellarBorrowWidget(props)</a></dt>
|
|
60
64
|
<dd><p>Borrow widget for Stellar pools</p></dd>
|
|
61
65
|
<dt><a href="#SolanaEnableAutoRedemptionWidget">SolanaEnableAutoRedemptionWidget(props)</a></dt>
|
|
@@ -171,6 +175,8 @@ To be used when re-enabling autopay and other pool actions that require allowanc
|
|
|
171
175
|
<dd><p>Lend pool supply widget props for Stellar pools</p></dd>
|
|
172
176
|
<dt><a href="#StellarLendAddRedemptionWidgetProps">StellarLendAddRedemptionWidgetProps</a> : <code>Object</code></dt>
|
|
173
177
|
<dd><p>Lend pool add redemption widget props for Stellar pools</p></dd>
|
|
178
|
+
<dt><a href="#StellarLendWithdrawWidgetProps">StellarLendWithdrawWidgetProps</a> : <code>Object</code></dt>
|
|
179
|
+
<dd><p>Lend pool withdraw widget props for Stellar pools</p></dd>
|
|
174
180
|
<dt><a href="#StellarLendSupplyWidgetProps">StellarLendSupplyWidgetProps</a> : <code>Object</code></dt>
|
|
175
181
|
<dd><p>Borrow widget props for Stellar pools</p></dd>
|
|
176
182
|
<dt><a href="#SolanaEnableAutoRedemptionWidgetProps">SolanaEnableAutoRedemptionWidgetProps</a> : <code>Object</code></dt>
|
|
@@ -193,6 +199,22 @@ To be used when re-enabling autopay and other pool actions that require allowanc
|
|
|
193
199
|
| handleClose | <code>function</code> | <p>Function to close the widget modal.</p> |
|
|
194
200
|
| handleSuccess | <code>function</code> | <p>Optional callback when redemption request succeeds.</p> |
|
|
195
201
|
|
|
202
|
+
<a name="StellarLendWithdraw"></a>
|
|
203
|
+
|
|
204
|
+
## StellarLendWithdraw()
|
|
205
|
+
<p>Stellar lend pool withdraw props – disburse (pool open) or withdraw after pool closure.</p>
|
|
206
|
+
|
|
207
|
+
**Kind**: global function
|
|
208
|
+
**Properties**
|
|
209
|
+
|
|
210
|
+
| Name | Type | Description |
|
|
211
|
+
| --- | --- | --- |
|
|
212
|
+
| poolInfo | <code>StellarPoolInfo</code> | <p>The metadata of the pool.</p> |
|
|
213
|
+
| poolState | <code>StellarPoolState</code> | <p>The current state config of the pool.</p> |
|
|
214
|
+
| tranche | <code>TrancheType</code> | <p>The tranche to withdraw from (junior or senior).</p> |
|
|
215
|
+
| handleClose | <code>function</code> | <p>Function to close the widget modal.</p> |
|
|
216
|
+
| handleSuccess | <code>function</code> | <p>Optional callback when withdraw succeeds.</p> |
|
|
217
|
+
|
|
196
218
|
<a name="InvoiceFactoringBorrowWidget"></a>
|
|
197
219
|
|
|
198
220
|
## InvoiceFactoringBorrowWidget(props) ⇒
|
|
@@ -499,6 +521,17 @@ To be used when re-enabling autopay and other pool actions that require allowanc
|
|
|
499
521
|
| --- | --- | --- |
|
|
500
522
|
| props | [<code>StellarLendAddRedemptionWidgetProps</code>](#StellarLendAddRedemptionWidgetProps) | <p>Widget props</p> |
|
|
501
523
|
|
|
524
|
+
<a name="StellarLendWithdrawWidget"></a>
|
|
525
|
+
|
|
526
|
+
## StellarLendWithdrawWidget(props)
|
|
527
|
+
<p>Lend pool withdraw widget for Stellar pools (disburse when pool open, withdraw_after_pool_closure when closed)</p>
|
|
528
|
+
|
|
529
|
+
**Kind**: global function
|
|
530
|
+
|
|
531
|
+
| Param | Type | Description |
|
|
532
|
+
| --- | --- | --- |
|
|
533
|
+
| props | [<code>StellarLendWithdrawWidgetProps</code>](#StellarLendWithdrawWidgetProps) | <p>Widget props</p> |
|
|
534
|
+
|
|
502
535
|
<a name="StellarBorrowWidget"></a>
|
|
503
536
|
|
|
504
537
|
## StellarBorrowWidget(props)
|
|
@@ -1213,6 +1246,12 @@ To be used when re-enabling autopay and other pool actions that require allowanc
|
|
|
1213
1246
|
## StellarLendAddRedemptionWidgetProps : <code>Object</code>
|
|
1214
1247
|
<p>Lend pool add redemption widget props for Stellar pools</p>
|
|
1215
1248
|
|
|
1249
|
+
**Kind**: global typedef
|
|
1250
|
+
<a name="StellarLendWithdrawWidgetProps"></a>
|
|
1251
|
+
|
|
1252
|
+
## StellarLendWithdrawWidgetProps : <code>Object</code>
|
|
1253
|
+
<p>Lend pool withdraw widget props for Stellar pools</p>
|
|
1254
|
+
|
|
1216
1255
|
**Kind**: global typedef
|
|
1217
1256
|
<a name="StellarLendSupplyWidgetProps"></a>
|
|
1218
1257
|
|
package/dist/index.js
CHANGED
|
@@ -71973,14 +71973,14 @@ const STELLAR_MAINNET_METADATA = {
|
|
|
71973
71973
|
chainId: StellarChainEnum.StellarTestnet,
|
|
71974
71974
|
industry: "Remittance Financing",
|
|
71975
71975
|
desc: "",
|
|
71976
|
-
poolStorage: "
|
|
71977
|
-
pool: "
|
|
71978
|
-
poolManager: "
|
|
71979
|
-
poolCredit: "
|
|
71980
|
-
creditManager: "
|
|
71981
|
-
creditStorage: "
|
|
71982
|
-
juniorTranche: "
|
|
71983
|
-
seniorTranche: "
|
|
71976
|
+
poolStorage: "CDH36NMUGJOJRKAEXCBS4CCJ4CQPIRBJY6ZLT426RWC6DWTRNXBECUTN",
|
|
71977
|
+
pool: "CDREMNHXG3UJEKTARVE3G3BPOM3Y5U65T6NYYYWAYM6BSHGXNUQW6TTY",
|
|
71978
|
+
poolManager: "CCNKUA62K3T4FQTFOGOVHZNS7UJ36UWYHS727TYSKSWTJ3LVZJOBFMVL",
|
|
71979
|
+
poolCredit: "CBTYMYCPN5P4ISEU47BWGZ5XATA4NKK3MEBB2S65SAKDIVSXUNGTHSBG",
|
|
71980
|
+
creditManager: "CB7RBNZ5EU6AYDTCURUAUQJIYUYTNOL4GLRBSDDZEAPI4NFGI6QQ3NL5",
|
|
71981
|
+
creditStorage: "CAEWZBNLBAJA7NLLKK237RWKI5RY6EO3GH2E2NPSAJRO3F2VBV6S3SFJ",
|
|
71982
|
+
juniorTranche: "CAZ6A7CIXW54JDT4VBASKJIEKMT4KTRGIB5AREWIVNSW2REAJOGP6PN5",
|
|
71983
|
+
seniorTranche: "CCBGPAVIG3ERMNKHF2SD3QPCRNUIRJVLJ577DHSYYGQL764TFG5UMCS6",
|
|
71984
71984
|
trancheDecimals: 6,
|
|
71985
71985
|
underlyingToken: {
|
|
71986
71986
|
address: "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA",
|
|
@@ -71997,7 +71997,7 @@ StellarChainEnum.StellarTestnet + "", StellarChainEnum.StellarMainnet + "";
|
|
|
71997
71997
|
const STELLAR_CHAINS_INFO = {
|
|
71998
71998
|
[StellarChainEnum.StellarTestnet]: {
|
|
71999
71999
|
rpc: "https://soroban-testnet.stellar.org",
|
|
72000
|
-
humaConfig: "
|
|
72000
|
+
humaConfig: "CDFM2ITMGBNOEVZ5LYOLOIRFYZ74M3EP2SD2KT36XESTBML4APJIW5KO",
|
|
72001
72001
|
networkPassphrase: "Test SDF Network ; September 2015"
|
|
72002
72002
|
},
|
|
72003
72003
|
[StellarChainEnum.StellarMainnet]: {
|
|
@@ -117062,7 +117062,7 @@ function TxSendModal({
|
|
|
117062
117062
|
}
|
|
117063
117063
|
);
|
|
117064
117064
|
}
|
|
117065
|
-
function Transfer$
|
|
117065
|
+
function Transfer$q({ poolInfo: ar }) {
|
|
117066
117066
|
const or = useAppDispatch(), ur = useResetAtom(txAtom), { borrowAmountBN: cr } = useAppSelector(selectWidgetState), fr = BigNumber$1.from(cr), lr = useCallback(() => {
|
|
117067
117067
|
ur();
|
|
117068
117068
|
const dr = WIDGET_STEP.Done;
|
|
@@ -144794,7 +144794,7 @@ function CreditLineBorrow({
|
|
|
144794
144794
|
Sr === WIDGET_STEP.Evaluation && /* @__PURE__ */ jsx(Evaluation$5, { poolInfo: yr, handleApprove: Qr }),
|
|
144795
144795
|
Sr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(ChooseAmount$j, { poolInfo: yr, accountStats: xr }),
|
|
144796
144796
|
Sr === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$d, { poolInfo: yr }),
|
|
144797
|
-
Sr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
144797
|
+
Sr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$q, { poolInfo: yr }),
|
|
144798
144798
|
Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
144799
144799
|
Success$g,
|
|
144800
144800
|
{
|
|
@@ -145544,7 +145544,7 @@ function TxSendModalV2({
|
|
|
145544
145544
|
}
|
|
145545
145545
|
);
|
|
145546
145546
|
}
|
|
145547
|
-
function Transfer$
|
|
145547
|
+
function Transfer$p({ poolInfo: ar }) {
|
|
145548
145548
|
const or = useAppDispatch(), { provider: ur, account: cr } = distExports$5.useWeb3React(), fr = useResetAtom(txAtom), { borrowAmountBN: lr } = useAppSelector(selectWidgetState), dr = BigNumber$1.from(lr), pr = useCreditContractV2(
|
|
145549
145549
|
ar.poolName,
|
|
145550
145550
|
ur,
|
|
@@ -145638,7 +145638,7 @@ function CreditLineBorrowV2({
|
|
|
145638
145638
|
poolUnderlyingToken: Ar
|
|
145639
145639
|
}
|
|
145640
145640
|
),
|
|
145641
|
-
gr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
145641
|
+
gr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$p, { poolInfo: hr }),
|
|
145642
145642
|
gr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
145643
145643
|
Success$f,
|
|
145644
145644
|
{
|
|
@@ -145706,7 +145706,7 @@ function ApproveAllowance$b({ poolInfo: ar }) {
|
|
|
145706
145706
|
}, [or]);
|
|
145707
145707
|
return /* @__PURE__ */ jsx(ApproveAllowanceModal, { poolInfo: ar, handleSuccess: ur });
|
|
145708
145708
|
}
|
|
145709
|
-
function Transfer$
|
|
145709
|
+
function Transfer$o({ poolInfo: ar }) {
|
|
145710
145710
|
const or = useAppDispatch(), { account: ur } = distExports$5.useWeb3React(), { paymentAmount: cr } = useAppSelector(selectWidgetState), { decimals: fr } = ar.poolUnderlyingToken, lr = upScale(
|
|
145711
145711
|
toBigNumber(cr),
|
|
145712
145712
|
fr
|
|
@@ -145772,7 +145772,7 @@ function CreditLinePayment({
|
|
|
145772
145772
|
}
|
|
145773
145773
|
),
|
|
145774
145774
|
yr === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$b, { poolInfo: gr }),
|
|
145775
|
-
yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
145775
|
+
yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$o, { poolInfo: gr }),
|
|
145776
145776
|
yr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Success$e, { poolInfo: gr, handleAction: ur }),
|
|
145777
145777
|
yr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
145778
145778
|
ErrorModal,
|
|
@@ -145849,7 +145849,7 @@ function ApproveAllowance$a({
|
|
|
145849
145849
|
}
|
|
145850
145850
|
);
|
|
145851
145851
|
}
|
|
145852
|
-
function Transfer$
|
|
145852
|
+
function Transfer$n({
|
|
145853
145853
|
poolInfo: ar,
|
|
145854
145854
|
poolUnderlyingToken: or
|
|
145855
145855
|
}) {
|
|
@@ -145937,7 +145937,7 @@ function CreditLinePaymentV2({
|
|
|
145937
145937
|
}
|
|
145938
145938
|
),
|
|
145939
145939
|
Ar === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(
|
|
145940
|
-
Transfer$
|
|
145940
|
+
Transfer$n,
|
|
145941
145941
|
{
|
|
145942
145942
|
poolInfo: hr,
|
|
145943
145943
|
poolUnderlyingToken: xr
|
|
@@ -178669,7 +178669,7 @@ function SolanaTxSendModal({
|
|
|
178669
178669
|
}
|
|
178670
178670
|
);
|
|
178671
178671
|
}
|
|
178672
|
-
function Transfer$
|
|
178672
|
+
function Transfer$m({ poolInfo: ar }) {
|
|
178673
178673
|
const or = useAppDispatch(), { wallet: ur, publicKey: cr } = useWallet(), fr = getSentinelAddress(ar.chainId), { connection: lr } = useConnection(), [dr, pr] = useState(), hr = useHumaProgram(ar.chainId), { borrowAmountBN: Ar } = useAppSelector(selectWidgetState), gr = useCallback(() => {
|
|
178674
178674
|
or(setStep(WIDGET_STEP.Done));
|
|
178675
178675
|
}, [or]);
|
|
@@ -178835,7 +178835,7 @@ function SolanaTxDoneModal({
|
|
|
178835
178835
|
] })
|
|
178836
178836
|
] });
|
|
178837
178837
|
}
|
|
178838
|
-
function Done$
|
|
178838
|
+
function Done$9({
|
|
178839
178839
|
poolInfo: ar,
|
|
178840
178840
|
poolState: or,
|
|
178841
178841
|
handleAction: ur
|
|
@@ -178905,9 +178905,9 @@ function SolanaBorrow({
|
|
|
178905
178905
|
creditConfigAccount: hr
|
|
178906
178906
|
}
|
|
178907
178907
|
),
|
|
178908
|
-
dr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
178908
|
+
dr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$m, { poolInfo: ar }),
|
|
178909
178909
|
dr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
178910
|
-
Done$
|
|
178910
|
+
Done$9,
|
|
178911
178911
|
{
|
|
178912
178912
|
poolInfo: ar,
|
|
178913
178913
|
poolState: or,
|
|
@@ -178982,7 +178982,7 @@ function ChooseAmount$e({
|
|
|
178982
178982
|
}
|
|
178983
178983
|
);
|
|
178984
178984
|
}
|
|
178985
|
-
function Transfer$
|
|
178985
|
+
function Transfer$l({ poolInfo: ar }) {
|
|
178986
178986
|
const or = useAppDispatch(), { wallet: ur, publicKey: cr } = useWallet(), { connection: fr } = useConnection(), [lr, dr] = useState(), pr = useHumaProgram(ar.chainId), { paymentAmount: hr } = useAppSelector(selectWidgetState), { decimals: Ar } = ar.underlyingMint, gr = useCallback(() => {
|
|
178987
178987
|
or(setStep(WIDGET_STEP.Done));
|
|
178988
178988
|
}, [or]);
|
|
@@ -179032,7 +179032,7 @@ function Transfer$k({ poolInfo: ar }) {
|
|
|
179032
179032
|
}
|
|
179033
179033
|
);
|
|
179034
179034
|
}
|
|
179035
|
-
function Done$
|
|
179035
|
+
function Done$8({ poolInfo: ar, handleAction: or }) {
|
|
179036
179036
|
const { solanaSignature: ur } = useAppSelector(selectWidgetState), { symbol: cr } = ar.underlyingMint, { connection: fr } = useConnection(), [lr, dr] = useState(null);
|
|
179037
179037
|
useEffect(() => {
|
|
179038
179038
|
(async () => {
|
|
@@ -179083,8 +179083,8 @@ function SolanaPayment({
|
|
|
179083
179083
|
creditStateAccount: pr
|
|
179084
179084
|
}
|
|
179085
179085
|
),
|
|
179086
|
-
lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
179087
|
-
lr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$
|
|
179086
|
+
lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$l, { poolInfo: ar }),
|
|
179087
|
+
lr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$8, { poolInfo: ar, handleAction: or }),
|
|
179088
179088
|
lr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
179089
179089
|
SolanaErrorModal,
|
|
179090
179090
|
{
|
|
@@ -179137,7 +179137,7 @@ function Success$c({
|
|
|
179137
179137
|
];
|
|
179138
179138
|
return /* @__PURE__ */ jsx(TxDoneModal, { handleAction: ur, content: dr });
|
|
179139
179139
|
}
|
|
179140
|
-
function Transfer$
|
|
179140
|
+
function Transfer$k({
|
|
179141
179141
|
poolInfo: ar,
|
|
179142
179142
|
amountToDeposit: or,
|
|
179143
179143
|
title: ur
|
|
@@ -179205,7 +179205,7 @@ function SupplyFirstLossCover({
|
|
|
179205
179205
|
}
|
|
179206
179206
|
),
|
|
179207
179207
|
gr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(
|
|
179208
|
-
Transfer$
|
|
179208
|
+
Transfer$k,
|
|
179209
179209
|
{
|
|
179210
179210
|
poolInfo: hr,
|
|
179211
179211
|
amountToDeposit: xr,
|
|
@@ -179516,7 +179516,7 @@ function ApproveNFT({ poolInfo: ar, tokenId: or }) {
|
|
|
179516
179516
|
}
|
|
179517
179517
|
);
|
|
179518
179518
|
}
|
|
179519
|
-
function Transfer$
|
|
179519
|
+
function Transfer$j({ poolInfo: ar, tokenId: or }) {
|
|
179520
179520
|
const ur = useAppDispatch(), { decimals: cr } = ar.poolUnderlyingToken, { borrowAmount: fr } = useAppSelector(selectWidgetState), lr = toBigNumber(upScale(fr, cr)), dr = useCallback(() => {
|
|
179521
179521
|
ur(setStep(WIDGET_STEP.Done));
|
|
179522
179522
|
}, [ur]);
|
|
@@ -179565,7 +179565,7 @@ function InvoiceFactoringBorrow({
|
|
|
179565
179565
|
Sr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(ChooseAmount$d, { poolInfo: yr, accountStats: xr }),
|
|
179566
179566
|
Sr === WIDGET_STEP.ConfirmTransfer && /* @__PURE__ */ jsx(ConfirmTransfer$2, {}),
|
|
179567
179567
|
Sr === WIDGET_STEP.ApproveNFT && /* @__PURE__ */ jsx(ApproveNFT, { poolInfo: yr, tokenId: ur.toString() }),
|
|
179568
|
-
Sr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
179568
|
+
Sr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$j, { poolInfo: yr, tokenId: ur.toString() }),
|
|
179569
179569
|
Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Success$b, { handleAction: cr }),
|
|
179570
179570
|
Sr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
179571
179571
|
ErrorModal,
|
|
@@ -179623,7 +179623,7 @@ function ApproveAllowance$8({ poolInfo: ar }) {
|
|
|
179623
179623
|
}, [or]);
|
|
179624
179624
|
return /* @__PURE__ */ jsx(ApproveAllowanceModal, { poolInfo: ar, handleSuccess: ur });
|
|
179625
179625
|
}
|
|
179626
|
-
function Transfer$
|
|
179626
|
+
function Transfer$i({ poolInfo: ar }) {
|
|
179627
179627
|
const or = useAppDispatch(), { account: ur } = distExports$5.useWeb3React(), { decimals: cr } = ar.poolUnderlyingToken, { paymentAmount: fr } = useAppSelector(selectWidgetState), lr = toBigNumber(upScale(fr, cr)), dr = useCallback(() => {
|
|
179628
179628
|
or(setStep(WIDGET_STEP.Done));
|
|
179629
179629
|
}, [or]);
|
|
@@ -179670,7 +179670,7 @@ function InvoiceFactoringPayment({
|
|
|
179670
179670
|
children: [
|
|
179671
179671
|
yr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(ChooseAmount$c, { creditRecord: Ir, poolInfo: gr }),
|
|
179672
179672
|
yr === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$8, { poolInfo: gr }),
|
|
179673
|
-
yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
179673
|
+
yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$i, { poolInfo: gr }),
|
|
179674
179674
|
yr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Success$a, { poolInfo: gr, handleAction: ur }),
|
|
179675
179675
|
yr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
179676
179676
|
ErrorModal,
|
|
@@ -180108,7 +180108,7 @@ function ChooseAmount$b({
|
|
|
180108
180108
|
}
|
|
180109
180109
|
);
|
|
180110
180110
|
}
|
|
180111
|
-
function Transfer$
|
|
180111
|
+
function Transfer$h({
|
|
180112
180112
|
poolInfo: ar,
|
|
180113
180113
|
poolUnderlyingToken: or,
|
|
180114
180114
|
trancheInfo: ur
|
|
@@ -180131,7 +180131,7 @@ function Transfer$g({
|
|
|
180131
180131
|
}
|
|
180132
180132
|
) : null;
|
|
180133
180133
|
}
|
|
180134
|
-
function Done$
|
|
180134
|
+
function Done$7({ handleAction: ar }) {
|
|
180135
180135
|
const { redeemShares: or } = useAppSelector(selectWidgetState), ur = [
|
|
180136
180136
|
`${formatNumber$1(or)} shares requested for redemption`
|
|
180137
180137
|
];
|
|
@@ -180224,14 +180224,14 @@ function AddRedemptionV2({
|
|
|
180224
180224
|
}
|
|
180225
180225
|
),
|
|
180226
180226
|
yr === WIDGET_STEP.Transfer && Ur && /* @__PURE__ */ jsx(
|
|
180227
|
-
Transfer$
|
|
180227
|
+
Transfer$h,
|
|
180228
180228
|
{
|
|
180229
180229
|
poolInfo: gr,
|
|
180230
180230
|
poolUnderlyingToken: xr,
|
|
180231
180231
|
trancheInfo: Ur
|
|
180232
180232
|
}
|
|
180233
180233
|
),
|
|
180234
|
-
yr === WIDGET_STEP.Done && Ur && /* @__PURE__ */ jsx(Done$
|
|
180234
|
+
yr === WIDGET_STEP.Done && Ur && /* @__PURE__ */ jsx(Done$7, { handleAction: ur }),
|
|
180235
180235
|
yr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
180236
180236
|
ErrorModal,
|
|
180237
180237
|
{
|
|
@@ -180245,7 +180245,7 @@ function AddRedemptionV2({
|
|
|
180245
180245
|
}
|
|
180246
180246
|
);
|
|
180247
180247
|
}
|
|
180248
|
-
function Transfer$
|
|
180248
|
+
function Transfer$g({
|
|
180249
180249
|
poolInfo: ar,
|
|
180250
180250
|
trancheType: or,
|
|
180251
180251
|
redemptionInfo: ur
|
|
@@ -180268,7 +180268,7 @@ function Transfer$f({
|
|
|
180268
180268
|
}
|
|
180269
180269
|
) : null;
|
|
180270
180270
|
}
|
|
180271
|
-
function Done$
|
|
180271
|
+
function Done$6({
|
|
180272
180272
|
poolUnderlyingToken: ar,
|
|
180273
180273
|
redemptionInfo: or,
|
|
180274
180274
|
handleAction: ur
|
|
@@ -180322,7 +180322,7 @@ function CancelRedemptionV2({
|
|
|
180322
180322
|
handleSuccess: Rr,
|
|
180323
180323
|
children: [
|
|
180324
180324
|
yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(
|
|
180325
|
-
Transfer$
|
|
180325
|
+
Transfer$g,
|
|
180326
180326
|
{
|
|
180327
180327
|
poolInfo: gr,
|
|
180328
180328
|
trancheType: or,
|
|
@@ -180330,7 +180330,7 @@ function CancelRedemptionV2({
|
|
|
180330
180330
|
}
|
|
180331
180331
|
),
|
|
180332
180332
|
yr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
180333
|
-
Done$
|
|
180333
|
+
Done$6,
|
|
180334
180334
|
{
|
|
180335
180335
|
poolUnderlyingToken: xr,
|
|
180336
180336
|
handleAction: ur,
|
|
@@ -180530,7 +180530,7 @@ function ChooseTranche$4({
|
|
|
180530
180530
|
)
|
|
180531
180531
|
] });
|
|
180532
180532
|
}
|
|
180533
|
-
function Done$
|
|
180533
|
+
function Done$5({ poolInfo: ar, handleAction: or }) {
|
|
180534
180534
|
const { redeemShares: ur, solanaSignature: cr } = useAppSelector(selectWidgetState), fr = [
|
|
180535
180535
|
`${formatNumber$1(ur)} shares requested for redemption`
|
|
180536
180536
|
];
|
|
@@ -180545,7 +180545,7 @@ function Done$4({ poolInfo: ar, handleAction: or }) {
|
|
|
180545
180545
|
}
|
|
180546
180546
|
);
|
|
180547
180547
|
}
|
|
180548
|
-
function Transfer$
|
|
180548
|
+
function Transfer$f({
|
|
180549
180549
|
poolInfo: ar,
|
|
180550
180550
|
selectedTranche: or
|
|
180551
180551
|
}) {
|
|
@@ -180673,8 +180673,8 @@ function SolanaLendAddRedemption({
|
|
|
180673
180673
|
selectedTranche: xr
|
|
180674
180674
|
}
|
|
180675
180675
|
),
|
|
180676
|
-
Sr === WIDGET_STEP.Transfer && xr && /* @__PURE__ */ jsx(Transfer$
|
|
180677
|
-
Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$
|
|
180676
|
+
Sr === WIDGET_STEP.Transfer && xr && /* @__PURE__ */ jsx(Transfer$f, { poolInfo: ar, selectedTranche: xr }),
|
|
180677
|
+
Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$5, { poolInfo: ar, handleAction: cr }),
|
|
180678
180678
|
Sr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
180679
180679
|
SolanaErrorModal,
|
|
180680
180680
|
{
|
|
@@ -180689,7 +180689,7 @@ function SolanaLendAddRedemption({
|
|
|
180689
180689
|
}
|
|
180690
180690
|
);
|
|
180691
180691
|
}
|
|
180692
|
-
function Transfer$
|
|
180692
|
+
function Transfer$e({
|
|
180693
180693
|
poolInfo: ar,
|
|
180694
180694
|
lenderState: or,
|
|
180695
180695
|
lenderStatePDA: ur,
|
|
@@ -180825,7 +180825,7 @@ function ChooseTranche$3({
|
|
|
180825
180825
|
)
|
|
180826
180826
|
] });
|
|
180827
180827
|
}
|
|
180828
|
-
function Done$
|
|
180828
|
+
function Done$4({
|
|
180829
180829
|
poolInfo: ar,
|
|
180830
180830
|
lenderState: or,
|
|
180831
180831
|
selectedTranche: ur,
|
|
@@ -180918,7 +180918,7 @@ function SolanaLendCancelRedemption({
|
|
|
180918
180918
|
}
|
|
180919
180919
|
),
|
|
180920
180920
|
gr === WIDGET_STEP.Transfer && Sr && /* @__PURE__ */ jsx(
|
|
180921
|
-
Transfer$
|
|
180921
|
+
Transfer$e,
|
|
180922
180922
|
{
|
|
180923
180923
|
poolInfo: ar,
|
|
180924
180924
|
lenderState: Sr === "senior" ? lr : dr,
|
|
@@ -180927,7 +180927,7 @@ function SolanaLendCancelRedemption({
|
|
|
180927
180927
|
}
|
|
180928
180928
|
),
|
|
180929
180929
|
gr === WIDGET_STEP.Done && Sr && /* @__PURE__ */ jsx(
|
|
180930
|
-
Done$
|
|
180930
|
+
Done$4,
|
|
180931
180931
|
{
|
|
180932
180932
|
poolInfo: ar,
|
|
180933
180933
|
lenderState: Sr === "senior" ? lr : dr,
|
|
@@ -180949,7 +180949,7 @@ function SolanaLendCancelRedemption({
|
|
|
180949
180949
|
}
|
|
180950
180950
|
);
|
|
180951
180951
|
}
|
|
180952
|
-
function Transfer$
|
|
180952
|
+
function Transfer$d({
|
|
180953
180953
|
poolInfo: ar,
|
|
180954
180954
|
poolState: or
|
|
180955
180955
|
}) {
|
|
@@ -181135,7 +181135,7 @@ function SolanaEnableAutoRedemption({
|
|
|
181135
181135
|
handleSuccess: cr,
|
|
181136
181136
|
children: [
|
|
181137
181137
|
lr === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$7, { poolState: or }),
|
|
181138
|
-
lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
181138
|
+
lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$d, { poolInfo: ar, poolState: or }),
|
|
181139
181139
|
lr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
181140
181140
|
Success$9,
|
|
181141
181141
|
{
|
|
@@ -182859,7 +182859,7 @@ function ApproveAllowance$6({ poolState: ar }) {
|
|
|
182859
182859
|
/* @__PURE__ */ jsx(BottomButton, { variant: "contained", onClick: cr, children: "SUPPLY" })
|
|
182860
182860
|
] });
|
|
182861
182861
|
}
|
|
182862
|
-
function Transfer$
|
|
182862
|
+
function Transfer$c({
|
|
182863
182863
|
poolInfo: ar,
|
|
182864
182864
|
poolState: or,
|
|
182865
182865
|
selectedTranche: ur,
|
|
@@ -183158,7 +183158,7 @@ function SolanaLendSupply({
|
|
|
183158
183158
|
),
|
|
183159
183159
|
Ir === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$6, { poolState: or }),
|
|
183160
183160
|
Ir === WIDGET_STEP.Transfer && Rr && /* @__PURE__ */ jsx(
|
|
183161
|
-
Transfer$
|
|
183161
|
+
Transfer$c,
|
|
183162
183162
|
{
|
|
183163
183163
|
poolInfo: ar,
|
|
183164
183164
|
poolState: or,
|
|
@@ -184197,7 +184197,7 @@ function TransferAndDeposit({
|
|
|
184197
184197
|
}
|
|
184198
184198
|
);
|
|
184199
184199
|
}
|
|
184200
|
-
function Transfer$
|
|
184200
|
+
function Transfer$b({
|
|
184201
184201
|
poolInfo: ar,
|
|
184202
184202
|
selectedTranche: or,
|
|
184203
184203
|
poolIsClosed: ur
|
|
@@ -184296,7 +184296,7 @@ function Transfer$a({
|
|
|
184296
184296
|
}
|
|
184297
184297
|
);
|
|
184298
184298
|
}
|
|
184299
|
-
function Done$
|
|
184299
|
+
function Done$3({
|
|
184300
184300
|
poolUnderlyingToken: ar,
|
|
184301
184301
|
withdrawAmount: or,
|
|
184302
184302
|
option: ur,
|
|
@@ -184457,7 +184457,7 @@ function SolanaLendWithdraw({
|
|
|
184457
184457
|
}
|
|
184458
184458
|
),
|
|
184459
184459
|
hr === WIDGET_STEP.Transfer && Jr.id === "withdraw-only" && /* @__PURE__ */ jsx(
|
|
184460
|
-
Transfer$
|
|
184460
|
+
Transfer$b,
|
|
184461
184461
|
{
|
|
184462
184462
|
poolInfo: ar,
|
|
184463
184463
|
selectedTranche: fr,
|
|
@@ -184465,7 +184465,7 @@ function SolanaLendWithdraw({
|
|
|
184465
184465
|
}
|
|
184466
184466
|
),
|
|
184467
184467
|
hr === WIDGET_STEP.Done && Qr && /* @__PURE__ */ jsx(
|
|
184468
|
-
Done$
|
|
184468
|
+
Done$3,
|
|
184469
184469
|
{
|
|
184470
184470
|
poolUnderlyingToken: ar.underlyingMint,
|
|
184471
184471
|
withdrawAmount: Qr,
|
|
@@ -227198,7 +227198,7 @@ function StellarTxSendModal({
|
|
|
227198
227198
|
}
|
|
227199
227199
|
);
|
|
227200
227200
|
}
|
|
227201
|
-
function Transfer$
|
|
227201
|
+
function Transfer$a({
|
|
227202
227202
|
poolInfo: ar,
|
|
227203
227203
|
selectedTranche: or
|
|
227204
227204
|
}) {
|
|
@@ -227307,7 +227307,7 @@ function StellarTxDoneModal({
|
|
|
227307
227307
|
] })
|
|
227308
227308
|
] });
|
|
227309
227309
|
}
|
|
227310
|
-
function Done$
|
|
227310
|
+
function Done$2({ poolInfo: ar, handleAction: or }) {
|
|
227311
227311
|
const { redeemAmount: ur, txHash: cr } = useAppSelector(selectWidgetState), { symbol: fr } = ar.underlyingToken, lr = [
|
|
227312
227312
|
`${formatNumber$1(ur ?? 0)} ${fr} requested for withdrawal`
|
|
227313
227313
|
], dr = useCallback(() => {
|
|
@@ -227352,8 +227352,8 @@ function StellarLendAddRedemption({
|
|
|
227352
227352
|
selectedTranche: ur
|
|
227353
227353
|
}
|
|
227354
227354
|
),
|
|
227355
|
-
pr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$
|
|
227356
|
-
pr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$
|
|
227355
|
+
pr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$a, { poolInfo: ar, selectedTranche: ur }),
|
|
227356
|
+
pr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$2, { poolInfo: ar, handleAction: cr }),
|
|
227357
227357
|
pr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
227358
227358
|
ErrorModal,
|
|
227359
227359
|
{
|
|
@@ -227518,7 +227518,7 @@ function ChooseAmount$7({
|
|
|
227518
227518
|
}
|
|
227519
227519
|
);
|
|
227520
227520
|
}
|
|
227521
|
-
function Transfer$
|
|
227521
|
+
function Transfer$9({
|
|
227522
227522
|
poolInfo: ar,
|
|
227523
227523
|
selectedTranche: or
|
|
227524
227524
|
}) {
|
|
@@ -227649,7 +227649,7 @@ function StellarLendSupply({
|
|
|
227649
227649
|
isUniTranche: lr
|
|
227650
227650
|
}
|
|
227651
227651
|
),
|
|
227652
|
-
Ir === WIDGET_STEP.Transfer && Cr && /* @__PURE__ */ jsx(Transfer$
|
|
227652
|
+
Ir === WIDGET_STEP.Transfer && Cr && /* @__PURE__ */ jsx(Transfer$9, { poolInfo: ar, selectedTranche: Cr }),
|
|
227653
227653
|
Ir === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
227654
227654
|
Success$7,
|
|
227655
227655
|
{
|
|
@@ -227671,6 +227671,197 @@ function StellarLendSupply({
|
|
|
227671
227671
|
}
|
|
227672
227672
|
);
|
|
227673
227673
|
}
|
|
227674
|
+
function Confirm({
|
|
227675
|
+
poolInfo: ar,
|
|
227676
|
+
withdrawableAmountFormatted: or,
|
|
227677
|
+
onConfirm: ur
|
|
227678
|
+
}) {
|
|
227679
|
+
const cr = useTheme(), { symbol: fr } = ar.underlyingToken, lr = {
|
|
227680
|
+
itemWrapper: css`
|
|
227681
|
+
margin-top: ${cr.spacing(9)};
|
|
227682
|
+
color: ${cr.palette.text.primary};
|
|
227683
|
+
font-weight: 400;
|
|
227684
|
+
font-size: 16px;
|
|
227685
|
+
line-height: 175%;
|
|
227686
|
+
letter-spacing: 0.15px;
|
|
227687
|
+
`,
|
|
227688
|
+
item: css`
|
|
227689
|
+
display: flex;
|
|
227690
|
+
justify-content: space-between;
|
|
227691
|
+
align-items: center;
|
|
227692
|
+
margin-bottom: ${cr.spacing(3)};
|
|
227693
|
+
`,
|
|
227694
|
+
itemValue: css`
|
|
227695
|
+
font-size: 20px;
|
|
227696
|
+
font-weight: 700;
|
|
227697
|
+
`
|
|
227698
|
+
};
|
|
227699
|
+
return /* @__PURE__ */ jsxs(
|
|
227700
|
+
WrapperModal,
|
|
227701
|
+
{
|
|
227702
|
+
title: `Withdraw ${fr}`,
|
|
227703
|
+
subTitle: "Withdraw all the available amount",
|
|
227704
|
+
children: [
|
|
227705
|
+
/* @__PURE__ */ jsx(Box, { css: lr.itemWrapper, children: /* @__PURE__ */ jsxs(Box, { css: lr.item, children: [
|
|
227706
|
+
/* @__PURE__ */ jsx(Box, { fontWeight: 700, children: "Available to withdraw" }),
|
|
227707
|
+
/* @__PURE__ */ jsxs(Box, { css: lr.itemValue, children: [
|
|
227708
|
+
or,
|
|
227709
|
+
" ",
|
|
227710
|
+
fr
|
|
227711
|
+
] })
|
|
227712
|
+
] }) }),
|
|
227713
|
+
/* @__PURE__ */ jsx(BottomButton, { variant: "contained", onClick: ur, children: "WITHDRAW" })
|
|
227714
|
+
]
|
|
227715
|
+
}
|
|
227716
|
+
);
|
|
227717
|
+
}
|
|
227718
|
+
function Transfer$8({
|
|
227719
|
+
poolInfo: ar,
|
|
227720
|
+
tranche: or,
|
|
227721
|
+
poolIsClosed: ur
|
|
227722
|
+
}) {
|
|
227723
|
+
const cr = useAppDispatch(), { address: fr } = useContext(StellarConnectionContext), [lr, dr] = useState(null), pr = useCallback(async () => {
|
|
227724
|
+
cr(setStep(WIDGET_STEP.Done));
|
|
227725
|
+
}, [cr]);
|
|
227726
|
+
return useEffect(() => {
|
|
227727
|
+
async function hr() {
|
|
227728
|
+
if (!fr)
|
|
227729
|
+
return;
|
|
227730
|
+
const Ar = STELLAR_CHAINS_INFO[ar.chainId], gr = or === "senior" ? ar.seniorTranche : ar.juniorTranche, yr = new distExports$2.Client({
|
|
227731
|
+
publicKey: fr,
|
|
227732
|
+
contractId: gr,
|
|
227733
|
+
...getClientCommonParams(Ar, fr)
|
|
227734
|
+
}), Sr = ur ? await yr.withdraw_after_pool_closure({
|
|
227735
|
+
lender: fr
|
|
227736
|
+
}) : await yr.disburse({
|
|
227737
|
+
lender: fr
|
|
227738
|
+
});
|
|
227739
|
+
dr(Sr);
|
|
227740
|
+
}
|
|
227741
|
+
hr();
|
|
227742
|
+
}, [ar, or, ur, fr]), /* @__PURE__ */ jsx(StellarTxSendModal, { tx: lr, handleSuccess: pr });
|
|
227743
|
+
}
|
|
227744
|
+
function Done$1({
|
|
227745
|
+
poolInfo: ar,
|
|
227746
|
+
withdrawAmount: or,
|
|
227747
|
+
handleAction: ur
|
|
227748
|
+
}) {
|
|
227749
|
+
const { txHash: cr } = useAppSelector(selectWidgetState), { symbol: fr } = ar.underlyingToken, lr = [
|
|
227750
|
+
`${formatNumber$1(or ?? 0)} ${fr} withdrawn to your wallet`
|
|
227751
|
+
], dr = useCallback(() => {
|
|
227752
|
+
ur({ isSuccess: !0 });
|
|
227753
|
+
}, [ur]);
|
|
227754
|
+
return /* @__PURE__ */ jsx(
|
|
227755
|
+
StellarTxDoneModal,
|
|
227756
|
+
{
|
|
227757
|
+
chainId: ar.chainId,
|
|
227758
|
+
handleAction: dr,
|
|
227759
|
+
content: lr,
|
|
227760
|
+
txHash: cr,
|
|
227761
|
+
buttonText: "DONE"
|
|
227762
|
+
}
|
|
227763
|
+
);
|
|
227764
|
+
}
|
|
227765
|
+
function StellarLendWithdraw({
|
|
227766
|
+
poolInfo: ar,
|
|
227767
|
+
poolState: or,
|
|
227768
|
+
tranche: ur,
|
|
227769
|
+
handleClose: cr,
|
|
227770
|
+
handleSuccess: fr
|
|
227771
|
+
}) {
|
|
227772
|
+
const lr = useDispatch(), { address: dr } = useContext(StellarConnectionContext), { step: pr, errorMessage: hr, withdrawAmount: Ar } = useAppSelector(selectWidgetState), [gr, yr] = useState(
|
|
227773
|
+
BigInt(0)
|
|
227774
|
+
), [Sr, Ir] = useState(!0), { symbol: xr, decimals: Cr } = ar.underlyingToken, Rr = `Withdraw ${xr}`, Pr = (or == null ? void 0 : or.status) === "closed", Mr = formatNumberFixed(
|
|
227775
|
+
tokenDecimalUtils.formatUnits(gr, Cr),
|
|
227776
|
+
2
|
|
227777
|
+
);
|
|
227778
|
+
useEffect(() => {
|
|
227779
|
+
!pr && dr && lr(setStep(WIDGET_STEP.ConfirmWithdrawOnly));
|
|
227780
|
+
}, [lr, pr, dr]), useEffect(() => {
|
|
227781
|
+
async function qr() {
|
|
227782
|
+
if (!dr || !ar) {
|
|
227783
|
+
Ir(!1);
|
|
227784
|
+
return;
|
|
227785
|
+
}
|
|
227786
|
+
Ir(!0);
|
|
227787
|
+
try {
|
|
227788
|
+
const Hr = STELLAR_CHAINS_INFO[ar.chainId], Jr = ur === "senior" ? ar.seniorTranche : ar.juniorTranche, Yr = (await new distExports$2.Client({
|
|
227789
|
+
publicKey: dr,
|
|
227790
|
+
contractId: Jr,
|
|
227791
|
+
networkPassphrase: Hr.networkPassphrase,
|
|
227792
|
+
rpcUrl: Hr.rpc
|
|
227793
|
+
}).get_latest_redemption_record({
|
|
227794
|
+
lender: dr
|
|
227795
|
+
})).result, Dr = BigInt(Yr.total_amount_processed) - BigInt(Yr.total_amount_withdrawn);
|
|
227796
|
+
yr(Dr);
|
|
227797
|
+
} catch (Hr) {
|
|
227798
|
+
console.error("Failed to fetch withdrawable amount:", Hr), yr(BigInt(0));
|
|
227799
|
+
} finally {
|
|
227800
|
+
Ir(!1);
|
|
227801
|
+
}
|
|
227802
|
+
}
|
|
227803
|
+
qr();
|
|
227804
|
+
}, [dr, ar, ur]);
|
|
227805
|
+
const Ur = useCallback(() => {
|
|
227806
|
+
lr(setWithdrawAmount(Number(Mr))), lr(setStep(WIDGET_STEP.Transfer));
|
|
227807
|
+
}, [lr, Mr]), Qr = useCallback(() => {
|
|
227808
|
+
fr == null || fr();
|
|
227809
|
+
}, [fr]);
|
|
227810
|
+
return Sr && pr === WIDGET_STEP.ConfirmWithdrawOnly ? /* @__PURE__ */ jsx(
|
|
227811
|
+
WidgetWrapper,
|
|
227812
|
+
{
|
|
227813
|
+
isOpen: !0,
|
|
227814
|
+
loadingTitle: Rr,
|
|
227815
|
+
handleClose: cr,
|
|
227816
|
+
handleSuccess: Qr
|
|
227817
|
+
}
|
|
227818
|
+
) : /* @__PURE__ */ jsxs(
|
|
227819
|
+
WidgetWrapper,
|
|
227820
|
+
{
|
|
227821
|
+
isOpen: !0,
|
|
227822
|
+
loadingTitle: Rr,
|
|
227823
|
+
handleClose: cr,
|
|
227824
|
+
handleSuccess: Qr,
|
|
227825
|
+
children: [
|
|
227826
|
+
pr === WIDGET_STEP.ConfirmWithdrawOnly && /* @__PURE__ */ jsx(
|
|
227827
|
+
Confirm,
|
|
227828
|
+
{
|
|
227829
|
+
poolInfo: ar,
|
|
227830
|
+
withdrawableAmountFormatted: String(
|
|
227831
|
+
Mr ?? "0"
|
|
227832
|
+
),
|
|
227833
|
+
onConfirm: Ur
|
|
227834
|
+
}
|
|
227835
|
+
),
|
|
227836
|
+
pr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(
|
|
227837
|
+
Transfer$8,
|
|
227838
|
+
{
|
|
227839
|
+
poolInfo: ar,
|
|
227840
|
+
tranche: ur,
|
|
227841
|
+
poolIsClosed: Pr
|
|
227842
|
+
}
|
|
227843
|
+
),
|
|
227844
|
+
pr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
|
|
227845
|
+
Done$1,
|
|
227846
|
+
{
|
|
227847
|
+
poolInfo: ar,
|
|
227848
|
+
withdrawAmount: Ar,
|
|
227849
|
+
handleAction: cr
|
|
227850
|
+
}
|
|
227851
|
+
),
|
|
227852
|
+
pr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
|
|
227853
|
+
ErrorModal,
|
|
227854
|
+
{
|
|
227855
|
+
title: Rr,
|
|
227856
|
+
errorReason: "Sorry there was an error",
|
|
227857
|
+
errorMessage: hr,
|
|
227858
|
+
handleOk: cr
|
|
227859
|
+
}
|
|
227860
|
+
)
|
|
227861
|
+
]
|
|
227862
|
+
}
|
|
227863
|
+
);
|
|
227864
|
+
}
|
|
227674
227865
|
function EvaluationEA({
|
|
227675
227866
|
poolInfo: ar,
|
|
227676
227867
|
handleApproveSuccess: or
|
|
@@ -231139,6 +231330,9 @@ function StellarLendSupplyWidget(ar) {
|
|
|
231139
231330
|
function StellarLendAddRedemptionWidget(ar) {
|
|
231140
231331
|
return /* @__PURE__ */ jsx(GenericWidget, { ...ar, children: /* @__PURE__ */ jsx(StellarLendAddRedemption, { ...ar }) });
|
|
231141
231332
|
}
|
|
231333
|
+
function StellarLendWithdrawWidget(ar) {
|
|
231334
|
+
return /* @__PURE__ */ jsx(GenericWidget, { ...ar, children: /* @__PURE__ */ jsx(StellarLendWithdraw, { ...ar }) });
|
|
231335
|
+
}
|
|
231142
231336
|
function StellarBorrowWidget(ar) {
|
|
231143
231337
|
return /* @__PURE__ */ jsx(GenericWidget, { ...ar, children: /* @__PURE__ */ jsx(StellarBorrow, { ...ar }) });
|
|
231144
231338
|
}
|
|
@@ -231173,6 +231367,7 @@ export {
|
|
|
231173
231367
|
StellarBorrowWidget,
|
|
231174
231368
|
StellarLendAddRedemptionWidget,
|
|
231175
231369
|
StellarLendSupplyWidget,
|
|
231370
|
+
StellarLendWithdrawWidget,
|
|
231176
231371
|
SuperfluidFactoringWidget,
|
|
231177
231372
|
SupplyFirstLossCoverWidget
|
|
231178
231373
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StellarPoolInfo } from '../../../../../huma-shared/src';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
type Props = {
|
|
4
|
+
poolInfo: StellarPoolInfo;
|
|
5
|
+
withdrawableAmountFormatted: string;
|
|
6
|
+
onConfirm: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function Confirm({ poolInfo, withdrawableAmountFormatted, onConfirm, }: Props): React.ReactElement;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StellarPoolInfo, TrancheType } from '../../../../../huma-shared/src';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
type Props = {
|
|
4
|
+
poolInfo: StellarPoolInfo;
|
|
5
|
+
tranche: TrancheType;
|
|
6
|
+
poolIsClosed: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function Transfer({ poolInfo, tranche, poolIsClosed, }: Props): React.ReactElement | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StellarPoolInfo } from '../../../../../huma-shared/src';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
type Props = {
|
|
4
|
+
poolInfo: StellarPoolInfo;
|
|
5
|
+
withdrawAmount?: number;
|
|
6
|
+
handleAction: (options?: {
|
|
7
|
+
isSuccess?: boolean;
|
|
8
|
+
}) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function Done({ poolInfo, withdrawAmount, handleAction, }: Props): React.ReactElement;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CloseModalOptions, StellarPoolInfo, TrancheType } from '../../../../../huma-shared/src';
|
|
2
|
+
import { StellarPoolState } from '../../../../../huma-web-shared/src';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Stellar lend pool withdraw props – disburse (pool open) or withdraw after pool closure.
|
|
6
|
+
* @property {StellarPoolInfo} poolInfo The metadata of the pool.
|
|
7
|
+
* @property {StellarPoolState} poolState The current state config of the pool.
|
|
8
|
+
* @property {TrancheType} tranche The tranche to withdraw from (junior or senior).
|
|
9
|
+
* @property {function((CloseModalOptions|undefined)):void} handleClose Function to close the widget modal.
|
|
10
|
+
* @property {function():void|undefined} handleSuccess Optional callback when withdraw succeeds.
|
|
11
|
+
*/
|
|
12
|
+
export interface StellarLendWithdrawProps {
|
|
13
|
+
poolInfo: StellarPoolInfo;
|
|
14
|
+
poolState: StellarPoolState;
|
|
15
|
+
tranche: TrancheType;
|
|
16
|
+
handleClose: (options?: CloseModalOptions) => void;
|
|
17
|
+
handleSuccess?: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function StellarLendWithdraw({ poolInfo, poolState, tranche, handleClose, handleSuccess, }: StellarLendWithdrawProps): React.ReactElement | null;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { SolanaLendSupplyProps } from './components/Lend/solanaSupply';
|
|
|
19
19
|
import { SolanaLendWithdrawProps } from './components/Lend/solanaWithdraw';
|
|
20
20
|
import { StellarLendAddRedemptionProps } from './components/Lend/stellarAddRedemption';
|
|
21
21
|
import { StellarLendSupplyProps } from './components/Lend/stellarSupply';
|
|
22
|
+
import { StellarLendWithdrawProps } from './components/Lend/stellarWithdraw';
|
|
22
23
|
import { LendSupplyProps } from './components/Lend/supply';
|
|
23
24
|
import { LendSupplyPropsV2 } from './components/Lend/supplyV2';
|
|
24
25
|
import { LendWithdrawProps } from './components/Lend/withdraw';
|
|
@@ -384,6 +385,17 @@ type StellarLendAddRedemptionWidgetProps = StellarLendAddRedemptionProps & Gener
|
|
|
384
385
|
* @param {StellarLendAddRedemptionWidgetProps} props - Widget props
|
|
385
386
|
*/
|
|
386
387
|
export declare function StellarLendAddRedemptionWidget(props: StellarLendAddRedemptionWidgetProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
388
|
+
/**
|
|
389
|
+
* Lend pool withdraw widget props for Stellar pools
|
|
390
|
+
* @typedef {Object} StellarLendWithdrawWidgetProps
|
|
391
|
+
*/
|
|
392
|
+
type StellarLendWithdrawWidgetProps = StellarLendWithdrawProps & GenericWidgetProps;
|
|
393
|
+
/**
|
|
394
|
+
* Lend pool withdraw widget for Stellar pools (disburse when pool open, withdraw_after_pool_closure when closed)
|
|
395
|
+
*
|
|
396
|
+
* @param {StellarLendWithdrawWidgetProps} props - Widget props
|
|
397
|
+
*/
|
|
398
|
+
export declare function StellarLendWithdrawWidget(props: StellarLendWithdrawWidgetProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
387
399
|
/**
|
|
388
400
|
* Borrow widget props for Stellar pools
|
|
389
401
|
* @typedef {Object} StellarLendSupplyWidgetProps
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.80-beta.
|
|
3
|
+
"version": "0.0.80-beta.1085+a708f6d",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"@ethersproject/contracts": "^5.7.0",
|
|
23
23
|
"@ethersproject/experimental": "^5.7.0",
|
|
24
24
|
"@ethersproject/units": "^5.6.0",
|
|
25
|
-
"@huma-finance/sdk": "^0.0.80-beta.
|
|
26
|
-
"@huma-finance/shared": "^0.0.80-beta.
|
|
27
|
-
"@huma-finance/web-shared": "^0.0.80-beta.
|
|
25
|
+
"@huma-finance/sdk": "^0.0.80-beta.1085+a708f6d",
|
|
26
|
+
"@huma-finance/shared": "^0.0.80-beta.1085+a708f6d",
|
|
27
|
+
"@huma-finance/web-shared": "^0.0.80-beta.1085+a708f6d",
|
|
28
28
|
"@mui/x-date-pickers": "^5.0.7",
|
|
29
29
|
"@notifi-network/notifi-frontend-client": "^1.1.2",
|
|
30
30
|
"@notifi-network/notifi-react": "^1.1.2",
|
|
@@ -190,5 +190,5 @@
|
|
|
190
190
|
"optionalDependencies": {
|
|
191
191
|
"encoding": "^0.1.13"
|
|
192
192
|
},
|
|
193
|
-
"gitHead": "
|
|
193
|
+
"gitHead": "a708f6d84ca846198c99171638c7415bb2330e38"
|
|
194
194
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { StellarPoolInfo } from '@huma-finance/shared'
|
|
2
|
+
import { Box, css, useTheme } from '@mui/material'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { BottomButton } from '../../BottomButton'
|
|
5
|
+
import { WrapperModal } from '../../WrapperModal'
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
poolInfo: StellarPoolInfo
|
|
9
|
+
withdrawableAmountFormatted: string
|
|
10
|
+
onConfirm: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function Confirm({
|
|
14
|
+
poolInfo,
|
|
15
|
+
withdrawableAmountFormatted,
|
|
16
|
+
onConfirm,
|
|
17
|
+
}: Props): React.ReactElement {
|
|
18
|
+
const theme = useTheme()
|
|
19
|
+
const { symbol } = poolInfo.underlyingToken
|
|
20
|
+
|
|
21
|
+
const styles = {
|
|
22
|
+
itemWrapper: css`
|
|
23
|
+
margin-top: ${theme.spacing(9)};
|
|
24
|
+
color: ${theme.palette.text.primary};
|
|
25
|
+
font-weight: 400;
|
|
26
|
+
font-size: 16px;
|
|
27
|
+
line-height: 175%;
|
|
28
|
+
letter-spacing: 0.15px;
|
|
29
|
+
`,
|
|
30
|
+
item: css`
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
align-items: center;
|
|
34
|
+
margin-bottom: ${theme.spacing(3)};
|
|
35
|
+
`,
|
|
36
|
+
itemValue: css`
|
|
37
|
+
font-size: 20px;
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
`,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<WrapperModal
|
|
44
|
+
title={`Withdraw ${symbol}`}
|
|
45
|
+
subTitle='Withdraw all the available amount'
|
|
46
|
+
>
|
|
47
|
+
<Box css={styles.itemWrapper}>
|
|
48
|
+
<Box css={styles.item}>
|
|
49
|
+
<Box fontWeight={700}>Available to withdraw</Box>
|
|
50
|
+
<Box css={styles.itemValue}>
|
|
51
|
+
{withdrawableAmountFormatted} {symbol}
|
|
52
|
+
</Box>
|
|
53
|
+
</Box>
|
|
54
|
+
</Box>
|
|
55
|
+
<BottomButton variant='contained' onClick={onConfirm}>
|
|
56
|
+
WITHDRAW
|
|
57
|
+
</BottomButton>
|
|
58
|
+
</WrapperModal>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
STELLAR_CHAINS_INFO,
|
|
3
|
+
StellarPoolInfo,
|
|
4
|
+
TrancheType,
|
|
5
|
+
} from '@huma-finance/shared'
|
|
6
|
+
import { Client as TrancheVaultClient } from '@huma-finance/soroban-tranche-vault'
|
|
7
|
+
import React, { useCallback, useContext, useEffect, useState } from 'react'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
getClientCommonParams,
|
|
11
|
+
StellarConnectionContext,
|
|
12
|
+
} from '@huma-finance/web-shared'
|
|
13
|
+
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
14
|
+
import { setStep } from '../../../store/widgets.reducers'
|
|
15
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
16
|
+
import { StellarTxSendModal } from '../../StellarTxSendModal'
|
|
17
|
+
|
|
18
|
+
type Props = {
|
|
19
|
+
poolInfo: StellarPoolInfo
|
|
20
|
+
tranche: TrancheType
|
|
21
|
+
poolIsClosed: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Transfer({
|
|
25
|
+
poolInfo,
|
|
26
|
+
tranche,
|
|
27
|
+
poolIsClosed,
|
|
28
|
+
}: Props): React.ReactElement | null {
|
|
29
|
+
const dispatch = useAppDispatch()
|
|
30
|
+
const { address: stellarAddress } = useContext(StellarConnectionContext)
|
|
31
|
+
const [tx, setTx] = useState<Awaited<
|
|
32
|
+
ReturnType<TrancheVaultClient['disburse']>
|
|
33
|
+
> | null>(null)
|
|
34
|
+
|
|
35
|
+
const handleSuccess = useCallback(async () => {
|
|
36
|
+
dispatch(setStep(WIDGET_STEP.Done))
|
|
37
|
+
}, [dispatch])
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
async function getTx() {
|
|
41
|
+
if (!stellarAddress) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const chainMetadata = STELLAR_CHAINS_INFO[poolInfo.chainId]
|
|
46
|
+
const contractId =
|
|
47
|
+
tranche === 'senior' ? poolInfo.seniorTranche! : poolInfo.juniorTranche
|
|
48
|
+
const trancheVaultClient = new TrancheVaultClient({
|
|
49
|
+
publicKey: stellarAddress,
|
|
50
|
+
contractId,
|
|
51
|
+
...getClientCommonParams(chainMetadata, stellarAddress),
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const assembledTx = poolIsClosed
|
|
55
|
+
? await trancheVaultClient.withdraw_after_pool_closure({
|
|
56
|
+
lender: stellarAddress,
|
|
57
|
+
})
|
|
58
|
+
: await trancheVaultClient.disburse({
|
|
59
|
+
lender: stellarAddress,
|
|
60
|
+
})
|
|
61
|
+
setTx(assembledTx)
|
|
62
|
+
}
|
|
63
|
+
getTx()
|
|
64
|
+
}, [poolInfo, tranche, poolIsClosed, stellarAddress])
|
|
65
|
+
|
|
66
|
+
return <StellarTxSendModal tx={tx} handleSuccess={handleSuccess} />
|
|
67
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { formatNumber, StellarPoolInfo } from '@huma-finance/shared'
|
|
2
|
+
import React, { useCallback } from 'react'
|
|
3
|
+
import { useAppSelector } from '../../../hooks/useRedux'
|
|
4
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
5
|
+
import { StellarTxDoneModal } from '../../StellarTxDoneModal'
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
poolInfo: StellarPoolInfo
|
|
9
|
+
withdrawAmount?: number
|
|
10
|
+
handleAction: (options?: { isSuccess?: boolean }) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function Done({
|
|
14
|
+
poolInfo,
|
|
15
|
+
withdrawAmount,
|
|
16
|
+
handleAction,
|
|
17
|
+
}: Props): React.ReactElement {
|
|
18
|
+
const { txHash } = useAppSelector(selectWidgetState)
|
|
19
|
+
const { symbol } = poolInfo.underlyingToken
|
|
20
|
+
|
|
21
|
+
const content = [
|
|
22
|
+
`${formatNumber(withdrawAmount ?? 0)} ${symbol} withdrawn to your wallet`,
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
const handleUserAction = useCallback(() => {
|
|
26
|
+
handleAction({ isSuccess: true })
|
|
27
|
+
}, [handleAction])
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<StellarTxDoneModal
|
|
31
|
+
chainId={poolInfo.chainId}
|
|
32
|
+
handleAction={handleUserAction}
|
|
33
|
+
content={content}
|
|
34
|
+
txHash={txHash}
|
|
35
|
+
buttonText='DONE'
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CloseModalOptions,
|
|
3
|
+
formatNumberFixed,
|
|
4
|
+
STELLAR_CHAINS_INFO,
|
|
5
|
+
StellarPoolInfo,
|
|
6
|
+
tokenDecimalUtils,
|
|
7
|
+
TrancheType,
|
|
8
|
+
} from '@huma-finance/shared'
|
|
9
|
+
import { Client as TrancheVaultClient } from '@huma-finance/soroban-tranche-vault'
|
|
10
|
+
import {
|
|
11
|
+
StellarConnectionContext,
|
|
12
|
+
StellarPoolState,
|
|
13
|
+
} from '@huma-finance/web-shared'
|
|
14
|
+
import React, { useCallback, useContext, useEffect, useState } from 'react'
|
|
15
|
+
import { useDispatch } from 'react-redux'
|
|
16
|
+
|
|
17
|
+
import { useAppSelector } from '../../../hooks/useRedux'
|
|
18
|
+
import { setStep, setWithdrawAmount } from '../../../store/widgets.reducers'
|
|
19
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
20
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
21
|
+
import { ErrorModal } from '../../ErrorModal'
|
|
22
|
+
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
23
|
+
import { Confirm } from './1-Confirm'
|
|
24
|
+
import { Transfer } from './2-Transfer'
|
|
25
|
+
import { Done } from './3-Done'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stellar lend pool withdraw props – disburse (pool open) or withdraw after pool closure.
|
|
29
|
+
* @property {StellarPoolInfo} poolInfo The metadata of the pool.
|
|
30
|
+
* @property {StellarPoolState} poolState The current state config of the pool.
|
|
31
|
+
* @property {TrancheType} tranche The tranche to withdraw from (junior or senior).
|
|
32
|
+
* @property {function((CloseModalOptions|undefined)):void} handleClose Function to close the widget modal.
|
|
33
|
+
* @property {function():void|undefined} handleSuccess Optional callback when withdraw succeeds.
|
|
34
|
+
*/
|
|
35
|
+
export interface StellarLendWithdrawProps {
|
|
36
|
+
poolInfo: StellarPoolInfo
|
|
37
|
+
poolState: StellarPoolState
|
|
38
|
+
tranche: TrancheType
|
|
39
|
+
handleClose: (options?: CloseModalOptions) => void
|
|
40
|
+
handleSuccess?: () => void
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function StellarLendWithdraw({
|
|
44
|
+
poolInfo,
|
|
45
|
+
poolState,
|
|
46
|
+
tranche,
|
|
47
|
+
handleClose,
|
|
48
|
+
handleSuccess,
|
|
49
|
+
}: StellarLendWithdrawProps): React.ReactElement | null {
|
|
50
|
+
const dispatch = useDispatch()
|
|
51
|
+
const { address: stellarAddress } = useContext(StellarConnectionContext)
|
|
52
|
+
const { step, errorMessage, withdrawAmount } =
|
|
53
|
+
useAppSelector(selectWidgetState)
|
|
54
|
+
const [withdrawableAmount, setWithdrawableAmount] = useState<bigint>(
|
|
55
|
+
BigInt(0),
|
|
56
|
+
)
|
|
57
|
+
const [isLoadingWithdrawable, setIsLoadingWithdrawable] = useState(true)
|
|
58
|
+
|
|
59
|
+
const { symbol, decimals } = poolInfo.underlyingToken
|
|
60
|
+
const title = `Withdraw ${symbol}`
|
|
61
|
+
const poolIsClosed = poolState?.status === 'closed'
|
|
62
|
+
const withdrawableAmountFormatted = formatNumberFixed(
|
|
63
|
+
tokenDecimalUtils.formatUnits(withdrawableAmount, decimals),
|
|
64
|
+
2,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!step && stellarAddress) {
|
|
69
|
+
dispatch(setStep(WIDGET_STEP.ConfirmWithdrawOnly))
|
|
70
|
+
}
|
|
71
|
+
}, [dispatch, step, stellarAddress])
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
async function fetchWithdrawable() {
|
|
75
|
+
if (!stellarAddress || !poolInfo) {
|
|
76
|
+
setIsLoadingWithdrawable(false)
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
setIsLoadingWithdrawable(true)
|
|
80
|
+
try {
|
|
81
|
+
const chainMetadata = STELLAR_CHAINS_INFO[poolInfo.chainId]
|
|
82
|
+
const contractId =
|
|
83
|
+
tranche === 'senior'
|
|
84
|
+
? poolInfo.seniorTranche!
|
|
85
|
+
: poolInfo.juniorTranche
|
|
86
|
+
const client = new TrancheVaultClient({
|
|
87
|
+
publicKey: stellarAddress,
|
|
88
|
+
contractId,
|
|
89
|
+
networkPassphrase: chainMetadata.networkPassphrase,
|
|
90
|
+
rpcUrl: chainMetadata.rpc,
|
|
91
|
+
})
|
|
92
|
+
const res = await client.get_latest_redemption_record({
|
|
93
|
+
lender: stellarAddress,
|
|
94
|
+
})
|
|
95
|
+
const record = res.result
|
|
96
|
+
const withdrawable =
|
|
97
|
+
BigInt(record.total_amount_processed) -
|
|
98
|
+
BigInt(record.total_amount_withdrawn)
|
|
99
|
+
setWithdrawableAmount(withdrawable)
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.error('Failed to fetch withdrawable amount:', err)
|
|
102
|
+
setWithdrawableAmount(BigInt(0))
|
|
103
|
+
} finally {
|
|
104
|
+
setIsLoadingWithdrawable(false)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
fetchWithdrawable()
|
|
108
|
+
}, [stellarAddress, poolInfo, tranche])
|
|
109
|
+
|
|
110
|
+
const handleConfirmWithdraw = useCallback(() => {
|
|
111
|
+
dispatch(setWithdrawAmount(Number(withdrawableAmountFormatted)))
|
|
112
|
+
dispatch(setStep(WIDGET_STEP.Transfer))
|
|
113
|
+
}, [dispatch, withdrawableAmountFormatted])
|
|
114
|
+
|
|
115
|
+
const handleWithdrawSuccess = useCallback(() => {
|
|
116
|
+
handleSuccess?.()
|
|
117
|
+
}, [handleSuccess])
|
|
118
|
+
|
|
119
|
+
if (isLoadingWithdrawable && step === WIDGET_STEP.ConfirmWithdrawOnly) {
|
|
120
|
+
return (
|
|
121
|
+
<WidgetWrapper
|
|
122
|
+
isOpen
|
|
123
|
+
loadingTitle={title}
|
|
124
|
+
handleClose={handleClose}
|
|
125
|
+
handleSuccess={handleWithdrawSuccess}
|
|
126
|
+
/>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<WidgetWrapper
|
|
132
|
+
isOpen
|
|
133
|
+
loadingTitle={title}
|
|
134
|
+
handleClose={handleClose}
|
|
135
|
+
handleSuccess={handleWithdrawSuccess}
|
|
136
|
+
>
|
|
137
|
+
{step === WIDGET_STEP.ConfirmWithdrawOnly && (
|
|
138
|
+
<Confirm
|
|
139
|
+
poolInfo={poolInfo}
|
|
140
|
+
withdrawableAmountFormatted={String(
|
|
141
|
+
withdrawableAmountFormatted ?? '0',
|
|
142
|
+
)}
|
|
143
|
+
onConfirm={handleConfirmWithdraw}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
{step === WIDGET_STEP.Transfer && (
|
|
147
|
+
<Transfer
|
|
148
|
+
poolInfo={poolInfo}
|
|
149
|
+
tranche={tranche}
|
|
150
|
+
poolIsClosed={poolIsClosed}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
{step === WIDGET_STEP.Done && (
|
|
154
|
+
<Done
|
|
155
|
+
poolInfo={poolInfo}
|
|
156
|
+
withdrawAmount={withdrawAmount}
|
|
157
|
+
handleAction={handleClose}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
{step === WIDGET_STEP.Error && (
|
|
161
|
+
<ErrorModal
|
|
162
|
+
title={title}
|
|
163
|
+
errorReason='Sorry there was an error'
|
|
164
|
+
errorMessage={errorMessage}
|
|
165
|
+
handleOk={handleClose}
|
|
166
|
+
/>
|
|
167
|
+
)}
|
|
168
|
+
</WidgetWrapper>
|
|
169
|
+
)
|
|
170
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -85,6 +85,10 @@ import {
|
|
|
85
85
|
StellarLendSupply,
|
|
86
86
|
StellarLendSupplyProps,
|
|
87
87
|
} from './components/Lend/stellarSupply'
|
|
88
|
+
import {
|
|
89
|
+
StellarLendWithdraw,
|
|
90
|
+
StellarLendWithdrawProps,
|
|
91
|
+
} from './components/Lend/stellarWithdraw'
|
|
88
92
|
import { LendSupply, LendSupplyProps } from './components/Lend/supply'
|
|
89
93
|
import { LendSupplyPropsV2, LendSupplyV2 } from './components/Lend/supplyV2'
|
|
90
94
|
import { LendWithdraw, LendWithdrawProps } from './components/Lend/withdraw'
|
|
@@ -739,6 +743,28 @@ export function StellarLendAddRedemptionWidget(
|
|
|
739
743
|
)
|
|
740
744
|
}
|
|
741
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Lend pool withdraw widget props for Stellar pools
|
|
748
|
+
* @typedef {Object} StellarLendWithdrawWidgetProps
|
|
749
|
+
*/
|
|
750
|
+
type StellarLendWithdrawWidgetProps = StellarLendWithdrawProps &
|
|
751
|
+
GenericWidgetProps
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Lend pool withdraw widget for Stellar pools (disburse when pool open, withdraw_after_pool_closure when closed)
|
|
755
|
+
*
|
|
756
|
+
* @param {StellarLendWithdrawWidgetProps} props - Widget props
|
|
757
|
+
*/
|
|
758
|
+
export function StellarLendWithdrawWidget(
|
|
759
|
+
props: StellarLendWithdrawWidgetProps,
|
|
760
|
+
) {
|
|
761
|
+
return (
|
|
762
|
+
<GenericWidget {...props}>
|
|
763
|
+
<StellarLendWithdraw {...props} />
|
|
764
|
+
</GenericWidget>
|
|
765
|
+
)
|
|
766
|
+
}
|
|
767
|
+
|
|
742
768
|
/**
|
|
743
769
|
* Borrow widget props for Stellar pools
|
|
744
770
|
* @typedef {Object} StellarLendSupplyWidgetProps
|