-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
|
Nice, can definitely style it further:
|
@@ -284,7 +307,8 @@ export default function InvestOption({ approveData, claim, optionIndex }: Invest | |||
</label> | |||
<i>Receive: {formatSmartLocaleAware(vCowAmount, AMOUNT_PRECISION) || 0} vCOW</i> | |||
{/* Insufficient balance validation error */} | |||
{inputError ? <small>{inputError}</small> : ''} | |||
{inputError && <small>{inputError}</small>} | |||
{inputWarning && <small className="warn">{inputWarning}</small>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will probably refactor to pass a prop
instead of applying a className.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, and worked.
I guess it could have more testing in mainnet, cause in Rinkeby is so cheap that even though i tested very near the limit, i was not getting the warning (i assume 10 tx are cheaper than the marginal Ether i had)
When i went slightly less, i saw the error.
Nice introduction of not blocking WARN
|
||
// USER_BALANCE - (USER_WRAP_AMT + 1_TX_CST) / 1_TX_COST = AVAILABLE_TXS | ||
const txsAvailable = nativeBalance.subtract(nativeInput.add(singleTxCost)).divide(singleTxCost) | ||
return txsAvailable.lessThan('1') ? null : txsAvailable.toSignificant(1) | ||
} | ||
|
||
export function _estimateTxCost(gasPrice: ReturnType<typeof useGasPrices>, native: Currency | undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think is a bit strange to expose a function starting with an underscore. I assume this was a "private function" convention. If it's useful to expose, maybe should be without?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, not sure if this should live in a more generic place instead of inside swap -> wrapEth
const amount = BigNumber.from(gas).mul(MINIMUM_TXS).mul(AVG_APPROVE_COST_GWEI) | ||
|
||
return { | ||
multiTxCost: CurrencyAmount.fromRawAmount(native, amount.toString()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I felt the name was a bit hard to understand. What about recomendedMarginalEther
? i also don't love it. Maybe you find a better one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just moving this fn around.
If you want to complain about the names bother @W3stside =P
But ok... I'll refactor this next week when I'm more in the mood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its just a nit, the PR was approved :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wrote this? 😂
@@ -935,6 +935,10 @@ export const InvestInput = styled.span` | |||
color: red; | |||
margin: 12px 0; | |||
font-size: 15px; | |||
|
|||
&.warn { | |||
color: orange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@biocom might want to review colors for validations
One question though, right now, if we use It might be OK since we show the % already, but curious on @biocom, @alfetopito opinions |
@anxolin Yes, at the end of the day, the question is if the label My assumption is, that a majority will over-read this, and take it as a 'use my max balance', based on expected UX of using trading/DeFi UI's in general. But perhaps as you pointed out, given the
Something to do a few user test runs with? |
Yes @biocom , i useed it more and more, and I like this approach very much. The progress bar makes it intuitive in my oppinion. The user might understand quicly that they only have balance to cover 63% of their opportunity. |
I believe this is the right behavior because doesn't make sense to have a button that fills in incorrect data. If we set it to fill is all investment opportunity but you have no balance to cover it, you can't proceed. The way it's implemented makes sure you fill in everything you can. |
One reason we need to find out how much gas we need for this transfer because it'll be blocking for EOAs. Also, imagine this is not a wallet you regularly use and you only deposited on it enough to cover the investment, but forgot about the gas. You'll have to either deposit more or invest a tiny bit less to succeed. I agree the gas for 1 approval would be much cheaper than claiming, depending on how many claims we are doing, but we'd need some experimentation on mainnet to find the best spot |
Yep, i think we all agree then! Happy to get this merged |
}) => { | ||
if (!nativeBalance || !nativeInput || nativeBalance.lessThan(nativeInput.add(singleTxCost))) return null | ||
if (!nativeBalance || !nativeInput || !singleTxCost || nativeBalance.lessThan(nativeInput.add(singleTxCost))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you cache the last nativeBalance check?
LGTM besides this rounding issue: #2276 |
4052480
to
5ee6163
Compare
As discussed, I'll address the comments in a follow up PR. |
Summary
Waterfalls into #2250
Show warning/error when using too much native currency to invest
Uses current gas estimation for 1 approval. Might need to adjust that for a higher amount
If it's a Smart contract wallet, show a warning and let user proceed.
If it's an EOA wallet, show an error and block from moving forward until amount is corrected.
Smart contract:
EOA:
To Test
2
)On approvals page, you should see the warning and be able to move forward
Background
Note: Color is of course dumb and doesn't quite work on light more.
Neither does the error color for that matter.
Counting on @biocom to make it look good