Skip to content

Commit

Permalink
Fix hooks contract and hide coming soon pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Jul 14, 2024
1 parent 742a43d commit f01f07a
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 132 deletions.
3 changes: 2 additions & 1 deletion packages/foundry/contracts/hooks/VeBALFeeDiscountHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ contract VeBALFeeDiscountHook is BaseHooks {

function onComputeDynamicSwapFee(
IBasePool.PoolSwapParams calldata params,
address,
uint256 staticSwapFeePercentage
) external view returns (bool, uint256) {
) external view override returns (bool, uint256) {
// If the router is not trusted, does not apply the veBAL discount because getSender() may be manipulated by a
// malicious router.
if (params.router != _trustedRouter) {
Expand Down
2 changes: 1 addition & 1 deletion packages/foundry/script/01_DeployConstantSumPool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ contract DeployConstantSumPool is PoolHelpers, ScaffoldHelpers {
uint256[] memory exactAmountsIn = new uint256[](2); // Exact amounts of tokens to be added, sorted in token alphanumeric order
exactAmountsIn[0] = 50e18; // amount of token1 to send during pool initialization
exactAmountsIn[1] = 50e18; // amount of token2 to send during pool initialization
uint256 minBptAmountOut = 1 ether; // Minimum amount of pool tokens to be received
uint256 minBptAmountOut = 99e18; // Minimum amount of pool tokens to be received
bool wethIsEth = false; // If true, incoming ETH will be wrapped to WETH; otherwise the Vault will pull WETH tokens
bytes memory userData = bytes(""); // Additional (optional) data required for adding initial liquidity

Expand Down
2 changes: 1 addition & 1 deletion packages/foundry/script/02_DeployConstantProductPool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ contract DeployConstantProductPool is PoolHelpers, ScaffoldHelpers {
uint256[] memory exactAmountsIn = new uint256[](2); // Exact amounts of tokens to be added, sorted in token alphanumeric order
exactAmountsIn[0] = 50e18; // amount of token1 to send during pool initialization
exactAmountsIn[1] = 50e18; // amount of token2 to send during pool initialization
uint256 minBptAmountOut = 1 ether; // Minimum amount of pool tokens to be received
uint256 minBptAmountOut = 49e18; // Minimum amount of pool tokens to be received
bool wethIsEth = false; // If true, incoming ETH will be wrapped to WETH; otherwise the Vault will pull WETH tokens
bytes memory userData = bytes(""); // Additional (optional) data required for adding initial liquidity

Expand Down
24 changes: 12 additions & 12 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ const TOOLS = [
href: "/hooks",
description: "Extend pool functionality with hooks",
},
{
emoji: "🧭",
title: "Smart Order Router",
href: "/router",
description: "Integrate pools with the smart order router",
},
{
emoji: "📡",
title: "Subgraph",
href: "/subgraph",
description: "Integrate pools with the Balancer subgraph",
},
// {
// emoji: "🧭",
// title: "Smart Order Router",
// href: "/router",
// description: "Integrate pools with the smart order router",
// },
// {
// emoji: "📡",
// title: "Subgraph",
// href: "/subgraph",
// description: "Integrate pools with the Balancer subgraph",
// },
];

const Home: NextPage = () => {
Expand Down
60 changes: 32 additions & 28 deletions packages/nextjs/app/pools/_components/PoolActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ export const PoolActions: React.FC<{ pool: Pool; refetchPool: RefetchPool }> = (

const userHasNoTokens = Object.values(tokenBalances).every(balance => balance === 0n);

const { writeAsync: mintToken1 } = useScaffoldContractWrite({
contractName: "MockToken1",
functionName: "mint",
args: [5000000000000000000n],
});

const { writeAsync: mintToken2 } = useScaffoldContractWrite({
contractName: "MockToken2",
functionName: "mint",
args: [5000000000000000000n],
});

const tabs = {
Swap: (
<SwapForm
Expand Down Expand Up @@ -80,21 +68,7 @@ export const PoolActions: React.FC<{ pool: Pool; refetchPool: RefetchPool }> = (
<div className="flex mb-3 items-center gap-5">
<h5 className="text-xl font-bold text-nowrap">Pool Actions</h5>
{address && !balance ? <Alert>Click the faucet button in the top right corner!</Alert> : null}
{balance !== 0 && userHasNoTokens && (
<Alert>
Zero balance. To mint mock tokens{" "}
<span
className="link"
onClick={async () => {
await mintToken1();
await mintToken2();
refetchTokenBalances();
}}
>
click here
</span>
</Alert>
)}
{balance !== 0 && userHasNoTokens && <ZeroTokensAlert refetchTokenBalances={refetchTokenBalances} />}
</div>
<div className="border border-base-100 rounded-lg">
<div className="flex">
Expand All @@ -119,9 +93,39 @@ export const PoolActions: React.FC<{ pool: Pool; refetchPool: RefetchPool }> = (
);
};

const ZeroTokensAlert = ({ refetchTokenBalances }: { refetchTokenBalances: () => void }) => {
const { writeAsync: mintToken1 } = useScaffoldContractWrite({
contractName: "MockToken1",
functionName: "mint",
args: [10000000000000000000n],
});

const { writeAsync: mintToken2 } = useScaffoldContractWrite({
contractName: "MockToken2",
functionName: "mint",
args: [10000000000000000000n],
});

return (
<Alert>
Zero token balances. To mint some{" "}
<span
className="link"
onClick={async () => {
await mintToken1();
await mintToken2();
refetchTokenBalances();
}}
>
click here
</span>
</Alert>
);
};

const Alert = ({ children }: { children: React.ReactNode }) => {
return (
<div className="w-full text-neutral bg-[#fb923c40] border border-orange-400 rounded-lg py-1 px-5 flex gap-2 items-center justify-center">
<div className="w-full text-base-content bg-[#fb923c40] border border-orange-400 rounded-lg py-1 px-5 flex gap-2 items-center justify-center">
<div>
<ExclamationTriangleIcon className="w-5 h-5" />
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/app/pools/_components/PoolSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const PoolSelector = ({
logs.forEach(log => {
const { pool } = log.args;
if (pool) {
setSumPools(pools => [...pools, pool]);
setProductPools(pools => [...pools, pool]);
}
});
},
Expand All @@ -87,7 +87,7 @@ export const PoolSelector = ({

return (
<section className="">
<div className="mb-4 flex flex-wrap justify-center gap-3">
<div className="flex flex-wrap justify-center gap-3 h-12">
{sumPools.length > 0 &&
sumPools.map(pool => (
<button
Expand Down
26 changes: 12 additions & 14 deletions packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
ArrowUturnUpIcon,
ArrowsRightLeftIcon,
ArrowUturnUpIcon, // ArrowsRightLeftIcon,
Bars3Icon,
BugAntIcon,
CircleStackIcon,
BugAntIcon, // CircleStackIcon,
ScaleIcon,
} from "@heroicons/react/24/outline";
import { SwitchTheme } from "~~/components/SwitchTheme";
Expand All @@ -33,16 +31,16 @@ export const menuLinks: HeaderMenuLink[] = [
href: "/hooks",
icon: <ArrowUturnUpIcon className="h-5 w-5" />,
},
{
label: "Router",
href: "/router",
icon: <ArrowsRightLeftIcon className="h-5 w-5" />,
},
{
label: "Subgraph",
href: "/subgraph",
icon: <CircleStackIcon className="h-5 w-5" />,
},
// {
// label: "Router",
// href: "/router",
// icon: <ArrowsRightLeftIcon className="h-5 w-5" />,
// },
// {
// label: "Subgraph",
// href: "/subgraph",
// icon: <CircleStackIcon className="h-5 w-5" />,
// },
{
label: "Debug Contracts",
href: "/debug",
Expand Down
80 changes: 7 additions & 73 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
const deployedContracts = {
31337: {
ConstantSumFactory: {
address: "0x54AA2E6A501137aF781AFbAC999Abc331Bd0C483",
address: "0x579bB3a775c831526D5E94EF9ccd6601F62790Bc",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -391,7 +391,7 @@ const deployedContracts = {
},
},
ConstantProductFactory: {
address: "0x5AdCb90027D061F29206D2acf1bf3F7DA70A1683",
address: "0x3626DEff4AFB3Acd8f217288cd33FBE3a337Ce0B",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -775,7 +775,7 @@ const deployedContracts = {
},
},
MockToken1: {
address: "0x51df3BFcD303b9B19438e40E335b246b82636569",
address: "0x69221a99e5Bc30E0cf891992e958E3Ba3815bfc6",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1133,7 +1133,7 @@ const deployedContracts = {
},
},
MockToken2: {
address: "0x4DA8240316441C9145f113E5Bab3A0Cb43ac5C29",
address: "0x66B4cF3Be49431371E4241C462B4A75ae3a6E986",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1491,7 +1491,7 @@ const deployedContracts = {
},
},
MockVeBAL: {
address: "0xf29152265F3f4E2262956Ad28310Ae58d0a5E3c6",
address: "0x01eE8e2C72a2Cd4C5206823ce393520758F5Bc79",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1849,7 +1849,7 @@ const deployedContracts = {
},
},
VeBALFeeDiscountHook: {
address: "0x7822a308e4c31E3Ae918FeB680468b86d6f99607",
address: "0xB93eD7BbBFfcedfA8125f0653Bc07E7D229ffE21",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -2363,7 +2363,7 @@ const deployedContracts = {
name: "onComputeDynamicSwapFee",
inputs: [
{
name: "",
name: "params",
type: "tuple",
internalType: "struct IBasePool.PoolSwapParams",
components: [
Expand Down Expand Up @@ -2409,72 +2409,6 @@ const deployedContracts = {
type: "address",
internalType: "address",
},
{
name: "",
type: "uint256",
internalType: "uint256",
},
],
outputs: [
{
name: "",
type: "bool",
internalType: "bool",
},
{
name: "",
type: "uint256",
internalType: "uint256",
},
],
stateMutability: "view",
},
{
type: "function",
name: "onComputeDynamicSwapFee",
inputs: [
{
name: "params",
type: "tuple",
internalType: "struct IBasePool.PoolSwapParams",
components: [
{
name: "kind",
type: "uint8",
internalType: "enum SwapKind",
},
{
name: "amountGivenScaled18",
type: "uint256",
internalType: "uint256",
},
{
name: "balancesScaled18",
type: "uint256[]",
internalType: "uint256[]",
},
{
name: "indexIn",
type: "uint256",
internalType: "uint256",
},
{
name: "indexOut",
type: "uint256",
internalType: "uint256",
},
{
name: "router",
type: "address",
internalType: "address",
},
{
name: "userData",
type: "bytes",
internalType: "bytes",
},
],
},
{
name: "staticSwapFeePercentage",
type: "uint256",
Expand Down

0 comments on commit f01f07a

Please sign in to comment.