@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/index.js
CHANGED
|
@@ -9309,7 +9309,7 @@ function ChooseAmount$2(_ref) {
|
|
|
9309
9309
|
decimals
|
|
9310
9310
|
} = poolInfo.underlyingMint;
|
|
9311
9311
|
const [currentAmount, setCurrentAmount] = useState(0);
|
|
9312
|
-
const balance = useMemo(() => new BN(tokenAccount.amount), [tokenAccount.amount]);
|
|
9312
|
+
const balance = useMemo(() => new BN(tokenAccount.amount.toString()), [tokenAccount.amount]);
|
|
9313
9313
|
const {
|
|
9314
9314
|
juniorAvailableCapBN,
|
|
9315
9315
|
seniorAvailableCapBN
|
|
@@ -9320,11 +9320,11 @@ function ChooseAmount$2(_ref) {
|
|
|
9320
9320
|
seniorTrancheAssets,
|
|
9321
9321
|
juniorTrancheAssets
|
|
9322
9322
|
} = poolState;
|
|
9323
|
-
const juniorTrancheAssetsBN = new BN(juniorTrancheAssets);
|
|
9324
|
-
const seniorTrancheAssetsBN = new BN(seniorTrancheAssets);
|
|
9323
|
+
const juniorTrancheAssetsBN = new BN(juniorTrancheAssets !== null && juniorTrancheAssets !== void 0 ? juniorTrancheAssets : 0);
|
|
9324
|
+
const seniorTrancheAssetsBN = new BN(seniorTrancheAssets !== null && seniorTrancheAssets !== void 0 ? seniorTrancheAssets : 0);
|
|
9325
9325
|
const totalDeployedBN = seniorTrancheAssetsBN.add(juniorTrancheAssetsBN);
|
|
9326
|
-
const totalAvailableCapBN = new BN(liquidityCap).sub(totalDeployedBN);
|
|
9327
|
-
const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(maxSeniorJuniorRatio);
|
|
9326
|
+
const totalAvailableCapBN = new BN(liquidityCap !== null && liquidityCap !== void 0 ? liquidityCap : 0).sub(totalDeployedBN);
|
|
9327
|
+
const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(maxSeniorJuniorRatio !== null && maxSeniorJuniorRatio !== void 0 ? maxSeniorJuniorRatio : 0);
|
|
9328
9328
|
let seniorAvailableCapBN = maxSeniorAssetsBN.sub(seniorTrancheAssetsBN);
|
|
9329
9329
|
seniorAvailableCapBN = seniorAvailableCapBN.gt(totalAvailableCapBN) ? totalAvailableCapBN : seniorAvailableCapBN;
|
|
9330
9330
|
return {
|
|
@@ -9628,6 +9628,9 @@ function SolanaLendSupply(_ref) {
|
|
|
9628
9628
|
handleSuccess
|
|
9629
9629
|
} = _ref;
|
|
9630
9630
|
const dispatch = useDispatch();
|
|
9631
|
+
const {
|
|
9632
|
+
isUniTranche
|
|
9633
|
+
} = poolState;
|
|
9631
9634
|
const {
|
|
9632
9635
|
seniorLenderApproved,
|
|
9633
9636
|
juniorLenderApproved,
|
|
@@ -9638,7 +9641,6 @@ function SolanaLendSupply(_ref) {
|
|
|
9638
9641
|
step,
|
|
9639
9642
|
errorMessage
|
|
9640
9643
|
} = useAppSelector(selectWidgetState);
|
|
9641
|
-
const isUniTranche = poolState.maxSeniorJuniorRatio === 0;
|
|
9642
9644
|
const [selectedTranche, setSelectedTranche] = useState();
|
|
9643
9645
|
useEffect(() => {
|
|
9644
9646
|
if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccount) {
|
|
@@ -9726,24 +9728,26 @@ function ChooseAmount$1(_ref) {
|
|
|
9726
9728
|
loading: isLoadingTokenAccounts
|
|
9727
9729
|
} = useTrancheTokenAccounts(poolInfo);
|
|
9728
9730
|
const maxSharesFormatted = useMemo(() => {
|
|
9731
|
+
var _seniorTokenAccount$a, _seniorTokenAccount$a2, _juniorTokenAccount$a, _juniorTokenAccount$a2;
|
|
9729
9732
|
if (!(mintAccount !== null && mintAccount !== void 0 && mintAccount.decimals)) {
|
|
9730
9733
|
return 0;
|
|
9731
9734
|
}
|
|
9732
|
-
return SolanaTokenUtils.formatUnits(selectedTranche === 'senior' ? new BN(seniorTokenAccount === null || seniorTokenAccount === void 0 ? void 0 :
|
|
9735
|
+
return SolanaTokenUtils.formatUnits(selectedTranche === 'senior' ? new 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 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);
|
|
9733
9736
|
}, [mintAccount, juniorTokenAccount === null || juniorTokenAccount === void 0 ? void 0 : juniorTokenAccount.amount, selectedTranche, seniorTokenAccount === null || seniorTokenAccount === void 0 ? void 0 : seniorTokenAccount.amount]);
|
|
9734
9737
|
const sharePrice = useMemo(() => {
|
|
9738
|
+
var _poolState$seniorTran, _poolState$juniorTran;
|
|
9735
9739
|
if (!(mintAccount !== null && mintAccount !== void 0 && mintAccount.decimals) || !(mintAccount !== null && mintAccount !== void 0 && mintAccount.supply)) {
|
|
9736
9740
|
return 0;
|
|
9737
9741
|
}
|
|
9738
|
-
const mintSupplyFormatted = Number(SolanaTokenUtils.formatUnits(new BN(mintAccount.supply), mintAccount.decimals));
|
|
9742
|
+
const mintSupplyFormatted = Number(SolanaTokenUtils.formatUnits(new BN(mintAccount.supply.toString()), mintAccount.decimals));
|
|
9739
9743
|
if (mintSupplyFormatted === 0) {
|
|
9740
9744
|
return 0;
|
|
9741
9745
|
}
|
|
9742
|
-
const seniorTrancheAssetsFormatted = Number(SolanaTokenUtils.formatUnits(new BN(poolState === null || poolState === void 0 ? void 0 : poolState.seniorTrancheAssets), mintAccount.decimals));
|
|
9746
|
+
const seniorTrancheAssetsFormatted = Number(SolanaTokenUtils.formatUnits(new BN((_poolState$seniorTran = poolState === null || poolState === void 0 ? void 0 : poolState.seniorTrancheAssets) !== null && _poolState$seniorTran !== void 0 ? _poolState$seniorTran : 0), mintAccount.decimals));
|
|
9743
9747
|
if (selectedTranche === 'senior') {
|
|
9744
9748
|
return seniorTrancheAssetsFormatted / mintSupplyFormatted;
|
|
9745
9749
|
}
|
|
9746
|
-
const juniorTrancheAssetsFormatted = Number(SolanaTokenUtils.formatUnits(new BN(poolState === null || poolState === void 0 ? void 0 : poolState.juniorTrancheAssets), mintAccount.decimals));
|
|
9750
|
+
const juniorTrancheAssetsFormatted = Number(SolanaTokenUtils.formatUnits(new BN((_poolState$juniorTran = poolState === null || poolState === void 0 ? void 0 : poolState.juniorTrancheAssets) !== null && _poolState$juniorTran !== void 0 ? _poolState$juniorTran : 0), mintAccount.decimals));
|
|
9747
9751
|
return juniorTrancheAssetsFormatted / mintSupplyFormatted;
|
|
9748
9752
|
}, [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]);
|
|
9749
9753
|
useEffect(() => {
|
|
@@ -9950,8 +9954,9 @@ function SolanaLendAddRedemption(_ref) {
|
|
|
9950
9954
|
const [selectedTranche, setSelectedTranche] = useState();
|
|
9951
9955
|
useEffect(() => {
|
|
9952
9956
|
if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccounts) {
|
|
9953
|
-
|
|
9954
|
-
const
|
|
9957
|
+
var _seniorTokenAccount$a, _seniorTokenAccount$a2, _juniorTokenAccount$a, _juniorTokenAccount$a2;
|
|
9958
|
+
const seniorTrancheShares = new 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);
|
|
9959
|
+
const juniorTrancheShares = new 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);
|
|
9955
9960
|
if (juniorTrancheShares.gtn(0) && seniorTrancheShares.lten(0)) {
|
|
9956
9961
|
setSelectedTranche('junior');
|
|
9957
9962
|
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
@@ -10156,8 +10161,9 @@ function SolanaLendCancelRedemption(_ref) {
|
|
|
10156
10161
|
const [selectedTranche, setSelectedTranche] = useState();
|
|
10157
10162
|
useEffect(() => {
|
|
10158
10163
|
if (!step && !isLoadingLenderAccounts) {
|
|
10159
|
-
|
|
10160
|
-
const
|
|
10164
|
+
var _seniorLenderStateAcc, _juniorLenderStateAcc;
|
|
10165
|
+
const seniorTrancheSharesRequested = new BN((_seniorLenderStateAcc = seniorLenderStateAccount === null || seniorLenderStateAccount === void 0 ? void 0 : seniorLenderStateAccount.redemptionRecord.numSharesRequested) !== null && _seniorLenderStateAcc !== void 0 ? _seniorLenderStateAcc : 0);
|
|
10166
|
+
const juniorTrancheSharesRequested = new BN((_juniorLenderStateAcc = juniorLenderStateAccount === null || juniorLenderStateAccount === void 0 ? void 0 : juniorLenderStateAccount.redemptionRecord.numSharesRequested) !== null && _juniorLenderStateAcc !== void 0 ? _juniorLenderStateAcc : 0);
|
|
10161
10167
|
if (juniorTrancheSharesRequested.gtn(0) && seniorTrancheSharesRequested.lten(0)) {
|
|
10162
10168
|
setSelectedTranche('junior');
|
|
10163
10169
|
dispatch(setStep(WIDGET_STEP.Transfer));
|
|
@@ -10233,10 +10239,10 @@ function ChooseAmount(_ref) {
|
|
|
10233
10239
|
return;
|
|
10234
10240
|
}
|
|
10235
10241
|
const borrowAmountBN = SolanaTokenUtils.parseUnits(String(currentAmount), decimals);
|
|
10236
|
-
const nextStep = borrowAmountBN.gt(new BN(tokenAccount.delegatedAmount)) || ((_tokenAccount$delegat = tokenAccount.delegate) === null || _tokenAccount$delegat === void 0 ? void 0 : _tokenAccount$delegat.toString()) !== sentinel ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
|
|
10242
|
+
const nextStep = borrowAmountBN.gt(new 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;
|
|
10237
10243
|
dispatch(setBorrowInfo({
|
|
10238
10244
|
borrowAmount: currentAmount,
|
|
10239
|
-
borrowAmountBN,
|
|
10245
|
+
borrowAmountBN: JSON.parse(borrowAmountBN.toString()),
|
|
10240
10246
|
chargedFees: 0,
|
|
10241
10247
|
nextStep
|
|
10242
10248
|
}));
|
|
@@ -10283,9 +10289,9 @@ function ApproveAllowance(_ref) {
|
|
|
10283
10289
|
// delegate
|
|
10284
10290
|
publicKey,
|
|
10285
10291
|
// owner of the wallet
|
|
10286
|
-
SolanaTokenUtils.parseUnits('100000000000',
|
|
10292
|
+
BigInt(SolanaTokenUtils.parseUnits('100000000000',
|
|
10287
10293
|
// 100 billion
|
|
10288
|
-
poolInfo.underlyingMint.decimals),
|
|
10294
|
+
poolInfo.underlyingMint.decimals).toString()),
|
|
10289
10295
|
// amount
|
|
10290
10296
|
poolInfo.underlyingMint.decimals, undefined,
|
|
10291
10297
|
// multiSigners
|