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: add modius configs #567

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ DEV_RPC=
GNOSIS_RPC=
ETHEREUM_RPC=
OPTIMISM_RPC=
BASE_RPC=
BASE_RPC=
MODE_RPC=
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const safeChainPrefix = {
[EvmChainId.Base]: 'base',
[EvmChainId.Optimism]: 'oeth',
[EvmChainId.Gnosis]: 'gno',
[EvmChainId.Mode]: 'mode', // TODO: Modius - the above link doesn't have Mode, so the prefix is a guess
Copy link
Collaborator

Choose a reason for hiding this comment

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

bit of a worry that safe.global doesn't support mode..

};

export const AddBackupWalletViaSafePage = () => {
Expand Down
10 changes: 10 additions & 0 deletions frontend/config/activityCheckers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Contract as MulticallContract } from 'ethers-multicall';
import { MECH_ACTIVITY_CHECKER_ABI } from '@/abis/mechActivityChecker';
import { MEME_ACTIVITY_CHECKER_ABI } from '@/abis/memeActivityChecker';
import { REQUESTER_ACTIVITY_CHECKER_ABI } from '@/abis/requesterActivityChecker';
import { STAKING_ACTIVITY_CHECKER_ABI } from '@/abis/stakingActivityChecker';
import { EvmChainId } from '@/enums/Chain';

import { MechType } from './mechs';
Expand Down Expand Up @@ -37,6 +38,14 @@ export const BASE_ACTIVITY_CHECKERS: ActivityCheckers = {
MEME_ACTIVITY_CHECKER_ABI,
),
};

export const MODE_ACTIVITY_CHECKERS: ActivityCheckers = {
[ActivityCheckerType.Staking]: new MulticallContract(
'0x534c0a05b6d4d28d5f3630d6d74857b253cf8332',
Tanya-atatakai marked this conversation as resolved.
Show resolved Hide resolved
STAKING_ACTIVITY_CHECKER_ABI,
),
};

export const ACTIVITY_CHECKERS: {
[chainId: number]: {
[activityCheckerType: string]: MulticallContract;
Expand All @@ -45,4 +54,5 @@ export const ACTIVITY_CHECKERS: {
[EvmChainId.Gnosis]: GNOSIS_ACTIVITY_CHECKERS,
[EvmChainId.Optimism]: OPTIMISM_ACTIVITY_CHECKERS,
[EvmChainId.Base]: BASE_ACTIVITY_CHECKERS,
[EvmChainId.Mode]: MODE_ACTIVITY_CHECKERS,
} as const;
15 changes: 15 additions & 0 deletions frontend/config/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MiddlewareChain } from '@/client';
import { AgentType } from '@/enums/Agent';
import { EvmChainId } from '@/enums/Chain';
import { MemeooorBaseService } from '@/service/agents/Memeooor';
import { ModiusService } from '@/service/agents/Modius';
import { PredictTraderService } from '@/service/agents/PredictTrader';
// import { OptimusService } from '@/service/agents/Optimus';
import { AgentConfig } from '@/types/Agent';
Expand Down Expand Up @@ -52,4 +53,18 @@ export const AGENT_CONFIG: {
description:
'Autonomously post to Twitter, create and trade memecoins, and interact with other agents.',
},
[AgentType.Modius]: {
name: 'Modius agent',
evmHomeChainId: EvmChainId.Mode,
middlewareHomeChainId: MiddlewareChain.MODE,
requiresAgentSafesOn: [EvmChainId.Mode],
agentSafeFundingRequirements: {
[EvmChainId.Mode]: 5260000000000000, // 0.00526 eth
},
requiresMasterSafesOn: [EvmChainId.Mode],
serviceApi: ModiusService,
displayName: 'Modius agent',
description:
'Invests crypto assets in DEXs on your behalf and grow your portfolio.',
},
};
9 changes: 9 additions & 0 deletions frontend/config/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,20 @@ export const ETHEREUM_CHAIN_CONFIG: ChainConfig = {
rpc: process.env.GNOSIS_RPC as HttpUrl,
};

