diff --git a/src/custom/abis/types/VCow.d.ts b/src/custom/abis/types/VCow.d.ts index 61300dda4..2bdc28a11 100644 --- a/src/custom/abis/types/VCow.d.ts +++ b/src/custom/abis/types/VCow.d.ts @@ -11,6 +11,7 @@ import { PopulatedTransaction, BaseContract, ContractTransaction, + Overrides, PayableOverrides, CallOverrides, } from "ethers"; @@ -31,6 +32,7 @@ interface VCowInterface extends ethers.utils.Interface { "nativeTokenPrice()": FunctionFragment; "swappableBalanceOf(address)": FunctionFragment; "balanceOf(address)": FunctionFragment; + "swapAll()": FunctionFragment; }; encodeFunctionData( @@ -79,6 +81,7 @@ interface VCowInterface extends ethers.utils.Interface { values: [string] ): string; encodeFunctionData(functionFragment: "balanceOf", values: [string]): string; + encodeFunctionData(functionFragment: "swapAll", values?: undefined): string; decodeFunctionResult(functionFragment: "claim", data: BytesLike): Result; decodeFunctionResult(functionFragment: "claimMany", data: BytesLike): Result; @@ -99,6 +102,7 @@ interface VCowInterface extends ethers.utils.Interface { data: BytesLike ): Result; decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "swapAll", data: BytesLike): Result; events: { "Claimed(uint256,uint8,address,uint256,uint256)": EventFragment; @@ -203,6 +207,10 @@ export class VCow extends BaseContract { ): Promise<[BigNumber]>; balanceOf(user: string, overrides?: CallOverrides): Promise<[BigNumber]>; + + swapAll( + overrides?: Overrides & { from?: string | Promise } + ): Promise; }; claim( @@ -245,6 +253,10 @@ export class VCow extends BaseContract { balanceOf(user: string, overrides?: CallOverrides): Promise; + swapAll( + overrides?: Overrides & { from?: string | Promise } + ): Promise; + callStatic: { claim( index: BigNumberish, @@ -285,6 +297,8 @@ export class VCow extends BaseContract { ): Promise; balanceOf(user: string, overrides?: CallOverrides): Promise; + + swapAll(overrides?: CallOverrides): Promise; }; filters: { @@ -366,6 +380,10 @@ export class VCow extends BaseContract { ): Promise; balanceOf(user: string, overrides?: CallOverrides): Promise; + + swapAll( + overrides?: Overrides & { from?: string | Promise } + ): Promise; }; populateTransaction: { @@ -416,5 +434,9 @@ export class VCow extends BaseContract { user: string, overrides?: CallOverrides ): Promise; + + swapAll( + overrides?: Overrides & { from?: string | Promise } + ): Promise; }; } diff --git a/src/custom/abis/types/factories/VCow__factory.ts b/src/custom/abis/types/factories/VCow__factory.ts index 124428c42..6062e9a9e 100644 --- a/src/custom/abis/types/factories/VCow__factory.ts +++ b/src/custom/abis/types/factories/VCow__factory.ts @@ -247,6 +247,19 @@ const _abi = [ stateMutability: "view", type: "function", }, + { + inputs: [], + name: "swapAll", + outputs: [ + { + internalType: "uint256", + name: "swappedBalance", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, ]; export class VCow__factory { diff --git a/src/custom/abis/vCow.json b/src/custom/abis/vCow.json index b6422e0d1..4b41727fb 100644 --- a/src/custom/abis/vCow.json +++ b/src/custom/abis/vCow.json @@ -238,5 +238,18 @@ ], "stateMutability": "view", "type": "function" + }, + { + "inputs": [], + "name": "swapAll", + "outputs": [ + { + "internalType": "uint256", + "name": "swappedBalance", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" } ] diff --git a/src/custom/constants/index.ts b/src/custom/constants/index.ts index c3f8fed6d..99a7698c0 100644 --- a/src/custom/constants/index.ts +++ b/src/custom/constants/index.ts @@ -60,13 +60,13 @@ export const GP_VAULT_RELAYER: Partial> = { export const V_COW_CONTRACT_ADDRESS: Record = { [ChainId.MAINNET]: '0xd057b63f5e69cf1b929b356b579cba08d7688048', [ChainId.XDAI]: '0xc20C9C13E853fc64d054b73fF21d3636B2d97eaB', - [ChainId.RINKEBY]: '0x5Bf4d1f8d1cB35E0aeA69B220beb97b8807504eA', + [ChainId.RINKEBY]: '0x9386177e95A853070076Df2403b9D547D653126D', // <- TODO: change these at some point after testing is done } export const COW_CONTRACT_ADDRESS: Record = { [ChainId.MAINNET]: '0xDEf1CA1fb7FBcDC777520aa7f396b4E015F497aB', [ChainId.XDAI]: '0x177127622c4A00F3d409B75571e12cB3c8973d3c', - [ChainId.RINKEBY]: '0x263D0C7a63D25564cFDc299C97Fd92A61B5fc7d1', + [ChainId.RINKEBY]: '0xbdf1e19f8c78A77fb741b44EbA5e4c0C8DBAeF91', // <- TODO: change these at some point after testing is done } // See https://github.com/gnosis/gp-v2-contracts/commit/821b5a8da213297b0f7f1d8b17c893c5627020af#diff-12bbbe13cd5cf42d639e34a39d8795021ba40d3ee1e1a8282df652eb161a11d6R13 diff --git a/src/custom/pages/Profile/index.tsx b/src/custom/pages/Profile/index.tsx index 12f1a7509..bc3641b1f 100644 --- a/src/custom/pages/Profile/index.tsx +++ b/src/custom/pages/Profile/index.tsx @@ -25,10 +25,7 @@ import { RefreshCcw } from 'react-feather' import Web3Status from 'components/Web3Status' import useReferralLink from 'hooks/useReferralLink' import useFetchProfile from 'hooks/useFetchProfile' -import { - // formatSmartLocaleAware, - numberFormatter, -} from 'utils/format' +import { formatSmartLocaleAware, numberFormatter } from 'utils/format' import { getExplorerAddressLink } from 'utils/explorer' import useTimeAgo from 'hooks/useTimeAgo' import { MouseoverTooltipContent } from 'components/Tooltip' @@ -43,10 +40,10 @@ import SVG from 'react-inlinesvg' import ArrowIcon from 'assets/cow-swap/arrow.svg' import CowImage from 'assets/cow-swap/cow_v2.svg' import CowProtocolImage from 'assets/cow-swap/cowprotocol.svg' -// import { useTokenBalance } from 'state/wallet/hooks' -// import { useVCowData } from 'state/claim/hooks' -// import { V_COW, COW } from 'constants/tokens' -// import { isPr, isLocal } from 'utils/environments' +import { useTokenBalance } from 'state/wallet/hooks' +import { useVCowData } from 'state/claim/hooks' +import { AMOUNT_PRECISION } from 'constants/index' +import { COW } from 'constants/tokens' export default function Profile() { const referralLink = useReferralLink() @@ -56,31 +53,28 @@ export default function Profile() { const isTradesTooltipVisible = account && chainId == 1 && !!profileData?.totalTrades const hasOrders = useHasOrders(account) - // const vCowBalance = useTokenBalance(account || undefined, chainId ? V_COW[chainId] : undefined) - const vCowBalance = '10,240,800.32' - // const cowBalance = useTokenBalance(account || undefined, chainId ? COW[chainId] : undefined) - const cowBalance = '0' + // Cow balance + const cow = useTokenBalance(account || undefined, chainId ? COW[chainId] : undefined) + + // vCow balance values + const { unvested, vested, total } = useVCowData() - // const { vested, total, unvested } = useVCowData() - const unvested = '9,240,800.32' - const vested = '1,240,800.32' + const cowBalance = formatSmartLocaleAware(cow, AMOUNT_PRECISION) || '0' + const vCowBalanceVested = formatSmartLocaleAware(vested, AMOUNT_PRECISION) || '0' + const vCowBalanceUnvested = formatSmartLocaleAware(unvested, AMOUNT_PRECISION) || '0' + const vCowBalance = formatSmartLocaleAware(total, AMOUNT_PRECISION) || '0' - // TODO: remove once this is not needed anymore - // if (isPr || isLocal) { - // console.force.log('vested', formatSmartLocaleAware(vested, vested?.currency.decimals)) - // console.force.log('total', formatSmartLocaleAware(total, total?.currency.decimals)) - // console.force.log('unvested', formatSmartLocaleAware(unvested, unvested?.currency.decimals)) - // console.force.log('cowBalance', formatSmartLocaleAware(cowBalance, cowBalance?.currency.decimals)) - // } + const hasCowBalance = cow && !cow.equalTo(0) + const hasVCowBalance = total && !total.equalTo(0) const tooltipText = { balanceBreakdown: ( - Unvested

{unvested} vCOW

+ Unvested

{vCowBalanceUnvested} vCOW

- Vested

{vested} vCOW

+ Vested

{vCowBalanceVested} vCOW

), @@ -119,7 +113,7 @@ export default function Profile() { Profile - {vCowBalance && ( + {hasVCowBalance && ( vCOW token @@ -141,7 +135,7 @@ export default function Profile() { - {vested} + {vCowBalanceVested} Convert to COW @@ -150,7 +144,7 @@ export default function Profile() { )} - {cowBalance && ( + {hasCowBalance && ( Cow Balance diff --git a/src/custom/pages/Profile/styled.tsx b/src/custom/pages/Profile/styled.tsx index 4adb28a11..3e55669e2 100644 --- a/src/custom/pages/Profile/styled.tsx +++ b/src/custom/pages/Profile/styled.tsx @@ -286,6 +286,7 @@ export const BannerCard = styled(BannerExplainer)` padding: 0 100px 0 24px; flex: 1; overflow: hidden; + height: auto; ${({ theme }) => theme.mediaWidth.upToSmall` text-align: center; diff --git a/src/custom/state/claim/hooks/index.ts b/src/custom/state/claim/hooks/index.ts index 35ecdd070..e3157eb71 100644 --- a/src/custom/state/claim/hooks/index.ts +++ b/src/custom/state/claim/hooks/index.ts @@ -62,7 +62,9 @@ import useIsMounted from 'hooks/useIsMounted' import { ChainId } from '@uniswap/sdk' import { ClaimInfo } from 'state/claim/reducer' -const CLAIMS_REPO_BRANCH = 'gip-13' +// TODO: Change back this to commented line before it goes to production +// const CLAIMS_REPO_BRANCH = 'gip-13' +const CLAIMS_REPO_BRANCH = '2022-02-15_Rinkeby-full' export const CLAIMS_REPO = `https://raw.githubusercontent.com/gnosis/cow-merkle-drop/${CLAIMS_REPO_BRANCH}/` // Base amount = 1 VCOW