From 6a11f4267ec54a5e224962d4a6687c73df6d114b Mon Sep 17 00:00:00 2001
From: aon <21188659+aon@users.noreply.github.com>
Date: Fri, 13 Dec 2024 12:53:38 -0300
Subject: [PATCH] feat: update cpamm
---
contracts/src/CPAMM.sol | 6 +++++-
web/components/Header.tsx | 11 +++++++++--
web/contracts/cpamm.ts | 7 +++++++
web/hooks/use-cpamm.ts | 34 ++++++++++++++++++----------------
4 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/contracts/src/CPAMM.sol b/contracts/src/CPAMM.sol
index 5a74491..bba4017 100644
--- a/contracts/src/CPAMM.sol
+++ b/contracts/src/CPAMM.sol
@@ -110,6 +110,10 @@ contract CPAMM {
);
}
+ function allowedToAddLiquidity() external view returns (bool) {
+ return userFeeTier[msg.sender] == 1 || userFeeTier[msg.sender] == 2;
+ }
+
function addLiquidity(
uint256 _amount0,
uint256 _amount1
@@ -316,7 +320,7 @@ contract CPAMM {
modifier onlyPremiumOrVip() {
require(
- userFeeTier[msg.sender] == 2 || userFeeTier[msg.sender] == 1,
+ userFeeTier[msg.sender] == 1 || userFeeTier[msg.sender] == 2,
"Only VIP or premium users can call this function"
);
_;
diff --git a/web/components/Header.tsx b/web/components/Header.tsx
index 486fc9b..65b9aaf 100644
--- a/web/components/Header.tsx
+++ b/web/components/Header.tsx
@@ -1,5 +1,6 @@
"use client";
+import { useEffect, useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
@@ -14,6 +15,12 @@ type HeaderMenuLink = {
export const Header = () => {
const { addLiquidityAllowed } = useCpamm();
+ const [showPool, setShowPool] = useState(false);
+
+ // Use it to update the state after hydration
+ useEffect(() => {
+ setShowPool(addLiquidityAllowed);
+ }, [addLiquidityAllowed]);
return (
@@ -23,9 +30,9 @@ export const Header = () => {
Double Zero Swap
-