Skip to content

Commit

Permalink
Merge branch 'v2' into am/bex-create-pool-polish
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMcInnis committed Dec 23, 2024
2 parents c81f118 + 23b05db commit a78c1d9
Show file tree
Hide file tree
Showing 197 changed files with 3,398 additions and 3,003 deletions.
1 change: 0 additions & 1 deletion .env.bartio
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ NEXT_PUBLIC_BALANCER_API_CHAIN_NAME="BARTIO"
# HUB Addresses ===================================================================
NEXT_PUBLIC_BGT_ADDRESS="0xbDa130737BDd9618301681329bF2e46A016ff9Ad"
NEXT_PUBLIC_BGT_STAKER="0x791fb53432eED7e2fbE4cf8526ab6feeA604Eb6d"
NEXT_PUBLIC_POL_ENDPOINT="https://bartio-pol-indexer.berachain.com/berachain/v1alpha1/beacon"
NEXT_PUBLIC_BERA_CHEF_ADDRESS="0xfb81E39E3970076ab2693fA5C45A07Cc724C93c2"
NEXT_PUBLIC_REWARD_VAULT_FACTORY_ADDRESS="0x2B6e40f65D82A0cB98795bC7587a71bfa49fBB2B"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ipfs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.17
node-version: 22.12
cache: 'pnpm'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ipfs-static-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.11.1
node-version: 22.12
cache: 'pnpm'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20.17.0'
node-version: '22.12.0'

- name: Install pnpm
uses: pnpm/action-setup@v4
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.17
v22.12
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,21 @@ All Berachain dapps are built to be single chain applications.
| --------------------- | ---------------------------------------------------------------------------------------------- |
| `.env.bartio` | Environment variables for Berachain bartio testnet |

## Development Tips

Sometimes your VSCode will not correctly pick up type information from `/packages`.

```bash
pnpm build:pkg # This will build all packages
pnpm format # This will format all packages
```

Then in VSCode press `CMD+Shift+P` to open the command pallette and type `>` then type `Restart TS Server` and press enter. This will
restart the typescript server and should pick up the new types.

## Commands

Monobera requires node 20.17+.
Monobera requires node 22.12+.

| Script | Description |
| ------------------------ | -------------------------------------------------------------------------------------------------------- |
Expand Down
39 changes: 0 additions & 39 deletions apps/honey/src/app/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import {
homepageUrl,
hubName,
hubUrl,
lendName,
lendUrl,
perpsName,
perpsUrl,
} from "@bera/config";
import { Icons } from "@bera/ui/icons";

Expand All @@ -34,20 +30,6 @@ export const navItems = [
blurb: "The hub for BGT governance",
icon: <Icons.hubFav className="h-8 w-8" />,
},
{
href: lendUrl,
type: "external",
title: lendName,
blurb: "Supply assets and borrow honey",
icon: <Icons.bendFav className="h-8 w-8" />,
},
{
href: perpsUrl,
type: "external",
title: perpsName,
blurb: "Trade your favourite pairs",
icon: <Icons.berpsFav className="h-8 w-8" />,
},
{
href: blockExplorerUrl,
type: "external",
Expand All @@ -62,13 +44,6 @@ export const navItems = [
blurb: "Explore Berachain and learn more about our vision",
icon: <Icons.foundationFav className="h-8 w-8" />,
},
{
href: faucetUrl,
type: "external",
title: faucetName,
blurb: "Fund your testnet wallet with BERA tokens",
icon: <Icons.faucetFav className="h-8 w-8" />,
},
],
},
];
Expand All @@ -85,20 +60,6 @@ export const mobileNavItems = [
blurb: "The hub for BGT governance",
icon: <Icons.hubFav className="h-8 w-8" />,
},
{
href: lendUrl,
type: "external",
title: lendName,
blurb: "Supply assets and borrow honey",
icon: <Icons.bendFav className="h-8 w-8" />,
},
{
href: perpsUrl,
type: "external",
title: perpsName,
blurb: "Trade your favourite pairs",
icon: <Icons.berpsFav className="h-8 w-8" />,
},
{
href: blockExplorerUrl,
type: "external",
Expand Down
28 changes: 22 additions & 6 deletions apps/honey/src/components/swap-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import { Card, CardContent, CardHeader, CardTitle } from "@bera/ui/card";
import { Icons } from "@bera/ui/icons";
import { Skeleton } from "@bera/ui/skeleton";
import { Tabs, TabsList, TabsTrigger } from "@bera/ui/tabs";
import { Address, parseUnits } from "viem";
import { Address, formatUnits, parseUnits } from "viem";

import { usePsm } from "~/hooks/usePsm";
import { cn } from "@bera/ui";
import BigNumber from "bignumber.js";

export function SwapCard() {
const [tabValue, setTabValue] = useState<"mint" | "burn">("mint");
Expand Down Expand Up @@ -68,6 +69,13 @@ export function SwapCard() {
setToAmount(newToAmounts);
};

const userFriendlyAmount = (
amount: string | undefined,
): string | undefined => {
if (!amount) return undefined;
return new BigNumber(amount).decimalPlaces(2, 1).toString();
};

return (
<div className="w-full">
<Card className="relative z-10 m-auto block w-full max-w-[500px] bg-background shadow-2xl">
Expand All @@ -79,7 +87,7 @@ export function SwapCard() {
<Skeleton className="absolute right-6 top-5 h-6 w-40" />
) : (
<div className="absolute right-6 top-5 text-base font-medium text-muted-foreground">
Static fee of <FormattedNumber value={fee ?? 0} />%
Static fee of <FormattedNumber value={fee ?? 0} percent />
</div>
)}
</CardTitle>
Expand Down Expand Up @@ -119,7 +127,9 @@ export function SwapCard() {
)}
>
<TokenInput
amount={fromAmount[selectedFrom?.[0]?.address!]}
amount={userFriendlyAmount(
fromAmount[selectedFrom?.[0]?.address!],
)}
balance={fromBalance?.[0]}
selected={selectedFrom?.[0]}
selectable={selectedFrom?.[0]?.address !== honey?.address}
Expand Down Expand Up @@ -155,7 +165,9 @@ export function SwapCard() {
<>
<hr />
<TokenInput
amount={fromAmount[selectedFrom?.[1]?.address!]}
amount={userFriendlyAmount(
fromAmount[selectedFrom?.[1]?.address!],
)}
balance={fromBalance?.[1]}
selected={selectedFrom?.[1]}
selectable={selectedFrom?.[1]?.address !== honey?.address}
Expand Down Expand Up @@ -198,7 +210,9 @@ export function SwapCard() {
)}
>
<TokenInput
amount={toAmount[selectedTo?.[0]?.address!]}
amount={userFriendlyAmount(
toAmount[selectedTo?.[0]?.address!],
)}
balance={toBalance?.[0]}
selected={selectedTo?.[0]}
selectable={selectedTo?.[0]?.address !== honey?.address}
Expand Down Expand Up @@ -236,7 +250,9 @@ export function SwapCard() {
<>
<hr />
<TokenInput
amount={toAmount[selectedTo?.[1]?.address!]}
amount={userFriendlyAmount(
toAmount[selectedTo?.[1]?.address!],
)}
balance={toBalance?.[1]}
selected={selectedTo?.[1]}
selectable={selectedTo?.[1]?.address !== honey?.address}
Expand Down
26 changes: 10 additions & 16 deletions apps/honey/src/hooks/usePsm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,12 @@ export const usePsm = (): PsmHookReturn => {
const isBadCollateral1 = useIsBadCollateralAsset({
collateral: collaterals[0]?.address,
});
const isBadCollateral2 = useIsBadCollateralAsset({
collateral: collaterals[1]?.address,
});
const isBadCollateral =
isBadCollateral1.data?.isBlacklisted ||
isBadCollateral1.data?.isDepegged ||
isBadCollateral2.data?.isBlacklisted ||
isBadCollateral2.data?.isDepegged;
// const isBadCollateral2 = useIsBadCollateralAsset({
// collateral: collaterals[1]?.address,
// });
const isBadCollateral = isBasketModeEnabled
? false
: isBadCollateral1.data?.isBlacklisted || isBadCollateral1.data?.isDepegged;

// ===== TOKEN BALANCES =====
// retrieve token balances for both input and output tokens
Expand Down Expand Up @@ -297,16 +295,14 @@ export const usePsm = (): PsmHookReturn => {
// User input collateral amount (fromAmount)
// Set the resulting Honey amount
setToAmount({
[honey?.address!]: new BigNumber(formatUnits(previewRes.honey, 18))
.decimalPlaces(2, 1)
.toString(),
[honey?.address!]: formatUnits(previewRes.honey, 18),
});

// In basket mode, update all collaterals except the one user is currently modifying
if (previewBasketMode && changedAsset) {
setFromAmount((prevColl) => ({
...newCollaterals,
[changedAsset]: Number(prevColl[changedAsset]).toFixed(2),
[changedAsset]: prevColl[changedAsset],
}));
}
} else {
Expand All @@ -325,16 +321,14 @@ export const usePsm = (): PsmHookReturn => {
// User input collateral amount (toAmount)
// Set required Honey amount
setFromAmount({
[honey?.address!]: new BigNumber(formatUnits(previewRes.honey, 18))
.decimalPlaces(2, 1)
.toString(),
[honey?.address!]: formatUnits(previewRes.honey, 18),
});

// In basket mode, update all collaterals except the one user is currently modifying
if (previewBasketMode && changedAsset) {
setToAmount((prevColl) => ({
...newCollaterals,
[changedAsset]: Number(prevColl[changedAsset]).toFixed(2),
[changedAsset]: prevColl[changedAsset],
}));
}
}
Expand Down
21 changes: 0 additions & 21 deletions apps/hub/src/app/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ export const navItems = [
blurb: "Mint or redeem Berachain’s native stablecoin",
icon: <Icons.honeyFav className="h-8 w-8" />,
},
{
href: lendUrl,
type: "external",
title: lendName,
blurb: "Supply assets and borrow honey",
icon: <Icons.bendFav className="h-8 w-8" />,
},
{
href: perpsUrl,
type: "external",
title: perpsName,
blurb: "Trade your favourite pairs",
icon: <Icons.berpsFav className="h-8 w-8" />,
},
{
href: blockExplorerUrl,
type: "external",
Expand All @@ -74,13 +60,6 @@ export const navItems = [
blurb: "Explore Berachain and learn more about our vision",
icon: <Icons.foundationFav className="h-8 w-8" />,
},
{
href: faucetUrl,
type: "external",
title: faucetName,
blurb: "Fund your testnet wallet with BERA tokens",
icon: <Icons.faucetFav className="h-8 w-8" />,
},
],
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function VoteDialog({
</DialogHeader>
<div className="flex w-full items-center justify-center">
<p className="text-3xl font-semibold">{votingPower}</p>
<p className="text-sm font-medium">BGT delegated</p>
<p className="text-sm font-medium">Boosts</p>
</div>

<div className="flex w-full flex-col items-center justify-center">
Expand Down
19 changes: 12 additions & 7 deletions apps/hub/src/app/governance/[genre]/components/proposals-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export const ProposalsList = () => {
const [search, setSearch] = useState<string>("");
const [statusFilter, setStatusFilter] = useState<ProposalStatus[]>([]);

const { data, hasMore, isLoading, size, setSize } = usePollAllProposals({
topic: currentTopic.slug,
orderBy: sortBy.orderBy,
status_in: statusFilter,
orderDirection: sortBy.orderDirection,
text: search,
});
const { data, hasMore, isLoading, size, setSize } = usePollAllProposals(
{
topic: currentTopic.slug,
orderBy: sortBy.orderBy,
status_in: statusFilter,
orderDirection: sortBy.orderDirection,
text: search,
},
{
autoRefresh: true,
},
);

const areFiltersSet = !!search || statusFilter.length !== 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useBeraJs,
useGetPastVotes,
useHasVoted,
usePollProposal,
} from "@bera/berajs";
import { governorAddress } from "@bera/config";
import {
Expand Down Expand Up @@ -57,12 +58,20 @@ export function VoteDialog({
proposalId: proposalId,
});

const { refresh: refreshPollProposal } = usePollProposal(
proposalId.toString(),
{
autoRefresh: true,
},
);

const { write, ModalPortal } = useTxn({
message: "Vote Proposal",
actionType: TransactionActionType.VOTE,
onSuccess: () => {
setOpen(false);
mutate(true);
refreshPollProposal();
},
});

Expand Down
Loading

0 comments on commit a78c1d9

Please sign in to comment.