-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
f905873
to
9d650ba
Compare
d92af23
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.
Nice, context is much cleaner than always using the global store!
I didn't manage to see the whole PR yet (it's huge)
userPoolBalances={userPoolBalances} | ||
updateFormValues={updateFormValues} | ||
/> | ||
<DepositContext.Provider |
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.
idem here, imo this component is too large
apps/main/src/components/PagePool/Deposit/components/FormDeposit.tsx
Outdated
Show resolved
Hide resolved
apps/main/src/components/PagePool/Deposit/components/FormStake.tsx
Outdated
Show resolved
Hide resolved
warning: '', | ||
} | ||
export function calcNewCrvApr(crvApr: number, lpToken: string, gaugeTotalSupply: string | number) { | ||
if (!crvApr && !gaugeTotalSupply && Number(gaugeTotalSupply) === 0 && Number(lpToken) === 0) return null |
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.
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 }) => { |
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.
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> |
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.
what's the wrapper <div>
for?
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.
Prevents a gap between the input field and dollar amount.
usdRatesMapper: QueryRespUsdRatesMapper | undefined | ||
} | ||
|
||
const FieldTo: React.FC<Props> = ({ usdRatesMapper }) => { |
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.
This is almost a duplicate from FieldFrom
couldn't we use the same field?
apps/main/src/components/PagePool/Claim/components/BtnClaim.tsx
Outdated
Show resolved
Hide resolved
apps/main/src/components/PagePool/Claim/components/BtnClaimCrv.tsx
Outdated
Show resolved
Hide resolved
apps/main/src/components/PagePool/Claim/components/BtnClaimRewards.tsx
Outdated
Show resolved
Hide resolved
|
||
export const ClaimContext = createContext<ClaimContextType | null>(null) | ||
|
||
export const useClaimContext = () => { |
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 understand you created the context so you don't have to use react-hook-forms?
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.
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
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.
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 = () => { |
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.
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 |
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.
to lib
UnstakeEstGas, | ||
} from '@/entities/withdraw' | ||
|
||
export const withdrawKeys = { |
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.
Same advices
selected, | ||
lpToken, | ||
amounts, | ||
selectedTokenAddress, |
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.
Follow the good naming
packages/curve-lib/src/web3.ts
Outdated
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.
The path should be like src/shared/transaction/status.ts
d92af23
to
110a24d
Compare
110a24d
to
10e87e2
Compare
No description provided.