MaxButton
Description
The Max Button is a user interface element that serves a specific purpose: when clicked, it selects the maximum amount. This component is particularly useful in scenarios where users need to quickly and easily choose the highest available value, such as their balance.
Variants
Max BTC
(BTC balance - 0.000402832 BTC)
or 0
if the amount would go negative with this formula
Max token
Token balance
Max AMM pool deposit
The lesser of (Token balance, (BTC balance - 0.000402832) * BTC price denominated in the token according to the given AMM pool)
Default max borrow with BTC collateral:
The lesser of (available liquidity in the lending pool, ((((BTC balance - 0.000402832) * (1 - Origination fee rate)) * BTC price in the loan asset) * Maximum initial loan-to-value ratio) - Prepaid interest amount)
If the user hasn't changed the prepaid interest duration, Prepaid interest amount is calculated using the default prepaid interest duration specified in the Lend page frontend spec.
Prepaid interest amount formula:
(maxBorrow / (1 - interestRateForDuration)) - maxBorrow
maxBorrow is ((((BTC balance - 0.000402832) * (1 - Origination fee rate)) * BTC price denominated in the loan asset) * Maximum initial loan-to-value ratio)
interestRateForDuration is (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)
Putting it all together:
((((BTC balance - 0.000402832) * (1 - Origination fee rate)) * BTC price denominated in the loan asset) * Maximum initial loan-to-value ratio) / (1 - (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)) - ((((BTC balance - 0.000402832) * (1 - Origination fee rate)) * BTC price in the loan asset) * Maximum initial loan-to-value ratio)
Default max borrow with token collateral:
The lesser of (available liquidity in the lending pool, (((Collateral token balance * (1 - Origination fee rate)) * Collateral asset price in the loan asset) * Maximum initial loan-to-value ratio) - Prepaid interest amount)
If the user hasn't changed the prepaid interest duration, Prepaid interest amount is calculated using the default prepaid interest duration specified in the Lend page frontend spec.
Prepaid interest amount formula:
(maxBorrow / (1 - interestRateForDuration)) - maxBorrow
maxBorrow is (((Collateral token balance * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio)
interestRateForDuration is (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)
Putting it all together:
(((Collateral token balance * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) / (1 - (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)) - (((Collateral token balance * (1 - Origination fee rate)) * Collateral asset price in the loan asset) * Maximum initial loan-to-value ratio)
Max borrow:
The lesser of (available liquidity in the lending pool, (((Collateral amount * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) - Prepaid interest amount)
Prepaid interest amount formula:
(((Collateral amount * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) / (1 - (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)) - (((Collateral amount * (1 - Origination fee rate)) * Collateral asset price in the loan asset) * Maximum initial loan-to-value ratio)
Default max borrow increase with BTC collateral:
The lesser of (available liquidity in the lending pool, ((((Current collateral + (BTC balance - 0.000402832)) * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) - Prepaid interest amount - Current debt)
Prepaid interest amount formula:
((((Current collateral + (BTC balance - 0.000402832)) * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) / (1 - (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)) - ((((Current collateral + (BTC balance - 0.000402832)) * (1 - Origination fee rate)) * Collateral asset price in the loan asset) * Maximum initial loan-to-value ratio)
Default max borrow increase with token collateral:
The lesser of (available liquidity in the lending pool, ((((Current collateral + Collateral token balance) * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) - Prepaid interest amount - Current debt)
Prepaid interest amount formula:
((((Current collateral + Collateral token balance) * (1 - Origination fee rate)) * Collateral asset price denominated in the loan asset) * Maximum initial loan-to-value ratio) / (1 - (Borrow APR * (60 * 60 * 24 * Prepaid interest duration) / 31536000)) - ((((Current collateral + Collateral token balance) * (1 - Origination fee rate)) * Collateral asset price in the loan asset) * Maximum initial loan-to-value ratio)
Max BTC collateral:
(BTC balance - 0.000402832) * (1 - origination fee rate)
Max token collateral:
Token balance * (1 - origination fee rate)
Max collateral withdrawal:
Collateral balance - ((Total debt * Maintenance margin) / Collateral price denominated in loan asset)
Max BTC repayment:
The lesser of (total debt - interest refund, BTC balance - 0.000402832 BTC, 0 if the amount would go negative with the previous formula)
Max token repayment:
The lesser of (total debt - interest refund, token balance)
Max contract withdrawal:
The lesser of (balance in the contract owned by or owed to the user, contract balance available liquidity)
Max aggregator withdrawal:
The lesser of (token balance, aggregator balance + conversion fee)
Max bridge:
The lesser of (token balance, aggregator balance, destination bridge max limit, destination chain bridge balance)
Max FastBTC:
The lesser of (FastBTC max limit, BTC balance - 0.000402832 BTC, 0 if the amount would go negative with the previous formula)
Last updated