@huma-finance/widgets 0.0.79 → 0.0.80-beta.1081

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/index.js CHANGED
@@ -3,7 +3,7 @@ var h8 = (ar, or, ur) => or in ar ? p8(ar, or, { enumerable: !0, configurable: !
3
3
  var Aa = (ar, or, ur) => h8(ar, typeof or != "symbol" ? or + "" : or, ur);
4
4
  import * as React from "react";
5
5
  import React__default, { forwardRef, useContext, Children, isValidElement, cloneElement, useState, useEffect, useRef, createElement, createContext, useReducer, useDebugValue, useCallback, useMemo, useLayoutEffect } from "react";
6
- import { txAtom, useMQ, LoggingContextHelper, sendTxAtom, usePoolUnderlyingTokenContract, useMount, usePoolInfo, useAccountStats, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, checkIsDev, useCLFeeManager, useCLPoolAllowance, usePoolContract, useCreditContractV2, useCreditStatsV2, useForceRefresh, useHumaProgram, useBorrowerAccounts, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, useTrancheVaultContractV2, useCancellableRedemptionInfoV2, useTrancheMintAccounts, useTrancheTokenAccounts, useLenderAccounts, notEnabledAutoRedeem, getLenderLockupDates, AUTH_ERROR_TYPE, useChainInfo, useTokenAccount, usePermissionlessApy, usePermissionlessProgram, usePermissionlessLenderStateAccount, usePermissionlessLenderModeATA, logErrorRaw, StellarConnectionContext, getClientCommonParams, useStellarLender, useStellarTokenBalance, useParamsSearch, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useTrancheVaultAssetsV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, useFactoring, fetchStellarPoolSentinel, useStellarBorrower } from "@huma-finance/web-shared";
6
+ import { txAtom, useMQ, LoggingContextHelper, sendTxAtom, usePoolUnderlyingTokenContract, useMount, usePoolInfo, useAccountStats, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, checkIsDev, useCLFeeManager, useCLPoolAllowance, usePoolContract, useCreditContractV2, useCreditStatsV2, useForceRefresh, useHumaProgram, useBorrowerAccounts, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, useTrancheVaultContractV2, useCancellableRedemptionInfoV2, useTrancheMintAccounts, useTrancheTokenAccounts, useLenderAccounts, notEnabledAutoRedeem, getLenderLockupDates, AUTH_ERROR_TYPE, useChainInfo, useTokenAccount, usePermissionlessApy, usePermissionlessProgram, usePermissionlessLenderStateAccount, usePermissionlessLenderModeATA, logErrorRaw, StellarConnectionContext, getStellarSharesFromUnderlyingTokenAmount, fetchStellarDepositRecord, getClientCommonParams, useStellarLender, useStellarTokenBalance, useParamsSearch, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useTrancheVaultAssetsV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, useFactoring, fetchStellarPoolSentinel, useStellarBorrower } from "@huma-finance/web-shared";
7
7
  import { useWallet, useConnection } from "@solana/wallet-adapter-react";
8
8
  function _mergeNamespaces(ar, or) {
9
9
  for (var ur = 0; ur < or.length; ur++) {
@@ -116970,7 +116970,7 @@ function ChooseAmountModal({
116970
116970
  ] })
116971
116971
  ] });
116972
116972
  }
