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

feat: agents.fun in celo (UI configs) #647

Merged
merged 23 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5b7a716
fix: add new agent type 'agents-fun-celo' to Agent enum
mohandast52 Jan 6, 2025
154a673
feat: add support for CELO chain in configuration and enums
mohandast52 Jan 6, 2025
5f0d593
feat: add Agents.fun Celo template and update StakingProgramId enum
mohandast52 Jan 6, 2025
36267dc
feat: add support for Agents.fun Celo in agent selection and fund req…
mohandast52 Jan 6, 2025
38989ca
feat: add CELO activity checkers to support new chain integration
mohandast52 Jan 7, 2025
8299474
feat: add CELO staking program configuration and support in middleware
mohandast52 Jan 7, 2025
fd8894f
feat: implement Agents.fun Celo agent configuration and service integ…
mohandast52 Jan 7, 2025
2bb41c5
feat: add feature flags for Agents.fun Celo agent configuration
mohandast52 Jan 7, 2025
0a0aa34
feat: refactor EVM chain handling and remove Optimism support
mohandast52 Jan 7, 2025
b59f48d
feat: add CELO RPC configuration to release workflows
mohandast52 Jan 7, 2025
0fa7452
feat: enhance useService hook to support nullable service chain addre…
mohandast52 Jan 7, 2025
673f90a
feat: add CELO RPC support to release workflows and configuration
mohandast52 Jan 7, 2025
89724cc
feat: update type definitions to use EvmChainId and improve code reus…
mohandast52 Jan 7, 2025
d247cac
feat: enhance useNeedsFunds hook to utilize EvmChainId for improved t…
mohandast52 Jan 7, 2025
159b758
feat: disable Celo agent in configuration
mohandast52 Jan 7, 2025
876ae52
feat: update Celo configurations and templates for improved clarity a…
mohandast52 Jan 10, 2025
03d8ed1
fix: correct grammatical errors in agent descriptions for clarity
mohandast52 Jan 13, 2025
c5eeede
feat: refactor agent services and consolidate StakedAgentService imports
mohandast52 Jan 13, 2025
55eb0ae
chore: conflict fixes
mohandast52 Jan 13, 2025
7b19748
feat: add support for BASE staking programs in AgentsFunService
mohandast52 Jan 13, 2025
92553d2
chore: images
mohandast52 Jan 13, 2025
68c02b1
feat: update service templates and refactor agent service imports to …
mohandast52 Jan 13, 2025
eefa8a6
chore: images
mohandast52 Jan 13, 2025
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ GNOSIS_RPC=
ETHEREUM_RPC=
OPTIMISM_RPC=
BASE_RPC=
MODE_RPC=
MODE_RPC=
CELO_RPC=
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ jobs:
GNOSIS_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/
ETHEREUM_RPC: https://rpc-gate.autonolas.tech/ethereum-rpc/
MODE_RPC: https://mainnet.mode.network

CELO_RPC: https://forno.celo.org

# Build frontend for development
- name: Build frontend for development
Expand All @@ -234,6 +234,7 @@ jobs:
GNOSIS_RPC: https://virtual.gnosis.rpc.tenderly.co/7de511da-9ad7-4e9f-98c1-e99052e92b15
ETHEREUM_RPC: https://rpc-gate.autonolas.tech/ethereum-rpc/
MODE_RPC: https://virtual.mode.rpc.tenderly.co/9f5ab06c-f005-4f8d-8bb2-786cb7b8f865
CELO_RPC: https://forno.celo.org

