Skip to content

Commit 4ef0d31

Browse files
authored
Merge pull request #114 from valory-xyz/precious/pearl-cosmetic-fixes
fix(basius): [OPE-1816] Aerodrome branding + msUSD token logo
2 parents a7f3758 + 6979e14 commit 4ef0d31

7 files changed

Lines changed: 140 additions & 21 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { render, screen } from '@testing-library/react';
2+
3+
import { OperatingProtocols } from '../../../src/components/Chat/SystemChat';
4+
5+
// Regression test: with live data the Basius backend reports `velodrome`
6+
// (Aerodrome is a Velodrome fork) — the chat protocols message must normalize
7+
// it, same as the Strategy card / Allocation table. agentMap resolves the
8+
// agent from process.env at module load time, so we mock the basius mapping
9+
// here; the env-driven branch itself is unit-covered in utils/agentMap.spec.ts.
10+
jest.mock('../../../src/utils/agentMap', () => ({
11+
...jest.requireActual('../../../src/utils/agentMap'),
12+
normalizeProtocol: (protocol: string) => (protocol === 'velodrome' ? 'aerodrome' : protocol),
13+
}));
14+
15+
describe('OperatingProtocols (basius)', () => {
16+
it('renders backend-reported velodrome as Aerodrome', () => {
17+
render(<OperatingProtocols protocols={['velodrome']} />);
18+
expect(screen.getByText('Aerodrome')).toBeInTheDocument();
19+
expect(screen.queryByText('Velodrome')).not.toBeInTheDocument();
20+
expect(screen.getByAltText('aerodrome')).toHaveAttribute(
21+
'src',
22+
'/logos/protocols/aerodrome.png',
23+
);
24+
});
25+
26+
it('leaves other protocols untouched', () => {
27+
render(<OperatingProtocols protocols={['balancerPool', 'velodrome']} />);
28+
expect(screen.getByText('Balancer')).toBeInTheDocument();
29+
expect(screen.getByText('Aerodrome')).toBeInTheDocument();
30+
});
31+
});

apps/babydegen-ui/__tests__/utils/agentMap.spec.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,67 @@ describe('agentMap (babydegen-ui)', () => {
5151

5252
expect(() => require('../../src/utils/agentMap')).not.toThrow();
5353
});
54+
55+
describe('normalizeProtocol', () => {
56+
it('maps velodrome to aerodrome for basius', () => {
57+
process.env.REACT_APP_AGENT_NAME = 'basius';
58+
59+
const { normalizeProtocol } = require('../../src/utils/agentMap');
60+
expect(normalizeProtocol('velodrome')).toBe('aerodrome');
61+
});
62+
63+
it('leaves other protocols untouched for basius', () => {
64+
process.env.REACT_APP_AGENT_NAME = 'basius';
65+
66+
const { normalizeProtocol } = require('../../src/utils/agentMap');
67+
expect(normalizeProtocol('balancerPool')).toBe('balancerPool');
68+
expect(normalizeProtocol('uniswapV3')).toBe('uniswapV3');
69+
expect(normalizeProtocol('aerodrome')).toBe('aerodrome');
70+
});
71+
72+
it('leaves velodrome untouched for modius', () => {
73+
process.env.REACT_APP_AGENT_NAME = 'modius';
74+
75+
const { normalizeProtocol } = require('../../src/utils/agentMap');
76+
expect(normalizeProtocol('velodrome')).toBe('velodrome');
77+
});
78+
79+
it('leaves velodrome untouched for optimus', () => {
80+
process.env.REACT_APP_AGENT_NAME = 'optimus';
81+
82+
const { normalizeProtocol } = require('../../src/utils/agentMap');
83+
expect(normalizeProtocol('velodrome')).toBe('velodrome');
84+
});
85+
});
86+
87+
describe('normalizeDetails', () => {
88+
it('relabels velodrome case-insensitively for basius', () => {
89+
process.env.REACT_APP_AGENT_NAME = 'basius';
90+
91+
const { normalizeDetails } = require('../../src/utils/agentMap');
92+
expect(normalizeDetails('Velodrome pool')).toBe('Aerodrome pool');
93+
expect(normalizeDetails('velodrome CL pool')).toBe('Aerodrome CL pool');
94+
});
95+
96+
it('leaves details without velodrome untouched for basius', () => {
97+
process.env.REACT_APP_AGENT_NAME = 'basius';
98+
99+
const { normalizeDetails } = require('../../src/utils/agentMap');
100+
expect(normalizeDetails('Balancer pool')).toBe('Balancer pool');
101+
});
102+
103+
it('leaves details untouched for modius', () => {
104+
process.env.REACT_APP_AGENT_NAME = 'modius';
105+
106+
const { normalizeDetails } = require('../../src/utils/agentMap');
107+
expect(normalizeDetails('Velodrome pool')).toBe('Velodrome pool');
108+
});
109+
110+
it('leaves details untouched for optimus', () => {
111+
process.env.REACT_APP_AGENT_NAME = 'optimus';
112+
113+
const { normalizeDetails } = require('../../src/utils/agentMap');
114+
expect(normalizeDetails('Velodrome pool')).toBe('Velodrome pool');
115+
});
116+
});
54117
});
50.7 KB
Loading