export const MODE_CHAIN_CONFIG: ChainConfig = {
evmChainId: EvmChainId.Mode,
name: 'Mode',
nativeToken: TOKEN_CONFIG[EvmChainId.Mode][TokenSymbol.ETH],
middlewareChain: MiddlewareChainId.MODE,
rpc: process.env.MODE_RPC as HttpUrl,
};

export const CHAIN_CONFIG: {
[evmChainId: number]: ChainConfig;
} = {
[EvmChainId.Base]: BASE_CHAIN_CONFIG,
// [EvmChainId.Ethereum]: ETHEREUM_CHAIN_CONFIG,
[EvmChainId.Gnosis]: GNOSIS_CHAIN_CONFIG,
// [EvmChainId.Optimism]: OPTIMISM_CHAIN_CONFIG,
[EvmChainId.Mode]: MODE_CHAIN_CONFIG,
} as const;
12 changes: 12 additions & 0 deletions frontend/config/olasContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,22 @@ export const BASE_OLAS_CONTRACTS: ContractsByType = {
),
};

export const MODE_OLAS_CONTRACTS: ContractsByType = {
[ContractType.ServiceRegistryL2]: new MulticallContract(
'0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE',
SERVICE_REGISTRY_L2_ABI,
),
[ContractType.ServiceRegistryTokenUtility]: new MulticallContract(
'0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5',
SERVICE_REGISTRY_TOKEN_UTILITY_ABI,
),
};

export const OLAS_CONTRACTS: {
[chainId: number]: ContractsByType;
} = {
[EvmChainId.Gnosis]: GNOSIS_OLAS_CONTRACTS,
[EvmChainId.Optimism]: OPTIMISM_OLAS_CONTRACTS,
[EvmChainId.Base]: BASE_OLAS_CONTRACTS,
[EvmChainId.Mode]: MODE_OLAS_CONTRACTS,
};
7 changes: 7 additions & 0 deletions frontend/config/stakingPrograms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import {
GNOSIS_STAKING_PROGRAMS,
GNOSIS_STAKING_PROGRAMS_CONTRACT_ADDRESSES,
} from './gnosis';
import {
MODE_STAKING_PROGRAMS,
MODE_STAKING_PROGRAMS_CONTRACT_ADDRESSES,
} from './mode';

