From 6b1436e791a620a8bb05001917db23aafe9c7f73 Mon Sep 17 00:00:00 2001 From: Finnian Jacobson-Schulte <140328381+finnian0826@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:16:14 -0700 Subject: [PATCH] add referrer --- src/abis/IWalletJumpstart.ts | 19 +++++++++++++++++++ src/swap/useSwapQuote.ts | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/abis/IWalletJumpstart.ts b/src/abis/IWalletJumpstart.ts index 698fe935d4f..c3c1acf6aa0 100644 --- a/src/abis/IWalletJumpstart.ts +++ b/src/abis/IWalletJumpstart.ts @@ -391,6 +391,25 @@ const jumpstart = { stateMutability: 'view', type: 'function', }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'referrer', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { diff --git a/src/swap/useSwapQuote.ts b/src/swap/useSwapQuote.ts index 7239c0b04af..274a17a4375 100644 --- a/src/swap/useSwapQuote.ts +++ b/src/swap/useSwapQuote.ts @@ -1,5 +1,6 @@ import BigNumber from 'bignumber.js' import { useAsyncCallback } from 'react-async-hook' +import walletJumpstart from 'src/abis/IWalletJumpstart' import { useSelector } from 'src/redux/hooks' import { FetchQuoteResponse, @@ -193,7 +194,14 @@ function useSwapQuote({ return null } - const referrer = '' // TODO: Add logic to get referrer from https://github.com/valora-labs/peer2peer-funding-layer/blob/main/contracts/WalletJumpstartHack.sol#L33 using walletAddress + const client = publicClient[networkIdToNetwork[networkId]] + + const referrer = await client.readContract({ + address: '' as Address, // Add the new WalletJumpstartHack address here + abi: walletJumpstart.abi, + functionName: 'referrer', + args: [walletAddress as Address], + }) const swapAmountParam = updatedField === Field.FROM ? 'sellAmount' : 'buyAmount' const params = {