apps/babydegen-ui/src/components/Allocation/AllocationTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useMemo } from 'react';
44
import { PROTOCOLS_MAP } from '../../constants/textMaps';
55
import { usePortfolio } from '../../hooks/usePortfolio';
66
import { SelectedProtocol } from '../../types';
7+
import { normalizeDetails, normalizeProtocol } from '../../utils/agentMap';
78
import { piePalette } from '../../utils/chartjs/palette';
89
import { AssetBadges } from './AllocationAssets';
910

@@ -66,9 +67,9 @@ export const AllocationTable = () => {
6667
data?.allocations?.map(({ type, assets, details, apr }) => ({
6768
key: `${type}-${assets.join('-')}-${details}`,
6869
pool: assets,
69-
details: `${details}`,
70+
details: normalizeDetails(`${details}`),
7071
apr: `${apr}`,
71-
type,
72+
type: normalizeProtocol(type),
7273
})),
7374
[data?.allocations],
7475
);

apps/babydegen-ui/src/components/Chat/SystemChat.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { COLOR } from '../../constants/colors';
77
import { PROTOCOLS_MAP, TRADING_TYPE_MAP } from '../../constants/textMaps';
88
import { SelectedProtocol, TradingType } from '../../types';
99
import { Pill } from '../../ui/Pill';
10+
import { normalizeProtocol } from '../../utils/agentMap';
1011

1112
const { Text } = Typography;
1213

@@ -73,15 +74,18 @@ export const OperatingProtocols = ({ protocols }: OperatingProtocolsProps) => (
7374
<SystemMessage label="Operating protocols updated:" type="protocols">
7475
{protocols.length === 0
7576
? NA
76-
: protocols.map((protocol) => (
77-
<Pill size="large" key={protocol} style={{ marginLeft: 0, paddingRight: 16 }}>
78-
<img
79-
src={PROTOCOLS_MAP[protocol].logo}
80-
alt={protocol}
81-
style={{ width: 18, height: 18 }}
82-
/>
83-
{PROTOCOLS_MAP[protocol].name}
84-
</Pill>
85-
))}
77+
: protocols.map((protocol) => {
78+
const displayProtocol = normalizeProtocol(protocol);
79+
return (
80+
<Pill size="large" key={displayProtocol} style={{ marginLeft: 0, paddingRight: 16 }}>
81+
<img
82+
src={PROTOCOLS_MAP[displayProtocol].logo}
83+
alt={displayProtocol}
84+
style={{ width: 18, height: 18 }}
85+
/>
86+
{PROTOCOLS_MAP[displayProtocol].name}
87+
</Pill>
88+
);
89+
})}
8690
</SystemMessage>
8791
);

apps/babydegen-ui/src/components/Strategy/Strategy.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PROTOCOLS_MAP, TRADING_TYPE_MAP } from '../../constants/textMaps';
88
import { usePortfolio } from '../../hooks/usePortfolio';
99
import { SelectedProtocol } from '../../types';
1010
import { Pill } from '../../ui/Pill';
11-
import { agentName } from '../../utils/agentMap';
11+
import { agentName, normalizeProtocol } from '../../utils/agentMap';
1212

1313
const { Title, Text } = Typography;
1414

@@ -40,14 +40,17 @@ const StrategyContent = () => {
4040
const operatingProtocols = useMemo(() => {
4141
if (!data?.selected_protocols) return [];
4242

43-
return data.selected_protocols.map((protocol: SelectedProtocol) => (
44-
<Avatar
45-
key={protocol}
46-
size={36}
47-
src={PROTOCOLS_MAP[protocol].logo}
48-
style={{ border: `1px solid ${COLOR.lightGrey}`, padding: 6 }}
49-
/>
50-
));
43+
return data.selected_protocols.map((protocol: SelectedProtocol) => {
44+
const displayProtocol = normalizeProtocol(protocol);
45+
return (
46+
<Avatar
47+
key={displayProtocol}
48+
size={36}
49+
src={PROTOCOLS_MAP[displayProtocol].logo}
50+
style={{ border: `1px solid ${COLOR.lightGrey}`, padding: 6 }}
51+
/>
52+
);
53+
});
5154
}, [data?.selected_protocols]);
5255

5356
return (

apps/babydegen-ui/src/utils/agentMap.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { SelectedProtocol } from '../types';
2+
13
/**
24
* Supported agents map.
35
* - modius: Modius agent (Mode chain)
@@ -23,3 +25,18 @@ export const agentChainName = ((): 'mode' | 'base' | 'optimism' => {
2325
if (agentType === 'basius') return 'base';
2426
return 'optimism';
2527
})();
28+
29+
/**
30+
* Aerodrome (Base) is a Velodrome fork sharing the same contract ABIs, so the
31+
* agent backend reports it as `velodrome`. Basius runs only on Base, so display
32+
* that protocol as Aerodrome.
33+
*/
34+
export const normalizeProtocol = (protocol: SelectedProtocol): SelectedProtocol =>
35+
agentType === 'basius' && protocol === 'velodrome' ? 'aerodrome' : protocol;
36+
37+
/**
38+
* Backend-provided free-text detail strings (e.g. "Velodrome pool") reference
39+
* the reported protocol name. Relabel for Basius to match {@link normalizeProtocol}.
40+
*/
41+
export const normalizeDetails = (details: string): string =>
42+
agentType === 'basius' ? details.replace(/velodrome/gi, 'Aerodrome') : details;

0 commit comments

Comments
 (0)