@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/dist/cjs/index.cjs +24 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +24 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/CreditLine/solanaBorrow/1-ChooseAmount.tsx +2 -2
- package/src/components/CreditLine/solanaBorrow/2-ApproveAllowance.tsx +5 -3
- package/src/components/Lend/solanaAddRedemption/2-ChooseAmount.tsx +5 -5
- package/src/components/Lend/solanaAddRedemption/index.tsx +6 -2
- package/src/components/Lend/solanaCancelRedemption/index.tsx +2 -2
- package/src/components/Lend/solanaSupply/3-ChooseAmount.tsx +8 -6
- package/src/components/Lend/solanaSupply/index.tsx +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -9350,7 +9350,7 @@ function ChooseAmount$2(_ref) {
|
|
|
9350
9350
|
decimals
|
|
9351
9351
|
} = poolInfo.underlyingMint;
|
|
9352
9352
|
const [currentAmount, setCurrentAmount] = React.useState(0);
|
|
9353
|
-
const balance = React.useMemo(() => new anchor.BN(tokenAccount.amount), [tokenAccount.amount]);
|
|
9353
|
+
const balance = React.useMemo(() => new anchor.BN(tokenAccount.amount.toString()), [tokenAccount.amount]);
|
|
9354
9354
|
const {
|
|
9355
9355
|
juniorAvailableCapBN,
|
|
9356
9356
|
seniorAvailableCapBN
|
|
@@ -9361,11 +9361,11 @@ function ChooseAmount$2(_ref) {
|
|
|
9361
9361
|
seniorTrancheAssets,
|
|
9362
9362
|
juniorTrancheAssets
|
|
9363
9363
|
} = poolState;
|
|
9364
|
-
const juniorTrancheAssetsBN = new anchor.BN(juniorTrancheAssets);
|
|
9365
|
-
const seniorTrancheAssetsBN = new anchor.BN(seniorTrancheAssets);
|
|
9364
|
+
const juniorTrancheAssetsBN = new anchor.BN(juniorTrancheAssets !== null && juniorTrancheAssets !== void 0 ? juniorTrancheAssets : 0);
|
|
9365
|
+
const seniorTrancheAssetsBN = new anchor.BN(seniorTrancheAssets !== null && seniorTrancheAssets !== void 0 ? seniorTrancheAssets : 0);
|
|
9366
9366
|
const totalDeployedBN = seniorTrancheAssetsBN.add(juniorTrancheAssetsBN);
|
|
9367
|
-
const totalAvailableCapBN = new anchor.BN(liquidityCap).sub(totalDeployedBN);
|
|
9368
|
-
const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(maxSeniorJuniorRatio);
|
|
9367
|
+
const totalAvailableCapBN = new anchor.BN(liquidityCap !== null && liquidityCap !== void 0 ? liquidityCap : 0).sub(totalDeployedBN);
|
|
9368
|
+
const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(maxSeniorJuniorRatio !== null && maxSeniorJuniorRatio !== void 0 ? maxSeniorJuniorRatio : 0);
|
|
9369
9369
|
let seniorAvailableCapBN = maxSeniorAssetsBN.sub(seniorTrancheAssetsBN);
|
|
9370
9370
|
seniorAvailableCapBN = seniorAvailableCapBN.gt(totalAvailableCapBN) ? totalAvailableCapBN : seniorAvailableCapBN;
|
|
9371
9371
|
return {
|
|
@@ -9669,6 +9669,9 @@ function SolanaLendSupply(_ref) {
|
|
|
9669
9669
|
handleSuccess
|
|
9670
9670
|
} = _ref;
|
|
9671
9671
|
const dispatch = reactRedux.useDispatch();
|
|
9672
|
+
const {
|
|
9673
|
+
isUniTranche
|
|
9674
|
+
} = poolState;
|
|
9672
9675
|
const {
|
|
9673
9676
|
seniorLenderApproved,
|
|
9674
9677
|
juniorLenderApproved,
|
|
@@ -9679,7 +9682,6 @@ function SolanaLendSupply(_ref) {
|
|
|
9679
9682
|
step,
|
|
9680
9683
|
errorMessage
|
|
9681
9684
|
} = useAppSelector(selectWidgetState);
|
|
9682
|
-
const isUniTranche = poolState.maxSeniorJuniorRatio === 0;
|
|
9683
9685
|
const [selectedTranche, setSelectedTranche] = React.useState();
|
|
9684
9686
|
React.useEffect(() => {
|
|
9685
9687
|
if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccount) {
|
|
@@ -9767,24 +9769,26 @@ function ChooseAmount$1(_ref) {
|
|
|
9767
9769
|
loading: isLoadingTokenAccounts
|
|
9768
9770
|
} = webShared.useTrancheTokenAccounts(poolInfo);
|
|
9769
9771
|
const maxSharesFormatted = React.useMemo(() => {
|
|
9772
|
+
var _seniorTokenAccount$a, _seniorTokenAccount$a2, _juniorTokenAccount$a, _juniorTokenAccount$a2;
|
|
9770
9773
|
if (!(mintAccount !== null && mintAccount !== void 0 && mintAccount.decimals)) {
|
|
9771
9774
|
return 0;
|
|
9772
9775
|
}
|
|
9773
|
-
return shared.SolanaTokenUtils.formatUnits(selectedTranche === 'senior' ? new anchor.BN(seniorTokenAccount === null || seniorTokenAccount === void 0 ? void 0 :
|
|
9776
|
+
return shared.SolanaTokenUtils.formatUnits(selectedTranche === 'senior' ? new anchor.BN((_seniorTokenAccount$a = seniorTokenAccount === null || seniorTokenAccount === void 0 || (_seniorTokenAccount$a2 = seniorTokenAccount.amount) === null || _seniorTokenAccount$a2 === void 0 ? void 0 : _seniorTokenAccount$a2.toString()) !== null && _seniorTokenAccount$a !== void 0 ? _seniorTokenAccount$a : 0) : new anchor.BN((_juniorTokenAccount$a = juniorTokenAccount === null || juniorTokenAccount === void 0 || (_juniorTokenAccount$a2 = juniorTokenAccount.amount) === null || _juniorTokenAccount$a2 === void 0 ? void 0 : _juniorTokenAccount$a2.toString()) !== null && _juniorTokenAccount$a !== void 0 ? _juniorTokenAccount$a : 0), mintAccount.decimals);
|
|
9774
9777
|
}, [mintAccount, juniorTokenAccount === null || juniorTokenAccount === void 0 ? void 0 : juniorTokenAccount.amount, selectedTranche, seniorTokenAccount === null || seniorTokenAccount === void 0 ? void 0 : seniorTokenAccount.amount]);
|
|
9775
9778
|
const sharePrice = React.useMemo(() => {
|
|
9779
|
+
var _poolState$seniorTran, _poolState$juniorTran;
|
|
9776
9780
|
if (!(mintAccount !== null && mintAccount !== void 0 && mintAccount.decimals) || !(mintAccount !== null && mintAccount !== void 0 && mintAccount.supply)) {
|
|
9777
9781
|
return 0;
|
|
9778
9782
|
}
|
|
9779
|
-
const mintSupplyFormatted = Number(shared.SolanaTokenUtils.formatUnits(new anchor.BN(mintAccount.supply), mintAccount.decimals));
|
|
9783
|
+
const mintSupplyFormatted = Number(shared.SolanaTokenUtils.formatUnits(new anchor.BN(mintAccount.supply.toString()), mintAccount.decimals));
|
|
9780
9784
|
if (mintSupplyFormatted === 0) {
|
|
9781
9785
|
return 0;
|
|
9782
9786
|
}
|
|
9783
|
-
const seniorTrancheAssetsFormatted = Number(shared.SolanaTokenUtils.formatUnits(new anchor.BN(poolState === null || poolState === void 0 ? void 0 : poolState.seniorTrancheAssets), mintAccount.decimals));
|
|
9787
|
+
const seniorTrancheAssetsFormatted = Number(shared.SolanaTokenUtils.formatUnits(new anchor.BN((_poolState$seniorTran = poolState === null || poolState === void 0 ? void 0 : poolState.seniorTrancheAssets) !== null && _poolState$seniorTran !== void 0 ? _poolState$seniorTran : 0), mintAccount.decimals));
|
|
9784
9788
|
if (selectedTranche === 'senior') {
|
|
9785
9789
|
return seniorTrancheAssetsFormatted / mintSupplyFormatted;
|
|
9786
9790
|
}
|
|
9787
|
-
const juniorTrancheAssetsFormatted = Number(shared.SolanaTokenUtils.formatUnits(new anchor.BN(poolState === null || poolState === void 0 ? void 0 : poolState.juniorTrancheAssets), mintAccount.decimals));
|
|
9791
|
+
const juniorTrancheAssetsFormatted = Number(shared.SolanaTokenUtils.formatUnits(new anchor.BN((_poolState$juniorTran = poolState === null || poolState === void 0 ? void 0 : poolState.juniorTrancheAssets) !== null && _poolState$juniorTran !== void 0 ? _poolState$juniorTran : 0), mintAccount.decimals));
|
|
9788
9792
|
return juniorTrancheAssetsFormatted / mintSupplyFormatted;
|
|
9789
9793
|
}, [mintAccount === null || mintAccount === void 0 ? void 0 : mintAccount.decimals, mintAccount === null || mintAccount === void 0 ? void 0 : mintAccount.supply, poolState === null || poolState === void 0 ? void 0 : poolState.juniorTrancheAssets, poolState === null || poolState === void 0 ? void 0 : poolState.seniorTrancheAssets, selectedTranche]);
|
|
9790
9794
|
React.useEffect(() => {
|
|
@@ -9991,8 +9995,9 @@ function SolanaLendAddRedemption(_ref) {
|
|
|
9991
9995
|
const [selectedTranche, setSelectedTranche] = React.useState();
|
|
9992
9996
|
React.useEffect(() => {
|
|
9993
9997
|
if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccounts) {
|
|
9994
|
-
|
|
9995
|
-
const
|
|
9998
|
+
var _seniorTokenAccount$a, _seniorTokenAccount$a2, _juniorTokenAccount$a, _juniorTokenAccount$a2;
|
|
9999
|
+
const seniorTrancheShares = new anchor.BN((_seniorTokenAccount$a = seniorTokenAccount === null || seniorTokenAccount === void 0 || (_seniorTokenAccount$a2 = seniorTokenAccount.amount) === null || _seniorTokenAccount$a2 === void 0 ? void 0 : _seniorTokenAccount$a2.toString()) !== null && _seniorTokenAccount$a !== void 0 ? _seniorTokenAccount$a : 0);
|
|
10000
|
+
const juniorTrancheShares = new anchor.BN((_juniorTokenAccount$a = juniorTokenAccount === null || juniorTokenAccount === void 0 || (_juniorTokenAccount$a2 = juniorTokenAccount.amount) === null || _juniorTokenAccount$a2 === void 0 ? void 0 : _juniorTokenAccount$a2.toString()) !== null && _juniorTokenAccount$a !== void 0 ? _juniorTokenAccount$a : 0);
|
|
9996
10001
|
if (juniorTrancheShares.gtn(0) && seniorTrancheShares.lten(0)) {
|
|
9997
10002
|
setSelectedTranche('junior');
|
|
9998
10003
|
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
@@ -10197,8 +10202,9 @@ function SolanaLendCancelRedemption(_ref) {
|
|
|
10197
10202
|
const [selectedTranche, setSelectedTranche] = React.useState();
|
|
10198
10203
|
React.useEffect(() => {
|
|
10199
10204
|
if (!step && !isLoadingLenderAccounts) {
|
|
10200
|
-
|
|
10201
|
-
const
|
|
10205
|
+
var _seniorLenderStateAcc, _juniorLenderStateAcc;
|
|
10206
|
+
const seniorTrancheSharesRequested = new anchor.BN((_seniorLenderStateAcc = seniorLenderStateAccount === null || seniorLenderStateAccount === void 0 ? void 0 : seniorLenderStateAccount.redemptionRecord.numSharesRequested) !== null && _seniorLenderStateAcc !== void 0 ? _seniorLenderStateAcc : 0);
|
|
10207
|
+
const juniorTrancheSharesRequested = new anchor.BN((_juniorLenderStateAcc = juniorLenderStateAccount === null || juniorLenderStateAccount === void 0 ? void 0 : juniorLenderStateAccount.redemptionRecord.numSharesRequested) !== null && _juniorLenderStateAcc !== void 0 ? _juniorLenderStateAcc : 0);
|
|
10202
10208
|
if (juniorTrancheSharesRequested.gtn(0) && seniorTrancheSharesRequested.lten(0)) {
|
|
10203
10209
|
setSelectedTranche('junior');
|
|
10204
10210
|
dispatch(setStep(WIDGET_STEP.Transfer));
|
|
@@ -10274,10 +10280,10 @@ function ChooseAmount(_ref) {
|
|
|
10274
10280
|
return;
|
|
10275
10281
|
}
|
|
10276
10282
|
const borrowAmountBN = shared.SolanaTokenUtils.parseUnits(String(currentAmount), decimals);
|
|
10277
|
-
const nextStep = borrowAmountBN.gt(new anchor.BN(tokenAccount.delegatedAmount)) || ((_tokenAccount$delegat = tokenAccount.delegate) === null || _tokenAccount$delegat === void 0 ? void 0 : _tokenAccount$delegat.toString()) !== sentinel ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
|
|
10283
|
+
const nextStep = borrowAmountBN.gt(new anchor.BN(tokenAccount.delegatedAmount.toString())) || ((_tokenAccount$delegat = tokenAccount.delegate) === null || _tokenAccount$delegat === void 0 ? void 0 : _tokenAccount$delegat.toString()) !== sentinel ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
|
|
10278
10284
|
dispatch(setBorrowInfo({
|
|
10279
10285
|
borrowAmount: currentAmount,
|
|
10280
|
-
borrowAmountBN,
|
|
10286
|
+
borrowAmountBN: JSON.parse(borrowAmountBN.toString()),
|
|
10281
10287
|
chargedFees: 0,
|
|
10282
10288
|
nextStep
|
|
10283
10289
|
}));
|
|
@@ -10324,9 +10330,9 @@ function ApproveAllowance(_ref) {
|
|
|
10324
10330
|
// delegate
|
|
10325
10331
|
publicKey,
|
|
10326
10332
|
// owner of the wallet
|
|
10327
|
-
shared.SolanaTokenUtils.parseUnits('100000000000',
|
|
10333
|
+
BigInt(shared.SolanaTokenUtils.parseUnits('100000000000',
|
|
10328
10334
|
// 100 billion
|
|
10329
|
-
poolInfo.underlyingMint.decimals),
|
|
10335
|
+
poolInfo.underlyingMint.decimals).toString()),
|
|
10330
10336
|
// amount
|
|
10331
10337
|
poolInfo.underlyingMint.decimals, undefined,
|
|
10332
10338
|
// multiSigners
|