Skip to content

Commit

Permalink
feat: refactor staking program handling in Memeooor and PredictTrader…
Browse files Browse the repository at this point in the history
… services
  • Loading branch information
mohandast52 committed Dec 5, 2024
1 parent 0367f7b commit a812cc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
4 changes: 2 additions & 2 deletions frontend/config/stakingPrograms/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const GNOSIS_STAKING_PROGRAMS_CONTRACT_ADDRESSES: Record<
[StakingProgramId.PearlBeta5]: '0x4Abe376Fda28c2F43b84884E5f822eA775DeA9F4',
[StakingProgramId.PearlBetaMechMarketplace]:
'0xDaF34eC46298b53a3d24CBCb431E84eBd23927dA',
};
} as const;

export const GNOSIS_STAKING_PROGRAMS: StakingProgramMap = {
[StakingProgramId.PearlAlpha]: {
Expand Down Expand Up @@ -134,4 +134,4 @@ export const GNOSIS_STAKING_PROGRAMS: StakingProgramMap = {
STAKING_TOKEN_PROXY_ABI,
),
},
};
} as const;
12 changes: 3 additions & 9 deletions frontend/service/agents/Memeooor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ethers } from 'ethers';
import { formatEther } from 'ethers/lib/utils';

import { STAKING_PROGRAMS } from '@/config/stakingPrograms';
import { BASE_STAKING_PROGRAMS } from '@/config/stakingPrograms/base';
import { PROVIDERS } from '@/constants/providers';
import { EvmChainId } from '@/enums/Chain';
import { StakingProgramId } from '@/enums/StakingProgram';
Expand All @@ -14,9 +15,6 @@ import {

import { ONE_YEAR, StakedAgentService } from './StakedAgentService';

// TODO: move to common place, enums/StakingProgram.ts?
const MEMEOOORR_STAKING_PROGRAMS_IDS = [StakingProgramId.MemeBaseAlpha];

export abstract class MemeooorBaseService extends StakedAgentService {
static getAgentStakingRewardsInfo = async ({
agentMultisigAddress,
Expand Down Expand Up @@ -187,12 +185,8 @@ export abstract class MemeooorBaseService extends StakedAgentService {
): Promise<StakingContractDetails | undefined> => {
const { multicallProvider } = PROVIDERS[chainId];

if (!MEMEOOORR_STAKING_PROGRAMS_IDS.includes(stakingProgramId)) {
return;
}

const stakingTokenProxy =
STAKING_PROGRAMS[chainId][stakingProgramId]?.contract;
const stakingTokenProxy = BASE_STAKING_PROGRAMS[stakingProgramId]?.contract;
if (!stakingTokenProxy) return;

const contractCalls = [
stakingTokenProxy.availableRewards(),
Expand Down
18 changes: 3 additions & 15 deletions frontend/service/agents/PredictTrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ethers } from 'ethers';
import { formatEther } from 'ethers/lib/utils';

import { STAKING_PROGRAMS } from '@/config/stakingPrograms';
import { GNOSIS_STAKING_PROGRAMS } from '@/config/stakingPrograms/gnosis';
import { PROVIDERS } from '@/constants/providers';
import { EvmChainId } from '@/enums/Chain';
import { StakingProgramId } from '@/enums/StakingProgram';
Expand All @@ -16,17 +17,6 @@ import { ONE_YEAR, StakedAgentService } from './StakedAgentService';

const MECH_REQUESTS_SAFETY_MARGIN = 1;

// TODO: move to common place, enums/StakingProgram.ts?
const PREDICT_TRADER_STAKING_PROGRAM_IDS = [
StakingProgramId.PearlAlpha,
StakingProgramId.PearlBeta,
StakingProgramId.PearlBeta2,
StakingProgramId.PearlBeta3,
StakingProgramId.PearlBeta4,
StakingProgramId.PearlBeta5,
StakingProgramId.PearlBetaMechMarketplace,
];

export abstract class PredictTraderService extends StakedAgentService {
static getAgentStakingRewardsInfo = async ({
agentMultisigAddress,
Expand Down Expand Up @@ -198,11 +188,9 @@ export abstract class PredictTraderService extends StakedAgentService {
): Promise<StakingContractDetails | undefined> => {
const { multicallProvider } = PROVIDERS[chainId];
const stakingTokenProxy =
STAKING_PROGRAMS[chainId][stakingProgramId]?.contract;
GNOSIS_STAKING_PROGRAMS[stakingProgramId]?.contract;

if (!PREDICT_TRADER_STAKING_PROGRAM_IDS.includes(stakingProgramId)) {
return Promise.resolve(undefined);
}
if (!stakingTokenProxy) return;

const contractCalls = [
stakingTokenProxy.availableRewards(),
Expand Down

0 comments on commit a812cc6

Please sign in to comment.