@huma-finance/widgets 0.0.62-beta.617 → 0.0.62-beta.620

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.62-beta.617+10ec4cd",
3
+ "version": "0.0.62-beta.620+c0e0d29",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,7 +30,7 @@
30
30
  "@ethersproject/units": "^5.6.0",
31
31
  "@huma-finance/sdk": "^0.0.61",
32
32
  "@huma-finance/shared": "^0.0.61",
33
- "@huma-finance/web-shared": "^0.0.62-beta.617+10ec4cd",
33
+ "@huma-finance/web-shared": "^0.0.62-beta.620+c0e0d29",
34
34
  "@notifi-network/notifi-frontend-client": "^0.91.1",
35
35
  "@reduxjs/toolkit": "^1.8.6",
36
36
  "@types/utf8": "^3.0.1",
@@ -200,5 +200,5 @@
200
200
  "optionalDependencies": {
201
201
  "encoding": "^0.1.13"
202
202
  },
203
- "gitHead": "10ec4cd7144139bbec751768015e41a0bc79a1d7"
203
+ "gitHead": "c0e0d29e4570dd75f346f1b8a61dcb7abf174df2"
204
204
  }
@@ -55,7 +55,7 @@ export function ChooseAmount({
55
55
  decimals,
56
56
  )
57
57
  const nextStep =
58
- borrowAmountBN.gt(new BN(tokenAccount.delegatedAmount)) ||
58
+ borrowAmountBN.gt(new BN(tokenAccount.delegatedAmount.toString())) ||
59
59
  tokenAccount.delegate?.toString() !== sentinel
60
60
  ? WIDGET_STEP.ApproveAllowance
61
61
  : WIDGET_STEP.Transfer
@@ -63,7 +63,7 @@ export function ChooseAmount({
63
63
  dispatch(
64
64
  setBorrowInfo({
65
65
  borrowAmount: currentAmount,
66
- borrowAmountBN,
66
+ borrowAmountBN: JSON.parse(borrowAmountBN.toString()),
67
67
  chargedFees: 0,
68
68
  nextStep,
69
69
  }),
@@ -51,9 +51,11 @@ export function ApproveAllowance({
51
51
  new PublicKey(poolInfo.underlyingMint.address),
52
52
  new PublicKey(sentinel), // delegate
53
53
  publicKey, // owner of the wallet
54
- SolanaTokenUtils.parseUnits(
55
- '100000000000', // 100 billion
56
- poolInfo.underlyingMint.decimals,
54
+ BigInt(
55
+ SolanaTokenUtils.parseUnits(
56
+ '100000000000', // 100 billion
57
+ poolInfo.underlyingMint.decimals,
58
+ ).toString(),
57
59
  ), // amount
58
60
  poolInfo.underlyingMint.decimals,
59
61
  undefined, // multiSigners
@@ -58,8 +58,8 @@ export function ChooseAmount({
58
58
 
59
59
  return SolanaTokenUtils.formatUnits(
60
60
  selectedTranche === 'senior'
61
- ? new BN(seniorTokenAccount?.amount)
62
- : new BN(juniorTokenAccount?.amount),
61
+ ? new BN(seniorTokenAccount?.amount?.toString() ?? 0)
62
+ : new BN(juniorTokenAccount?.amount?.toString() ?? 0),
63
63
  mintAccount.decimals,
64
64
  )
65
65
  }, [
@@ -76,7 +76,7 @@ export function ChooseAmount({
76
76
 
77
77
  const mintSupplyFormatted = Number(
78
78
  SolanaTokenUtils.formatUnits(
79
- new BN(mintAccount.supply),
79
+ new BN(mintAccount.supply.toString()),
80
80
  mintAccount.decimals,
81
81
  ),
82
82
  )
@@ -87,7 +87,7 @@ export function ChooseAmount({
87
87
 
88
88
  const seniorTrancheAssetsFormatted = Number(
89
89
  SolanaTokenUtils.formatUnits(
90
- new BN(poolState?.seniorTrancheAssets),
90
+ new BN(poolState?.seniorTrancheAssets ?? 0),
91
91
  mintAccount.decimals,
92
92
  ),
93
93
  )
@@ -98,7 +98,7 @@ export function ChooseAmount({
98
98
 
99
99
  const juniorTrancheAssetsFormatted = Number(
100
100
  SolanaTokenUtils.formatUnits(
101
- new BN(poolState?.juniorTrancheAssets),
101
+ new BN(poolState?.juniorTrancheAssets ?? 0),
102
102
  mintAccount.decimals,
103
103
  ),
104
104
  )
@@ -55,8 +55,12 @@ export function SolanaLendAddRedemption({
55
55
 
56
56
  useEffect(() => {
57
57
  if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccounts) {
58
- const seniorTrancheShares = new BN(seniorTokenAccount?.amount)
59
- const juniorTrancheShares = new BN(juniorTokenAccount?.amount)
58
+ const seniorTrancheShares = new BN(
59
+ seniorTokenAccount?.amount?.toString() ?? 0,
60
+ )
61
+ const juniorTrancheShares = new BN(
62
+ juniorTokenAccount?.amount?.toString() ?? 0,
63
+ )
60
64
 
61
65
  if (juniorTrancheShares.gtn(0) && seniorTrancheShares.lten(0)) {
62
66
  setSelectedTranche('junior')
@@ -46,10 +46,10 @@ export function SolanaLendCancelRedemption({
46
46
  useEffect(() => {
47
47
  if (!step && !isLoadingLenderAccounts) {
48
48
  const seniorTrancheSharesRequested = new BN(
49
- seniorLenderStateAccount?.redemptionRecord.numSharesRequested,
49
+ seniorLenderStateAccount?.redemptionRecord.numSharesRequested ?? 0,
50
50
  )
51
51
  const juniorTrancheSharesRequested = new BN(
52
- juniorLenderStateAccount?.redemptionRecord.numSharesRequested,
52
+ juniorLenderStateAccount?.redemptionRecord.numSharesRequested ?? 0,
53
53
  )
54
54
 
55
55
  if (
@@ -18,7 +18,7 @@ type Props = {
18
18
  poolState: SolanaPoolState
19
19
  tokenAccount: Account
20
20
  selectedTranche: TrancheType | undefined
21
- isUniTranche: boolean
21
+ isUniTranche?: boolean
22
22
  }
23
23
 
24
24
  export function ChooseAmount({
@@ -32,7 +32,7 @@ export function ChooseAmount({
32
32
  const { symbol, decimals } = poolInfo.underlyingMint
33
33
  const [currentAmount, setCurrentAmount] = useState<number | string>(0)
34
34
  const balance = useMemo(
35
- () => new BN(tokenAccount.amount),
35
+ () => new BN(tokenAccount.amount.toString()),
36
36
  [tokenAccount.amount],
37
37
  )
38
38
 
@@ -43,11 +43,13 @@ export function ChooseAmount({
43
43
  seniorTrancheAssets,
44
44
  juniorTrancheAssets,
45
45
  } = poolState
46
- const juniorTrancheAssetsBN = new BN(juniorTrancheAssets)
47
- const seniorTrancheAssetsBN = new BN(seniorTrancheAssets)
46
+ const juniorTrancheAssetsBN = new BN(juniorTrancheAssets ?? 0)
47
+ const seniorTrancheAssetsBN = new BN(seniorTrancheAssets ?? 0)
48
48
  const totalDeployedBN = seniorTrancheAssetsBN.add(juniorTrancheAssetsBN)
49
- const totalAvailableCapBN = new BN(liquidityCap).sub(totalDeployedBN)
50
- const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(maxSeniorJuniorRatio)
49
+ const totalAvailableCapBN = new BN(liquidityCap ?? 0).sub(totalDeployedBN)
50
+ const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(
51
+ maxSeniorJuniorRatio ?? 0,
52
+ )
51
53
  let seniorAvailableCapBN = maxSeniorAssetsBN.sub(seniorTrancheAssetsBN)
52
54
  seniorAvailableCapBN = seniorAvailableCapBN.gt(totalAvailableCapBN)
53
55
  ? totalAvailableCapBN
@@ -40,6 +40,7 @@ export function SolanaLendSupply({
40
40
  handleSuccess,
41
41
  }: SolanaLendSupplyProps): React.ReactElement | null {
42
42
  const dispatch = useDispatch()
43
+ const { isUniTranche } = poolState
43
44
  const {
44
45
  seniorLenderApproved,
45
46
  juniorLenderApproved,
@@ -47,7 +48,6 @@ export function SolanaLendSupply({
47
48
  } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
48
49
  const [tokenAccount, isLoadingTokenAccount] = useTokenAccount(poolInfo)
49
50
  const { step, errorMessage } = useAppSelector(selectWidgetState)
50
- const isUniTranche = poolState.maxSeniorJuniorRatio === 0
51
51
  const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
52
52
 
53
53
  useEffect(() => {