Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: pool's Deposit, Withdraw and Swap forms #362

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

amytsang
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Sep 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
curve-dapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 9:31pm
curve-dapp-crvusd ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 9:31pm
curve-dapp-dao ❌ Failed (Inspect) Oct 7, 2024 9:31pm
curve-dapp-lend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 9:31pm

michwill
michwill previously approved these changes Sep 24, 2024
OnlyJousting
OnlyJousting previously approved these changes Sep 24, 2024
Copy link
Contributor

@DanielSchiavini DanielSchiavini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, context is much cleaner than always using the global store!

I didn't manage to see the whole PR yet (it's huge)

apps/main/src/components/PagePool/Claim/index.tsx Outdated Show resolved Hide resolved
apps/main/src/components/PagePool/Claim/index.tsx Outdated Show resolved Hide resolved
userPoolBalances={userPoolBalances}
updateFormValues={updateFormValues}
/>
<DepositContext.Provider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem here, imo this component is too large

warning: '',
}
export function calcNewCrvApr(crvApr: number, lpToken: string, gaugeTotalSupply: string | number) {
if (!crvApr && !gaugeTotalSupply && Number(gaugeTotalSupply) === 0 && Number(lpToken) === 0) return null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the expected values for gaugeTotalSupply? Won't this go wrong with a '0' string?

value: string
}

const FieldAmount: React.FC<Props> = ({ idx, estimatedGas, error, tokenObj, value }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, why are we inverting the forms and fields names? I would expect this to be called AmountField

}, [basePlusPriority, estimatedGas, estimatedGasIsLoading, fromAddress, updateFormValues, fromBalance])

return (
<div>
Copy link
Contributor

@DanielSchiavini DanielSchiavini Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the wrapper <div> for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents a gap between the input field and dollar amount.

usdRatesMapper: QueryRespUsdRatesMapper | undefined
}

const FieldTo: React.FC<Props> = ({ usdRatesMapper }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost a duplicate from FieldFrom couldn't we use the same field?


export const ClaimContext = createContext<ClaimContextType | null>(null)

export const useClaimContext = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand you created the context so you don't have to use react-hook-forms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, so I don't have to keep on passing it as a prop. This PR does not have anything to do with switching to react-hook-form

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can see why you did it. React-hook-forms also uses context to pass data between components, essentially does the same thing you did, but gives you the ability to work with the form. Migrating those forms to this library will be the next step.

import Spinner, { SpinnerWrapper } from '@/ui/Spinner'
import TransferActions from '@/components/PagePool/components/TransferActions'

const FormClaim = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const FormClaim = () => {
const FormClaim = ({chainId, poolId}) => {

I would suggest passing the basic parameters that define exactly what this form refers to through the props. In the specific case, these are chainId and poolId. This can be useful in the future when creating static components, it will exclude their memoization when changing the parameter (like key in lists). Also it will be useful if we make modal windows and there will be a situation when 2 identical modal windows are rendered for different pools.

return { mutation, enabled: conditions.enableClaim(params) }
}

// helpers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to lib

UnstakeEstGas,
} from '@/entities/withdraw'

export const withdrawKeys = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same advices

selected,
lpToken,
amounts,
selectedTokenAddress,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the good naming

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path should be like src/shared/transaction/status.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants