Skip to content

Commit d00a326

Browse files
committed
Merge branch 'stage' into staging-beta
2 parents 8d0f19b + 80c4d31 commit d00a326

File tree

8 files changed

+187
-10
lines changed

8 files changed

+187
-10
lines changed

src/api/agent.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
IVaultCollateral,
2121
IOwnerUnderlyingBalance,
2222
IOwnerFassetBalance,
23-
IRedemptionQueueData
23+
IRedemptionQueueData,
24+
IOtherBot
2425
} from "@/types";
2526
import { orderBy } from "lodash";
2627

@@ -43,7 +44,8 @@ const AGENT_KEY = {
4344
UNDERLYING_ADDRESSES: 'agent.underlyingAddresses',
4445
OWNER_UNDERLYING_BALANCE: 'agent.ownerUnderlyingBalance',
4546
OWNER_FASSET_BALANCE: 'agent.ownerFassetBalance',
46-
REDEMPTION_QUEUE_DATA: 'agent.redemptionQueueData'
47+
REDEMPTION_QUEUE_DATA: 'agent.redemptionQueueData',
48+
OTHER_BOTS: 'agent.otherBots'
4749
}
4850

4951
export function useWorkAddress(enabled: boolean = true) {
@@ -389,3 +391,15 @@ export function useRedemptionQueueData(enabled: boolean = true) {
389391
enabled: enabled
390392
})
391393
}
394+
395+
export function useOtherBots(enabled: boolean = true) {
396+
return useQuery({
397+
queryKey: [AGENT_KEY.OTHER_BOTS],
398+
queryFn: async () => {
399+
const response = await apiClient.get(`${resource}/otherBots`);
400+
return response.data.data as IOtherBot[];
401+
},
402+
enabled: enabled
403+
})
404+
}
405+

src/components/cards/AgentBotsCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export default function AgentBotsCard({ className, balances}: IAgentBotsCard) {
8888
<span className="status-dot mr-2"
8989
style={{backgroundColor: textColorStatus}}></span>
9090
<span style={{color: textColorStatus}}>
91-
{t(`agent_bots_card.table.agent_${botStatus.data ? 'live' : 'offline'}_label`)}
92-
</span>
91+
{t(`agent_bots_card.table.agent_${botStatus.data ? 'live' : 'offline'}_label`)}
92+
</span>
9393
</div>
9494
</Badge>
9595
</div>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { Badge, Loader, Paper, Table } from "@mantine/core";
2+
import { useTranslation } from "react-i18next";
3+
import { truncateString } from "@/utils";
4+
import CopyIcon from "@/components/icons/CopyIcon";
5+
import { IOtherBot } from "@/types";
6+
7+
interface IOtherBotsCard {
8+
className?: string;
9+
otherBots: IOtherBot[];
10+
}
11+
12+
export default function OtherBotsCard({ otherBots, className }: IOtherBotsCard) {
13+
const { t } = useTranslation();
14+
15+
const tokenColumns: string[] = otherBots[0]
16+
? otherBots[0].balances.map(balance => balance.symbol)
17+
: [];
18+
19+
return (
20+
<Paper
21+
className={`${className}`}
22+
withBorder
23+
>
24+
<Table.ScrollContainer minWidth={470}>
25+
<Table
26+
verticalSpacing="md"
27+
>
28+
<Table.Thead>
29+
<Table.Tr>
30+
<Table.Th className="uppercase">#</Table.Th>
31+
<Table.Th className="uppercase">{t('other_bots_card.table.type_label')}</Table.Th>
32+
<Table.Th className="uppercase">{t('other_bots_card.table.status_label')}</Table.Th>
33+
<Table.Th className="uppercase">{t('other_bots_card.table.working_address_label')}</Table.Th>
34+
{tokenColumns.map(column => (
35+
<Table.Th
36+
key={column}
37+
className="uppercase"
38+
>
39+
{column}
40+
</Table.Th>
41+
))}
42+
</Table.Tr>
43+
</Table.Thead>
44+
<Table.Tbody>
45+
{otherBots.map(((bot, index) => (
46+
<Table.Tr key={index}>
47+
<Table.Td>
48+
{index + 1}
49+
</Table.Td>
50+
<Table.Td>
51+
{bot.type}
52+
</Table.Td>
53+
<Table.Td>
54+
<div className="flex items-center mb-1">
55+
<Badge
56+
variant="outline"
57+
color={bot.status ? 'var(--green-default)' : 'var(--dark-red-default)'}
58+
radius="xs"
59+
className={`font-normal`}
60+
>
61+
<div className="flex items-center">
62+
<span
63+
className="status-dot mr-2"
64+
style={{
65+
backgroundColor: bot.status ? 'var(--green-default)' : 'var(--dark-red-default)'
66+
}}
67+
/>
68+
<span style={{color: bot.status ? 'var(--green-default)' : 'var(--dark-red-default)'}}>
69+
{t(`other_bots_card.table.agent_${bot.status ? 'live' : 'offline'}_label`)}
70+
</span>
71+
</div>
72+
</Badge>
73+
</div>
74+
</Table.Td>
75+
<Table.Td>
76+
<div className="flex items-center">
77+
{truncateString(bot.address ?? '', 5, 5)}
78+
<CopyIcon
79+
text={bot.address ?? ''}
80+
/>
81+
</div>
82+
</Table.Td>
83+
{bot.balances.map(balance => (
84+
<Table.Td key={balance.symbol}>
85+
{balance.balance}
86+
</Table.Td>
87+
))}
88+
</Table.Tr>
89+
)))}
90+
</Table.Tbody>
91+
</Table>
92+
</Table.ScrollContainer>
93+
</Paper>
94+
);
95+
}

src/components/forms/VaultForm.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface ICollateralTemplate {
3333
mintingPoolCollateralRatio: number;
3434
poolExitCollateralRatio: number;
3535
buyFAssetByAgentFactor: number;
36+
redemptionPoolFeeShare: string;
3637
}
3738
interface IFormValues {
3839
name: string | undefined;
@@ -46,6 +47,7 @@ interface IFormValues {
4647
mintingPoolCollateralRatio: number | undefined;
4748
poolExitCollateralRatio: number | undefined;
4849
buyFAssetByAgentFactor: number | undefined;
50+
redemptionPoolFeeShare: number | undefined;
4951
}
5052
export type FormRef = {
5153
form: () => UseFormReturnType<any>;
@@ -110,6 +112,16 @@ const VaultForm = forwardRef<FormRef, IForm>(({ vault, disabled }: IForm, ref) =
110112
});
111113
}
112114

115+
if (!vault) {
116+
schema = schema.shape({
117+
redemptionPoolFeeShare: yup
118+
.string()
119+
.required(
120+
t('validation.messages.required', { field: t('forms.vault.redemption_pool_fee_share_label') })
121+
),
122+
});
123+
}
124+
113125
return schema;
114126
}
115127

@@ -126,7 +138,8 @@ const VaultForm = forwardRef<FormRef, IForm>(({ vault, disabled }: IForm, ref) =
126138
mintingVaultCollateralRatio: undefined,
127139
mintingPoolCollateralRatio: undefined,
128140
poolExitCollateralRatio: undefined,
129-
buyFAssetByAgentFactor: undefined
141+
buyFAssetByAgentFactor: undefined,
142+
redemptionPoolFeeShare: undefined
130143
},
131144
//@ts-ignore
132145
validate: yupResolver(getSchema(vault)),
@@ -208,6 +221,7 @@ const VaultForm = forwardRef<FormRef, IForm>(({ vault, disabled }: IForm, ref) =
208221
mintingVaultCollateralRatio: Number(collateralTemplate.mintingVaultCollateralRatio),
209222
poolExitCollateralRatio: Number(collateralTemplate.poolExitCollateralRatio),
210223
buyFAssetByAgentFactor: Number(collateralTemplate.buyFAssetByAgentFactor),
224+
redemptionPoolFeeShare: Number(collateralTemplate.redemptionPoolFeeShare.replace('%', '')),
211225
});
212226
}, [collateralTemplate]);
213227

@@ -428,6 +442,23 @@ const VaultForm = forwardRef<FormRef, IForm>(({ vault, disabled }: IForm, ref) =
428442
className="mt-4"
429443
onKeyDownCapture={onKeyDownCapture}
430444
/>
445+
{vault == undefined &&
446+
<NumberInput
447+
{...form.getInputProps('redemptionPoolFeeShare')}
448+
//@ts-ignore
449+
key={form.key('redemptionPoolFeeShareBIPS')}
450+
label={t('forms.vault.redemption_pool_fee_share_label')}
451+
description={t('forms.vault.redemption_pool_fee_share_description_label')}
452+
disabled={isHiddenInputDisabled || disabled}
453+
placeholder={t('forms.vault.enter_placeholder')}
454+
withAsterisk
455+
allowNegative={false}
456+
step={1}
457+
suffix="%"
458+
className="mt-4"
459+
onKeyDownCapture={onKeyDownCapture}
460+
/>
461+
}
431462
</>
432463
}
433464
{minAmountDescriptionLabel &&

src/languages/en.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
"dashboard": {
189189
"agent_title": "Agent Bots",
190190
"alerts_title": "Alerts & Notifications",
191+
"other_title": "Other",
191192
"title": "Overview",
192193
"vaults_title": "Vaults",
193194
"xrp_supply_title": "{{token}} Supply"
@@ -358,6 +359,15 @@
358359
"show_all_button": "Show all",
359360
"title": "Notifications from Flare"
360361
},
362+
"other_bots_card": {
363+
"table": {
364+
"agent_live_label": "Online",
365+
"agent_offline_label": "Offline",
366+
"status_label": "Status",
367+
"type_label": "Type",
368+
"working_address_label": "Working address"
369+
}
370+
},
361371
"select_wallet_button": {
362372
"connect_label": "Connect",
363373
"disconnect_label": "Disconnect",
@@ -521,8 +531,8 @@
521531
"cancel_underlying_withdrawal_label": "Cancel underlying withdrawal",
522532
"cancel_withdraw_from_core_vault_label": "Cancel withdraw from Core Vault",
523533
"claim_rewards_label": "Claim Rewards",
524-
"close_vault_label": "Close Vault (Exit)",
525-
"deactivate_vault_label": "Deactivate Vault",
534+
"close_vault_label": "Close Vault",
535+
"deactivate_vault_label": "Deactivate Vault (Exit)",
526536
"delegate_pool_collateral_label": "Delegate Pool Collateral",
527537
"deposit_collateral_lots_label": "Deposit Collateral (Lots)",
528538
"deposit_pool_collateral_label": "Deposit Pool Collateral",

src/pages/index.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import AgentBotsCard from '@/components/cards/AgentBotsCard';
88
import ManagementAddressCard from '@/components/cards/ManagementAddressCard';
99
import VaultsCard from '@/components/cards/VaultsCard';
1010
import XrpSupplyCard from "@/components/cards/XrpSupplyCard";
11-
import { useBalances, useCollaterals } from '@/api/agent';
11+
import OtherBotsCard from "@/components/cards/OtherBotsCard";
12+
import { useBalances, useCollaterals, useOtherBots } from '@/api/agent';
1213

1314
export default function Dashboard() {
1415
const { t } = useTranslation();
1516
const balances = useBalances();
1617
const collateral = useCollaterals();
18+
const otherBots = useOtherBots();
1719

1820
const xrpBalance = balances.data?.find(balance => balance.symbol.toLowerCase().includes('xrp'));
1921

@@ -37,7 +39,20 @@ export default function Dashboard() {
3739
>
3840
{t('dashboard.agent_title')}
3941
</Title>
40-
<AgentBotsCard balances={balances} />
42+
<AgentBotsCard
43+
balances={balances}
44+
/>
45+
{otherBots?.data && otherBots.data.length > 0 &&
46+
<>
47+
<Title
48+
order={1}
49+
className="mt-10 mb-3"
50+
>
51+
{t('dashboard.other_title')}
52+
</Title>
53+
<OtherBotsCard otherBots={otherBots.data} />
54+
</>
55+
}
4156
</div>
4257
<div className="hidden lg:block w-full lg:w-2/5">
4358
<Title

src/pages/vault/add.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export default function AddVault() {
8585
mintingVaultCollateralRatio: data.mintingVaultCollateralRatio,
8686
mintingPoolCollateralRatio: data.mintingPoolCollateralRatio,
8787
poolExitCollateralRatio: data.poolExitCollateralRatio,
88-
buyFAssetByAgentFactor: data.buyFAssetByAgentFactor
88+
buyFAssetByAgentFactor: data.buyFAssetByAgentFactor,
89+
redemptionPoolFeeShare: `${data.redemptionPoolFeeShare}%`,
8990
}
9091

9192
createVault.mutateAsync({

src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface IAgentSettingsConfig {
107107
poolExitCollateralRatio: string;
108108
buyFAssetByAgentFactor: string;
109109
redemptionPoolFeeShareBIPS?: string;
110+
redemptionPoolFeeShare?: string;
110111
}
111112

112113
export interface IAgentVault {
@@ -264,3 +265,13 @@ export interface IRedemptionQueueData {
264265
mintedLots: number;
265266
redemptionQueueLots: number;
266267
}
268+
269+
export interface IOtherBot {
270+
type: string;
271+
address: string;
272+
status: boolean;
273+
balances: {
274+
symbol: string;
275+
balance: string;
276+
}[];
277+
}

0 commit comments

Comments
 (0)