@turtleclub/hooks 0.5.0-beta.50 → 0.5.0-beta.52
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.cjs
CHANGED
|
@@ -397,6 +397,7 @@ var vaultConfigSchema = import_zod.z.object({
|
|
|
397
397
|
minDepositAmount: import_zod.z.number().optional().nullable(),
|
|
398
398
|
minDepositValueUSD: import_zod.z.number().optional().nullable(),
|
|
399
399
|
depositCapAmount: import_zod.z.number().optional().nullable(),
|
|
400
|
+
depositCapValueUSD: import_zod.z.number().optional().nullable(),
|
|
400
401
|
depositFillSecs: import_zod.z.number().int().optional().nullable(),
|
|
401
402
|
lockupPeriodSecs: import_zod.z.number().int().optional().nullable(),
|
|
402
403
|
asyncDeposit: import_zod.z.boolean().optional().nullable(),
|
|
@@ -1989,8 +1990,11 @@ function useDepositValidation({
|
|
|
1989
1990
|
isDepositDisabled: false,
|
|
1990
1991
|
isZeroAmount: true,
|
|
1991
1992
|
isNoTokenSelected: true,
|
|
1993
|
+
isVaultFull: false,
|
|
1992
1994
|
minDepositUSD: 0,
|
|
1993
1995
|
maxDepositUSD: null,
|
|
1996
|
+
depositCapUSD: null,
|
|
1997
|
+
depositCapPercentFilled: null,
|
|
1994
1998
|
depositDisabledReason: null,
|
|
1995
1999
|
depositFee: null,
|
|
1996
2000
|
performanceFee: null,
|
|
@@ -2021,7 +2025,9 @@ function useDepositValidation({
|
|
|
2021
2025
|
const isWrongChain = walletChainId !== void 0 && walletChainId !== requiredChainId;
|
|
2022
2026
|
const isNoTokenSelected = !selectedTokenBalance;
|
|
2023
2027
|
const isZeroAmount = !amountBigInt || amountBigInt <= 0n;
|
|
2024
|
-
const
|
|
2028
|
+
const selectedTokenPrice = selectedTokenBalance?.token.priceUsd ?? null;
|
|
2029
|
+
const primaryDepositToken = opportunity.depositTokens?.[0];
|
|
2030
|
+
const primaryDepositTokenPrice = primaryDepositToken?.priceUsd ?? null;
|
|
2025
2031
|
let inputAmountUSD = null;
|
|
2026
2032
|
let balanceUSD = null;
|
|
2027
2033
|
if (selectedTokenBalance && amountBigInt) {
|
|
@@ -2034,11 +2040,16 @@ function useDepositValidation({
|
|
|
2034
2040
|
const minDepositAmount = vaultConfig?.minDepositAmount ?? 0;
|
|
2035
2041
|
const minDepositValueUSD = vaultConfig?.minDepositValueUSD ?? 0;
|
|
2036
2042
|
const minDepositUSD = Math.max(
|
|
2037
|
-
minDepositAmount * (
|
|
2043
|
+
minDepositAmount * (primaryDepositTokenPrice ?? 0),
|
|
2038
2044
|
minDepositValueUSD
|
|
2039
2045
|
);
|
|
2040
2046
|
const depositCapAmount = vaultConfig?.depositCapAmount;
|
|
2041
|
-
const
|
|
2047
|
+
const depositCapValueUSD = vaultConfig?.depositCapValueUSD;
|
|
2048
|
+
const depositCapUSD = depositCapValueUSD ?? (depositCapAmount && primaryDepositTokenPrice ? depositCapAmount * primaryDepositTokenPrice : null);
|
|
2049
|
+
const maxDepositUSD = depositCapUSD;
|
|
2050
|
+
const tvl = opportunity.tvl ?? 0;
|
|
2051
|
+
const isVaultFull = depositCapUSD !== null && tvl >= depositCapUSD;
|
|
2052
|
+
const depositCapPercentFilled = depositCapUSD !== null && depositCapUSD > 0 ? Math.min(tvl / depositCapUSD * 100, 100) : null;
|
|
2042
2053
|
let hasInsufficientBalance = false;
|
|
2043
2054
|
if (selectedTokenBalance && amountBigInt) {
|
|
2044
2055
|
const balanceAmount = BigInt(selectedTokenBalance.amount);
|
|
@@ -2057,6 +2068,9 @@ function useDepositValidation({
|
|
|
2057
2068
|
} else if (depositDisabled) {
|
|
2058
2069
|
buttonText = depositDisabledReason || "Deposits disabled";
|
|
2059
2070
|
validationMessage = depositDisabledReason || "Deposits are currently disabled for this opportunity";
|
|
2071
|
+
} else if (isVaultFull) {
|
|
2072
|
+
buttonText = "Deposit cap reached";
|
|
2073
|
+
validationMessage = "This vault has reached its deposit cap";
|
|
2060
2074
|
} else if (isNoTokenSelected) {
|
|
2061
2075
|
buttonText = "Select token";
|
|
2062
2076
|
validationMessage = "Please select a token to deposit";
|
|
@@ -2079,7 +2093,7 @@ function useDepositValidation({
|
|
|
2079
2093
|
buttonText = "Deposit";
|
|
2080
2094
|
}
|
|
2081
2095
|
const isDepositing = isPending || isConfirming;
|
|
2082
|
-
const canDeposit = !depositDisabled && !isDepositing && !isNoTokenSelected && !isZeroAmount && !hasInsufficientBalance && !isBelowMinimum && !isAboveMaximum;
|
|
2096
|
+
const canDeposit = !depositDisabled && !isVaultFull && !isDepositing && !isNoTokenSelected && !isZeroAmount && !hasInsufficientBalance && !isBelowMinimum && !isAboveMaximum;
|
|
2083
2097
|
return {
|
|
2084
2098
|
canDeposit,
|
|
2085
2099
|
isBelowMinimum,
|
|
@@ -2088,8 +2102,11 @@ function useDepositValidation({
|
|
|
2088
2102
|
isDepositDisabled: depositDisabled,
|
|
2089
2103
|
isZeroAmount,
|
|
2090
2104
|
isNoTokenSelected,
|
|
2105
|
+
isVaultFull,
|
|
2091
2106
|
minDepositUSD,
|
|
2092
2107
|
maxDepositUSD,
|
|
2108
|
+
depositCapUSD,
|
|
2109
|
+
depositCapPercentFilled,
|
|
2093
2110
|
depositDisabledReason,
|
|
2094
2111
|
depositFee,
|
|
2095
2112
|
performanceFee,
|