# Run the build and notarization process for production
- name: Build, notarize, and publish (Production)
Expand All @@ -255,12 +256,14 @@ jobs:
GNOSIS_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/
ETHEREUM_RPC: https://rpc-gate.autonolas.tech/ethereum-rpc/
MODE_RPC: https://mainnet.mode.network
CELO_RPC: https://forno.celo.org
run: |
echo "OPTIMISM_RPC=https://rpc-gate.autonolas.tech/optimism-rpc/" >> .env
echo "BASE_RPC=https://rpc-gate.autonolas.tech/base-rpc/" >> .env
echo "GNOSIS_RPC=https://rpc-gate.autonolas.tech/gnosis-rpc/" >> .env
echo "ETHEREUM_RPC=https://rpc-gate.autonolas.tech/ethereum-rpc/" >> .env
echo "MODE_RPC=https://mainnet.mode.network" >> .env
echo "CELO_RPC=https://forno.celo.org" >> .env
node build.js

# Run the build and notarization process for development
Expand All @@ -283,10 +286,12 @@ jobs:
GNOSIS_RPC: https://virtual.gnosis.rpc.tenderly.co/7de511da-9ad7-4e9f-98c1-e99052e92b15
ETHEREUM_RPC: https://rpc-gate.autonolas.tech/ethereum-rpc/
MODE_RPC: https://virtual.mode.rpc.tenderly.co/9f5ab06c-f005-4f8d-8bb2-786cb7b8f865
CELO_RPC: https://forno.celo.org
run: |
echo "OPTIMISM_RPC=https://rpc-gate.autonolas.tech/optimism-rpc/" >> .env
echo "BASE_RPC=https://virtual.base.rpc.tenderly.co/2a91611a-3251-48a6-8095-b86815de84bf" >> .env
echo "GNOSIS_RPC=https://virtual.gnosis.rpc.tenderly.co/7de511da-9ad7-4e9f-98c1-e99052e92b15" >> .env
echo "ETHEREUM_RPC=https://rpc-gate.autonolas.tech/ethereum-rpc/" >> .env
echo "MODE_RPC=https://virtual.mode.rpc.tenderly.co/9f5ab06c-f005-4f8d-8bb2-786cb7b8f865" >> .env
echo "CELO_RPC=https://forno.celo.org" >> .env
node build.js
4 changes: 4 additions & 0 deletions .github/workflows/release_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ jobs:
GNOSIS_RPC: "https://rpc-gate.autonolas.tech/gnosis-rpc/"
ETHEREUM_RPC: "https://rpc-gate.autonolas.tech/ethereum-rpc/"
MODE_RPC: "https://mainnet.mode.network"
CELO_RPC: "https://forno.celo.org"
arch: "x64"
- env: "development"
OPTIMISM_RPC: "https://rpc-gate.autonolas.tech/optimism-rpc/"
BASE_RPC: "https://virtual.base.rpc.tenderly.co/2a91611a-3251-48a6-8095-b86815de84bf"
GNOSIS_RPC: "https://virtual.gnosis.rpc.tenderly.co/7de511da-9ad7-4e9f-98c1-e99052e92b15"
ETHEREUM_RPC: "https://rpc-gate.autonolas.tech/ethereum-rpc/"
MODE_RPC: "https://virtual.mode.rpc.tenderly.co/9f5ab06c-f005-4f8d-8bb2-786cb7b8f865"
CELO_RPC: "https://forno.celo.org"
arch: "x64"
defaults:
run:
Expand Down Expand Up @@ -139,6 +141,7 @@ jobs:
ETHEREUM_RPC: ${{ matrix.ETHEREUM_RPC }}
OPTIMISM_RPC: ${{ matrix.OPTIMISM_RPC }}
MODE_RPC: ${{ matrix.MODE_RPC }}
CELO_RPC: ${{ matrix.CELO_RPC }}
IS_STAGING: ${{ github.ref != 'refs/heads/main' && 'true' || 'false' }}
GH_TOKEN: ${{ secrets.github_token}}
run: |
Expand All @@ -149,6 +152,7 @@ jobs:
echo ETHEREUM_RPC=$ETHEREUM_RPC >> prod.env
echo GNOSIS_RPC=$GNOSIS_RPC >> prod.env
echo MODE_RPC=$MODE_RPC >> prod.env
echo CELO_RPC=$CELO_RPC >> prod.env
cat prod.env
echo GH_TOKEN=$GH_TOKEN >> prod.env
- run: rm -rf /dist
Expand Down
Binary file added electron/public/agent-agents-fun-celo-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified electron/public/agent-memeooorr-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions electron/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const schema = {
trader: { type: 'object', default: defaultInitialAgentSettings },
memeooorr: { type: 'object', default: defaultInitialAgentSettings },
modius: { type: 'object', default: defaultInitialAgentSettings },
agentsFunCelo: { type: 'object', default: defaultInitialAgentSettings },
};

