Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/custom_modules/@filterswap-libs/sdk/dist/sdk.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/pages/AddLiquidity/ConfirmAddModalBottom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TranslateString } from 'utils/translateTextHelpers'
import { RowBetween, RowFixed } from '../../components/Row'
import CurrencyLogo from '../../components/CurrencyLogo'
import { Field } from '../../state/mint/actions'
import { useMintState } from '../../state/mint/hooks'

export function ConfirmAddModalBottom({
noLiquidity,
Expand All @@ -21,6 +22,8 @@ export function ConfirmAddModalBottom({
poolTokenPercentage?: Percent
onAdd: () => void
}) {
const { daysToLock, lockForever } = useMintState()

return (
<>
<RowBetween>
Expand Down Expand Up @@ -56,6 +59,11 @@ export function ConfirmAddModalBottom({
<Text>Share of Pool:</Text>
<Text>{noLiquidity ? '100' : poolTokenPercentage?.toSignificant(4)}%</Text>
</RowBetween>
<RowBetween>
<Text>Liquidity Lock Time</Text>
{/* <QuestionHelper text={'To Change'} /> */}
<Text>{lockForever ? 'Forever' : `${daysToLock} Days`}</Text>
</RowBetween>
<Button mt="20px" onClick={onAdd}>
{noLiquidity ? 'Create Pool & Supply' : 'Confirm Supply'}
</Button>
Expand Down
18 changes: 5 additions & 13 deletions src/pages/AddLiquidity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useCurrency } from 'hooks/Tokens'
import { ApprovalState, useApproveCallback } from 'hooks/useApproveCallback'
import { Field } from 'state/mint/actions'
import { useDerivedMintInfo, useMintActionHandlers, useMintState } from 'state/mint/hooks'
import { useDaysToLock } from 'state/deploy/hooks'

import { useTransactionAdder } from 'state/transactions/hooks'
import { useIsExpertMode, useUserDeadline, useUserSlippageTolerance } from 'state/user/hooks'
Expand Down Expand Up @@ -62,7 +63,7 @@ export default function AddLiquidity({
const expertMode = useIsExpertMode()

// mint state
const { independentField, typedValue, otherTypedValue } = useMintState()
const { independentField, typedValue, otherTypedValue, daysToLock, lockForever } = useMintState()
const {
dependentField,
currencies,
Expand Down Expand Up @@ -122,17 +123,8 @@ export default function AddLiquidity({

const addTransaction = useTransactionAdder()
// const { isSm, isXs } = useMatchBreakpoints()
const [lockForever, setBurnForever] = useState(false)
const [daysToLock, setDaysToLock] = useState(365)
const handleDaysToLockChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
const { value: inputValue } = evt.target

const num: number = parseFloat(inputValue || '0')
const min: number = parseFloat(evt.target.min || '-1')
const max: number = parseFloat(evt.target.max || '1000000000000')

setDaysToLock(Math.min(Math.max(num, min), max))
}
const { handleDaysToLockChange, handleLockForever } = useDaysToLock()

async function onAdd() {
if (!chainId || !library || !account) return
Expand All @@ -149,7 +141,7 @@ export default function AddLiquidity({
}

const deadlineFromNow = Math.ceil(Date.now() / 1000) + deadline
const liquidityLockTime = daysToLock * 86400 // Convert Days to Hours to Minutes
const liquidityLockTime = lockForever ? Number.MAX_SAFE_INTEGER - 1 : daysToLock * 86400 // Convert Days to Hours to Minutes

let estimate
let method: (...args: any) => Promise<TransactionResponse>
Expand Down Expand Up @@ -413,7 +405,7 @@ export default function AddLiquidity({
</UIKitText>
<Box>
{/* <Toggle scale={isSm || isXs ? 'sm' : 'md'} checked={burnForever} onChange={() => setBurnForever(!burnForever)} /> */}
<Toggle scale={'md'} checked={lockForever} onChange={() => setBurnForever(!lockForever)} />
<Toggle scale={'md'} checked={lockForever} onChange={handleLockForever} />
</Box>
</RowBetween>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/state/mint/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ export enum Field {
CURRENCY_B = 'CURRENCY_B'
}

export const typeInput = createAction<{ field: Field; typedValue: string; noLiquidity: boolean }>('mint/typeInputMint')
export const typeInput = createAction<{
field: Field;
typedValue: string;
noLiquidity: boolean
}>('mint/typeInputMint')
export const resetMintState = createAction<void>('mint/resetMintState')
export const daysToLockChange = createAction<{ daysToLock: number }>('mint/daysToLockChange')
export const toggleLockForever = createAction('mint/toggleLockForever')
20 changes: 19 additions & 1 deletion src/state/mint/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { createReducer } from '@reduxjs/toolkit'
import { Field, resetMintState, typeInput } from './actions'
import { daysToLockChange, toggleLockForever } from '../deploy/actions'


export interface MintState {
readonly independentField: Field
readonly typedValue: string
readonly otherTypedValue: string // for the case when there's no liquidity
readonly daysToLock: number
readonly lockForever: boolean
}

const initialState: MintState = {
independentField: Field.CURRENCY_A,
typedValue: '',
otherTypedValue: ''
otherTypedValue: '',
daysToLock: 365,
lockForever: false,
}

export default createReducer<MintState>(initialState, builder =>
Expand Down Expand Up @@ -44,4 +50,16 @@ export default createReducer<MintState>(initialState, builder =>
}

})
.addCase(daysToLockChange, (state, { payload: { daysToLock } }) => {
return {
...state,
daysToLock
}
})
.addCase(toggleLockForever, (state) => {
return {
...state,
lockForever: !state.lockForever,
}
})
)