116973
- function ChooseAmount$i({
116973
+ function ChooseAmount$j({
116974
116974
  poolInfo: ar,
116975
116975
  accountStats: or
116976
116976
  }) {
@@ -117062,7 +117062,7 @@ function TxSendModal({
117062
117062
  }
117063
117063
  );
117064
117064
  }
117065
- function Transfer$o({ poolInfo: ar }) {
117065
+ function Transfer$p({ 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;
@@ -144792,9 +144792,9 @@ function CreditLineBorrow({
144792
144792
  handleSuccess: fr,
144793
144793
  children: [
144794
144794
  Sr === WIDGET_STEP.Evaluation && /* @__PURE__ */ jsx(Evaluation$5, { poolInfo: yr, handleApprove: Qr }),
144795
- Sr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(ChooseAmount$i, { poolInfo: yr, accountStats: xr }),
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$o, { poolInfo: yr }),
144797
+ Sr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$p, { poolInfo: yr }),
144798
144798
  Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
144799
144799
  Success$g,
144800
144800
  {
@@ -145468,7 +145468,7 @@ function InputAmountModal({
145468
145468
  )
145469
145469
  ] });
145470
145470
  }
145471
- function ChooseAmount$h({
145471
+ function ChooseAmount$i({
145472
145472
  poolInfo: ar,
145473
145473
  poolUnderlyingToken: or,
145474
145474
  accountStats: ur
@@ -145544,7 +145544,7 @@ function TxSendModalV2({
145544
145544
  }
145545
145545
  );
145546
145546
  }
145547
- function Transfer$n({ poolInfo: ar }) {
145547
+ function Transfer$o({ 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,
@@ -145624,7 +145624,7 @@ function CreditLineBorrowV2({
145624
145624
  children: [
145625
145625
  !gr && /* @__PURE__ */ jsx(LoadingModal, { title: "Borrow" }),
145626
145626
  gr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
145627
- ChooseAmount$h,
145627
+ ChooseAmount$i,
145628
145628
  {
145629
145629
  poolInfo: hr,
145630
145630
  poolUnderlyingToken: Ar,
@@ -145638,7 +145638,7 @@ function CreditLineBorrowV2({
145638
145638
  poolUnderlyingToken: Ar
145639
145639
  }
145640
145640
  ),
145641
- gr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$n, { poolInfo: hr }),
145641
+ gr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$o, { poolInfo: hr }),
145642
145642
  gr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
145643
145643
  Success$f,
145644
145644
  {
@@ -145661,7 +145661,7 @@ function CreditLineBorrowV2({
145661
145661
  }
145662
145662
  );
145663
145663
  }
145664
- function ChooseAmount$g({
145664
+ function ChooseAmount$h({
145665
145665
  payoffAmount: ar,
145666
145666
  totalDueAmount: or,
145667
145667
  poolInfo: ur
@@ -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$m({ poolInfo: ar }) {
145709
+ function Transfer$n({ 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
@@ -145764,7 +145764,7 @@ function CreditLinePayment({
145764
145764
  handleSuccess: cr,
145765
145765
  children: [
145766
145766
  yr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
145767
- ChooseAmount$g,
145767
+ ChooseAmount$h,
145768
145768
  {
145769
145769
  poolInfo: gr,
145770
145770
  payoffAmount: xr,
@@ -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$m, { poolInfo: gr }),
145775
+ yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$n, { 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,
@@ -145786,7 +145786,7 @@ function CreditLinePayment({
145786
145786
  }
145787
145787
  ) : null;
145788
145788
  }
145789
- function ChooseAmount$f({
145789
+ function ChooseAmount$g({
145790
145790
  payoffAmount: ar,
145791
145791
  totalDueAmount: or,
145792
145792
  poolInfo: ur,
@@ -145849,7 +145849,7 @@ function ApproveAllowance$a({
145849
145849
  }
145850
145850
  );
145851
145851
  }
145852
- function Transfer$l({
145852
+ function Transfer$m({
145853
145853
  poolInfo: ar,
145854
145854
  poolUnderlyingToken: or
145855
145855
  }) {
@@ -145921,7 +145921,7 @@ function CreditLinePaymentV2({
145921
145921
  handleSuccess: ur,
145922
145922
  children: [
145923
145923
  Ar === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
145924
- ChooseAmount$f,
145924
+ ChooseAmount$g,
145925
145925
  {
145926
145926
  poolInfo: hr,
145927
145927
  poolUnderlyingToken: xr,
@@ -145937,7 +145937,7 @@ function CreditLinePaymentV2({
145937
145937
  }
145938
145938
  ),
145939
145939
  Ar === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(
145940
- Transfer$l,
145940
+ Transfer$m,
145941
145941
  {
145942
145942
  poolInfo: hr,
145943
145943
  poolUnderlyingToken: xr
@@ -145962,7 +145962,7 @@ function CreditLinePaymentV2({
145962
145962
  }
145963
145963
  );
145964
145964
  }
145965
- function ChooseAmount$e({
145965
+ function ChooseAmount$f({
145966
145966
  poolInfo: ar,
145967
145967
  creditConfigAccount: or
145968
145968
  }) {
@@ -178669,7 +178669,7 @@ function SolanaTxSendModal({
178669
178669
  }
178670
178670
  );
178671
178671
  }
178672
- function Transfer$k({ poolInfo: ar }) {
178672
+ function Transfer$l({ 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$7({
178838
+ function Done$8({
178839
178839
  poolInfo: ar,
178840
178840
  poolState: or,
178841
178841
  handleAction: ur
@@ -178899,15 +178899,15 @@ function SolanaBorrow({
178899
178899
  handleSuccess: cr,
178900
178900
  children: [
178901
178901
  dr === WIDGET_STEP.ChooseAmount && hr && /* @__PURE__ */ jsx(
178902
- ChooseAmount$e,
178902
+ ChooseAmount$f,
178903
178903
  {
178904
178904
  poolInfo: ar,
178905
178905
  creditConfigAccount: hr
178906
178906
  }
178907
178907
  ),
178908
- dr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$k, { poolInfo: ar }),
178908
+ dr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$l, { poolInfo: ar }),
178909
178909
  dr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
178910
- Done$7,
178910
+ Done$8,
178911
178911
  {
178912
178912
  poolInfo: ar,
178913
178913
  poolState: or,
@@ -178937,7 +178937,7 @@ function SolanaBorrow({
178937
178937
  }
178938
178938
  );
178939
178939
  }
178940
- function ChooseAmount$d({
178940
+ function ChooseAmount$e({
178941
178941
  poolInfo: ar,
178942
178942
  creditStateAccount: or
178943
178943
  }) {
@@ -178982,7 +178982,7 @@ function ChooseAmount$d({
178982
178982
  }
178983
178983
  );
178984
178984
  }
178985
- function Transfer$j({ poolInfo: ar }) {
178985
+ function Transfer$k({ 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$j({ poolInfo: ar }) {
179032
179032
  }
179033
179033
  );
179034
179034
  }
179035
- function Done$6({ poolInfo: ar, handleAction: or }) {
179035
+ function Done$7({ 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 () => {
@@ -179077,14 +179077,14 @@ function SolanaPayment({
179077
179077
  handleSuccess: ur,
179078
179078
  children: [
179079
179079
  lr === WIDGET_STEP.ChooseAmount && pr && /* @__PURE__ */ jsx(
179080
- ChooseAmount$d,
179080
+ ChooseAmount$e,
179081
179081
  {
179082
179082
  poolInfo: ar,
179083
179083
  creditStateAccount: pr
179084
179084
  }
179085
179085
  ),
179086
- lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$j, { poolInfo: ar }),
179087
- lr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$6, { poolInfo: ar, handleAction: or }),
179086
+ lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$k, { poolInfo: ar }),
179087
+ lr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$7, { 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$i({
179140
+ function Transfer$j({
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$i,
179208
+ Transfer$j,
179209
179209
  {
179210
179210
  poolInfo: hr,
179211
179211
  amountToDeposit: xr,
@@ -179268,7 +179268,7 @@ function Evaluation$4({ poolInfo: ar, tokenId: or }) {
179268
179268
  }
179269
179269
  );
179270
179270
  }
179271
- function ChooseAmount$c({
179271
+ function ChooseAmount$d({
179272
179272
  poolInfo: ar,
179273
179273
  accountStats: or
179274
179274
  }) {
@@ -179516,7 +179516,7 @@ function ApproveNFT({ poolInfo: ar, tokenId: or }) {
179516
179516
  }
179517
179517
  );
179518
179518
  }
179519
- function Transfer$h({ poolInfo: ar, tokenId: or }) {
179519
+ function Transfer$i({ 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]);
@@ -179562,10 +179562,10 @@ function InvoiceFactoringBorrow({
179562
179562
  handleSuccess: fr,
179563
179563
  children: [
179564
179564
  Sr === WIDGET_STEP.Evaluation && /* @__PURE__ */ jsx(Evaluation$4, { poolInfo: yr, tokenId: ur.toString() }),
179565
- Sr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(ChooseAmount$c, { poolInfo: yr, accountStats: xr }),
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$h, { poolInfo: yr, tokenId: ur.toString() }),
179568
+ Sr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$i, { 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,
@@ -179579,7 +179579,7 @@ function InvoiceFactoringBorrow({
179579
179579
  }
179580
179580
  ) : null;
179581
179581
  }
179582
- function ChooseAmount$b({
179582
+ function ChooseAmount$c({
179583
179583
  creditRecord: ar,
179584
179584
  poolInfo: or
179585
179585
  }) {
@@ -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$g({ poolInfo: ar }) {
179626
+ function Transfer$h({ 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]);
@@ -179668,9 +179668,9 @@ function InvoiceFactoringPayment({
179668
179668
  handleClose: ur,
179669
179669
  handleSuccess: cr,
179670
179670
  children: [
179671
- yr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(ChooseAmount$b, { creditRecord: Ir, poolInfo: gr }),
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$g, { poolInfo: gr }),
179673
+ yr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$h, { 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,
@@ -180048,7 +180048,7 @@ function requireDayjs_min() {
180048
180048
  }
180049
180049
  var dayjs_minExports = requireDayjs_min();
180050
180050
  const dayjs = /* @__PURE__ */ getDefaultExportFromCjs$3(dayjs_minExports);
180051
- function ChooseAmount$a({
180051
+ function ChooseAmount$b({
180052
180052
  poolInfo: ar,
180053
180053
  poolUnderlyingToken: or,
180054
180054
  trancheInfo: ur
@@ -180108,7 +180108,7 @@ function ChooseAmount$a({
180108
180108
  }
180109
180109
  );
180110
180110
  }
180111
- function Transfer$f({
180111
+ function Transfer$g({
180112
180112
  poolInfo: ar,
180113
180113
  poolUnderlyingToken: or,
180114
180114
  trancheInfo: ur
@@ -180131,7 +180131,7 @@ function Transfer$f({
180131
180131
  }
180132
180132
  ) : null;
180133
180133
  }
180134
- function Done$5({ handleAction: ar }) {
180134
+ function Done$6({ handleAction: ar }) {
180135
180135
  const { redeemShares: or } = useAppSelector(selectWidgetState), ur = [
180136
180136
  `${formatNumber$1(or)} shares requested for redemption`
180137
180137
  ];
@@ -180216,7 +180216,7 @@ function AddRedemptionV2({
180216
180216
  }
180217
180217
  ),
180218
180218
  yr === WIDGET_STEP.ChooseAmount && Ur && /* @__PURE__ */ jsx(
180219
- ChooseAmount$a,
180219
+ ChooseAmount$b,
180220
180220
  {
180221
180221
  poolInfo: gr,
180222
180222
  poolUnderlyingToken: xr,
@@ -180224,14 +180224,14 @@ function AddRedemptionV2({
180224
180224
  }
180225
180225
  ),
180226
180226
  yr === WIDGET_STEP.Transfer && Ur && /* @__PURE__ */ jsx(
180227
- Transfer$f,
180227
+ Transfer$g,
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$5, { handleAction: ur }),
180234
+ yr === WIDGET_STEP.Done && Ur && /* @__PURE__ */ jsx(Done$6, { 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$e({
180248
+ function Transfer$f({
180249
180249
  poolInfo: ar,
180250
180250
  trancheType: or,
180251
180251
  redemptionInfo: ur
@@ -180268,7 +180268,7 @@ function Transfer$e({
180268
180268
  }
180269
180269
  ) : null;
180270
180270
  }
180271
- function Done$4({
180271
+ function Done$5({
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$e,
180325
+ Transfer$f,
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$4,
180333
+ Done$5,
180334
180334
  {
180335
180335
  poolUnderlyingToken: xr,
180336
180336
  handleAction: ur,
@@ -180350,7 +180350,7 @@ function CancelRedemptionV2({
180350
180350
  }
180351
180351
  );
180352
180352
  }
180353
- function ChooseAmount$9({
180353
+ function ChooseAmount$a({
180354
180354
  poolInfo: ar,
180355
180355
  poolState: or,
180356
180356
  selectedTranche: ur,
@@ -180530,7 +180530,7 @@ function ChooseTranche$4({
180530
180530
  )
180531
180531
  ] });
180532
180532
  }
180533
- function Done$3({ poolInfo: ar, handleAction: or }) {
180533
+ function Done$4({ 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$3({ poolInfo: ar, handleAction: or }) {
180545
180545
  }
180546
180546
  );
180547
180547
  }
180548
- function Transfer$d({
180548
+ function Transfer$e({
180549
180549
  poolInfo: ar,
180550
180550
  selectedTranche: or
180551
180551
  }) {
@@ -180665,7 +180665,7 @@ function SolanaLendAddRedemption({
180665
180665
  }
180666
180666
  ),
180667
180667
  Sr === WIDGET_STEP.ChooseAmount && xr && /* @__PURE__ */ jsx(
180668
- ChooseAmount$9,
180668
+ ChooseAmount$a,
180669
180669
  {
180670
180670
  poolInfo: ar,
180671
180671
  poolState: or,
@@ -180673,8 +180673,8 @@ function SolanaLendAddRedemption({
180673
180673
  selectedTranche: xr
180674
180674
  }
180675
180675
  ),
180676
- Sr === WIDGET_STEP.Transfer && xr && /* @__PURE__ */ jsx(Transfer$d, { poolInfo: ar, selectedTranche: xr }),
180677
- Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$3, { poolInfo: ar, handleAction: cr }),
180676
+ Sr === WIDGET_STEP.Transfer && xr && /* @__PURE__ */ jsx(Transfer$e, { poolInfo: ar, selectedTranche: xr }),
180677
+ Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$4, { 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$c({
180692
+ function Transfer$d({
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$2({
180828
+ function Done$3({
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$c,
180921
+ Transfer$d,
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$2,
180930
+ Done$3,
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$b({
180952
+ function Transfer$c({
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$b, { poolInfo: ar, poolState: or }),
181138
+ lr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$c, { poolInfo: ar, poolState: or }),
181139
181139
  lr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
181140
181140
  Success$9,
181141
181141
  {
@@ -182759,7 +182759,7 @@ function ChooseTranche$2({
182759
182759
  )
182760
182760
  ] });
182761
182761
  }
182762
- function ChooseAmount$8({
182762
+ function ChooseAmount$9({
182763
182763
  poolInfo: ar,
182764
182764
  poolState: or,
182765
182765
  tokenAccount: ur,
@@ -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$a({
182862
+ function Transfer$b({
182863
182863
  poolInfo: ar,
182864
182864
  poolState: or,
182865
182865
  selectedTranche: ur,
@@ -183147,7 +183147,7 @@ function SolanaLendSupply({
183147
183147
  }
183148
183148
  ),
183149
183149
  Ir === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
183150
- ChooseAmount$8,
183150
+ ChooseAmount$9,
183151
183151
  {
183152
183152
  poolInfo: ar,
183153
183153
  poolState: or,
@@ -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$a,
183161
+ Transfer$b,
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$9({
184200
+ function Transfer$a({
184201
184201
  poolInfo: ar,
184202
184202
  selectedTranche: or,
184203
184203
  poolIsClosed: ur
@@ -184229,7 +184229,15 @@ function Transfer$9({
184229
184229
  )
184230
184230
  ));
184231
184231
  }
184232
- if (ur) {
184232
+ if (yr.add(
184233
+ createAssociatedTokenAccountIdempotentInstruction(
184234
+ cr,
184235
+ Rr,
184236
+ cr,
184237
+ new PublicKey$2(Cr),
184238
+ TOKEN_2022_PROGRAM_ID
184239
+ )
184240
+ ), ur) {
184233
184241
  const Mr = await dr.methods.withdrawAfterPoolClosure().accountsPartial({
184234
184242
  lender: cr,
184235
184243
  humaConfig: ar.humaConfig,
@@ -184288,7 +184296,7 @@ function Transfer$9({
184288
184296
  }
184289
184297
  );
184290
184298
  }
184291
- function Done$1({
184299
+ function Done$2({
184292
184300
  poolUnderlyingToken: ar,
184293
184301
  withdrawAmount: or,
184294
184302
  option: ur,
@@ -184449,7 +184457,7 @@ function SolanaLendWithdraw({
184449
184457
  }
184450
184458
  ),
184451
184459
  hr === WIDGET_STEP.Transfer && Jr.id === "withdraw-only" && /* @__PURE__ */ jsx(
184452
- Transfer$9,
184460
+ Transfer$a,
184453
184461
  {
184454
184462
  poolInfo: ar,
184455
184463
  selectedTranche: fr,
@@ -184457,7 +184465,7 @@ function SolanaLendWithdraw({
184457
184465
  }
184458
184466
  ),
184459
184467
  hr === WIDGET_STEP.Done && Qr && /* @__PURE__ */ jsx(
184460
- Done$1,
184468
+ Done$2,
184461
184469
  {
184462
184470
  poolUnderlyingToken: ar.underlyingMint,
184463
184471
  withdrawAmount: Qr,
@@ -184478,154 +184486,76 @@ function SolanaLendWithdraw({
184478
184486
  }
184479
184487
  );
184480
184488
  }
184481
- function ChooseTranche$1({
184482
- poolUnderlyingToken: ar,
184483
- selectedTranche: or,
184484
- changeTranche: ur
184485
- }) {
184486
- const cr = useTheme(), fr = useAppDispatch(), lr = {
184487
- subTitle: css`
184488
- color: ${cr.palette.text.primary} !important;
184489
- font-weight: 400;
184490
- font-size: 16px;
184491
- line-height: 150%;
184492
- letter-spacing: 0.15px;
184493
- margin-top: ${cr.spacing(5)};
184494
- margin-left: ${cr.spacing(2)};
184495
- `,
184496
- radioGroup: css`
184497
- margin-left: ${cr.spacing(3)};
184498
- margin-top: ${cr.spacing(3)};
184499
- `,
184500
- formControl: css`
184501
- margin-bottom: ${cr.spacing(1)};
184502
-
184503
- .MuiFormControlLabel-label {
184504
- color: ${cr.palette.text.primary};
184505
- font-weight: 400;
184506
- font-size: 16px;
184507
- line-height: 150%;
184508
- letter-spacing: 0.15px;
184509
- }
184510
- `
184511
- }, dr = () => {
184512
- fr(setStep(WIDGET_STEP.ChooseAmount));
184513
- }, pr = [
184514
- {
184515
- label: "Senior",
184516
- value: "senior"
184517
- },
184518
- {
184519
- label: "Junior",
184520
- value: "junior"
184521
- }
184522
- ];
184523
- return /* @__PURE__ */ jsxs(WrapperModal, { title: `Supply ${ar.symbol}`, children: [
184524
- /* @__PURE__ */ jsxs(FormControl, { children: [
184525
- /* @__PURE__ */ jsx(FormLabel, { css: lr.subTitle, children: "Select Tranche Type" }),
184526
- /* @__PURE__ */ jsx(
184527
- RadioGroup,
184528
- {
184529
- "aria-labelledby": "buttons-group-label",
184530
- name: "radio-buttons-group",
184531
- css: lr.radioGroup,
184532
- onChange: (hr) => ur(hr.target.value),
184533
- children: pr.map((hr) => /* @__PURE__ */ jsx(
184534
- FormControlLabel,
184535
- {
184536
- value: hr.value,
184537
- control: /* @__PURE__ */ jsx(
184538
- Radio,
184539
- {
184540
- sx: {
184541
- "& .MuiSvgIcon-root": {
184542
- fontSize: 24
184543
- }
184544
- }
184545
- }
184546
- ),
184547
- label: hr.label,
184548
- css: lr.formControl
184549
- },
184550
- hr.label
184551
- ))
184552
- }
184553
- )
184554
- ] }),
184555
- /* @__PURE__ */ jsx(
184556
- BottomButton,
184557
- {
184558
- variant: "contained",
184559
- disabled: !or,
184560
- onClick: dr,
184561
- children: "NEXT"
184562
- }
184563
- )
184564
- ] });
184565
- }
184566
- function ChooseAmount$7({
184489
+ function ChooseAmount$8({
184567
184490
  poolInfo: ar,
184568
184491
  poolState: or,
184569
- tokenBalance: ur,
184570
- selectedTranche: cr,
184571
- isUniTranche: fr
184492
+ selectedTranche: ur
184572
184493
  }) {
184573
- const lr = useAppDispatch(), { symbol: dr, decimals: pr } = ar.underlyingToken, [hr, Ar] = useState(0), gr = BigInt(ur || 0), { juniorAvailableCapBN: yr, seniorAvailableCapBN: Sr } = useMemo(() => {
184574
- const {
184575
- maxSeniorJuniorRatio: Ur,
184576
- liquidityCap: Qr,
184577
- seniorTrancheAssets: qr,
184578
- juniorTrancheAssets: Hr
184579
- } = or, Jr = BigInt(Hr ?? 0), zr = BigInt(qr ?? 0), Vr = zr + Jr;
184580
- let Yr = BigInt(Qr ?? 0) - Vr;
184581
- Yr = Yr < 0 ? BigInt(0) : Yr;
184582
- let br = Jr * BigInt(Ur ?? 0) - zr;
184583
- return br = br > Yr ? Yr : br, {
184584
- juniorAvailableCapBN: Yr - br,
184585
- seniorAvailableCapBN: br
184494
+ const cr = useAppDispatch(), { address: fr } = useContext(StellarConnectionContext), [lr, dr] = useState(0), [pr, hr] = useState(null), [Ar, gr] = useState(!0), { symbol: yr, decimals: Sr } = ar.underlyingToken, { trancheDecimals: Ir } = ar, xr = BigInt(
184495
+ ur === "senior" ? or.seniorTrancheAssets ?? 0 : or.juniorTrancheAssets ?? 0
184496
+ ), Cr = BigInt(
184497
+ ur === "senior" ? or.seniorTrancheTokenSupply ?? 0 : or.juniorTrancheTokenSupply ?? 0
184498
+ );
184499
+ useEffect(() => {
184500
+ let Qr = !1;
184501
+ async function qr() {
184502
+ if (!fr) {
184503
+ gr(!1);
184504
+ return;
184505
+ }
184506
+ gr(!0);
184507
+ try {
184508
+ const Hr = await fetchStellarDepositRecord(
184509
+ ar,
184510
+ ur,
184511
+ fr
184512
+ );
184513
+ Qr || hr((Hr == null ? void 0 : Hr.principal) ?? 0n);
184514
+ } finally {
184515
+ Qr || gr(!1);
184516
+ }
184517
+ }
184518
+ return qr(), () => {
184519
+ Qr = !0;
184586
184520
  };
184587
- }, [or]), Ir = (Ur) => {
184588
- Ar(Ur), lr(setSupplyAmount(Number(Ur)));
184589
- }, xr = () => {
184590
- lr(setStep(WIDGET_STEP.Transfer));
184591
- }, Cr = () => cr === "junior" ? yr : Sr, Rr = () => {
184592
- const Ur = or.minDepositAmount ? tokenDecimalUtils.formatUnits(
184593
- BigInt(or.minDepositAmount),
184594
- pr
184595
- ) : 0;
184596
- return Math.max(0, Math.ceil(Number(Ur)));
184597
- }, Pr = () => {
184598
- const Ur = Cr();
184599
- return gr > Ur ? Ur : gr;
184600
- }, Mr = () => {
184601
- const Ur = Cr(), Qr = tokenDecimalUtils.parseUnits(
184602
- String(hr),
184603
- pr
184604
- ), qr = Ur - Qr;
184605
- return qr <= BigInt(0) ? ["0 remaining capacity"] : [
184606
- `${formatNumber$1(
184607
- tokenDecimalUtils.formatUnits(qr, pr)
184608
- )} remaining capacity`
184609
- ];
184610
- };
184521
+ }, [ar, ur, fr]);
184522
+ const Rr = useCallback(() => pr == null ? 0 : Number(tokenDecimalUtils.formatUnits(pr, Sr)), [pr, Sr]), Pr = useCallback(
184523
+ (Qr) => {
184524
+ if (dr(Qr), cr(setRedeemAmount(Qr)), Qr <= 0 || xr <= 0n) {
184525
+ cr(setRedeemShares(0));
184526
+ return;
184527
+ }
184528
+ const qr = tokenDecimalUtils.parseUnits(
184529
+ String(Qr),
184530
+ Sr
184531
+ ), Hr = getStellarSharesFromUnderlyingTokenAmount(
184532
+ qr,
184533
+ xr,
184534
+ Cr
184535
+ ), Jr = Number(
184536
+ tokenDecimalUtils.formatUnits(Hr, Ir)
184537
+ );
184538
+ cr(setRedeemShares(Jr));
184539
+ },
184540
+ [cr, Sr, Ir, xr, Cr]
184541
+ ), Mr = useCallback(() => {
184542
+ cr(setStep(WIDGET_STEP.Transfer));
184543
+ }, [cr]);
184544
+ if (Ar)
184545
+ return /* @__PURE__ */ jsx(LoadingModal, { title: "Redemption" });
184546
+ const Ur = Rr();
184611
184547
  return /* @__PURE__ */ jsx(
184612
184548
  InputAmountModal,
184613
184549
  {
184614
- title: "Enter Amount",
184615
- subTitle: `Depositing to ${fr ? "uni" : cr} tranche`,
184616
- tokenSymbol: dr,
184617
- currentAmount: hr,
184618
- handleChangeAmount: Ir,
184619
- minimumAmount: Rr(),
184620
- maxAmount: Number(
184621
- tokenDecimalUtils.formatUnits(Pr(), pr)
184622
- ),
184623
- maxAmountTitle: `${formatNumber$1(
184624
- tokenDecimalUtils.formatUnits(gr, pr)
184625
- )} balance`,
184626
- infos: Mr(),
184627
- handleAction: xr,
184628
- actionText: "SUPPLY"
184550
+ title: "Redemption",
184551
+ subTitle: `Enter amount of ${yr} to withdraw from the ${ur} tranche`,
184552
+ tokenSymbol: yr,
184553
+ currentAmount: lr,
184554
+ handleChangeAmount: Pr,
184555
+ maxAmount: Ur,
184556
+ maxAmountTitle: `${formatNumber$1(Ur)} ${yr} requestable`,
184557
+ handleAction: Mr,
184558
+ actionText: "REQUEST"
184629
184559
  }
184630
184560
  );
184631
184561
  }
@@ -227268,27 +227198,28 @@ function StellarTxSendModal({
227268
227198
  }
227269
227199
  );
227270
227200
  }
227271
- function Transfer$8({
227201
+ function Transfer$9({
227272
227202
  poolInfo: ar,
227273
227203
  selectedTranche: or
227274
227204
  }) {
227275
- const ur = useAppDispatch(), [cr, fr] = useState(null), { address: lr } = useContext(StellarConnectionContext), { supplyAmount: dr } = useAppSelector(selectWidgetState), { decimals: pr } = ar.underlyingToken, hr = tokenDecimalUtils.parseUnits(
227276
- String(dr),
227205
+ const ur = useAppDispatch(), [cr, fr] = useState(null), { address: lr } = useContext(StellarConnectionContext), { redeemShares: dr } = useAppSelector(selectWidgetState), pr = ar.trancheDecimals, hr = tokenDecimalUtils.parseUnits(
227206
+ String(dr ?? 0),
227277
227207
  pr
227278
227208
  ), Ar = useCallback(async () => {
227279
227209
  ur(setStep(WIDGET_STEP.Done));
227280
227210
  }, [ur]);
227281
227211
  return useEffect(() => {
227282
227212
  async function gr() {
227283
- if (!lr)
227213
+ if (!lr || hr <= BigInt(0))
227284
227214
  return;
227285
227215
  const yr = STELLAR_CHAINS_INFO[ar.chainId], Ir = await new distExports$2.Client({
227286
227216
  publicKey: lr,
227287
227217
  contractId: or === "senior" ? ar.seniorTranche : ar.juniorTranche,
227288
227218
  ...getClientCommonParams(yr, lr)
227289
- }).deposit({
227219
+ }).add_redemption_request({
227220
+ caller: lr,
227290
227221
  lender: lr,
227291
- assets: hr
227222
+ shares: hr
227292
227223
  });
227293
227224
  fr(Ir);
227294
227225
  }
@@ -227376,6 +227307,244 @@ function StellarTxDoneModal({
227376
227307
  ] })
227377
227308
  ] });
227378
227309
  }
227310
+ function Done$1({ poolInfo: ar, handleAction: or }) {
227311
+ const { redeemAmount: ur, txHash: cr } = useAppSelector(selectWidgetState), { symbol: fr } = ar.underlyingToken, lr = [
227312
+ `${formatNumber$1(ur ?? 0)} ${fr} requested for withdrawal`
227313
+ ], dr = useCallback(() => {
227314
+ or({ isSuccess: !0 });
227315
+ }, [or]);
227316
+ return /* @__PURE__ */ jsx(
227317
+ StellarTxDoneModal,
227318
+ {
227319
+ chainId: ar.chainId,
227320
+ handleAction: dr,
227321
+ content: lr,
227322
+ txHash: cr,
227323
+ buttonText: "DONE"
227324
+ }
227325
+ );
227326
+ }
227327
+ function StellarLendAddRedemption({
227328
+ poolInfo: ar,
227329
+ poolState: or,
227330
+ tranche: ur,
227331
+ handleClose: cr,
227332
+ handleSuccess: fr
227333
+ }) {
227334
+ const lr = useDispatch(), { address: dr } = useContext(StellarConnectionContext), { step: pr, errorMessage: hr } = useAppSelector(selectWidgetState);
227335
+ useEffect(() => {
227336
+ !pr && dr && lr(setStep(WIDGET_STEP.ChooseAmount));
227337
+ }, [lr, pr, dr]);
227338
+ const Ar = "Redemption";
227339
+ return /* @__PURE__ */ jsxs(
227340
+ WidgetWrapper,
227341
+ {
227342
+ isOpen: !0,
227343
+ loadingTitle: Ar,
227344
+ handleClose: cr,
227345
+ handleSuccess: fr,
227346
+ children: [
227347
+ pr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
227348
+ ChooseAmount$8,
227349
+ {
227350
+ poolInfo: ar,
227351
+ poolState: or,
227352
+ selectedTranche: ur
227353
+ }
227354
+ ),
227355
+ pr === WIDGET_STEP.Transfer && /* @__PURE__ */ jsx(Transfer$9, { poolInfo: ar, selectedTranche: ur }),
227356
+ pr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(Done$1, { poolInfo: ar, handleAction: cr }),
227357
+ pr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
227358
+ ErrorModal,
227359
+ {
227360
+ title: Ar,
227361
+ errorReason: "Sorry there was an error",
227362
+ errorMessage: hr,
227363
+ handleOk: cr
227364
+ }
227365
+ )
227366
+ ]
227367
+ }
227368
+ );
227369
+ }
227370
+ function ChooseTranche$1({
227371
+ poolUnderlyingToken: ar,
227372
+ selectedTranche: or,
227373
+ changeTranche: ur
227374
+ }) {
227375
+ const cr = useTheme(), fr = useAppDispatch(), lr = {
227376
+ subTitle: css`
227377
+ color: ${cr.palette.text.primary} !important;
227378
+ font-weight: 400;
227379
+ font-size: 16px;
227380
+ line-height: 150%;
227381
+ letter-spacing: 0.15px;
227382
+ margin-top: ${cr.spacing(5)};
227383
+ margin-left: ${cr.spacing(2)};
227384
+ `,
227385
+ radioGroup: css`
227386
+ margin-left: ${cr.spacing(3)};
227387
+ margin-top: ${cr.spacing(3)};
227388
+ `,
227389
+ formControl: css`
227390
+ margin-bottom: ${cr.spacing(1)};
227391
+
227392
+ .MuiFormControlLabel-label {
227393
+ color: ${cr.palette.text.primary};
227394
+ font-weight: 400;
227395
+ font-size: 16px;
227396
+ line-height: 150%;
227397
+ letter-spacing: 0.15px;
227398
+ }
227399
+ `
227400
+ }, dr = () => {
227401
+ fr(setStep(WIDGET_STEP.ChooseAmount));
227402
+ }, pr = [
227403
+ {
227404
+ label: "Senior",
227405
+ value: "senior"
227406
+ },
227407
+ {
227408
+ label: "Junior",
227409
+ value: "junior"
227410
+ }
227411
+ ];
227412
+ return /* @__PURE__ */ jsxs(WrapperModal, { title: `Supply ${ar.symbol}`, children: [
227413
+ /* @__PURE__ */ jsxs(FormControl, { children: [
227414
+ /* @__PURE__ */ jsx(FormLabel, { css: lr.subTitle, children: "Select Tranche Type" }),
227415
+ /* @__PURE__ */ jsx(
227416
+ RadioGroup,
227417
+ {
227418
+ "aria-labelledby": "buttons-group-label",
227419
+ name: "radio-buttons-group",
227420
+ css: lr.radioGroup,
227421
+ onChange: (hr) => ur(hr.target.value),
227422
+ children: pr.map((hr) => /* @__PURE__ */ jsx(
227423
+ FormControlLabel,
227424
+ {
227425
+ value: hr.value,
227426
+ control: /* @__PURE__ */ jsx(
227427
+ Radio,
227428
+ {
227429
+ sx: {
227430
+ "& .MuiSvgIcon-root": {
227431
+ fontSize: 24
227432
+ }
227433
+ }
227434
+ }
227435
+ ),
227436
+ label: hr.label,
227437
+ css: lr.formControl
227438
+ },
227439
+ hr.label
227440
+ ))
227441
+ }
227442
+ )
227443
+ ] }),
227444
+ /* @__PURE__ */ jsx(
227445
+ BottomButton,
227446
+ {
227447
+ variant: "contained",
227448
+ disabled: !or,
227449
+ onClick: dr,
227450
+ children: "NEXT"
227451
+ }
227452
+ )
227453
+ ] });
227454
+ }
227455
+ function ChooseAmount$7({
227456
+ poolInfo: ar,
227457
+ poolState: or,
227458
+ tokenBalance: ur,
227459
+ selectedTranche: cr,
227460
+ isUniTranche: fr
227461
+ }) {
227462
+ const lr = useAppDispatch(), { symbol: dr, decimals: pr } = ar.underlyingToken, [hr, Ar] = useState(0), gr = BigInt(ur || 0), { juniorAvailableCapBN: yr, seniorAvailableCapBN: Sr } = useMemo(() => {
227463
+ const {
227464
+ maxSeniorJuniorRatio: Ur,
227465
+ liquidityCap: Qr,
227466
+ seniorTrancheAssets: qr,
227467
+ juniorTrancheAssets: Hr
227468
+ } = or, Jr = BigInt(Hr ?? 0), zr = BigInt(qr ?? 0), Vr = zr + Jr;
227469
+ let Yr = BigInt(Qr ?? 0) - Vr;
227470
+ Yr = Yr < 0 ? BigInt(0) : Yr;
227471
+ let br = Jr * BigInt(Ur ?? 0) - zr;
227472
+ return br = br > Yr ? Yr : br, {
227473
+ juniorAvailableCapBN: Yr - br,
227474
+ seniorAvailableCapBN: br
227475
+ };
227476
+ }, [or]), Ir = (Ur) => {
227477
+ Ar(Ur), lr(setSupplyAmount(Number(Ur)));
227478
+ }, xr = () => {
227479
+ lr(setStep(WIDGET_STEP.Transfer));
227480
+ }, Cr = () => cr === "junior" ? yr : Sr, Rr = () => {
227481
+ const Ur = or.minDepositAmount ? tokenDecimalUtils.formatUnits(
227482
+ BigInt(or.minDepositAmount),
227483
+ pr
227484
+ ) : 0;
227485
+ return Math.max(0, Math.ceil(Number(Ur)));
227486
+ }, Pr = () => {
227487
+ const Ur = Cr();
227488
+ return gr > Ur ? Ur : gr;
227489
+ }, Mr = () => {
227490
+ const Ur = Cr(), Qr = tokenDecimalUtils.parseUnits(
227491
+ String(hr),
227492
+ pr
227493
+ ), qr = Ur - Qr;
227494
+ return qr <= BigInt(0) ? ["0 remaining capacity"] : [
227495
+ `${formatNumber$1(
227496
+ tokenDecimalUtils.formatUnits(qr, pr)
227497
+ )} remaining capacity`
227498
+ ];
227499
+ };
227500
+ return /* @__PURE__ */ jsx(
227501
+ InputAmountModal,
227502
+ {
227503
+ title: "Enter Amount",
227504
+ subTitle: `Depositing to ${fr ? "uni" : cr} tranche`,
227505
+ tokenSymbol: dr,
227506
+ currentAmount: hr,
227507
+ handleChangeAmount: Ir,
227508
+ minimumAmount: Rr(),
227509
+ maxAmount: Number(
227510
+ tokenDecimalUtils.formatUnits(Pr(), pr)
227511
+ ),
227512
+ maxAmountTitle: `${formatNumber$1(
227513
+ tokenDecimalUtils.formatUnits(gr, pr)
227514
+ )} balance`,
227515
+ infos: Mr(),
227516
+ handleAction: xr,
227517
+ actionText: "SUPPLY"
227518
+ }
227519
+ );
227520
+ }
227521
+ function Transfer$8({
227522
+ poolInfo: ar,
227523
+ selectedTranche: or
227524
+ }) {
227525
+ const ur = useAppDispatch(), [cr, fr] = useState(null), { address: lr } = useContext(StellarConnectionContext), { supplyAmount: dr } = useAppSelector(selectWidgetState), { decimals: pr } = ar.underlyingToken, hr = tokenDecimalUtils.parseUnits(
227526
+ String(dr),
227527
+ pr
227528
+ ), Ar = useCallback(async () => {
227529
+ ur(setStep(WIDGET_STEP.Done));
227530
+ }, [ur]);
227531
+ return useEffect(() => {
227532
+ async function gr() {
227533
+ if (!lr)
227534
+ return;
227535
+ const yr = STELLAR_CHAINS_INFO[ar.chainId], Ir = await new distExports$2.Client({
227536
+ publicKey: lr,
227537
+ contractId: or === "senior" ? ar.seniorTranche : ar.juniorTranche,
227538
+ ...getClientCommonParams(yr, lr)
227539
+ }).deposit({
227540
+ lender: lr,
227541
+ assets: hr
227542
+ });
227543
+ fr(Ir);
227544
+ }
227545
+ gr();
227546
+ }, [ar, or, lr, hr]), /* @__PURE__ */ jsx(StellarTxSendModal, { tx: cr, handleSuccess: Ar });
227547
+ }
227379
227548
  function Success$7({
227380
227549
  poolInfo: ar,
227381
227550
  poolState: or,
@@ -230967,6 +231136,9 @@ function SolanaLendWithdrawWidget(ar) {
230967
231136
  function StellarLendSupplyWidget(ar) {
230968
231137
  return /* @__PURE__ */ jsx(GenericWidget, { ...ar, children: /* @__PURE__ */ jsx(StellarLendSupply, { ...ar }) });
230969
231138
  }
231139
+ function StellarLendAddRedemptionWidget(ar) {
231140
+ return /* @__PURE__ */ jsx(GenericWidget, { ...ar, children: /* @__PURE__ */ jsx(StellarLendAddRedemption, { ...ar }) });
231141
+ }
230970
231142
  function StellarBorrowWidget(ar) {
230971
231143
  return /* @__PURE__ */ jsx(GenericWidget, { ...ar, children: /* @__PURE__ */ jsx(StellarBorrow, { ...ar }) });
230972
231144
  }
@@ -230999,6 +231171,7 @@ export {
230999
231171
  SolanaLendWithdrawWidget,
231000
231172
  SolanaPaymentWidget,
231001
231173
  StellarBorrowWidget,
231174
+ StellarLendAddRedemptionWidget,
231002
231175
  StellarLendSupplyWidget,
231003
231176
  SuperfluidFactoringWidget,
231004
231177
  SupplyFirstLossCoverWidget