/**
Expand Down
1 change: 1 addition & 0 deletions frontend/client/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum MiddlewareChain {
OPTIMISM = 'optimism',
BASE = 'base',
MODE = 'mode',
CELO = 'celo',
}

export enum MiddlewareLedger {
Expand Down
6 changes: 5 additions & 1 deletion frontend/components/AgentSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ const EachAgent = memo(
}

// Neither service nor safe is created
if (agentType === AgentType.Memeooorr || agentType === AgentType.Modius) {
if (
agentType === AgentType.Memeooorr ||
agentType === AgentType.Modius ||
agentType === AgentType.AgentsFunCelo
) {
// if the selected type requires setting up an agent - should redirect to SetupYourAgent first
// TODO: can have this as a boolean flag in agentConfig?
gotoPage(Pages.Setup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const FUNDS_REQUIRED_FOR_BY_AGENT_TYPE = {
[AgentType.PredictTrader]: 'for trading',
[AgentType.Memeooorr]: 'for agent operations',
[AgentType.Modius]: 'minimum for investment',
[AgentType.AgentsFunCelo]: 'for agent operations',
};

export const FundsToActivate = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Card, Flex, Skeleton, Typography } from 'antd';
import { CardTitle } from '@/components/Card/CardTitle';
import { UNICODE_SYMBOLS } from '@/constants/symbols';
import { DISCORD_TICKET_URL } from '@/constants/urls';
import { EvmChainId } from '@/enums/Chain';
import { AllEvmChainId, EvmChainId } from '@/enums/Chain';
import { useServices } from '@/hooks/useServices';
import { useMasterWalletContext } from '@/hooks/useWallet';

Expand All @@ -15,11 +15,12 @@ const { Text } = Typography;
* update as needed; check https://app.safe.global/new-safe/create for prefixes
*/
const safeChainPrefix = {
[EvmChainId.Ethereum]: 'eth',
[AllEvmChainId.Ethereum]: 'eth',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you think we need two separate sets of evmChainIds? wouldn't that be confusing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to the “EvmChainId” type. In several places, we were using EvmChainId | number, which isn’t ideal as it allows any valid number. To make it stricter, we need to limit it to the specific chain IDs we support. AllEvmChainId (possibly a better name could be chosen) could simply act as an enum holding these chain IDs. Personally, I’d prefer to stick to EvmChainId, but for safeChainPrefix, we might require a more generic type. Let me know your thoughts.

[EvmChainId.Base]: 'base',
[EvmChainId.Optimism]: 'oeth',
[AllEvmChainId.Optimism]: 'oeth',
[EvmChainId.Gnosis]: 'gno',
[EvmChainId.Mode]: '', // TODO: provide correct prefix once mode is supported on safe
[EvmChainId.Celo]: 'celo',
};

