Skip to content

Commit

Permalink
feat: vesting claim treasury grant (#2467)
Browse files Browse the repository at this point in the history
* feat: vesting claim treasury grant

* update contract addresss
  • Loading branch information
viet-nv authored Feb 6, 2024
1 parent 7b86171 commit 67f0037
Show file tree
Hide file tree
Showing 6 changed files with 20,106 additions and 48,001 deletions.
16 changes: 9 additions & 7 deletions src/pages/ElasticSnapshot/components/Vesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import { MEDIA_WIDTHS } from 'theme'
import { shortenAddress } from 'utils'
import { formatDisplayNumber } from 'utils/numbers'

import vestingOptionA from '../data/vesting/optionA.json'
import vestingOptionB from '../data/vesting/optionB.json'
import abi from '../data/vestingAbi.json'
import claimVestingData from '../data/vestingData.json'
import VestingClaimModal, { vestingContractAddress } from './VestingClaimModal'

const Details = styled.div`
Expand Down Expand Up @@ -86,11 +87,13 @@ const Legend = styled.div`

const format = (value: number) => formatDisplayNumber(value, { style: 'currency', significantDigits: 6 })

export default function Vesting({ userSelectedOption }: { userSelectedOption: string }) {
export default function Vesting({ userSelectedOption }: { userSelectedOption: 'A' | 'B' }) {
const theme = useTheme()
const { account } = useActiveWeb3React()
const userVestingData = useMemo(
() => claimVestingData.find(item => item.claimData.receiver.toLowerCase() === account?.toLowerCase()),
() =>
vestingOptionA.find(item => item.claimData.receiver.toLowerCase() === account?.toLowerCase()) ||
vestingOptionB.find(item => item.claimData.receiver.toLowerCase() === account?.toLowerCase()),
[account],
)

Expand All @@ -102,7 +105,7 @@ export default function Vesting({ userSelectedOption }: { userSelectedOption: st
const [endTime, setEndTime] = useState(0)
const [vestedAmount, setVestedAmount] = useState(0)

const vestingContract = useReadingContract(vestingContractAddress, abi, ChainId.MATIC)
const vestingContract = useReadingContract(vestingContractAddress[userSelectedOption], abi, ChainId.MATIC)

const [, setRender] = useState(0)
const getVestedData = useCallback(() => {
Expand Down Expand Up @@ -139,9 +142,7 @@ export default function Vesting({ userSelectedOption }: { userSelectedOption: st

const [show, setShow] = useState(false)

const fakeCondition = 1 + 1 === 2
// TODO: hide to release instant grant
if (!userVestingData || fakeCondition) return null
if (!userVestingData) return null

const totalAmount = userVestingData.claimData.vestingAmount / 10 ** 6

Expand All @@ -163,6 +164,7 @@ export default function Vesting({ userSelectedOption }: { userSelectedOption: st
proof={proof}
tokenAmount={claimableAmount}
vestingAmount={userVestingData.claimData.vestingAmount}
option={userSelectedOption}
/>
)}
<Text fontSize={14} color={theme.subText} lineHeight="20px">
Expand Down
28 changes: 20 additions & 8 deletions src/pages/ElasticSnapshot/components/VestingClaimModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@ import { friendlyError } from 'utils/errorMessage'
import VestingAbi from '../data/vestingAbi.json'

const ContractInterface = new Interface(VestingAbi)
export const vestingContractAddress = '0x1c0D000D309072fE54F272d255f5de3aBe54e541'
export const vestingContractAddress = {
A: '0x04F57dE350E76ec952b6B4d1283Ba800ab3c95e3',
B: '0xF3E4C1f21a1218Ae8e48569c94275ABd605563fD',
}

export default function VestingClaimModal({
onDismiss,
leafIndex,
proof,
tokenAmount,
vestingAmount,
option,
}: {
leafIndex: number
onDismiss: () => void
proof: string[]
tokenAmount: number
vestingAmount: number
option: 'A' | 'B'
}) {
const upToSmall = useMedia(`(max-width: ${MEDIA_WIDTHS.upToSmall}px)`)
const theme = useTheme()
Expand Down Expand Up @@ -103,11 +108,12 @@ export default function VestingClaimModal({
name: 'Kyberswap Linear Vesting Grant',
version: '1',
chainId: ChainId.MATIC,
verifyingContract: vestingContractAddress,
verifyingContract: vestingContractAddress[option],
},
message: {
leafIndex,
termsAndConditions: `I accept KyberSwap’s Terms and Conditions published here https://bafkreic3csqhyqrz3wir2wd7sn2owrsuwbn4aakbaje5zmmpoy2dmbdlyi.ipfs.w3s.link`,
termsAndConditions:
'By confirming this transaction, I agree to the Terms and Conditions of KyberSwap Treasury Grant Program which can be found at this link https://bafkreidnmptjtdvhzcuy4jiib34j5aapsuklhrryqptvfprnld7o6st42y.ipfs.w3s.link',
},
}),
])
Expand All @@ -125,7 +131,7 @@ export default function VestingClaimModal({
library
?.getSigner()
.sendTransaction({
to: vestingContractAddress,
to: vestingContractAddress[option],
data: encodedData,
})
.then(tx => {
Expand Down Expand Up @@ -155,7 +161,7 @@ export default function VestingClaimModal({
type: NotificationType.ERROR,
})
})
}, [account, library, notify, addTransactionWithType, onDismiss, leafIndex, proof, vestingAmount])
}, [option, account, library, notify, addTransactionWithType, onDismiss, leafIndex, proof, vestingAmount])

useEffect(() => {
if (autoSign && chainId === ChainId.MATIC) {
Expand Down Expand Up @@ -216,8 +222,11 @@ export default function VestingClaimModal({

<Text color={theme.subText} fontSize={14} marginTop="24px">
Make sure you have read and understand the{' '}
<ExternalLink href="/todo">KyberSwap’s Terms and Conditions</ExternalLink> before proceeding. You will need to
Sign a message to confirm that you have read and accepted before claiming your assets.
<ExternalLink href="https://bafkreidnmptjtdvhzcuy4jiib34j5aapsuklhrryqptvfprnld7o6st42y.ipfs.w3s.link/">
KyberSwap’s Terms and Conditions
</ExternalLink>{' '}
before proceeding. You will need to Sign a message to confirm that you have read and accepted before claiming
your assets.
</Text>

<TermAndCondition
Expand All @@ -231,7 +240,10 @@ export default function VestingClaimModal({
style={{ marginRight: '12px', height: '14px', width: '14px', minWidth: '14px', cursor: 'pointer' }}
/>
<Text>
Accept <ExternalLink href="/todo">KyberSwap’s Terms and Conditions</ExternalLink>
Accept{' '}
<ExternalLink href="https://bafkreidnmptjtdvhzcuy4jiib34j5aapsuklhrryqptvfprnld7o6st42y.ipfs.w3s.link/">
KyberSwap’s Terms and Conditions
</ExternalLink>
</Text>
</TermAndCondition>
<Flex marginTop="24px" sx={{ gap: '1rem' }}>
Expand Down
Loading

0 comments on commit 67f0037

Please sign in to comment.