Skip to content
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: 2 additions & 2 deletions packages/ui/app/veion/governance/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';

import { useSearchParams, useRouter } from 'next/navigation';

import { base, mode } from 'viem/chains';
import { base, lisk, mode } from 'viem/chains';

import ActionButton from '@ui/components/ActionButton';
import NetworkSelector from '@ui/components/markets/NetworkSelector';
Expand Down Expand Up @@ -57,7 +57,7 @@ export default function Governance() {
<NetworkSelector
nopool
dropdownSelectedChain={+chain}
enabledChains={[base.id, mode.id]}
enabledChains={[base.id, mode.id, lisk.id]}
upcomingChains={['Optimism']}
/>

Expand Down
13 changes: 7 additions & 6 deletions packages/ui/app/veion/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Image from 'next/image';
import Link from 'next/link';

import { ExternalLink } from 'lucide-react';
import { base, mode } from 'viem/chains';
import { base, mode, lisk } from 'viem/chains';

import { Button } from '@ui/components/ui/button';
import { Card, CardContent, CardHeader } from '@ui/components/ui/card';
Expand All @@ -32,7 +32,8 @@ export default function EnhancedVeIon() {
const [isAddLiquidityOpen, setIsAddLiquidityOpen] = useState(false);
const [isMigrateOpen, setIsMigrateOpen] = useState(false);

const selectedtoken = currentChain === 8453 ? 'eth' : 'mode';
const selectedtoken =
currentChain === 34443 ? 'mode' : currentChain === 1135 ? 'weth' : 'eth';

return (
<div className="min-h-screen">
Expand Down Expand Up @@ -70,7 +71,7 @@ export default function EnhancedVeIon() {
<NetworkSelector
dropdownSelectedChain={currentChain}
nopool={true}
enabledChains={[mode.id, base.id]}
enabledChains={[mode.id, base.id, lisk.id]}
/>
</div>
</CardHeader>
Expand Down Expand Up @@ -150,17 +151,17 @@ export default function EnhancedVeIon() {
<AddLiquidityDialog
isOpen={isAddLiquidityOpen}
onOpenChange={setIsAddLiquidityOpen}
selectedToken={selectedtoken as 'eth' | 'mode' | 'weth'}
selectedToken={selectedtoken as 'eth' | 'lsk' | 'mode' | 'weth'}
/>
<UnstakeIonDialog
isOpen={isMigrateOpen}
onOpenChange={setIsMigrateOpen}
selectedToken={selectedtoken as 'eth' | 'mode' | 'weth'}
selectedToken={selectedtoken as 'eth' | 'lsk' | 'mode' | 'weth'}
/>
<GetVeIONDialog
isOpen={isDialogOpen}
onOpenChange={setIsDialogOpen}
selectedToken={selectedtoken as 'eth' | 'mode' | 'weth'}
selectedToken={selectedtoken as 'eth' | 'lsk' | 'mode' | 'weth'}
/>
</Card>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/components/dialogs/VeIon/AddLiquidityDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { useVeIONActions } from '@ui/hooks/veion/useVeIONActions';
interface AddLiquidityDialogProps {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
selectedToken: 'eth' | 'mode' | 'weth';
selectedToken: 'eth' | 'lsk' | 'mode' | 'weth';
}

// AddLiquidityDialog.tsx
Expand Down Expand Up @@ -129,7 +129,7 @@ export default function AddLiquidityDialog({
<div className="space-y-8">
<DialogHeader className="space-y-3">
<DialogTitle className="text-2xl font-bold bg-gradient-to-r from-white to-accent bg-clip-text text-transparent">
Add ION Liquidity
Add ION/{selectedToken.toUpperCase()} Liquidity
</DialogTitle>
<p className="text-sm text-white/60">
Provide liquidity to earn fees and participate in governance
Expand Down
7 changes: 2 additions & 5 deletions packages/ui/components/dialogs/VeIon/GetVeIONDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const MINIMUM_AMOUNT = BigInt('10000000000000000');
interface GetVeIONDialogProps {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
selectedToken: 'eth' | 'mode' | 'weth';
selectedToken: 'eth' | 'lsk' | 'mode' | 'weth';
}

export default function GetVeIONDialog({
Expand All @@ -38,7 +38,7 @@ export default function GetVeIONDialog({
const [success, setSuccess] = useState<boolean>(false);
const [amount, setAmount] = useState<string>('0');
const { currentChain } = useVeIONContext();
const { createLock, isPending } = useVeIONActions();
const { createLock } = useVeIONActions();
const { address, isConnected } = useAccount();

const isAboveMinimum = useMemo(() => {
Expand Down Expand Up @@ -102,9 +102,6 @@ export default function GetVeIONDialog({
}
}

const isButtonDisabled =
!lockDate || Number(amount) === 0 || !isAboveMinimum || isPending;

return (
<Dialog
open={isOpen}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/dialogs/VeIon/UnstakeIonDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
interface UnstakeIonDialogProps {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
selectedToken: 'eth' | 'mode' | 'weth';
selectedToken: 'eth' | 'lsk' | 'mode' | 'weth';
}

export default function UnstakeIonDialog({
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/components/veion/LPRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArrowRight } from 'lucide-react';
import { mode } from 'viem/chains';
import { lisk, mode } from 'viem/chains';

import { Button } from '@ui/components/ui/button';
import { Card, CardContent } from '@ui/components/ui/card';
Expand Down Expand Up @@ -29,7 +29,7 @@ const LPRow = ({
detail: Detail;
chain: number;
}) => {
const token2 = chain == mode.id ? 'mode' : 'eth';
const token2 = chain == mode.id ? 'mode' : chain == lisk.id ? 'weth' : 'eth';

return (
<div className="grid grid-cols-6 gap-3 group">
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/components/veion/ManageDialog/Increase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export function Increase() {
headerText={'Lock Amount'}
max={String(tokenValue)}
amount={amount}
tokenName={chain === 34443 ? 'ion/mode' : 'ion/eth'}
tokenName={
chain === 34443 ? 'ion/mode' : chain === 1135 ? 'ion/weth' : 'ion/eth'
}
token={token}
handleInput={(val) => setAmount(val || '0')}
chain={+chain}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/veion/VotesManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function VotesManagement({
const querychain = searchParams.get('chain');
const querypool = searchParams.get('pool');
const chain = querychain ? querychain : mode.id.toString();
const selectedPool = +chain === mode.id ? '1' : querypool ?? '0';
const selectedPool = querypool ?? (+chain === mode.id ? '1' : '0');

const hiddenPools: HiddenPool[] = [{ chainId: mode.id, poolId: '0' }];

Expand Down
8 changes: 8 additions & 0 deletions packages/ui/constants/liskLp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const LiskLiquidityContractAdd =
'0x3a63171DD9BebF4D07BC782FECC7eb0b890C2A45';
export const LiskStakingContractAddr =
'0x6BFF62258b7BD76F79B4F0818cDDF3628A2fFA58';
export const LiskReservesContractAddr =
'0x076d0CD6228B042aA28E1E6A0894Cf6C97abc23b';
export const LiskIonTokenAddress = '0x3f608A49a3ab475dA7fBb167C1Be6b7a45cD7013';
export const LiskLPPoolContract = '0x076d0CD6228B042aA28E1E6A0894Cf6C97abc23b';
7 changes: 6 additions & 1 deletion packages/ui/constants/veIon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { iveIonAbi, iVoterAbi, voterAbi } from '@ionicprotocol/sdk';
export const VEION_CONTRACTS: Partial<Record<ChainId, `0x${string}`>> = {
8453: '0x8865E0678E3b1BD0F5302e4C178a4B576F6aAA27' as `0x${string}`, // Base
34443: '0x2Abd9eB57Fb7727138f4181B68DA0426B7fd47e8' as `0x${string}`, // Mode
1135: '0x6136BeC00Ba7C6d44BB10ee8683C792a0F8cDd6a' as `0x${string}`, // Lisk
0: '0x'
};

export const VOTER_CONTRACTS: Partial<Record<ChainId, `0x${string}`>> = {
8453: '0x669A6F5421dA53696fa06f1043CF127d380f6EB9' as `0x${string}`, // Base
34443: '0x141F7f2aa313Ff4C60Dd58fDe493aA2048170429' as `0x${string}` // Mode
34443: '0x141F7f2aa313Ff4C60Dd58fDe493aA2048170429' as `0x${string}`, // Mode
1135: '0x8865E0678E3b1BD0F5302e4C178a4B576F6aAA27' as `0x${string}` // Lisk
};

export function getVeIonContract(chainId: number): {
Expand Down Expand Up @@ -81,5 +83,8 @@ export const EXCLUDED_MARKETS: MarketExclusionConfig = {
ezETH: {
borrow: true
}
},
1135: {
// Add any Lisk-specific market exclusions here if needed
}
};
2 changes: 1 addition & 1 deletion packages/ui/context/VeIonVoteContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const VeIonVoteProvider: React.FC<{
const querychain = searchParams.get('chain');
const querypool = searchParams.get('pool');
const chain = querychain ? querychain : mode.id.toString();
const selectedPool = +chain === mode.id ? '1' : querypool ?? '0';
const selectedPool = querypool ?? (+chain === mode.id ? '1' : '0');

const votingPeriod = useVotingPeriod(chain, tokenId);

Expand Down
14 changes: 4 additions & 10 deletions packages/ui/hooks/rewards/useBribeRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { useQuery } from '@tanstack/react-query';
import { formatUnits } from 'viem';
import { useAccount, usePublicClient } from 'wagmi';

import { REWARDS_TO_SYMBOL } from '@ui/constants'; // Import the REWARDS_TO_SYMBOL mapping
import { REWARDS_TO_SYMBOL } from '@ui/constants';
import { useVeIONContext } from '@ui/context/VeIonContext';

import { VOTER_LENS_ADDRESSES } from '../veion/useMarketIncentives';

import type { Address, Hex } from 'viem';

import { voterLensAbi } from '@ionicprotocol/sdk';
Expand All @@ -16,19 +18,13 @@ const supabase = createClient(
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVvYWd0anN0c2RyanlweGxrdXpyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDc5MDE2MTcsImV4cCI6MjAyMzQ3NzYxN30.CYck7aPTmW5LE4hBh2F4Y89Cn15ArMXyvnP3F521S78'
);

export const VOTERLENS_CHAIN_ADDRESSES = {
8453: '0xFEF51b9B5a1050B2bBE52A39cC356dfCEE79D87B',
34443: '0x0286bf00b6f6Cc45D2bd7e8C2e728B1DF2854c7D'
} as const;

export interface BribeReward {
amount: bigint;
chainId: SupportedChains;
rewardToken: Hex;
bribeAddress: Address;
tokenId: bigint;
market?: Address;
// Add these fields for formatted display
formattedAmount?: string;
tokenSymbol?: string;
}
Expand Down Expand Up @@ -86,9 +82,7 @@ export const useBribeRewards = () => {
}

const voterLensAddress =
VOTERLENS_CHAIN_ADDRESSES[
currentChain as keyof typeof VOTERLENS_CHAIN_ADDRESSES
];
VOTER_LENS_ADDRESSES[currentChain as keyof typeof VOTER_LENS_ADDRESSES];
if (!voterLensAddress) return [];

try {
Expand Down
13 changes: 11 additions & 2 deletions packages/ui/hooks/useDexScreenerPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import axios from 'axios';
import { base, mode, optimism } from 'viem/chains';

import { BaseReservesContractAddr } from '@ui/constants/baselp';
import {
LiskIonTokenAddress,
LiskReservesContractAddr
} from '@ui/constants/liskLp';
import { ModeReservesContractAddr } from '@ui/constants/lp';
import { OPReservesContractAddr } from '@ui/constants/oplp';

Expand All @@ -28,6 +32,12 @@ const REWARD_TOKEN_CONFIGS = {
pairAddress: '0xc2026f3fb6fc51f4ecae40a88b4509cb6c143ed4', // MODE pair
tokenSymbol: 'xVELO',
ionAddress: ModeReservesContractAddr.toLocaleLowerCase()
},
[1135]: {
name: 'mode',
pairAddress: '0x076d0CD6228B042aA28E1E6A0894Cf6C97abc23b',
tokenSymbol: 'xVELO',
ionAddress: ModeReservesContractAddr.toLocaleLowerCase() // using mode ion address for lisk, because dexscreener does not have it
}
} as const;

Expand Down Expand Up @@ -77,7 +87,7 @@ export function useIonPrice({ chainId }: { chainId: number }) {

export function useIonPrices(specificChains?: number[]) {
// If no chains provided, use all available chains
const chains = specificChains || [8453, 34443, 10];
const chains = specificChains || [8453, 34443, 10, 1135];

return useQuery({
queryKey: ['ionPrices', chains], // Add chains to queryKey for proper caching
Expand All @@ -91,7 +101,6 @@ export function useIonPrices(specificChains?: number[]) {
const res = await axios.get(
`https://api.dexscreener.com/latest/dex/pairs/${config.name}/${config.ionAddress}`
);

return {
chainId,
price: Number(res.data.pairs[0]?.priceUsd || '0')
Expand Down
37 changes: 28 additions & 9 deletions packages/ui/hooks/useLiquidityCalculations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ import {
interface UseLiquidityCalculationsProps {
address?: Address;
chainId: number;
selectedToken: 'eth' | 'mode' | 'weth';
selectedToken: 'eth' | 'lsk' | 'mode' | 'weth';
}

export function useLiquidityCalculations({
address,
chainId,
selectedToken
}: UseLiquidityCalculationsProps) {
const reservesContractAddress = getReservesContract(chainId);
const reservesAbi = getReservesABI(chainId);
const reservesArgs = getReservesArgs(chainId, selectedToken);

const reserves = useReadContract({
abi: getReservesABI(chainId),
address: getReservesContract(chainId),
args: getReservesArgs(chainId, selectedToken),
abi: reservesAbi,
address: reservesContractAddress,
args: reservesArgs,
functionName: 'getReserves',
chainId: chainId,
query: {
Expand Down Expand Up @@ -65,11 +69,15 @@ export function useLiquidityCalculations({
};

const calculateTokenAmount = (ionAmount: string): string => {
if (!processedReserves || !ionAmount || processedReserves.ion === 0n)
return '';
if (!ionAmount) return '';

try {
const parsedIonAmount = parseUnits(ionAmount, 18);

if (!processedReserves || processedReserves.ion === 0n) {
return ionAmount;
}

const tokenVal =
(parsedIonAmount * processedReserves.token) / processedReserves.ion;
return formatEther(tokenVal);
Expand Down Expand Up @@ -104,12 +112,17 @@ export function useLiquidityCalculations({
}, [reserves.status, reserves.data, chainId]);

const getMaximumIonInput = (): string => {
if (!processedReserves || !selectedTokenBalance || !ionBalance) {
if (!selectedTokenBalance || !ionBalance) {
return '0';
}

try {
const maxIonBasedOnBalance = ionBalance.value;

if (!processedReserves || processedReserves.token === 0n) {
return formatEther(maxIonBasedOnBalance);
}

const maxIonBasedOnReserves =
(selectedTokenBalance.value * processedReserves.ion) /
processedReserves.token;
Expand All @@ -126,14 +139,20 @@ export function useLiquidityCalculations({
};

const wouldExceedLiquidity = (ionAmount: string): boolean => {
if (!processedReserves || !selectedTokenBalance || !ionAmount) return false;
if (!selectedTokenBalance || !ionAmount) return false;

try {
if (!processedReserves || processedReserves.ion === 0n) {
const parsedIonAmount = parseUnits(ionAmount, 18);
return parsedIonAmount > selectedTokenBalance.value;
}

const parsedIonAmount = parseUnits(ionAmount, 18);
const requiredToken =
(parsedIonAmount * processedReserves.token) / processedReserves.ion;
return requiredToken > selectedTokenBalance.value;
} catch {
} catch (error) {
console.warn('Error checking liquidity:', error);
return false;
}
};
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/hooks/useReserves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface Reserves {
token: bigint;
}

type SupportedToken = 'eth' | 'mode' | 'weth';
type SupportedToken = 'eth' | 'lsk' | 'mode' | 'weth';

export function useReserves(chainId: number) {
const tokens = ['eth', 'mode', 'weth'] as const;
const tokens = ['eth', 'mode', 'weth', 'lsk'] as const;

const contracts = tokens.map((token) => ({
abi: getReservesABI(chainId) as Abi,
Expand Down
Loading