export const AddBackupWalletViaSafePage = () => {
Expand Down
10 changes: 4 additions & 6 deletions frontend/components/SetupPage/Create/SetupEoaFunding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { CardFlex } from '@/components/styled/CardFlex';
import { CardSection } from '@/components/styled/CardSection';
import { CHAIN_CONFIG } from '@/config/chains';
import { NA } from '@/constants/symbols';
import { EvmChainId } from '@/enums/Chain';
import { SetupScreen } from '@/enums/SetupScreen';
import { useMasterBalances } from '@/hooks/useBalanceContext';
import { useServices } from '@/hooks/useServices';
import { useSetup } from '@/hooks/useSetup';
import { useMasterWalletContext } from '@/hooks/useWallet';
import { AgentSupportedEvmChainId } from '@/types/Agent';
import { copyToClipboard } from '@/utils/copyToClipboard';
import { delayInSeconds } from '@/utils/delay';

Expand Down Expand Up @@ -127,8 +127,8 @@ export const SetupEoaFunding = () => {
const { masterWalletBalances } = useMasterBalances();
const masterEoaAddress = masterEoa?.address;

const [currentChain, setCurrentChain] = useState<AgentSupportedEvmChainId>(
selectedAgentConfig.evmHomeChainId as AgentSupportedEvmChainId,
const [currentChain, setCurrentChain] = useState<EvmChainId>(
selectedAgentConfig.evmHomeChainId,
);

const currentFundingRequirements = CHAIN_CONFIG[currentChain];
Expand Down Expand Up @@ -156,9 +156,7 @@ export const SetupEoaFunding = () => {

// goto next chain
if (nextChainExists) {
setCurrentChain(
chains[indexOfCurrentChain + 1] as unknown as AgentSupportedEvmChainId,
);
setCurrentChain(chains[indexOfCurrentChain + 1] as unknown as EvmChainId);
return;
}

Expand Down
25 changes: 15 additions & 10 deletions frontend/config/activityCheckers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ActivityCheckers = {
[activityCheckerType: string]: MulticallContract;
};

export const GNOSIS_ACTIVITY_CHECKERS: ActivityCheckers = {
const GNOSIS_ACTIVITY_CHECKERS: ActivityCheckers = {
[ActivityCheckerType.MechActivityChecker]: new MulticallContract(
'0x155547857680A6D51bebC5603397488988DEb1c8',
MECH_ACTIVITY_CHECKER_ABI,
Expand All @@ -28,31 +28,36 @@ export const GNOSIS_ACTIVITY_CHECKERS: ActivityCheckers = {
'0x7Ec96996Cd146B91779f01419db42E67463817a0',
REQUESTER_ACTIVITY_CHECKER_ABI,
),
};

export const OPTIMISM_ACTIVITY_CHECKERS: ActivityCheckers = {};
} as const;

export const BASE_ACTIVITY_CHECKERS: ActivityCheckers = {
const BASE_ACTIVITY_CHECKERS: ActivityCheckers = {
[ActivityCheckerType.MemeActivityChecker]: new MulticallContract(
'0x026AB1c5ea14E61f67d245685D9561c0c2Cb39Ba',
MEME_ACTIVITY_CHECKER_ABI,
),
};
} as const;

export const MODE_ACTIVITY_CHECKERS: ActivityCheckers = {
const MODE_ACTIVITY_CHECKERS: ActivityCheckers = {
[ActivityCheckerType.Staking]: new MulticallContract(
'0x07bc3C23DbebEfBF866Ca7dD9fAA3b7356116164',
STAKING_ACTIVITY_CHECKER_ABI,
),
};
} as const;

const CELO_ACTIVITY_CHECKERS: ActivityCheckers = {
[ActivityCheckerType.MemeActivityChecker]: new MulticallContract(
'0x3FD8C757dE190bcc82cF69Df3Cd9Ab15bCec1426',
MEME_ACTIVITY_CHECKER_ABI,
),
} as const;

export const ACTIVITY_CHECKERS: {
[chainId: number]: {
[chainId in EvmChainId]: {
[activityCheckerType: string]: MulticallContract;
};
} = {
[EvmChainId.Gnosis]: GNOSIS_ACTIVITY_CHECKERS,
[EvmChainId.Optimism]: OPTIMISM_ACTIVITY_CHECKERS,
[EvmChainId.Base]: BASE_ACTIVITY_CHECKERS,
[EvmChainId.Mode]: MODE_ACTIVITY_CHECKERS,
[EvmChainId.Celo]: CELO_ACTIVITY_CHECKERS,
} as const;
50 changes: 43 additions & 7 deletions frontend/config/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { formatUnits } from 'ethers/lib/utils';

import { MiddlewareChain } from '@/client';
import {
MEMEOOORR_BASE_TEMPLATE,
AGENTS_FUN_BASE_TEMPLATE,
MODIUS_SERVICE_TEMPLATE,
PREDICT_SERVICE_TEMPLATE,
} from '@/constants/serviceTemplates';
import { AgentType } from '@/enums/Agent';
import { EvmChainId } from '@/enums/Chain';
import { TokenSymbol } from '@/enums/Token';
import { WalletOwnerType, WalletType } from '@/enums/Wallet';
import { MemeooorBaseService } from '@/service/agents/Memeooor';
import { AgentsFunBaseService } from '@/service/agents/AgentsFunBase';
import { ModiusService } from '@/service/agents/Modius';
import { PredictTraderService } from '@/service/agents/PredictTrader';
import { AgentConfig } from '@/types/Agent';
Expand All @@ -24,7 +24,11 @@ const traderFundRequirements =
.fund_requirements[ethers.constants.AddressZero];

const memeooorrRequirements =
MEMEOOORR_BASE_TEMPLATE.configurations[MiddlewareChain.BASE]
AGENTS_FUN_BASE_TEMPLATE.configurations[MiddlewareChain.BASE]
.fund_requirements[ethers.constants.AddressZero];

const agentsFunCeloRequirements =
AGENTS_FUN_BASE_TEMPLATE.configurations[MiddlewareChain.BASE]
.fund_requirements[ethers.constants.AddressZero];

const modiusFundRequirements =
Expand Down Expand Up @@ -87,11 +91,11 @@ export const AGENT_CONFIG: {
},
},
requiresMasterSafesOn: [EvmChainId.Base],
serviceApi: MemeooorBaseService,
displayName: 'Agents.fun agent',
serviceApi: AgentsFunBaseService,
displayName: 'Agents.fun agent - Base',
description:
'Autonomously post to Twitter, create and trade memecoins, and interact with other agents.',
isAgentEnabled: false,
'Autonomously posts to Twitter, creates and trades memecoins, and interacts with other agents. Agent is operating on Base chain.',
isAgentEnabled: true,
},
[AgentType.Modius]: {
name: 'Modius agent',
Expand Down Expand Up @@ -140,4 +144,36 @@ export const AGENT_CONFIG: {
'Invests crypto assets on your behalf and grows your portfolio.',
isAgentEnabled: true,
},
// TODO: celo (check each key)
[AgentType.AgentsFunCelo]: {
name: 'Agents.fun agent (Celo)',
evmHomeChainId: EvmChainId.Celo,
middlewareHomeChainId: MiddlewareChain.CELO,
requiresAgentSafesOn: [EvmChainId.Celo],
operatingThresholds: {
[WalletOwnerType.Master]: {
[WalletType.Safe]: {
[TokenSymbol.ETH]: Number(
formatEther(`${agentsFunCeloRequirements.safe}`),
),
},
[WalletType.EOA]: {
[TokenSymbol.ETH]: 0.0125, // TODO: should come from the template
},
},
[WalletOwnerType.Agent]: {
[WalletType.Safe]: {
[TokenSymbol.ETH]: Number(
formatEther(`${agentsFunCeloRequirements.agent}`),
),
},
},
},
requiresMasterSafesOn: [EvmChainId.Celo],
serviceApi: AgentsFunBaseService,
displayName: 'Agents.fun agent - Celo',
description:
'Autonomously posts to Twitter, creates and trades memecoins, and interacts with other agents. Agent is operating on Celo chain.',
isAgentEnabled: false,
},
};
Loading
Loading