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

More sig figs, more chains, and longer lock #354

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# misc
.DS_Store
*.pem
package-lock.json

# debug
npm-debug.log*
Expand All @@ -41,4 +42,5 @@ cypress/videos
notes.txt

# sitemap
public/sitemap*.xml
public/sitemap*.xml

16 changes: 14 additions & 2 deletions ui/components/nance/RetroactiveRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
DISTRIBUTION_TABLE_ADDRESSES,
HATS_ADDRESS,
PROJECT_ADDRESSES,
ARBITRUM_ASSETS_URL,
POLYGON_ASSETS_URL,
BASE_ASSETS_URL,
} from 'const/config'
import _ from 'lodash'
import Image from 'next/image'
Expand Down Expand Up @@ -209,7 +212,16 @@ export function RetroactiveRewards({
)
: {}

const { tokens } = useAssets()
const { tokens: mainnetTokens } = useAssets()
const { tokens: arbitrumTokens } = useAssets(ARBITRUM_ASSETS_URL)
const { tokens: polygonTokens } = useAssets(POLYGON_ASSETS_URL)
const { tokens: baseTokens } = useAssets(BASE_ASSETS_URL)

const tokens = mainnetTokens
.concat(arbitrumTokens)
.concat(polygonTokens)
.concat(baseTokens)
console.log(tokens)

const { ethBudget, usdBudget, mooneyBudget, ethPrice } = getBudget(
tokens,
Expand Down Expand Up @@ -328,7 +340,7 @@ export function RetroactiveRewards({
>
<RewardAsset
name="ETH"
value={ethBudget.toFixed(1)}
value={ethBudget.toFixed(4)}
usdValue={usdBudget.toFixed(2)}
/>
<div className="flex flex-col md:flex-row md:items-center justify-between">
Expand Down
27 changes: 15 additions & 12 deletions ui/const/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ interface DeploymentConfig {
type Index = { [key: string]: string }

//vMooneySweepstakesZeroG is always mainnet address (using infura provider)
const ethConfig = require(
`../../contracts/deployments/ethereum`
) as DeploymentConfig
const ethConfig =
require(`../../contracts/deployments/ethereum`) as DeploymentConfig

const polygonConfig = require(
`../../contracts/deployments/polygon`
) as DeploymentConfig
const polygonConfig =
require(`../../contracts/deployments/polygon`) as DeploymentConfig

const arbitrumConfig =
require('../../contracts/deployments/arbitrum') as DeploymentConfig

const baseConfig =
require('../../contracts/deployments/base') as DeploymentConfig

const goerliConfig = require(
`../../contracts/deployments/goerli`
) as DeploymentConfig
const goerliConfig =
require(`../../contracts/deployments/goerli`) as DeploymentConfig

const sepoliaConfig = require(
`../../contracts/deployments/sepolia`
) as DeploymentConfig
const sepoliaConfig =
require(`../../contracts/deployments/sepolia`) as DeploymentConfig

const arbitrumSepoliaConfig =
require('../../contracts/deployments/arbitrum-sepolia') as DeploymentConfig
Expand Down Expand Up @@ -327,3 +323,10 @@ export const CHAIN_TOKEN_NAMES: Index = {
arbitrum: 'ETH',
sepolia: 'ETH',
}

export const ARBITRUM_ASSETS_URL =
'https://safe-client.safe.global/v1/chains/42161/safes/0xAF26a002d716508b7e375f1f620338442F5470c0/balances/usd?trusted=true'
export const POLYGON_ASSETS_URL =
'https://safe-client.safe.global/v1/chains/137/safes/0x8C0252c3232A2c7379DDC2E44214697ae8fF097a/balances/usd?trusted=true'
export const BASE_ASSETS_URL =
'https://safe-client.safe.global/v1/chains/8453/safes/0x871e232Eb935E54Eb90B812cf6fe0934D45e7354/balances/usd?trusted=true'
9 changes: 5 additions & 4 deletions ui/lib/dashboard/hooks/useAssets.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { useState, useEffect } from 'react'

export function useAssets() {
const ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL as string
export function useAssets(
assetsUrl: string = process.env.NEXT_PUBLIC_ASSETS_URL as string
) {
const [tokens, setTokens] = useState<any>([])
const [balanceSum, setBalanceSum] = useState<any>()
const [isLoading, setIsLoading] = useState<boolean>(false)
const [error, setError] = useState<any>(null)

useEffect(() => {
setIsLoading(true)
fetch(ASSETS_URL)
fetch(assetsUrl)
.then((res) => res.json())
.then(
(result) => {
Expand All @@ -29,7 +30,7 @@ export function useAssets() {
setError(error)
}
)
}, [ASSETS_URL])
}, [assetsUrl])

return { tokens, isLoading, balanceSum, error }
}
Expand Down
15 changes: 7 additions & 8 deletions ui/pages/withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,19 @@ export default function Withdraw() {
!VMOONEYLockLoading && setHasLock(VMOONEYLock && VMOONEYLock[0] != 0)
}, [VMOONEYLock, VMOONEYLockLoading, address])

const [hasMoreThanSixMonths, setHasMoreThanSixMonths] =
useState<boolean>(false)
const sixMonths = 6 * 30 * 24 * 60 * 60 * 1000
// 3.75 years ~ 45 months
const [hasMoreThan45Months, setHasMoreThan45Months] = useState<boolean>(false)
const fortyFiveMonths = 45 * 30 * 24 * 60 * 60 * 1000
useEffect(() => {
console.log()
!VMOONEYLockLoading &&
setHasMoreThanSixMonths(
setHasMoreThan45Months(
VMOONEYLock &&
VMOONEYLock[1] != 0 &&
BigNumber.from(+new Date() + sixMonths).lte(
BigNumber.from(+new Date() + fortyFiveMonths).lte(
VMOONEYLock?.[1].toString() * 1000
)
)
}, [VMOONEYLock, VMOONEYLockLoading, address, sixMonths])
}, [VMOONEYLock, VMOONEYLockLoading, address, fortyFiveMonths])

const handleWithdraw = async () => {
try {
Expand Down Expand Up @@ -169,7 +168,7 @@ export default function Withdraw() {
usd=""
/>
</section>
{address && hasLock && hasMoreThanSixMonths ? (
{address && hasLock && hasMoreThan45Months ? (
<StandardButton
className="gradient-2 rounded-full"
onClick={handleWithdraw}
Expand Down
Loading