Skip to content

Commit

Permalink
feat: add uniswap universal router in ethereum (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
brucexc authored Dec 13, 2024
1 parent 604a198 commit 4d0ca59
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ func (w *worker) matchSwapTransaction(task *source.Task, transaction *ethereum.T
uniswap.AddressV3SwapRouter02Celo,
uniswap.AddressV3SwapRouter02BinanceSmartChain,
uniswap.AddressV3SwapRouter02Linea,
uniswap.AddressUniversalRouter:
uniswap.AddressUniversalRouter01,
uniswap.AddressUniversalRouter02:
return true
case // Uniswap V2
uniswap.AddressV2SwapRouter01,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestWorker_Ethereum(t *testing.T) {
Network: network.Ethereum,
Index: 4,
From: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
To: uniswap.AddressUniversalRouter.String(),
To: uniswap.AddressUniversalRouter02.String(),
Type: typex.ExchangeSwap,
Calldata: &activityx.Calldata{
FunctionHash: "0x3593564c",
Expand Down Expand Up @@ -346,7 +346,7 @@ func TestWorker_Ethereum(t *testing.T) {
Network: network.Ethereum,
Index: 113,
From: "0xB5A7c3f565f0DFDb4EE63d0ca4b4d59fa69c391C",
To: uniswap.AddressUniversalRouter.String(),
To: uniswap.AddressUniversalRouter02.String(),
Type: typex.ExchangeSwap,
Calldata: &activityx.Calldata{
FunctionHash: "0x24856bc3",
Expand All @@ -361,7 +361,7 @@ func TestWorker_Ethereum(t *testing.T) {
Type: typex.ExchangeSwap,
Platform: workerx.PlatformUniswap.String(),
From: "0xB5A7c3f565f0DFDb4EE63d0ca4b4d59fa69c391C",
To: uniswap.AddressUniversalRouter.String(),
To: uniswap.AddressUniversalRouter02.String(),
Metadata: metadata.ExchangeSwap{
From: metadata.Token{
Address: lo.ToPtr("0x5f98805A4E8be255a32880FDeC7F6728C6568bA0"),
Expand All @@ -384,8 +384,8 @@ func TestWorker_Ethereum(t *testing.T) {
{
Type: typex.ExchangeSwap,
Platform: workerx.PlatformUniswap.String(),
From: uniswap.AddressUniversalRouter.String(),
To: uniswap.AddressUniversalRouter.String(),
From: uniswap.AddressUniversalRouter02.String(),
To: uniswap.AddressUniversalRouter02.String(),
Metadata: metadata.ExchangeSwap{
From: metadata.Token{
Address: lo.ToPtr("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
Expand All @@ -408,7 +408,7 @@ func TestWorker_Ethereum(t *testing.T) {
{
Type: typex.ExchangeSwap,
Platform: workerx.PlatformUniswap.String(),
From: uniswap.AddressUniversalRouter.String(),
From: uniswap.AddressUniversalRouter02.String(),
To: "0xB5A7c3f565f0DFDb4EE63d0ca4b4d59fa69c391C",
Metadata: metadata.ExchangeSwap{
From: metadata.Token{
Expand Down
4 changes: 3 additions & 1 deletion provider/ethereum/contract/uniswap/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
//go:generate go run --mod=mod github.com/ethereum/go-ethereum/cmd/abigen --abi ./abi/NonfungiblePositionManager.abi --pkg uniswap --type NonfungiblePositionManager --out contract_nonfungible_position_manager.go

// https://docs.uniswap.org/
// https://github.com/Uniswap/universal-router/blob/main/deploy-addresses/mainnet.json
var (
AddressV1Factory = common.HexToAddress("0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95")
AddressV2Migrator = common.HexToAddress("0x16D4F26C15f3658ec65B1126ff27DD3dF2a2996b")
Expand All @@ -40,7 +41,8 @@ var (
AddressV3FactoryLinea = common.HexToAddress("0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9")
AddressV3FactoryCelo = common.HexToAddress("0xAfE208a311B21f13EF87E33A90049fC17A7acDEc")
AddressV3FactoryBinanceSmartChain = common.HexToAddress("0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7")
AddressUniversalRouter = common.HexToAddress("0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B")
AddressUniversalRouter01 = common.HexToAddress("0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD")
AddressUniversalRouter02 = common.HexToAddress("0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B")
AddressNonfungiblePositionManager = common.HexToAddress("0xC36442b4a4522E871399CD717aBDD847Ab11FE88")
AddressNonfungiblePositionManagerLinea = common.HexToAddress("0x4615C383F85D0a2BbED973d83ccecf5CB7121463")
AddressV2SwapRouterSAVM = common.HexToAddress("0xC7c934E224e8567df50058A907904b451bD1c57D")
Expand Down

0 comments on commit 4d0ca59

Please sign in to comment.