diff --git a/packages/diva-app/src/component/ApproveActionButtons.tsx b/packages/diva-app/src/component/ApproveActionButtons.tsx index ae377e50..744979c3 100644 --- a/packages/diva-app/src/component/ApproveActionButtons.tsx +++ b/packages/diva-app/src/component/ApproveActionButtons.tsx @@ -195,7 +195,10 @@ export const ApproveActionButtons = ({ CREATE_POOL_TYPE, formik.values.signature, account, - parseUnits(formik.values.yourShare.toString(), decimal) + parseUnits( + Number(formik.values.yourShare).toFixed(decimal).toString(), + decimal + ) ).then((res) => { if (!res.success) { setErrorMessage(res.message) @@ -565,7 +568,6 @@ export const ApproveActionButtons = ({ }) break case 'liquidity': - console.log(formik.values.longRecipient) diva! .addLiquidity( window.location.pathname.split('/')[1], diff --git a/packages/diva-app/src/component/CreatePool/CreatePool.tsx b/packages/diva-app/src/component/CreatePool/CreatePool.tsx index 99db711b..2575b096 100644 --- a/packages/diva-app/src/component/CreatePool/CreatePool.tsx +++ b/packages/diva-app/src/component/CreatePool/CreatePool.tsx @@ -88,6 +88,7 @@ export function CreatePool() { }, [formik.values.collateralToken]) const handleConfigPick = (event: SelectChangeEvent) => { setConfigPicked(event.target.value) + formik.setFieldValue('configPicked', event.target.value) } // actions after pool is successfully created const handlePoolSuccess = () => { diff --git a/packages/diva-app/src/component/CreatePool/Offer.tsx b/packages/diva-app/src/component/CreatePool/Offer.tsx index d9417b73..5dcdcb84 100644 --- a/packages/diva-app/src/component/CreatePool/Offer.tsx +++ b/packages/diva-app/src/component/CreatePool/Offer.tsx @@ -105,7 +105,7 @@ export function Offer() { Number(formatUnits(jsonResponse.data.data.inflection)) ) formik.setFieldValue('collateralWalletBalance', jsonResponse.data.data) - + formik.setFieldValue('collateralToken', token.symbol()) formik.setFieldValue( 'collateralToken.id', jsonResponse.data.data.collateralToken diff --git a/packages/diva-app/src/component/CreatePool/ReviewAndSubmit.tsx b/packages/diva-app/src/component/CreatePool/ReviewAndSubmit.tsx index f23434d6..971455a7 100644 --- a/packages/diva-app/src/component/CreatePool/ReviewAndSubmit.tsx +++ b/packages/diva-app/src/component/CreatePool/ReviewAndSubmit.tsx @@ -102,6 +102,15 @@ export function ReviewAndSubmit({ ERC20, provider.getSigner() ) + + useEffect(() => { + token.decimals().then((decimals: number) => { + setDecimal(decimals) + }) + token.symbol().then((symbol) => { + setTokenSymbol(symbol) + }) + }, [formik.values.collateralToken.id]) useEffect(() => { if ( diva != undefined && @@ -116,7 +125,10 @@ export function ReviewAndSubmit({ CREATE_POOL_TYPE, formik.values.signature, address, - parseUnits(formik.values.yourShare.toString(), decimal) + parseUnits( + Number(formik.values.yourShare).toFixed(decimal).toString(), + decimal + ) ).then((res) => { if (!res.success) { setErrorMessage(res.message) @@ -127,10 +139,6 @@ export function ReviewAndSubmit({ } }, [formik.values, address, diva, divaDomain]) - // QUESTION WHy not move this part into a useEffect hook? - token.decimals().then((decimals: number) => { - setDecimal(decimals) - }) useEffect(() => { if ( transaction === 'filloffer' && @@ -183,16 +191,7 @@ export function ReviewAndSubmit({ setMaxPayout(parseFloat(actualFillableAmount) * maxYieldTaker) } }, [actualFillableAmount, decimal]) - useEffect(() => { - const tokenContract = new ethers.Contract( - formik.values.collateralToken.id, - ERC20, - provider.getSigner() - ) - tokenContract.symbol().then((symbol) => { - setTokenSymbol(symbol) - }) - }, []) + useEffect(() => { if (window.innerWidth < 768) { setMobile(true) @@ -678,7 +677,7 @@ export function ReviewAndSubmit({ maxPayout, 2, 2 - )} ${'dUSD'}`} + )} ${tokenSymbol}`} { longRecipient, shortRecipient, permissionedERC721Token, + offerExpiry, } = values if (collateralToken != null && dataProvider != null) { @@ -190,6 +193,14 @@ export const useCreatePoolFormik = () => { threshold / 1000 / 60 } minutes from now` } + if ( + values.expiryTime.getTime() < Number(values.offerExpiry) * 1000 && + values.configPicked === 'createoffer' + ) { + console.log(values.configPicked) + errors.offerExpiry = + 'Offer expiry must be earlier than observation time' + } if (values.takerAddress == null) { errors.takerAddress = 'Taker address must not be empty' }