Skip to content

Commit

Permalink
Merge pull request #586 from valory-xyz/fix/format-ether
Browse files Browse the repository at this point in the history
Fix eth format underflow
  • Loading branch information
mohandast52 authored Dec 13, 2024
2 parents 381bc81 + 5156a79 commit 3882f89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
21 changes: 10 additions & 11 deletions frontend/config/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { MemeooorBaseService } from '@/service/agents/Memeooor';
import { PredictTraderService } from '@/service/agents/PredictTrader';
// import { OptimusService } from '@/service/agents/Optimus';
import { AgentConfig } from '@/types/Agent';
import { formatEther } from '@/utils/numberFormatters';

// TODO: complete this config
// TODO: add funding requirements
Expand All @@ -21,23 +20,23 @@ export const AGENT_CONFIG: {
middlewareHomeChainId: MiddlewareChain.GNOSIS,
requiresAgentSafesOn: [EvmChainId.Gnosis],
agentSafeFundingRequirements: {
[EvmChainId.Gnosis]: +formatEther(0.1),
[EvmChainId.Gnosis]: 0.1,
},
operatingThresholds: {
[WalletOwnerType.Master]: {
[WalletType.EOA]: {
[TokenSymbol.XDAI]: +formatEther(1.5),
[TokenSymbol.XDAI]: 1.5,
},
[WalletType.Safe]: {
[TokenSymbol.XDAI]: +formatEther(2),
[TokenSymbol.XDAI]: 2,
},
},
[WalletOwnerType.Agent]: {
[WalletType.EOA]: {
[TokenSymbol.XDAI]: +formatEther(0.1),
[TokenSymbol.XDAI]: 0.1,
},
[WalletType.Safe]: {
[TokenSymbol.XDAI]: +formatEther(0.1),
[TokenSymbol.XDAI]: 0.1,
},
},
},
Expand Down Expand Up @@ -65,23 +64,23 @@ export const AGENT_CONFIG: {
middlewareHomeChainId: MiddlewareChain.BASE,
requiresAgentSafesOn: [EvmChainId.Base],
agentSafeFundingRequirements: {
[EvmChainId.Base]: +formatEther(0.03),
[EvmChainId.Base]: 0.03,
},
operatingThresholds: {
[WalletOwnerType.Master]: {
[WalletType.EOA]: {
[TokenSymbol.ETH]: +formatEther(0.0001),
[TokenSymbol.ETH]: 0.0001,
},
[WalletType.Safe]: {
[TokenSymbol.ETH]: +formatEther(0.0001),
[TokenSymbol.ETH]: 0.0001,
},
},
[WalletOwnerType.Agent]: {
[WalletType.EOA]: {
[TokenSymbol.ETH]: +formatEther(0.0001),
[TokenSymbol.ETH]: 0.0001,
},
[WalletType.Safe]: {
[TokenSymbol.ETH]: +formatEther(0.0001),
[TokenSymbol.ETH]: 0.0001,
},
},
},
Expand Down
6 changes: 1 addition & 5 deletions frontend/hooks/useBalanceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useContext, useMemo } from 'react';
import { CHAIN_CONFIG } from '@/config/chains';
import { BalanceContext, WalletBalanceResult } from '@/context/BalanceProvider';
import { Optional } from '@/types/Util';
import { formatEther } from '@/utils/numberFormatters';

import { useService } from './useService';
import { useServices } from './useServices';
Expand Down Expand Up @@ -154,10 +153,7 @@ export const useMasterBalances = () => {

if (!agentNativeGasRequirement) return;

return (
masterSafeNative.balance <
parseFloat(formatEther(`${agentNativeGasRequirement}`))
);
return masterSafeNative.balance < agentNativeGasRequirement;
}, [masterSafeNative, homeChainNativeToken, selectedAgentConfig]);

const masterEoaNative = useMemo(() => {
Expand Down

0 comments on commit 3882f89

Please sign in to comment.