diff --git a/src/components/[guild]/collect/components/CollectNft/components/CollectNftButton.tsx b/src/components/[guild]/collect/components/CollectNft/components/CollectNftButton.tsx index 5d4c5e2139..515e039274 100644 --- a/src/components/[guild]/collect/components/CollectNft/components/CollectNftButton.tsx +++ b/src/components/[guild]/collect/components/CollectNft/components/CollectNftButton.tsx @@ -50,7 +50,7 @@ const CollectNftButton = ({ }) const amount = useWatch({ name: "amount" }) - const { guildFee } = useGuildFee(chain) + const { guildFee } = useGuildFee(chain, nftAddress) const { fee, isLoading: isNftDetailsLoading } = useNftDetails(chain, nftAddress) const { isLoading: isNftBalanceLoading } = useGuildRewardNftBalanceByUserId({ diff --git a/src/components/[guild]/collect/components/CollectNft/components/NftFeesTable.tsx b/src/components/[guild]/collect/components/CollectNft/components/NftFeesTable.tsx index 557ac45337..5b53ff81e1 100644 --- a/src/components/[guild]/collect/components/CollectNft/components/NftFeesTable.tsx +++ b/src/components/[guild]/collect/components/CollectNft/components/NftFeesTable.tsx @@ -18,7 +18,7 @@ const NftFeesTable = ({ ...rest }: StackProps) => { }) const claimAmount = claimAmountFromForm ?? 1 - const { guildFee } = useGuildFee(chain) + const { guildFee } = useGuildFee(chain, nftAddress) const formattedGuildFee = guildFee ? Number(formatUnits(guildFee, CHAIN_CONFIG[chain].nativeCurrency.decimals)) * claimAmount diff --git a/src/components/[guild]/collect/hooks/useCollectNft.ts b/src/components/[guild]/collect/hooks/useCollectNft.ts index dc9c82cc6e..a3593fffa6 100644 --- a/src/components/[guild]/collect/hooks/useCollectNft.ts +++ b/src/components/[guild]/collect/hooks/useCollectNft.ts @@ -82,7 +82,7 @@ const useCollectNft = () => { useCollectNftContext() const { setTxHash, setTxError, setTxSuccess } = useTransactionStatusContext() ?? {} - const { guildFee } = useGuildFee(chain) + const { guildFee } = useGuildFee(chain, nftAddress) const { fee, name, refetch: refetchNftDetails } = useNftDetails(chain, nftAddress) const { refetch: refetchBalance } = useGuildRewardNftBalanceByUserId({ diff --git a/src/components/[guild]/collect/hooks/useGuildFee.ts b/src/components/[guild]/collect/hooks/useGuildFee.ts index d53354dcdc..84ad7377d2 100644 --- a/src/components/[guild]/collect/hooks/useGuildFee.ts +++ b/src/components/[guild]/collect/hooks/useGuildFee.ts @@ -3,8 +3,18 @@ import guildRewardNFTFactoryAbi from "static/abis/guildRewardNFTFactory" import { useReadContract } from "wagmi" import { Chain, Chains } from "wagmiConfig/chains" +// TODO: remove this once we deploy the contracts on all chains +const chainsWithOverrides = [ + "BASE_MAINNET", + "BSC", + "ARBITRUM", + "OPTIMISM", + "POLYGON", +] + const useGuildFee = ( - chain: Chain + chain: Chain, + contractAddress?: `0x${string}` ): { guildFee: bigint; isLoading: boolean; error: any } => { const { data: guildFee, @@ -14,7 +24,14 @@ const useGuildFee = ( abi: guildRewardNFTFactoryAbi, chainId: Chains[chain], address: GUILD_REWARD_NFT_FACTORY_ADDRESSES[chain], - functionName: "fee", + functionName: + contractAddress && chainsWithOverrides.includes(chain) + ? "getFeeWithOverrides" + : "fee", + args: + contractAddress && chainsWithOverrides.includes(chain) + ? [contractAddress] + : [], }) return { diff --git a/src/static/abis/guildRewardNFTFactory.ts b/src/static/abis/guildRewardNFTFactory.ts index c4fa4dd8f0..235a35fc45 100644 --- a/src/static/abis/guildRewardNFTFactory.ts +++ b/src/static/abis/guildRewardNFTFactory.ts @@ -29,6 +29,25 @@ const guildRewardNFTFacotryAbi = [ name: "FeeChanged", type: "event", }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "tokenAddress", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "newFee", + type: "uint256", + }, + ], + name: "FeeOverrideChanged", + type: "event", + }, { anonymous: false, inputs: [ @@ -204,6 +223,13 @@ const guildRewardNFTFacotryAbi = [ stateMutability: "view", type: "function", }, + { + inputs: [{ internalType: "address", name: "tokenAddress", type: "address" }], + name: "getFeeWithOverrides", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, { inputs: [ { internalType: "address payable", name: "treasuryAddress", type: "address" }, @@ -256,6 +282,16 @@ const guildRewardNFTFacotryAbi = [ stateMutability: "nonpayable", type: "function", }, + { + inputs: [ + { internalType: "address", name: "tokenAddress", type: "address" }, + { internalType: "uint256", name: "newFee", type: "uint256" }, + ], + name: "setFeeOverride", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, { inputs: [ {