/**
* Single non-chain specific staking program configuration
Expand Down Expand Up @@ -46,6 +50,7 @@ export const STAKING_PROGRAMS: {
[EvmChainId.Gnosis]: GNOSIS_STAKING_PROGRAMS,
// [EvmChainId.Optimism]: OPTIMISM_STAKING_PROGRAMS,
[EvmChainId.Base]: BASE_STAKING_PROGRAMS,
[EvmChainId.Mode]: MODE_STAKING_PROGRAMS,
};

export const STAKING_PROGRAM_ADDRESS: {
Expand All @@ -54,6 +59,7 @@ export const STAKING_PROGRAM_ADDRESS: {
[EvmChainId.Gnosis]: GNOSIS_STAKING_PROGRAMS_CONTRACT_ADDRESSES,
// [EvmChainId.Optimism]: OPTIMISM_STAKING_PROGRAMS_CONTRACT_ADDRESSES,
[EvmChainId.Base]: BASE_STAKING_PROGRAMS_CONTRACT_ADDRESSES,
[EvmChainId.Mode]: MODE_STAKING_PROGRAMS_CONTRACT_ADDRESSES,
};

export const DEFAULT_STAKING_PROGRAM_IDS: {
Expand All @@ -62,4 +68,5 @@ export const DEFAULT_STAKING_PROGRAM_IDS: {
[EvmChainId.Gnosis]: StakingProgramId.PearlBeta,
// [EvmChainId.Optimism]: StakingProgramId.OptimusAlpha,
[EvmChainId.Base]: StakingProgramId.MemeBaseAlpha,
[EvmChainId.Mode]: StakingProgramId.ModiusAlpha,
};
34 changes: 34 additions & 0 deletions frontend/config/stakingPrograms/mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Contract as MulticallContract } from 'ethers-multicall';

import { STAKING_TOKEN_PROXY_ABI } from '@/abis/stakingTokenProxy';
import { AgentType } from '@/enums/Agent';
import { EvmChainId } from '@/enums/Chain';
import { StakingProgramId } from '@/enums/StakingProgram';
import { TokenSymbol } from '@/enums/Token';
import { Address } from '@/types/Address';

import { ACTIVITY_CHECKERS, ActivityCheckerType } from '../activityCheckers';
import { StakingProgramMap } from '.';

export const MODE_STAKING_PROGRAMS_CONTRACT_ADDRESSES: Record<string, Address> =
{
[StakingProgramId.ModiusAlpha]:
'0x534c0a05b6d4d28d5f3630d6d74857b253cf8332',
};

export const MODE_STAKING_PROGRAMS: StakingProgramMap = {
[StakingProgramId.ModiusAlpha]: {
chainId: EvmChainId.Mode,
name: 'Modius Alpha',
agentsSupported: [AgentType.Modius],
stakingRequirements: {
[TokenSymbol.OLAS]: 40,
},
activityChecker:
ACTIVITY_CHECKERS[EvmChainId.Mode][ActivityCheckerType.Staking],
contract: new MulticallContract(
MODE_STAKING_PROGRAMS_CONTRACT_ADDRESSES[StakingProgramId.ModiusAlpha],
STAKING_TOKEN_PROXY_ABI,
),
},
};
15 changes: 15 additions & 0 deletions frontend/config/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,26 @@ export const BASE_TOKEN_CONFIG: ChainTokenConfig = {
},
};

export const MODE_TOKEN_CONFIG: ChainTokenConfig = {
[TokenSymbol.ETH]: {
tokenType: TokenType.NativeGas,
decimals: 18,
symbol: TokenSymbol.ETH,
},
[TokenSymbol.OLAS]: {
address: '0xcfD1D50ce23C46D3Cf6407487B2F8934e96DC8f9',
decimals: 18,
tokenType: TokenType.Erc20,
symbol: TokenSymbol.OLAS,
},
};

export const TOKEN_CONFIG = {
[EvmChainId.Gnosis]: GNOSIS_TOKEN_CONFIG,
[EvmChainId.Optimism]: OPTIMISM_TOKEN_CONFIG,
[EvmChainId.Ethereum]: ETHEREUM_TOKEN_CONFIG,
[EvmChainId.Base]: BASE_TOKEN_CONFIG,
[EvmChainId.Mode]: MODE_TOKEN_CONFIG,
} as const;

/**
Expand Down
4 changes: 4 additions & 0 deletions frontend/constants/thresholds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const MIN_ETH_BALANCE_THRESHOLDS: Record<
safeCreation: 0.005,
safeAddSigner: 0.005,
},
[EvmChainId.Mode]: {
safeCreation: 0.00526,
safeAddSigner: 0.005, // TODO: Modius - confirm this value
},
};

// TODO: update to support multi-chain, very poor implementation
Expand Down
7 changes: 7 additions & 0 deletions frontend/constants/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export const BACKEND_URL_V2: Url = `http://localhost:${process.env.NODE_ENV ===
const COW_SWAP_GNOSIS_XDAI_OLAS_URL: Url =
'https://swap.cow.fi/#/100/swap/WXDAI/OLAS';
const SWAP_BASE_URL: Url = 'https://balancer.fi/swap/base/ETH/OLAS';
// TODO: Modius - confirm this URL is correct
const SWAP_MODE_URL: Url =
'https://jumper.exchange/?fromChain=34443&fromToken=0x0000000000000000000000000000000000000000&toChain=34443&toToken=0xcfD1D50ce23C46D3Cf6407487B2F8934e96DC8f9';

// olas.network
export const OPERATE_URL: Url = 'https://olas.network/operate';
Expand All @@ -26,6 +29,7 @@ export const REWARDS_HISTORY_SUBGRAPH_URLS_BY_EVM_CHAIN = {
'https://api.studio.thegraph.com/query/81371/gnosis-pearl-rewards-history/version/latest',
[EvmChainId.Base]:
'https://api.studio.thegraph.com/query/67875/olas-base-staking-rewards-history/version/latest',
[EvmChainId.Mode]: 'TBD',
};

// discord
Expand All @@ -42,6 +46,7 @@ export const GITHUB_API_LATEST_RELEASE: Url =
// export const OPTIMISM_EXPLORER_URL: Url = 'https://optimistic.etherscan.io';
const GNOSIS_EXPLORER_URL: Url = 'https://gnosisscan.io';
const BASE_EXPLORER_URL: Url = 'https://basescan.org';
const MODE_EXPLORER_URL: Url = 'https://explorer.mode.network';

export const EXPLORER_URL_BY_MIDDLEWARE_CHAIN: Record<
string | MiddlewareChain,
Expand All @@ -50,12 +55,14 @@ export const EXPLORER_URL_BY_MIDDLEWARE_CHAIN: Record<
[MiddlewareChain.GNOSIS]: GNOSIS_EXPLORER_URL,
// [MiddlewareChain.OPTIMISM]: OPTIMISM_EXPLORER_URL,
[MiddlewareChain.BASE]: BASE_EXPLORER_URL,
[MiddlewareChain.MODE]: MODE_EXPLORER_URL,
};

export const SWAP_URL_BY_EVM_CHAIN: Record<number | EvmChainId, Url> = {
[EvmChainId.Gnosis]: COW_SWAP_GNOSIS_XDAI_OLAS_URL,
// [EvmChainId.OPTIMISM]: COW_SWAP_GNOSIS_XDAI_OLAS_URL,
[EvmChainId.Base]: SWAP_BASE_URL,
[EvmChainId.Mode]: SWAP_MODE_URL,
};

export const EXPLORER_URL_BY_EVM_CHAIN_ID: Record<number | EvmChainId, Url> =
Expand Down
1 change: 1 addition & 0 deletions frontend/enums/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const AgentType = {
PredictTrader: 'trader',
// Optimus: 'optimus',
Memeooorr: 'memeooorr',
Modius: 'Modius',
} as const;

export type AgentType = (typeof AgentType)[keyof typeof AgentType];
2 changes: 2 additions & 0 deletions frontend/enums/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ export enum EvmChainId {
Optimism = 10,
Gnosis = 100,
Base = 8453,
Mode = 34443,
}

export const EvmChainName = {
[EvmChainId.Ethereum]: 'Ethereum',
[EvmChainId.Optimism]: 'Optimism',
[EvmChainId.Gnosis]: 'Gnosis',
[EvmChainId.Base]: 'Base',
[EvmChainId.Mode]: 'Mode',
};
1 change: 1 addition & 0 deletions frontend/enums/StakingProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export enum StakingProgramId {
PearlBetaMechMarketplace = 'pearl_beta_mech_marketplace',
OptimusAlpha = 'optimus_alpha',
MemeBaseAlpha = 'meme_base_alpha',
ModiusAlpha = 'modius_alpha',
}
6 changes: 6 additions & 0 deletions frontend/hooks/useFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const FEATURES_CONFIG = FeaturesConfigSchema.parse({
'rewards-streak': false,
'staking-contract-section': false,
},
[AgentType.Modius]: {
'manage-wallet': false,
'last-transactions': false,
'rewards-streak': false,
'staking-contract-section': false,
},
});

type FeatureFlagReturn<T extends FeatureFlags | FeatureFlags[]> =
Expand Down
Loading
Loading