fix_: hop contracts' addresses updated

This commit is contained in:
Sale Djenic 2024-05-23 14:38:39 +02:00 committed by saledjenic
parent c74931c333
commit 74b1dfd694
30 changed files with 16892 additions and 3621 deletions

View File

@ -7,10 +7,6 @@ import (
"github.com/status-im/status-go/contracts/balancechecker"
"github.com/status-im/status-go/contracts/directory"
"github.com/status-im/status-go/contracts/ethscan"
"github.com/status-im/status-go/contracts/hop"
hopBridge "github.com/status-im/status-go/contracts/hop/bridge"
hopSwap "github.com/status-im/status-go/contracts/hop/swap"
hopWrapper "github.com/status-im/status-go/contracts/hop/wrapper"
"github.com/status-im/status-go/contracts/ierc20"
"github.com/status-im/status-go/contracts/registrar"
"github.com/status-im/status-go/contracts/resolver"
@ -204,51 +200,3 @@ func (c *ContractMaker) NewBalanceChecker(chainID uint64) (*balancechecker.Balan
backend,
)
}
func (c *ContractMaker) NewHopL2SaddlSwap(chainID uint64, symbol string) (*hopSwap.HopSwap, error) {
contractAddr, err := hop.L2SaddleSwapContractAddress(chainID, symbol)
if err != nil {
return nil, err
}
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return hopSwap.NewHopSwap(
contractAddr,
backend,
)
}
func (c *ContractMaker) NewHopL1Bridge(chainID uint64, symbol string) (*hopBridge.HopBridge, error) {
contractAddr, err := hop.L1BridgeContractAddress(chainID, symbol)
if err != nil {
return nil, err
}
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return hopBridge.NewHopBridge(
contractAddr,
backend,
)
}
func (c *ContractMaker) NewHopL2AmmWrapper(chainID uint64, symbol string) (*hopWrapper.HopWrapper, error) {
contractAddr, err := hop.L2AmmWrapperContractAddress(chainID, symbol)
if err != nil {
return nil, err
}
backend, err := c.RPCClient.EthClient(chainID)
if err != nil {
return nil, err
}
return hopWrapper.NewHopWrapper(
contractAddr,
backend,
)
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"nativeTokenAddress","type":"address"},{"internalType":"address","name":"cctpAddress","type":"address"},{"internalType":"address","name":"feeCollectorAddress","type":"address"},{"internalType":"uint256","name":"minBonderFee","type":"uint256"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"},{"internalType":"uint32[]","name":"domains","type":"uint32[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"cctpNonce","type":"uint64"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bonderFee","type":"uint256"}],"name":"CCTPTransferSent","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"activeChainIds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cctp","outputs":[{"internalType":"contract ICCTP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"destinationDomains","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollectorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBonderFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nativeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"bonderFee","type":"uint256"}],"name":"send","outputs":[],"stateMutability":"nonpayable","type":"function"}]

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"nativeTokenAddress","type":"address"},{"internalType":"address","name":"cctpAddress","type":"address"},{"internalType":"address","name":"feeCollectorAddress","type":"address"},{"internalType":"uint256","name":"minBonderFee","type":"uint256"},{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"},{"internalType":"uint32[]","name":"domains","type":"uint32[]"},{"internalType":"address","name":"bridgedTokenAddress","type":"address"},{"internalType":"address","name":"ammAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"cctpNonce","type":"uint64"},{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bonderFee","type":"uint256"}],"name":"CCTPTransferSent","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"activeChainIds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amm","outputs":[{"internalType":"contract IAMM","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgedToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cctp","outputs":[{"internalType":"contract ICCTP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"destinationDomains","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollectorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBonderFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nativeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"bonderFee","type":"uint256"}],"name":"send","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"bonderFee","type":"uint256"},{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct IAMM.ExactInputParams","name":"swapParams","type":"tuple"}],"name":"swapAndSend","outputs":[],"stateMutability":"nonpayable","type":"function"}]

File diff suppressed because one or more lines are too long

View File

@ -4,112 +4,353 @@ import (
"errors"
"github.com/ethereum/go-ethereum/common"
walletCommon "github.com/status-im/status-go/services/wallet/common"
)
var errorNotAvailableOnChainID = errors.New("not available for chainID")
var l2SaddleSwapContractAddresses = map[uint64]map[string]common.Address{
10: {
"USDC": common.HexToAddress("0x3c0FFAca566fCcfD9Cc95139FEF6CBA143795963"),
"USDT": common.HexToAddress("0xeC4B41Af04cF917b54AEb6Df58c0f8D78895b5Ef"),
"DAI": common.HexToAddress("0xF181eD90D6CfaC84B8073FdEA6D34Aa744B41810"),
"ETH": common.HexToAddress("0xaa30D6bba6285d0585722e2440Ff89E23EF68864"),
"WBTC": common.HexToAddress("0x46fc3Af3A47792cA3ED06fdF3D657145A675a8D8"),
// List taken from Hop:
// https://github.com/hop-protocol/hop/blob/ef1ca4f8fac002c81fc0dc37ba021125947c6bc2/packages/sdk/src/addresses/mainnet.ts
// https://github.com/hop-protocol/hop/blob/ef1ca4f8fac002c81fc0dc37ba021125947c6bc2/packages/sdk/src/addresses/sepolia.ts
const (
L1CanonicalToken = "l1CanonicalToken"
L1Bridge = "l1Bridge"
L1CanonicalBridge = "l1CanonicalBridge"
L1MessengerWrapper = "l1MessengerWrapper"
CctpL1Bridge = "cctpL1Bridge"
CctpMessageTransmitter = "cctpMessageTransmitter"
L2CanonicalToken = "l2CanonicalToken"
L2Bridge = "l2Bridge"
L2CanonicalBridge = "l2CanonicalBridge"
L2HopBridgeToken = "l2HopBridgeToken"
L2AmmWrapper = "l2AmmWrapper"
L2SaddleSwap = "l2SaddleSwap"
L2SaddleLpToken = "l2SaddleLpToken"
CctpL2Bridge = "cctpL2Bridge"
)
var hopBridgeContractAddresses = map[string]map[uint64]map[string]common.Address{
"USDC": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"),
CctpL1Bridge: common.HexToAddress("0x7e77461CA2a9d82d26FD5e0Da2243BF72eA45747"),
CctpMessageTransmitter: common.HexToAddress("0x0a992d191deec32afe36203ad87d7d289a738f81"),
},
42161: {
"USDC": common.HexToAddress("0x10541b07d8Ad2647Dc6cD67abd4c03575dade261"),
"USDT": common.HexToAddress("0x18f7402B673Ba6Fb5EA4B95768aABb8aaD7ef18a"),
"DAI": common.HexToAddress("0xa5A33aB9063395A90CCbEa2D86a62EcCf27B5742"),
"ETH": common.HexToAddress("0x652d27c0F72771Ce5C76fd400edD61B406Ac6D97"),
"WBTC": common.HexToAddress("0x7191061D5d4C60f598214cC6913502184BAddf18"),
walletCommon.OptimismMainnet: {
L2CanonicalToken: common.HexToAddress("0x0b2c639c533813f4aa9d7837caf62653d097ff85"),
CctpL2Bridge: common.HexToAddress("0x469147af8Bde580232BE9DC84Bb4EC84d348De24"),
CctpMessageTransmitter: common.HexToAddress("0x4d41f22c5a0e5c74090899e5a8fb597a8842b3e8"),
},
420: {
"USDC": common.HexToAddress("0xE4757dD81AFbecF61E51824AB9238df6691c3D0e"),
"ETH": common.HexToAddress("0xa50395bdEaca7062255109fedE012eFE63d6D402"),
walletCommon.ArbitrumMainnet: {
L2CanonicalToken: common.HexToAddress("0xaf88d065e77c8cc2239327c5edb3a432268e5831"),
CctpL2Bridge: common.HexToAddress("0x6504BFcaB789c35325cA4329f1f41FaC340bf982"),
CctpMessageTransmitter: common.HexToAddress("0xC30362313FBBA5cf9163F0bb16a0e01f01A896ca"),
},
walletCommon.EthereumSepolia: {
L1CanonicalToken: common.HexToAddress("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
CctpL1Bridge: common.HexToAddress("0x05fda2db623fa6a89a2db33550848ab2006a4427"),
},
walletCommon.OptimismSepolia: {
L2CanonicalToken: common.HexToAddress("0x5fd84259d66Cd46123540766Be93DFE6D43130D7"),
CctpL2Bridge: common.HexToAddress("0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5"),
},
walletCommon.ArbitrumSepolia: {
L2CanonicalToken: common.HexToAddress("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
CctpL2Bridge: common.HexToAddress("0x9f3B8679c73C2Fef8b59B4f3444d4e156fb70AA5"),
},
},
"USDC.e": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"),
L1Bridge: common.HexToAddress("0x3666f603Cc164936C1b87e207F36BEBa4AC5f18a"),
CctpL1Bridge: common.HexToAddress("0x7e77461CA2a9d82d26FD5e0Da2243BF72eA45747"),
CctpMessageTransmitter: common.HexToAddress("0x0a992d191deec32afe36203ad87d7d289a738f81"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x6587a6164B091a058aCba2e91f971454Ec172940"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0x7F5c764cBc14f9669B88837ca1490cCa17c31607"),
L2Bridge: common.HexToAddress("0xa81D244A1814468C734E5b4101F7b9c0c577a8fC"),
CctpL2Bridge: common.HexToAddress("0x469147af8Bde580232BE9DC84Bb4EC84d348De24"),
CctpMessageTransmitter: common.HexToAddress("0x4d41f22c5a0e5c74090899e5a8fb597a8842b3e8"),
L2HopBridgeToken: common.HexToAddress("0x25D8039bB044dC227f741a9e381CA4cEAE2E6aE8"),
L2AmmWrapper: common.HexToAddress("0x2ad09850b0CA4c7c1B33f5AcD6cBAbCaB5d6e796"),
L2SaddleSwap: common.HexToAddress("0x3c0FFAca566fCcfD9Cc95139FEF6CBA143795963"),
L2SaddleLpToken: common.HexToAddress("0x2e17b8193566345a2Dd467183526dEdc42d2d5A8"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x39Bf4A32E689B6a79360854b7c901e991085D6a3"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"),
L2Bridge: common.HexToAddress("0x0e0E3d2C5c292161999474247956EF542caBF8dd"),
CctpL2Bridge: common.HexToAddress("0x6504BFcaB789c35325cA4329f1f41FaC340bf982"),
CctpMessageTransmitter: common.HexToAddress("0xC30362313FBBA5cf9163F0bb16a0e01f01A896ca"),
L2HopBridgeToken: common.HexToAddress("0x0ce6c85cF43553DE10FC56cecA0aef6Ff0DD444d"),
L2AmmWrapper: common.HexToAddress("0xe22D2beDb3Eca35E6397e0C6D62857094aA26F52"),
L2SaddleSwap: common.HexToAddress("0x10541b07d8Ad2647Dc6cD67abd4c03575dade261"),
L2SaddleLpToken: common.HexToAddress("0xB67c014FA700E69681a673876eb8BAFAA36BFf71"),
},
walletCommon.EthereumSepolia: {
L1CanonicalToken: common.HexToAddress("0x95B01328BA6f4de261C4907fB35eE3c4968e9CEF"),
CctpL1Bridge: common.HexToAddress("0x98bc5b835686e1a00e6c2168af162905899e93d6"),
},
walletCommon.OptimismSepolia: {
L2CanonicalToken: common.HexToAddress("0xB15312eA17d95375E64317C363A0e6304330D82e"),
},
},
"USDT": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7"),
L1Bridge: common.HexToAddress("0x3E4a3a4796d16c0Cd582C382691998f7c06420B6"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x9fc22E269c3752620EB281ce470855886b982501"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"),
L2Bridge: common.HexToAddress("0x46ae9BaB8CEA96610807a275EBD36f8e916b5C61"),
L2HopBridgeToken: common.HexToAddress("0x2057C8ECB70Afd7Bee667d76B4CD373A325b1a20"),
L2AmmWrapper: common.HexToAddress("0x7D269D3E0d61A05a0bA976b7DBF8805bF844AF3F"),
L2SaddleSwap: common.HexToAddress("0xeC4B41Af04cF917b54AEb6Df58c0f8D78895b5Ef"),
L2SaddleLpToken: common.HexToAddress("0xF753A50fc755c6622BBCAa0f59F0522f264F006e"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x967F8E2B66D624Ad544CB59a230b867Ac3dC60dc"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),
L2Bridge: common.HexToAddress("0x72209Fe68386b37A40d6bCA04f78356fd342491f"),
L2HopBridgeToken: common.HexToAddress("0x12e59C59D282D2C00f3166915BED6DC2F5e2B5C7"),
L2AmmWrapper: common.HexToAddress("0xCB0a4177E0A60247C0ad18Be87f8eDfF6DD30283"),
L2SaddleSwap: common.HexToAddress("0x18f7402B673Ba6Fb5EA4B95768aABb8aaD7ef18a"),
L2SaddleLpToken: common.HexToAddress("0xCe3B19D820CB8B9ae370E423B0a329c4314335fE"),
},
},
"MATIC": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0"),
L1Bridge: common.HexToAddress("0x22B1Cbb8D98a01a3B71D034BB899775A76Eb1cc2"),
},
},
"DAI": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
L1Bridge: common.HexToAddress("0x3d4Cc8A61c7528Fd86C55cfe061a78dCBA48EDd1"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x115F423b958A2847af0F5bF314DB0f27c644c308"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
L2Bridge: common.HexToAddress("0x7191061D5d4C60f598214cC6913502184BAddf18"),
L2HopBridgeToken: common.HexToAddress("0x56900d66D74Cb14E3c86895789901C9135c95b16"),
L2AmmWrapper: common.HexToAddress("0xb3C68a491608952Cb1257FC9909a537a0173b63B"),
L2SaddleSwap: common.HexToAddress("0xF181eD90D6CfaC84B8073FdEA6D34Aa744B41810"),
L2SaddleLpToken: common.HexToAddress("0x22D63A26c730d49e5Eab461E4f5De1D8BdF89C92"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x2d6fd82C7f531328BCaCA96EF985325C0894dB62"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
L2Bridge: common.HexToAddress("0x7aC115536FE3A185100B2c4DE4cb328bf3A58Ba6"),
L2HopBridgeToken: common.HexToAddress("0x46ae9BaB8CEA96610807a275EBD36f8e916b5C61"),
L2AmmWrapper: common.HexToAddress("0xe7F40BF16AB09f4a6906Ac2CAA4094aD2dA48Cc2"),
L2SaddleSwap: common.HexToAddress("0xa5A33aB9063395A90CCbEa2D86a62EcCf27B5742"),
L2SaddleLpToken: common.HexToAddress("0x68f5d998F00bB2460511021741D098c05721d8fF"),
},
},
"ETH": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1Bridge: common.HexToAddress("0xb8901acB165ed027E32754E0FFe830802919727f"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0xa45DF1A388049fb8d76E72D350d24E2C3F7aEBd1"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0x4200000000000000000000000000000000000006"),
L2Bridge: common.HexToAddress("0x83f6244Bd87662118d96D9a6D44f09dffF14b30E"),
L2HopBridgeToken: common.HexToAddress("0xE38faf9040c7F09958c638bBDB977083722c5156"),
L2AmmWrapper: common.HexToAddress("0x86cA30bEF97fB651b8d866D45503684b90cb3312"),
L2SaddleSwap: common.HexToAddress("0xaa30D6bba6285d0585722e2440Ff89E23EF68864"),
L2SaddleLpToken: common.HexToAddress("0x5C2048094bAaDe483D0b1DA85c3Da6200A88a849"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0xDD378a11475D588908001E0E99E4fD89ABda5434"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),
L2Bridge: common.HexToAddress("0x3749C4f034022c39ecafFaBA182555d4508caCCC"),
L2HopBridgeToken: common.HexToAddress("0xDa7c0de432a9346bB6e96aC74e3B61A36d8a77eB"),
L2AmmWrapper: common.HexToAddress("0x33ceb27b39d2Bb7D2e61F7564d3Df29344020417"),
L2SaddleSwap: common.HexToAddress("0x652d27c0F72771Ce5C76fd400edD61B406Ac6D97"),
L2SaddleLpToken: common.HexToAddress("0x59745774Ed5EfF903e615F5A2282Cae03484985a"),
},
},
"HOP": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"),
L1Bridge: common.HexToAddress("0x914f986a44AcB623A277d6Bd17368171FCbe4273"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x9D3A7fB18CA7F1237F977Dc5572883f8b24F5638"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"),
L2Bridge: common.HexToAddress("0x03D7f750777eC48d39D080b020D83Eb2CB4e3547"),
L2HopBridgeToken: common.HexToAddress("0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"),
L2AmmWrapper: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2SaddleSwap: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2SaddleLpToken: common.HexToAddress("0x0000000000000000000000000000000000000000"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x41BF5Fd5D1C85f00fd1F23C77740F1A7eBa6A35c"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"),
L2Bridge: common.HexToAddress("0x25FB92E505F752F730cAD0Bd4fa17ecE4A384266"),
L2HopBridgeToken: common.HexToAddress("0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC"),
L2AmmWrapper: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2SaddleSwap: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2SaddleLpToken: common.HexToAddress("0x0000000000000000000000000000000000000000"),
},
},
"SNX": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f"),
L1Bridge: common.HexToAddress("0x893246FACF345c99e4235E5A7bbEE7404c988b96"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0xf0727B1eB1A4c9319A5c34A68bcD5E6530850D47"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4"),
L2Bridge: common.HexToAddress("0x16284c7323c35F4960540583998C98B1CfC581a7"),
L2HopBridgeToken: common.HexToAddress("0x13B7F51BD865410c3AcC4d56083C5B56aB38D203"),
L2AmmWrapper: common.HexToAddress("0xf11EBB94EC986EA891Aec29cfF151345C83b33Ec"),
L2SaddleSwap: common.HexToAddress("0x1990BC6dfe2ef605Bfc08f5A23564dB75642Ad73"),
L2SaddleLpToken: common.HexToAddress("0xe63337211DdE2569C348D9B3A0acb5637CFa8aB3"),
},
},
"sUSD": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"),
L1Bridge: common.HexToAddress("0x36443fC70E073fe9D50425f82a3eE19feF697d62"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x4Ef4C1208F7374d0252767E3992546d61dCf9848"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9"),
L2Bridge: common.HexToAddress("0x33Fe5bB8DA466dA55a8A32D6ADE2BB104E2C5201"),
L2HopBridgeToken: common.HexToAddress("0x6F03052743CD99ce1b29265E377e320CD24Eb632"),
L2AmmWrapper: common.HexToAddress("0x29Fba7d2A6C95DB162ee09C6250e912D6893DCa6"),
L2SaddleSwap: common.HexToAddress("0x8d4063E82A4Db8CdAed46932E1c71e03CA69Bede"),
L2SaddleLpToken: common.HexToAddress("0xBD08972Cef7C9a5A046C9Ef13C9c3CE13739B8d6"),
},
},
"rETH": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xae78736Cd615f374D3085123A210448E74Fc6393"),
L1Bridge: common.HexToAddress("0x87269B23e73305117D0404557bAdc459CEd0dbEc"),
},
walletCommon.OptimismMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0xae26bbD1FA3083E1dae3AEaA2050b97c55886f5d"),
L2CanonicalBridge: common.HexToAddress("0x4200000000000000000000000000000000000010"),
L2CanonicalToken: common.HexToAddress("0x9Bcef72be871e61ED4fBbc7630889beE758eb81D"),
L2Bridge: common.HexToAddress("0xA0075E8cE43dcB9970cB7709b9526c1232cc39c2"),
L2HopBridgeToken: common.HexToAddress("0x755569159598f3702bdD7DFF6233A317C156d3Dd"),
L2AmmWrapper: common.HexToAddress("0x19B2162CA4C2C6F08C6942bFB846ce5C396aCB75"),
L2SaddleSwap: common.HexToAddress("0x9Dd8685463285aD5a94D2c128bda3c5e8a6173c8"),
L2SaddleLpToken: common.HexToAddress("0x0699BC1Ca03761110929b2B56BcCBeb691fa9ca6"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0x7fEb7af8d5B277e249868aCF7644e7BB4A5937f8"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0xEC70Dcb4A1EFa46b8F2D97C310C9c4790ba5ffA8"),
L2Bridge: common.HexToAddress("0xc315239cFb05F1E130E7E28E603CEa4C014c57f0"),
L2HopBridgeToken: common.HexToAddress("0x588Bae9C85a605a7F14E551d144279984469423B"),
L2AmmWrapper: common.HexToAddress("0x16e08C02e4B78B0a5b3A917FF5FeaeDd349a5a95"),
L2SaddleSwap: common.HexToAddress("0x0Ded0d521AC7B0d312871D18EA4FDE79f03Ee7CA"),
L2SaddleLpToken: common.HexToAddress("0xbBA837dFFB3eCf4638D200F11B8c691eA641AdCb"),
},
},
"MAGIC": {
walletCommon.EthereumMainnet: {
L1CanonicalToken: common.HexToAddress("0xB0c7a3Ba49C7a6EaBa6cD4a96C55a1391070Ac9A"),
L1Bridge: common.HexToAddress("0xf074540eb83c86211F305E145eB31743E228E57d"),
},
walletCommon.ArbitrumMainnet: {
L1CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L1MessengerWrapper: common.HexToAddress("0xa0c37738582E63B383E609624423d052BFA4b316"),
L2CanonicalBridge: common.HexToAddress("0x0000000000000000000000000000000000000000"),
L2CanonicalToken: common.HexToAddress("0x539bdE0d7Dbd336b79148AA742883198BBF60342"),
L2Bridge: common.HexToAddress("0xEa5abf2C909169823d939de377Ef2Bf897A6CE98"),
L2HopBridgeToken: common.HexToAddress("0xB76e673EBC922b1E8f10303D0d513a9E710f5c4c"),
L2AmmWrapper: common.HexToAddress("0x50a3a623d00fd8b8a4F3CbC5aa53D0Bc6FA912DD"),
L2SaddleSwap: common.HexToAddress("0xFFe42d3Ba79Ee5Ee74a999CAd0c60EF1153F0b82"),
L2SaddleLpToken: common.HexToAddress("0x163A9E12787dBFa2836caa549aE02ed67F73e7C2"),
},
421613: {
"USDC": common.HexToAddress("0x83f6244Bd87662118d96D9a6D44f09dffF14b30E"),
"ETH": common.HexToAddress("0x69a71b7F6Ff088a0310b4f911b4f9eA11e2E9740"),
},
}
var l2AmmWrapperContractAddress = map[uint64]map[string]common.Address{
10: {
"USDC": common.HexToAddress("0x2ad09850b0CA4c7c1B33f5AcD6cBAbCaB5d6e796"),
"USDT": common.HexToAddress("0x7D269D3E0d61A05a0bA976b7DBF8805bF844AF3F"),
"DAI": common.HexToAddress("0xb3C68a491608952Cb1257FC9909a537a0173b63B"),
"ETH": common.HexToAddress("0x86cA30bEF97fB651b8d866D45503684b90cb3312"),
"WBTC": common.HexToAddress("0x2A11a98e2fCF4674F30934B5166645fE6CA35F56"),
},
42161: {
"USDC": common.HexToAddress("0xe22D2beDb3Eca35E6397e0C6D62857094aA26F52"),
"USDT": common.HexToAddress("0xCB0a4177E0A60247C0ad18Be87f8eDfF6DD30283"),
"DAI": common.HexToAddress("0xe7F40BF16AB09f4a6906Ac2CAA4094aD2dA48Cc2"),
"ETH": common.HexToAddress("0x33ceb27b39d2Bb7D2e61F7564d3Df29344020417"),
"WBTC": common.HexToAddress("0xC08055b634D43F2176d721E26A3428D3b7E7DdB5"),
},
420: {
"USDC": common.HexToAddress("0xfF21e82a4Bc305BCE591530A68628192b5b6B6FD"),
"ETH": common.HexToAddress("0xC1985d7a3429cDC85E59E2E4Fcc805b857e6Ee2E"),
},
421613: {
"USDC": common.HexToAddress("0x32219766597DFbb10297127238D921E7CCF5D920"),
"ETH": common.HexToAddress("0xa832293f2DCe2f092182F17dd873ae06AD5fDbaF"),
},
func isHTokenSend() bool {
// isHTokenSend is false in Status app for now
return false
}
var l1BridgeContractAddress = map[uint64]map[string]common.Address{
1: {
"USDC": common.HexToAddress("0x3666f603Cc164936C1b87e207F36BEBa4AC5f18a"),
"USDT": common.HexToAddress("0x3666f603Cc164936C1b87e207F36BEBa4AC5f18a"),
"DAI": common.HexToAddress("0x3d4Cc8A61c7528Fd86C55cfe061a78dCBA48EDd1"),
"ETH": common.HexToAddress("0xb8901acB165ed027E32754E0FFe830802919727f"),
"WBTC": common.HexToAddress("0xb98454270065A31D71Bf635F6F7Ee6A518dFb849"),
},
5: {
"USDC": common.HexToAddress("0x7D269D3E0d61A05a0bA976b7DBF8805bF844AF3F"),
"ETH": common.HexToAddress("0xC8A4FB931e8D77df8497790381CA7d228E68a41b"),
},
func shouldUseCctpBridge(symbol string) bool {
if symbol == "USDC" {
return true
}
return symbol == "USDC.e" && isHTokenSend()
}
func L2SaddleSwapContractAddress(chainID uint64, symbol string) (common.Address, error) {
tokens, exists := l2SaddleSwapContractAddresses[chainID]
if !exists {
return *new(common.Address), errorNotAvailableOnChainID
func shouldUseAmm(symbol string) bool {
return symbol != "HOP"
}
addr, exists := tokens[symbol]
if !exists {
return *new(common.Address), errorNotAvailableOnChainID
func GetContractAddress(chainID uint64, symbol string) (addr common.Address, contractType string, err error) {
err = errorNotAvailableOnChainID
if chainID == walletCommon.EthereumMainnet ||
chainID == walletCommon.EthereumSepolia {
if shouldUseCctpBridge(symbol) {
if addr, ok := hopBridgeContractAddresses[symbol][chainID][CctpL1Bridge]; ok {
return addr, CctpL1Bridge, nil
}
return
}
return addr, nil
if addr, ok := hopBridgeContractAddresses[symbol][chainID][L1Bridge]; ok {
return addr, L1Bridge, nil
}
return
}
func L2AmmWrapperContractAddress(chainID uint64, symbol string) (common.Address, error) {
tokens, exists := l2AmmWrapperContractAddress[chainID]
if !exists {
return *new(common.Address), errorNotAvailableOnChainID
if shouldUseCctpBridge(symbol) {
if addr, ok := hopBridgeContractAddresses[symbol][chainID][CctpL2Bridge]; ok {
return addr, CctpL2Bridge, nil
}
return
}
addr, exists := tokens[symbol]
if !exists {
return *new(common.Address), errorNotAvailableOnChainID
if isHTokenSend() || !shouldUseAmm(symbol) {
if addr, ok := hopBridgeContractAddresses[symbol][chainID][L2Bridge]; ok {
return addr, L2Bridge, nil
}
return
}
return addr, nil
if addr, ok := hopBridgeContractAddresses[symbol][chainID][L2AmmWrapper]; ok {
return addr, L2AmmWrapper, nil
}
func L1BridgeContractAddress(chainID uint64, symbol string) (common.Address, error) {
tokens, exists := l1BridgeContractAddress[chainID]
if !exists {
return *new(common.Address), errorNotAvailableOnChainID
}
addr, exists := tokens[symbol]
if !exists {
return *new(common.Address), errorNotAvailableOnChainID
}
return addr, nil
return
}

View File

@ -0,0 +1,552 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package hopL1CctpImplementation
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
_ = abi.ConvertType
)
// HopL1CctpImplementationMetaData contains all meta data concerning the HopL1CctpImplementation contract.
var HopL1CctpImplementationMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cctpAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeCollectorAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minBonderFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"chainIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint32[]\",\"name\":\"domains\",\"type\":\"uint32[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"cctpNonce\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"}],\"name\":\"CCTPTransferSent\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"activeChainIds\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cctp\",\"outputs\":[{\"internalType\":\"contractICCTP\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"destinationDomains\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeCollectorAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minBonderFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nativeToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"}],\"name\":\"send\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
}
// HopL1CctpImplementationABI is the input ABI used to generate the binding from.
// Deprecated: Use HopL1CctpImplementationMetaData.ABI instead.
var HopL1CctpImplementationABI = HopL1CctpImplementationMetaData.ABI
// HopL1CctpImplementation is an auto generated Go binding around an Ethereum contract.
type HopL1CctpImplementation struct {
HopL1CctpImplementationCaller // Read-only binding to the contract
HopL1CctpImplementationTransactor // Write-only binding to the contract
HopL1CctpImplementationFilterer // Log filterer for contract events
}
// HopL1CctpImplementationCaller is an auto generated read-only Go binding around an Ethereum contract.
type HopL1CctpImplementationCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL1CctpImplementationTransactor is an auto generated write-only Go binding around an Ethereum contract.
type HopL1CctpImplementationTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL1CctpImplementationFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type HopL1CctpImplementationFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL1CctpImplementationSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type HopL1CctpImplementationSession struct {
Contract *HopL1CctpImplementation // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopL1CctpImplementationCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type HopL1CctpImplementationCallerSession struct {
Contract *HopL1CctpImplementationCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// HopL1CctpImplementationTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type HopL1CctpImplementationTransactorSession struct {
Contract *HopL1CctpImplementationTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopL1CctpImplementationRaw is an auto generated low-level Go binding around an Ethereum contract.
type HopL1CctpImplementationRaw struct {
Contract *HopL1CctpImplementation // Generic contract binding to access the raw methods on
}
// HopL1CctpImplementationCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type HopL1CctpImplementationCallerRaw struct {
Contract *HopL1CctpImplementationCaller // Generic read-only contract binding to access the raw methods on
}
// HopL1CctpImplementationTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type HopL1CctpImplementationTransactorRaw struct {
Contract *HopL1CctpImplementationTransactor // Generic write-only contract binding to access the raw methods on
}
// NewHopL1CctpImplementation creates a new instance of HopL1CctpImplementation, bound to a specific deployed contract.
func NewHopL1CctpImplementation(address common.Address, backend bind.ContractBackend) (*HopL1CctpImplementation, error) {
contract, err := bindHopL1CctpImplementation(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &HopL1CctpImplementation{HopL1CctpImplementationCaller: HopL1CctpImplementationCaller{contract: contract}, HopL1CctpImplementationTransactor: HopL1CctpImplementationTransactor{contract: contract}, HopL1CctpImplementationFilterer: HopL1CctpImplementationFilterer{contract: contract}}, nil
}
// NewHopL1CctpImplementationCaller creates a new read-only instance of HopL1CctpImplementation, bound to a specific deployed contract.
func NewHopL1CctpImplementationCaller(address common.Address, caller bind.ContractCaller) (*HopL1CctpImplementationCaller, error) {
contract, err := bindHopL1CctpImplementation(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &HopL1CctpImplementationCaller{contract: contract}, nil
}
// NewHopL1CctpImplementationTransactor creates a new write-only instance of HopL1CctpImplementation, bound to a specific deployed contract.
func NewHopL1CctpImplementationTransactor(address common.Address, transactor bind.ContractTransactor) (*HopL1CctpImplementationTransactor, error) {
contract, err := bindHopL1CctpImplementation(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &HopL1CctpImplementationTransactor{contract: contract}, nil
}
// NewHopL1CctpImplementationFilterer creates a new log filterer instance of HopL1CctpImplementation, bound to a specific deployed contract.
func NewHopL1CctpImplementationFilterer(address common.Address, filterer bind.ContractFilterer) (*HopL1CctpImplementationFilterer, error) {
contract, err := bindHopL1CctpImplementation(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &HopL1CctpImplementationFilterer{contract: contract}, nil
}
// bindHopL1CctpImplementation binds a generic wrapper to an already deployed contract.
func bindHopL1CctpImplementation(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := HopL1CctpImplementationMetaData.GetAbi()
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopL1CctpImplementation *HopL1CctpImplementationRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopL1CctpImplementation.Contract.HopL1CctpImplementationCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopL1CctpImplementation *HopL1CctpImplementationRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL1CctpImplementation.Contract.HopL1CctpImplementationTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopL1CctpImplementation *HopL1CctpImplementationRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopL1CctpImplementation.Contract.HopL1CctpImplementationTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopL1CctpImplementation.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopL1CctpImplementation *HopL1CctpImplementationTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL1CctpImplementation.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopL1CctpImplementation *HopL1CctpImplementationTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopL1CctpImplementation.Contract.contract.Transact(opts, method, params...)
}
// ActiveChainIds is a free data retrieval call binding the contract method 0xc97d172e.
//
// Solidity: function activeChainIds(uint256 ) view returns(bool)
func (_HopL1CctpImplementation *HopL1CctpImplementationCaller) ActiveChainIds(opts *bind.CallOpts, arg0 *big.Int) (bool, error) {
var out []interface{}
err := _HopL1CctpImplementation.contract.Call(opts, &out, "activeChainIds", arg0)
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// ActiveChainIds is a free data retrieval call binding the contract method 0xc97d172e.
//
// Solidity: function activeChainIds(uint256 ) view returns(bool)
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) ActiveChainIds(arg0 *big.Int) (bool, error) {
return _HopL1CctpImplementation.Contract.ActiveChainIds(&_HopL1CctpImplementation.CallOpts, arg0)
}
// ActiveChainIds is a free data retrieval call binding the contract method 0xc97d172e.
//
// Solidity: function activeChainIds(uint256 ) view returns(bool)
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerSession) ActiveChainIds(arg0 *big.Int) (bool, error) {
return _HopL1CctpImplementation.Contract.ActiveChainIds(&_HopL1CctpImplementation.CallOpts, arg0)
}
// Cctp is a free data retrieval call binding the contract method 0xe3329e32.
//
// Solidity: function cctp() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationCaller) Cctp(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL1CctpImplementation.contract.Call(opts, &out, "cctp")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Cctp is a free data retrieval call binding the contract method 0xe3329e32.
//
// Solidity: function cctp() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) Cctp() (common.Address, error) {
return _HopL1CctpImplementation.Contract.Cctp(&_HopL1CctpImplementation.CallOpts)
}
// Cctp is a free data retrieval call binding the contract method 0xe3329e32.
//
// Solidity: function cctp() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerSession) Cctp() (common.Address, error) {
return _HopL1CctpImplementation.Contract.Cctp(&_HopL1CctpImplementation.CallOpts)
}
// DestinationDomains is a free data retrieval call binding the contract method 0x89aad5dc.
//
// Solidity: function destinationDomains(uint256 ) view returns(uint32)
func (_HopL1CctpImplementation *HopL1CctpImplementationCaller) DestinationDomains(opts *bind.CallOpts, arg0 *big.Int) (uint32, error) {
var out []interface{}
err := _HopL1CctpImplementation.contract.Call(opts, &out, "destinationDomains", arg0)
if err != nil {
return *new(uint32), err
}
out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32)
return out0, err
}
// DestinationDomains is a free data retrieval call binding the contract method 0x89aad5dc.
//
// Solidity: function destinationDomains(uint256 ) view returns(uint32)
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) DestinationDomains(arg0 *big.Int) (uint32, error) {
return _HopL1CctpImplementation.Contract.DestinationDomains(&_HopL1CctpImplementation.CallOpts, arg0)
}
// DestinationDomains is a free data retrieval call binding the contract method 0x89aad5dc.
//
// Solidity: function destinationDomains(uint256 ) view returns(uint32)
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerSession) DestinationDomains(arg0 *big.Int) (uint32, error) {
return _HopL1CctpImplementation.Contract.DestinationDomains(&_HopL1CctpImplementation.CallOpts, arg0)
}
// FeeCollectorAddress is a free data retrieval call binding the contract method 0xf108e225.
//
// Solidity: function feeCollectorAddress() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationCaller) FeeCollectorAddress(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL1CctpImplementation.contract.Call(opts, &out, "feeCollectorAddress")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// FeeCollectorAddress is a free data retrieval call binding the contract method 0xf108e225.
//
// Solidity: function feeCollectorAddress() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) FeeCollectorAddress() (common.Address, error) {
return _HopL1CctpImplementation.Contract.FeeCollectorAddress(&_HopL1CctpImplementation.CallOpts)
}
// FeeCollectorAddress is a free data retrieval call binding the contract method 0xf108e225.
//
// Solidity: function feeCollectorAddress() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerSession) FeeCollectorAddress() (common.Address, error) {
return _HopL1CctpImplementation.Contract.FeeCollectorAddress(&_HopL1CctpImplementation.CallOpts)
}
// MinBonderFee is a free data retrieval call binding the contract method 0x50fc2401.
//
// Solidity: function minBonderFee() view returns(uint256)
func (_HopL1CctpImplementation *HopL1CctpImplementationCaller) MinBonderFee(opts *bind.CallOpts) (*big.Int, error) {
var out []interface{}
err := _HopL1CctpImplementation.contract.Call(opts, &out, "minBonderFee")
if err != nil {
return *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
return out0, err
}
// MinBonderFee is a free data retrieval call binding the contract method 0x50fc2401.
//
// Solidity: function minBonderFee() view returns(uint256)
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) MinBonderFee() (*big.Int, error) {
return _HopL1CctpImplementation.Contract.MinBonderFee(&_HopL1CctpImplementation.CallOpts)
}
// MinBonderFee is a free data retrieval call binding the contract method 0x50fc2401.
//
// Solidity: function minBonderFee() view returns(uint256)
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerSession) MinBonderFee() (*big.Int, error) {
return _HopL1CctpImplementation.Contract.MinBonderFee(&_HopL1CctpImplementation.CallOpts)
}
// NativeToken is a free data retrieval call binding the contract method 0xe1758bd8.
//
// Solidity: function nativeToken() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationCaller) NativeToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL1CctpImplementation.contract.Call(opts, &out, "nativeToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// NativeToken is a free data retrieval call binding the contract method 0xe1758bd8.
//
// Solidity: function nativeToken() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) NativeToken() (common.Address, error) {
return _HopL1CctpImplementation.Contract.NativeToken(&_HopL1CctpImplementation.CallOpts)
}
// NativeToken is a free data retrieval call binding the contract method 0xe1758bd8.
//
// Solidity: function nativeToken() view returns(address)
func (_HopL1CctpImplementation *HopL1CctpImplementationCallerSession) NativeToken() (common.Address, error) {
return _HopL1CctpImplementation.Contract.NativeToken(&_HopL1CctpImplementation.CallOpts)
}
// Send is a paid mutator transaction binding the contract method 0xa134ce5b.
//
// Solidity: function send(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee) returns()
func (_HopL1CctpImplementation *HopL1CctpImplementationTransactor) Send(opts *bind.TransactOpts, chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int) (*types.Transaction, error) {
return _HopL1CctpImplementation.contract.Transact(opts, "send", chainId, recipient, amount, bonderFee)
}
// Send is a paid mutator transaction binding the contract method 0xa134ce5b.
//
// Solidity: function send(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee) returns()
func (_HopL1CctpImplementation *HopL1CctpImplementationSession) Send(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int) (*types.Transaction, error) {
return _HopL1CctpImplementation.Contract.Send(&_HopL1CctpImplementation.TransactOpts, chainId, recipient, amount, bonderFee)
}
// Send is a paid mutator transaction binding the contract method 0xa134ce5b.
//
// Solidity: function send(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee) returns()
func (_HopL1CctpImplementation *HopL1CctpImplementationTransactorSession) Send(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int) (*types.Transaction, error) {
return _HopL1CctpImplementation.Contract.Send(&_HopL1CctpImplementation.TransactOpts, chainId, recipient, amount, bonderFee)
}
// HopL1CctpImplementationCCTPTransferSentIterator is returned from FilterCCTPTransferSent and is used to iterate over the raw logs and unpacked data for CCTPTransferSent events raised by the HopL1CctpImplementation contract.
type HopL1CctpImplementationCCTPTransferSentIterator struct {
Event *HopL1CctpImplementationCCTPTransferSent // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *HopL1CctpImplementationCCTPTransferSentIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(HopL1CctpImplementationCCTPTransferSent)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(HopL1CctpImplementationCCTPTransferSent)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *HopL1CctpImplementationCCTPTransferSentIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *HopL1CctpImplementationCCTPTransferSentIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// HopL1CctpImplementationCCTPTransferSent represents a CCTPTransferSent event raised by the HopL1CctpImplementation contract.
type HopL1CctpImplementationCCTPTransferSent struct {
CctpNonce uint64
ChainId *big.Int
Recipient common.Address
Amount *big.Int
BonderFee *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterCCTPTransferSent is a free log retrieval operation binding the contract event 0x10bf4019e09db5876a05d237bfcc676cd84eee2c23f820284906dd7cfa70d2c4.
//
// Solidity: event CCTPTransferSent(uint64 indexed cctpNonce, uint256 indexed chainId, address indexed recipient, uint256 amount, uint256 bonderFee)
func (_HopL1CctpImplementation *HopL1CctpImplementationFilterer) FilterCCTPTransferSent(opts *bind.FilterOpts, cctpNonce []uint64, chainId []*big.Int, recipient []common.Address) (*HopL1CctpImplementationCCTPTransferSentIterator, error) {
var cctpNonceRule []interface{}
for _, cctpNonceItem := range cctpNonce {
cctpNonceRule = append(cctpNonceRule, cctpNonceItem)
}
var chainIdRule []interface{}
for _, chainIdItem := range chainId {
chainIdRule = append(chainIdRule, chainIdItem)
}
var recipientRule []interface{}
for _, recipientItem := range recipient {
recipientRule = append(recipientRule, recipientItem)
}
logs, sub, err := _HopL1CctpImplementation.contract.FilterLogs(opts, "CCTPTransferSent", cctpNonceRule, chainIdRule, recipientRule)
if err != nil {
return nil, err
}
return &HopL1CctpImplementationCCTPTransferSentIterator{contract: _HopL1CctpImplementation.contract, event: "CCTPTransferSent", logs: logs, sub: sub}, nil
}
// WatchCCTPTransferSent is a free log subscription operation binding the contract event 0x10bf4019e09db5876a05d237bfcc676cd84eee2c23f820284906dd7cfa70d2c4.
//
// Solidity: event CCTPTransferSent(uint64 indexed cctpNonce, uint256 indexed chainId, address indexed recipient, uint256 amount, uint256 bonderFee)
func (_HopL1CctpImplementation *HopL1CctpImplementationFilterer) WatchCCTPTransferSent(opts *bind.WatchOpts, sink chan<- *HopL1CctpImplementationCCTPTransferSent, cctpNonce []uint64, chainId []*big.Int, recipient []common.Address) (event.Subscription, error) {
var cctpNonceRule []interface{}
for _, cctpNonceItem := range cctpNonce {
cctpNonceRule = append(cctpNonceRule, cctpNonceItem)
}
var chainIdRule []interface{}
for _, chainIdItem := range chainId {
chainIdRule = append(chainIdRule, chainIdItem)
}
var recipientRule []interface{}
for _, recipientItem := range recipient {
recipientRule = append(recipientRule, recipientItem)
}
logs, sub, err := _HopL1CctpImplementation.contract.WatchLogs(opts, "CCTPTransferSent", cctpNonceRule, chainIdRule, recipientRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(HopL1CctpImplementationCCTPTransferSent)
if err := _HopL1CctpImplementation.contract.UnpackLog(event, "CCTPTransferSent", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseCCTPTransferSent is a log parse operation binding the contract event 0x10bf4019e09db5876a05d237bfcc676cd84eee2c23f820284906dd7cfa70d2c4.
//
// Solidity: event CCTPTransferSent(uint64 indexed cctpNonce, uint256 indexed chainId, address indexed recipient, uint256 amount, uint256 bonderFee)
func (_HopL1CctpImplementation *HopL1CctpImplementationFilterer) ParseCCTPTransferSent(log types.Log) (*HopL1CctpImplementationCCTPTransferSent, error) {
event := new(HopL1CctpImplementationCCTPTransferSent)
if err := _HopL1CctpImplementation.contract.UnpackLog(event, "CCTPTransferSent", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,399 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package hopL2AmmWrapper
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
_ = abi.ConvertType
)
// HopL2AmmWrapperMetaData contains all meta data concerning the HopL2AmmWrapper contract.
var HopL2AmmWrapperMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[{\"internalType\":\"contractL2_Bridge\",\"name\":\"_bridge\",\"type\":\"address\"},{\"internalType\":\"contractIERC20\",\"name\":\"_l2CanonicalToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"_l2CanonicalTokenIsEth\",\"type\":\"bool\"},{\"internalType\":\"contractIERC20\",\"name\":\"_hToken\",\"type\":\"address\"},{\"internalType\":\"contractSwap\",\"name\":\"_exchangeAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"attemptSwap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contractL2_Bridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"exchangeAddress\",\"outputs\":[{\"internalType\":\"contractSwap\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"l2CanonicalToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"l2CanonicalTokenIsEth\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"destinationAmountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"destinationDeadline\",\"type\":\"uint256\"}],\"name\":\"swapAndSend\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]",
}
// HopL2AmmWrapperABI is the input ABI used to generate the binding from.
// Deprecated: Use HopL2AmmWrapperMetaData.ABI instead.
var HopL2AmmWrapperABI = HopL2AmmWrapperMetaData.ABI
// HopL2AmmWrapper is an auto generated Go binding around an Ethereum contract.
type HopL2AmmWrapper struct {
HopL2AmmWrapperCaller // Read-only binding to the contract
HopL2AmmWrapperTransactor // Write-only binding to the contract
HopL2AmmWrapperFilterer // Log filterer for contract events
}
// HopL2AmmWrapperCaller is an auto generated read-only Go binding around an Ethereum contract.
type HopL2AmmWrapperCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL2AmmWrapperTransactor is an auto generated write-only Go binding around an Ethereum contract.
type HopL2AmmWrapperTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL2AmmWrapperFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type HopL2AmmWrapperFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL2AmmWrapperSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type HopL2AmmWrapperSession struct {
Contract *HopL2AmmWrapper // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopL2AmmWrapperCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type HopL2AmmWrapperCallerSession struct {
Contract *HopL2AmmWrapperCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// HopL2AmmWrapperTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type HopL2AmmWrapperTransactorSession struct {
Contract *HopL2AmmWrapperTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopL2AmmWrapperRaw is an auto generated low-level Go binding around an Ethereum contract.
type HopL2AmmWrapperRaw struct {
Contract *HopL2AmmWrapper // Generic contract binding to access the raw methods on
}
// HopL2AmmWrapperCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type HopL2AmmWrapperCallerRaw struct {
Contract *HopL2AmmWrapperCaller // Generic read-only contract binding to access the raw methods on
}
// HopL2AmmWrapperTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type HopL2AmmWrapperTransactorRaw struct {
Contract *HopL2AmmWrapperTransactor // Generic write-only contract binding to access the raw methods on
}
// NewHopL2AmmWrapper creates a new instance of HopL2AmmWrapper, bound to a specific deployed contract.
func NewHopL2AmmWrapper(address common.Address, backend bind.ContractBackend) (*HopL2AmmWrapper, error) {
contract, err := bindHopL2AmmWrapper(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &HopL2AmmWrapper{HopL2AmmWrapperCaller: HopL2AmmWrapperCaller{contract: contract}, HopL2AmmWrapperTransactor: HopL2AmmWrapperTransactor{contract: contract}, HopL2AmmWrapperFilterer: HopL2AmmWrapperFilterer{contract: contract}}, nil
}
// NewHopL2AmmWrapperCaller creates a new read-only instance of HopL2AmmWrapper, bound to a specific deployed contract.
func NewHopL2AmmWrapperCaller(address common.Address, caller bind.ContractCaller) (*HopL2AmmWrapperCaller, error) {
contract, err := bindHopL2AmmWrapper(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &HopL2AmmWrapperCaller{contract: contract}, nil
}
// NewHopL2AmmWrapperTransactor creates a new write-only instance of HopL2AmmWrapper, bound to a specific deployed contract.
func NewHopL2AmmWrapperTransactor(address common.Address, transactor bind.ContractTransactor) (*HopL2AmmWrapperTransactor, error) {
contract, err := bindHopL2AmmWrapper(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &HopL2AmmWrapperTransactor{contract: contract}, nil
}
// NewHopL2AmmWrapperFilterer creates a new log filterer instance of HopL2AmmWrapper, bound to a specific deployed contract.
func NewHopL2AmmWrapperFilterer(address common.Address, filterer bind.ContractFilterer) (*HopL2AmmWrapperFilterer, error) {
contract, err := bindHopL2AmmWrapper(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &HopL2AmmWrapperFilterer{contract: contract}, nil
}
// bindHopL2AmmWrapper binds a generic wrapper to an already deployed contract.
func bindHopL2AmmWrapper(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := HopL2AmmWrapperMetaData.GetAbi()
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopL2AmmWrapper *HopL2AmmWrapperRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopL2AmmWrapper.Contract.HopL2AmmWrapperCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopL2AmmWrapper *HopL2AmmWrapperRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.HopL2AmmWrapperTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopL2AmmWrapper *HopL2AmmWrapperRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.HopL2AmmWrapperTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopL2AmmWrapper *HopL2AmmWrapperCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopL2AmmWrapper.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.contract.Transact(opts, method, params...)
}
// Bridge is a free data retrieval call binding the contract method 0xe78cea92.
//
// Solidity: function bridge() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCaller) Bridge(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2AmmWrapper.contract.Call(opts, &out, "bridge")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Bridge is a free data retrieval call binding the contract method 0xe78cea92.
//
// Solidity: function bridge() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) Bridge() (common.Address, error) {
return _HopL2AmmWrapper.Contract.Bridge(&_HopL2AmmWrapper.CallOpts)
}
// Bridge is a free data retrieval call binding the contract method 0xe78cea92.
//
// Solidity: function bridge() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCallerSession) Bridge() (common.Address, error) {
return _HopL2AmmWrapper.Contract.Bridge(&_HopL2AmmWrapper.CallOpts)
}
// ExchangeAddress is a free data retrieval call binding the contract method 0x9cd01605.
//
// Solidity: function exchangeAddress() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCaller) ExchangeAddress(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2AmmWrapper.contract.Call(opts, &out, "exchangeAddress")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// ExchangeAddress is a free data retrieval call binding the contract method 0x9cd01605.
//
// Solidity: function exchangeAddress() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) ExchangeAddress() (common.Address, error) {
return _HopL2AmmWrapper.Contract.ExchangeAddress(&_HopL2AmmWrapper.CallOpts)
}
// ExchangeAddress is a free data retrieval call binding the contract method 0x9cd01605.
//
// Solidity: function exchangeAddress() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCallerSession) ExchangeAddress() (common.Address, error) {
return _HopL2AmmWrapper.Contract.ExchangeAddress(&_HopL2AmmWrapper.CallOpts)
}
// HToken is a free data retrieval call binding the contract method 0xfc6e3b3b.
//
// Solidity: function hToken() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCaller) HToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2AmmWrapper.contract.Call(opts, &out, "hToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// HToken is a free data retrieval call binding the contract method 0xfc6e3b3b.
//
// Solidity: function hToken() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) HToken() (common.Address, error) {
return _HopL2AmmWrapper.Contract.HToken(&_HopL2AmmWrapper.CallOpts)
}
// HToken is a free data retrieval call binding the contract method 0xfc6e3b3b.
//
// Solidity: function hToken() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCallerSession) HToken() (common.Address, error) {
return _HopL2AmmWrapper.Contract.HToken(&_HopL2AmmWrapper.CallOpts)
}
// L2CanonicalToken is a free data retrieval call binding the contract method 0x1ee1bf67.
//
// Solidity: function l2CanonicalToken() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCaller) L2CanonicalToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2AmmWrapper.contract.Call(opts, &out, "l2CanonicalToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// L2CanonicalToken is a free data retrieval call binding the contract method 0x1ee1bf67.
//
// Solidity: function l2CanonicalToken() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) L2CanonicalToken() (common.Address, error) {
return _HopL2AmmWrapper.Contract.L2CanonicalToken(&_HopL2AmmWrapper.CallOpts)
}
// L2CanonicalToken is a free data retrieval call binding the contract method 0x1ee1bf67.
//
// Solidity: function l2CanonicalToken() view returns(address)
func (_HopL2AmmWrapper *HopL2AmmWrapperCallerSession) L2CanonicalToken() (common.Address, error) {
return _HopL2AmmWrapper.Contract.L2CanonicalToken(&_HopL2AmmWrapper.CallOpts)
}
// L2CanonicalTokenIsEth is a free data retrieval call binding the contract method 0x28555125.
//
// Solidity: function l2CanonicalTokenIsEth() view returns(bool)
func (_HopL2AmmWrapper *HopL2AmmWrapperCaller) L2CanonicalTokenIsEth(opts *bind.CallOpts) (bool, error) {
var out []interface{}
err := _HopL2AmmWrapper.contract.Call(opts, &out, "l2CanonicalTokenIsEth")
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// L2CanonicalTokenIsEth is a free data retrieval call binding the contract method 0x28555125.
//
// Solidity: function l2CanonicalTokenIsEth() view returns(bool)
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) L2CanonicalTokenIsEth() (bool, error) {
return _HopL2AmmWrapper.Contract.L2CanonicalTokenIsEth(&_HopL2AmmWrapper.CallOpts)
}
// L2CanonicalTokenIsEth is a free data retrieval call binding the contract method 0x28555125.
//
// Solidity: function l2CanonicalTokenIsEth() view returns(bool)
func (_HopL2AmmWrapper *HopL2AmmWrapperCallerSession) L2CanonicalTokenIsEth() (bool, error) {
return _HopL2AmmWrapper.Contract.L2CanonicalTokenIsEth(&_HopL2AmmWrapper.CallOpts)
}
// AttemptSwap is a paid mutator transaction binding the contract method 0x676c5ef6.
//
// Solidity: function attemptSwap(address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline) returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactor) AttemptSwap(opts *bind.TransactOpts, recipient common.Address, amount *big.Int, amountOutMin *big.Int, deadline *big.Int) (*types.Transaction, error) {
return _HopL2AmmWrapper.contract.Transact(opts, "attemptSwap", recipient, amount, amountOutMin, deadline)
}
// AttemptSwap is a paid mutator transaction binding the contract method 0x676c5ef6.
//
// Solidity: function attemptSwap(address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline) returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) AttemptSwap(recipient common.Address, amount *big.Int, amountOutMin *big.Int, deadline *big.Int) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.AttemptSwap(&_HopL2AmmWrapper.TransactOpts, recipient, amount, amountOutMin, deadline)
}
// AttemptSwap is a paid mutator transaction binding the contract method 0x676c5ef6.
//
// Solidity: function attemptSwap(address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline) returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactorSession) AttemptSwap(recipient common.Address, amount *big.Int, amountOutMin *big.Int, deadline *big.Int) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.AttemptSwap(&_HopL2AmmWrapper.TransactOpts, recipient, amount, amountOutMin, deadline)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0xeea0d7b2.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, uint256 amountOutMin, uint256 deadline, uint256 destinationAmountOutMin, uint256 destinationDeadline) payable returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactor) SwapAndSend(opts *bind.TransactOpts, chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, amountOutMin *big.Int, deadline *big.Int, destinationAmountOutMin *big.Int, destinationDeadline *big.Int) (*types.Transaction, error) {
return _HopL2AmmWrapper.contract.Transact(opts, "swapAndSend", chainId, recipient, amount, bonderFee, amountOutMin, deadline, destinationAmountOutMin, destinationDeadline)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0xeea0d7b2.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, uint256 amountOutMin, uint256 deadline, uint256 destinationAmountOutMin, uint256 destinationDeadline) payable returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) SwapAndSend(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, amountOutMin *big.Int, deadline *big.Int, destinationAmountOutMin *big.Int, destinationDeadline *big.Int) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.SwapAndSend(&_HopL2AmmWrapper.TransactOpts, chainId, recipient, amount, bonderFee, amountOutMin, deadline, destinationAmountOutMin, destinationDeadline)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0xeea0d7b2.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, uint256 amountOutMin, uint256 deadline, uint256 destinationAmountOutMin, uint256 destinationDeadline) payable returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactorSession) SwapAndSend(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, amountOutMin *big.Int, deadline *big.Int, destinationAmountOutMin *big.Int, destinationDeadline *big.Int) (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.SwapAndSend(&_HopL2AmmWrapper.TransactOpts, chainId, recipient, amount, bonderFee, amountOutMin, deadline, destinationAmountOutMin, destinationDeadline)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL2AmmWrapper.contract.RawTransact(opts, nil) // calldata is disallowed for receive function
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperSession) Receive() (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.Receive(&_HopL2AmmWrapper.TransactOpts)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_HopL2AmmWrapper *HopL2AmmWrapperTransactorSession) Receive() (*types.Transaction, error) {
return _HopL2AmmWrapper.Contract.Receive(&_HopL2AmmWrapper.TransactOpts)
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,643 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package hopL2CctpImplementation
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
_ = abi.ConvertType
)
// IAMMExactInputParams is an auto generated low-level Go binding around an user-defined struct.
type IAMMExactInputParams struct {
Path []byte
Recipient common.Address
AmountIn *big.Int
AmountOutMinimum *big.Int
}
// HopL2CctpImplementationMetaData contains all meta data concerning the HopL2CctpImplementation contract.
var HopL2CctpImplementationMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"nativeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"cctpAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeCollectorAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minBonderFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"chainIds\",\"type\":\"uint256[]\"},{\"internalType\":\"uint32[]\",\"name\":\"domains\",\"type\":\"uint32[]\"},{\"internalType\":\"address\",\"name\":\"bridgedTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"ammAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"cctpNonce\",\"type\":\"uint64\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"}],\"name\":\"CCTPTransferSent\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"activeChainIds\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"amm\",\"outputs\":[{\"internalType\":\"contractIAMM\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridgedToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cctp\",\"outputs\":[{\"internalType\":\"contractICCTP\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"destinationDomains\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeCollectorAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minBonderFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nativeToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"}],\"name\":\"send\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMinimum\",\"type\":\"uint256\"}],\"internalType\":\"structIAMM.ExactInputParams\",\"name\":\"swapParams\",\"type\":\"tuple\"}],\"name\":\"swapAndSend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
}
// HopL2CctpImplementationABI is the input ABI used to generate the binding from.
// Deprecated: Use HopL2CctpImplementationMetaData.ABI instead.
var HopL2CctpImplementationABI = HopL2CctpImplementationMetaData.ABI
// HopL2CctpImplementation is an auto generated Go binding around an Ethereum contract.
type HopL2CctpImplementation struct {
HopL2CctpImplementationCaller // Read-only binding to the contract
HopL2CctpImplementationTransactor // Write-only binding to the contract
HopL2CctpImplementationFilterer // Log filterer for contract events
}
// HopL2CctpImplementationCaller is an auto generated read-only Go binding around an Ethereum contract.
type HopL2CctpImplementationCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL2CctpImplementationTransactor is an auto generated write-only Go binding around an Ethereum contract.
type HopL2CctpImplementationTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL2CctpImplementationFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type HopL2CctpImplementationFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopL2CctpImplementationSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type HopL2CctpImplementationSession struct {
Contract *HopL2CctpImplementation // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopL2CctpImplementationCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type HopL2CctpImplementationCallerSession struct {
Contract *HopL2CctpImplementationCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// HopL2CctpImplementationTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type HopL2CctpImplementationTransactorSession struct {
Contract *HopL2CctpImplementationTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopL2CctpImplementationRaw is an auto generated low-level Go binding around an Ethereum contract.
type HopL2CctpImplementationRaw struct {
Contract *HopL2CctpImplementation // Generic contract binding to access the raw methods on
}
// HopL2CctpImplementationCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type HopL2CctpImplementationCallerRaw struct {
Contract *HopL2CctpImplementationCaller // Generic read-only contract binding to access the raw methods on
}
// HopL2CctpImplementationTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type HopL2CctpImplementationTransactorRaw struct {
Contract *HopL2CctpImplementationTransactor // Generic write-only contract binding to access the raw methods on
}
// NewHopL2CctpImplementation creates a new instance of HopL2CctpImplementation, bound to a specific deployed contract.
func NewHopL2CctpImplementation(address common.Address, backend bind.ContractBackend) (*HopL2CctpImplementation, error) {
contract, err := bindHopL2CctpImplementation(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &HopL2CctpImplementation{HopL2CctpImplementationCaller: HopL2CctpImplementationCaller{contract: contract}, HopL2CctpImplementationTransactor: HopL2CctpImplementationTransactor{contract: contract}, HopL2CctpImplementationFilterer: HopL2CctpImplementationFilterer{contract: contract}}, nil
}
// NewHopL2CctpImplementationCaller creates a new read-only instance of HopL2CctpImplementation, bound to a specific deployed contract.
func NewHopL2CctpImplementationCaller(address common.Address, caller bind.ContractCaller) (*HopL2CctpImplementationCaller, error) {
contract, err := bindHopL2CctpImplementation(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &HopL2CctpImplementationCaller{contract: contract}, nil
}
// NewHopL2CctpImplementationTransactor creates a new write-only instance of HopL2CctpImplementation, bound to a specific deployed contract.
func NewHopL2CctpImplementationTransactor(address common.Address, transactor bind.ContractTransactor) (*HopL2CctpImplementationTransactor, error) {
contract, err := bindHopL2CctpImplementation(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &HopL2CctpImplementationTransactor{contract: contract}, nil
}
// NewHopL2CctpImplementationFilterer creates a new log filterer instance of HopL2CctpImplementation, bound to a specific deployed contract.
func NewHopL2CctpImplementationFilterer(address common.Address, filterer bind.ContractFilterer) (*HopL2CctpImplementationFilterer, error) {
contract, err := bindHopL2CctpImplementation(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &HopL2CctpImplementationFilterer{contract: contract}, nil
}
// bindHopL2CctpImplementation binds a generic wrapper to an already deployed contract.
func bindHopL2CctpImplementation(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := HopL2CctpImplementationMetaData.GetAbi()
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopL2CctpImplementation *HopL2CctpImplementationRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopL2CctpImplementation.Contract.HopL2CctpImplementationCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopL2CctpImplementation *HopL2CctpImplementationRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.HopL2CctpImplementationTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopL2CctpImplementation *HopL2CctpImplementationRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.HopL2CctpImplementationTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopL2CctpImplementation.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopL2CctpImplementation *HopL2CctpImplementationTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopL2CctpImplementation *HopL2CctpImplementationTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.contract.Transact(opts, method, params...)
}
// ActiveChainIds is a free data retrieval call binding the contract method 0xc97d172e.
//
// Solidity: function activeChainIds(uint256 ) view returns(bool)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) ActiveChainIds(opts *bind.CallOpts, arg0 *big.Int) (bool, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "activeChainIds", arg0)
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// ActiveChainIds is a free data retrieval call binding the contract method 0xc97d172e.
//
// Solidity: function activeChainIds(uint256 ) view returns(bool)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) ActiveChainIds(arg0 *big.Int) (bool, error) {
return _HopL2CctpImplementation.Contract.ActiveChainIds(&_HopL2CctpImplementation.CallOpts, arg0)
}
// ActiveChainIds is a free data retrieval call binding the contract method 0xc97d172e.
//
// Solidity: function activeChainIds(uint256 ) view returns(bool)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) ActiveChainIds(arg0 *big.Int) (bool, error) {
return _HopL2CctpImplementation.Contract.ActiveChainIds(&_HopL2CctpImplementation.CallOpts, arg0)
}
// Amm is a free data retrieval call binding the contract method 0x2a943945.
//
// Solidity: function amm() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) Amm(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "amm")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Amm is a free data retrieval call binding the contract method 0x2a943945.
//
// Solidity: function amm() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) Amm() (common.Address, error) {
return _HopL2CctpImplementation.Contract.Amm(&_HopL2CctpImplementation.CallOpts)
}
// Amm is a free data retrieval call binding the contract method 0x2a943945.
//
// Solidity: function amm() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) Amm() (common.Address, error) {
return _HopL2CctpImplementation.Contract.Amm(&_HopL2CctpImplementation.CallOpts)
}
// BridgedToken is a free data retrieval call binding the contract method 0xee383937.
//
// Solidity: function bridgedToken() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) BridgedToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "bridgedToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// BridgedToken is a free data retrieval call binding the contract method 0xee383937.
//
// Solidity: function bridgedToken() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) BridgedToken() (common.Address, error) {
return _HopL2CctpImplementation.Contract.BridgedToken(&_HopL2CctpImplementation.CallOpts)
}
// BridgedToken is a free data retrieval call binding the contract method 0xee383937.
//
// Solidity: function bridgedToken() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) BridgedToken() (common.Address, error) {
return _HopL2CctpImplementation.Contract.BridgedToken(&_HopL2CctpImplementation.CallOpts)
}
// Cctp is a free data retrieval call binding the contract method 0xe3329e32.
//
// Solidity: function cctp() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) Cctp(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "cctp")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Cctp is a free data retrieval call binding the contract method 0xe3329e32.
//
// Solidity: function cctp() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) Cctp() (common.Address, error) {
return _HopL2CctpImplementation.Contract.Cctp(&_HopL2CctpImplementation.CallOpts)
}
// Cctp is a free data retrieval call binding the contract method 0xe3329e32.
//
// Solidity: function cctp() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) Cctp() (common.Address, error) {
return _HopL2CctpImplementation.Contract.Cctp(&_HopL2CctpImplementation.CallOpts)
}
// DestinationDomains is a free data retrieval call binding the contract method 0x89aad5dc.
//
// Solidity: function destinationDomains(uint256 ) view returns(uint32)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) DestinationDomains(opts *bind.CallOpts, arg0 *big.Int) (uint32, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "destinationDomains", arg0)
if err != nil {
return *new(uint32), err
}
out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32)
return out0, err
}
// DestinationDomains is a free data retrieval call binding the contract method 0x89aad5dc.
//
// Solidity: function destinationDomains(uint256 ) view returns(uint32)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) DestinationDomains(arg0 *big.Int) (uint32, error) {
return _HopL2CctpImplementation.Contract.DestinationDomains(&_HopL2CctpImplementation.CallOpts, arg0)
}
// DestinationDomains is a free data retrieval call binding the contract method 0x89aad5dc.
//
// Solidity: function destinationDomains(uint256 ) view returns(uint32)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) DestinationDomains(arg0 *big.Int) (uint32, error) {
return _HopL2CctpImplementation.Contract.DestinationDomains(&_HopL2CctpImplementation.CallOpts, arg0)
}
// FeeCollectorAddress is a free data retrieval call binding the contract method 0xf108e225.
//
// Solidity: function feeCollectorAddress() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) FeeCollectorAddress(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "feeCollectorAddress")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// FeeCollectorAddress is a free data retrieval call binding the contract method 0xf108e225.
//
// Solidity: function feeCollectorAddress() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) FeeCollectorAddress() (common.Address, error) {
return _HopL2CctpImplementation.Contract.FeeCollectorAddress(&_HopL2CctpImplementation.CallOpts)
}
// FeeCollectorAddress is a free data retrieval call binding the contract method 0xf108e225.
//
// Solidity: function feeCollectorAddress() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) FeeCollectorAddress() (common.Address, error) {
return _HopL2CctpImplementation.Contract.FeeCollectorAddress(&_HopL2CctpImplementation.CallOpts)
}
// MinBonderFee is a free data retrieval call binding the contract method 0x50fc2401.
//
// Solidity: function minBonderFee() view returns(uint256)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) MinBonderFee(opts *bind.CallOpts) (*big.Int, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "minBonderFee")
if err != nil {
return *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
return out0, err
}
// MinBonderFee is a free data retrieval call binding the contract method 0x50fc2401.
//
// Solidity: function minBonderFee() view returns(uint256)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) MinBonderFee() (*big.Int, error) {
return _HopL2CctpImplementation.Contract.MinBonderFee(&_HopL2CctpImplementation.CallOpts)
}
// MinBonderFee is a free data retrieval call binding the contract method 0x50fc2401.
//
// Solidity: function minBonderFee() view returns(uint256)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) MinBonderFee() (*big.Int, error) {
return _HopL2CctpImplementation.Contract.MinBonderFee(&_HopL2CctpImplementation.CallOpts)
}
// NativeToken is a free data retrieval call binding the contract method 0xe1758bd8.
//
// Solidity: function nativeToken() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCaller) NativeToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopL2CctpImplementation.contract.Call(opts, &out, "nativeToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// NativeToken is a free data retrieval call binding the contract method 0xe1758bd8.
//
// Solidity: function nativeToken() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) NativeToken() (common.Address, error) {
return _HopL2CctpImplementation.Contract.NativeToken(&_HopL2CctpImplementation.CallOpts)
}
// NativeToken is a free data retrieval call binding the contract method 0xe1758bd8.
//
// Solidity: function nativeToken() view returns(address)
func (_HopL2CctpImplementation *HopL2CctpImplementationCallerSession) NativeToken() (common.Address, error) {
return _HopL2CctpImplementation.Contract.NativeToken(&_HopL2CctpImplementation.CallOpts)
}
// Send is a paid mutator transaction binding the contract method 0xa134ce5b.
//
// Solidity: function send(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee) returns()
func (_HopL2CctpImplementation *HopL2CctpImplementationTransactor) Send(opts *bind.TransactOpts, chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int) (*types.Transaction, error) {
return _HopL2CctpImplementation.contract.Transact(opts, "send", chainId, recipient, amount, bonderFee)
}
// Send is a paid mutator transaction binding the contract method 0xa134ce5b.
//
// Solidity: function send(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee) returns()
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) Send(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.Send(&_HopL2CctpImplementation.TransactOpts, chainId, recipient, amount, bonderFee)
}
// Send is a paid mutator transaction binding the contract method 0xa134ce5b.
//
// Solidity: function send(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee) returns()
func (_HopL2CctpImplementation *HopL2CctpImplementationTransactorSession) Send(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.Send(&_HopL2CctpImplementation.TransactOpts, chainId, recipient, amount, bonderFee)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0x070d46e4.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, (bytes,address,uint256,uint256) swapParams) returns()
func (_HopL2CctpImplementation *HopL2CctpImplementationTransactor) SwapAndSend(opts *bind.TransactOpts, chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, swapParams IAMMExactInputParams) (*types.Transaction, error) {
return _HopL2CctpImplementation.contract.Transact(opts, "swapAndSend", chainId, recipient, amount, bonderFee, swapParams)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0x070d46e4.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, (bytes,address,uint256,uint256) swapParams) returns()
func (_HopL2CctpImplementation *HopL2CctpImplementationSession) SwapAndSend(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, swapParams IAMMExactInputParams) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.SwapAndSend(&_HopL2CctpImplementation.TransactOpts, chainId, recipient, amount, bonderFee, swapParams)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0x070d46e4.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, (bytes,address,uint256,uint256) swapParams) returns()
func (_HopL2CctpImplementation *HopL2CctpImplementationTransactorSession) SwapAndSend(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, swapParams IAMMExactInputParams) (*types.Transaction, error) {
return _HopL2CctpImplementation.Contract.SwapAndSend(&_HopL2CctpImplementation.TransactOpts, chainId, recipient, amount, bonderFee, swapParams)
}
// HopL2CctpImplementationCCTPTransferSentIterator is returned from FilterCCTPTransferSent and is used to iterate over the raw logs and unpacked data for CCTPTransferSent events raised by the HopL2CctpImplementation contract.
type HopL2CctpImplementationCCTPTransferSentIterator struct {
Event *HopL2CctpImplementationCCTPTransferSent // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *HopL2CctpImplementationCCTPTransferSentIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(HopL2CctpImplementationCCTPTransferSent)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(HopL2CctpImplementationCCTPTransferSent)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *HopL2CctpImplementationCCTPTransferSentIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *HopL2CctpImplementationCCTPTransferSentIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// HopL2CctpImplementationCCTPTransferSent represents a CCTPTransferSent event raised by the HopL2CctpImplementation contract.
type HopL2CctpImplementationCCTPTransferSent struct {
CctpNonce uint64
ChainId *big.Int
Recipient common.Address
Amount *big.Int
BonderFee *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterCCTPTransferSent is a free log retrieval operation binding the contract event 0x10bf4019e09db5876a05d237bfcc676cd84eee2c23f820284906dd7cfa70d2c4.
//
// Solidity: event CCTPTransferSent(uint64 indexed cctpNonce, uint256 indexed chainId, address indexed recipient, uint256 amount, uint256 bonderFee)
func (_HopL2CctpImplementation *HopL2CctpImplementationFilterer) FilterCCTPTransferSent(opts *bind.FilterOpts, cctpNonce []uint64, chainId []*big.Int, recipient []common.Address) (*HopL2CctpImplementationCCTPTransferSentIterator, error) {
var cctpNonceRule []interface{}
for _, cctpNonceItem := range cctpNonce {
cctpNonceRule = append(cctpNonceRule, cctpNonceItem)
}
var chainIdRule []interface{}
for _, chainIdItem := range chainId {
chainIdRule = append(chainIdRule, chainIdItem)
}
var recipientRule []interface{}
for _, recipientItem := range recipient {
recipientRule = append(recipientRule, recipientItem)
}
logs, sub, err := _HopL2CctpImplementation.contract.FilterLogs(opts, "CCTPTransferSent", cctpNonceRule, chainIdRule, recipientRule)
if err != nil {
return nil, err
}
return &HopL2CctpImplementationCCTPTransferSentIterator{contract: _HopL2CctpImplementation.contract, event: "CCTPTransferSent", logs: logs, sub: sub}, nil
}
// WatchCCTPTransferSent is a free log subscription operation binding the contract event 0x10bf4019e09db5876a05d237bfcc676cd84eee2c23f820284906dd7cfa70d2c4.
//
// Solidity: event CCTPTransferSent(uint64 indexed cctpNonce, uint256 indexed chainId, address indexed recipient, uint256 amount, uint256 bonderFee)
func (_HopL2CctpImplementation *HopL2CctpImplementationFilterer) WatchCCTPTransferSent(opts *bind.WatchOpts, sink chan<- *HopL2CctpImplementationCCTPTransferSent, cctpNonce []uint64, chainId []*big.Int, recipient []common.Address) (event.Subscription, error) {
var cctpNonceRule []interface{}
for _, cctpNonceItem := range cctpNonce {
cctpNonceRule = append(cctpNonceRule, cctpNonceItem)
}
var chainIdRule []interface{}
for _, chainIdItem := range chainId {
chainIdRule = append(chainIdRule, chainIdItem)
}
var recipientRule []interface{}
for _, recipientItem := range recipient {
recipientRule = append(recipientRule, recipientItem)
}
logs, sub, err := _HopL2CctpImplementation.contract.WatchLogs(opts, "CCTPTransferSent", cctpNonceRule, chainIdRule, recipientRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(HopL2CctpImplementationCCTPTransferSent)
if err := _HopL2CctpImplementation.contract.UnpackLog(event, "CCTPTransferSent", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseCCTPTransferSent is a log parse operation binding the contract event 0x10bf4019e09db5876a05d237bfcc676cd84eee2c23f820284906dd7cfa70d2c4.
//
// Solidity: event CCTPTransferSent(uint64 indexed cctpNonce, uint256 indexed chainId, address indexed recipient, uint256 amount, uint256 bonderFee)
func (_HopL2CctpImplementation *HopL2CctpImplementationFilterer) ParseCCTPTransferSent(log types.Log) (*HopL2CctpImplementationCCTPTransferSent, error) {
event := new(HopL2CctpImplementationCCTPTransferSent)
if err := _HopL2CctpImplementation.contract.UnpackLog(event, "CCTPTransferSent", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,390 +0,0 @@
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package hopWrapper
import (
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// HopWrapperABI is the input ABI used to generate the binding from.
const HopWrapperABI = "[{\"inputs\":[{\"internalType\":\"contractL2_Bridge\",\"name\":\"_bridge\",\"type\":\"address\"},{\"internalType\":\"contractIERC20\",\"name\":\"_l2CanonicalToken\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"_l2CanonicalTokenIsEth\",\"type\":\"bool\"},{\"internalType\":\"contractIERC20\",\"name\":\"_hToken\",\"type\":\"address\"},{\"internalType\":\"contractSwap\",\"name\":\"_exchangeAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"attemptSwap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contractL2_Bridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"exchangeAddress\",\"outputs\":[{\"internalType\":\"contractSwap\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"l2CanonicalToken\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"l2CanonicalTokenIsEth\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bonderFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"destinationAmountOutMin\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"destinationDeadline\",\"type\":\"uint256\"}],\"name\":\"swapAndSend\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]"
// HopWrapper is an auto generated Go binding around an Ethereum contract.
type HopWrapper struct {
HopWrapperCaller // Read-only binding to the contract
HopWrapperTransactor // Write-only binding to the contract
HopWrapperFilterer // Log filterer for contract events
}
// HopWrapperCaller is an auto generated read-only Go binding around an Ethereum contract.
type HopWrapperCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopWrapperTransactor is an auto generated write-only Go binding around an Ethereum contract.
type HopWrapperTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopWrapperFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type HopWrapperFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// HopWrapperSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type HopWrapperSession struct {
Contract *HopWrapper // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopWrapperCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type HopWrapperCallerSession struct {
Contract *HopWrapperCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// HopWrapperTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type HopWrapperTransactorSession struct {
Contract *HopWrapperTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// HopWrapperRaw is an auto generated low-level Go binding around an Ethereum contract.
type HopWrapperRaw struct {
Contract *HopWrapper // Generic contract binding to access the raw methods on
}
// HopWrapperCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type HopWrapperCallerRaw struct {
Contract *HopWrapperCaller // Generic read-only contract binding to access the raw methods on
}
// HopWrapperTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type HopWrapperTransactorRaw struct {
Contract *HopWrapperTransactor // Generic write-only contract binding to access the raw methods on
}
// NewHopWrapper creates a new instance of HopWrapper, bound to a specific deployed contract.
func NewHopWrapper(address common.Address, backend bind.ContractBackend) (*HopWrapper, error) {
contract, err := bindHopWrapper(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &HopWrapper{HopWrapperCaller: HopWrapperCaller{contract: contract}, HopWrapperTransactor: HopWrapperTransactor{contract: contract}, HopWrapperFilterer: HopWrapperFilterer{contract: contract}}, nil
}
// NewHopWrapperCaller creates a new read-only instance of HopWrapper, bound to a specific deployed contract.
func NewHopWrapperCaller(address common.Address, caller bind.ContractCaller) (*HopWrapperCaller, error) {
contract, err := bindHopWrapper(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &HopWrapperCaller{contract: contract}, nil
}
// NewHopWrapperTransactor creates a new write-only instance of HopWrapper, bound to a specific deployed contract.
func NewHopWrapperTransactor(address common.Address, transactor bind.ContractTransactor) (*HopWrapperTransactor, error) {
contract, err := bindHopWrapper(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &HopWrapperTransactor{contract: contract}, nil
}
// NewHopWrapperFilterer creates a new log filterer instance of HopWrapper, bound to a specific deployed contract.
func NewHopWrapperFilterer(address common.Address, filterer bind.ContractFilterer) (*HopWrapperFilterer, error) {
contract, err := bindHopWrapper(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &HopWrapperFilterer{contract: contract}, nil
}
// bindHopWrapper binds a generic wrapper to an already deployed contract.
func bindHopWrapper(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(HopWrapperABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopWrapper *HopWrapperRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopWrapper.Contract.HopWrapperCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopWrapper *HopWrapperRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopWrapper.Contract.HopWrapperTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopWrapper *HopWrapperRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopWrapper.Contract.HopWrapperTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_HopWrapper *HopWrapperCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _HopWrapper.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_HopWrapper *HopWrapperTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopWrapper.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_HopWrapper *HopWrapperTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _HopWrapper.Contract.contract.Transact(opts, method, params...)
}
// Bridge is a free data retrieval call binding the contract method 0xe78cea92.
//
// Solidity: function bridge() view returns(address)
func (_HopWrapper *HopWrapperCaller) Bridge(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopWrapper.contract.Call(opts, &out, "bridge")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// Bridge is a free data retrieval call binding the contract method 0xe78cea92.
//
// Solidity: function bridge() view returns(address)
func (_HopWrapper *HopWrapperSession) Bridge() (common.Address, error) {
return _HopWrapper.Contract.Bridge(&_HopWrapper.CallOpts)
}
// Bridge is a free data retrieval call binding the contract method 0xe78cea92.
//
// Solidity: function bridge() view returns(address)
func (_HopWrapper *HopWrapperCallerSession) Bridge() (common.Address, error) {
return _HopWrapper.Contract.Bridge(&_HopWrapper.CallOpts)
}
// ExchangeAddress is a free data retrieval call binding the contract method 0x9cd01605.
//
// Solidity: function exchangeAddress() view returns(address)
func (_HopWrapper *HopWrapperCaller) ExchangeAddress(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopWrapper.contract.Call(opts, &out, "exchangeAddress")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// ExchangeAddress is a free data retrieval call binding the contract method 0x9cd01605.
//
// Solidity: function exchangeAddress() view returns(address)
func (_HopWrapper *HopWrapperSession) ExchangeAddress() (common.Address, error) {
return _HopWrapper.Contract.ExchangeAddress(&_HopWrapper.CallOpts)
}
// ExchangeAddress is a free data retrieval call binding the contract method 0x9cd01605.
//
// Solidity: function exchangeAddress() view returns(address)
func (_HopWrapper *HopWrapperCallerSession) ExchangeAddress() (common.Address, error) {
return _HopWrapper.Contract.ExchangeAddress(&_HopWrapper.CallOpts)
}
// HToken is a free data retrieval call binding the contract method 0xfc6e3b3b.
//
// Solidity: function hToken() view returns(address)
func (_HopWrapper *HopWrapperCaller) HToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopWrapper.contract.Call(opts, &out, "hToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// HToken is a free data retrieval call binding the contract method 0xfc6e3b3b.
//
// Solidity: function hToken() view returns(address)
func (_HopWrapper *HopWrapperSession) HToken() (common.Address, error) {
return _HopWrapper.Contract.HToken(&_HopWrapper.CallOpts)
}
// HToken is a free data retrieval call binding the contract method 0xfc6e3b3b.
//
// Solidity: function hToken() view returns(address)
func (_HopWrapper *HopWrapperCallerSession) HToken() (common.Address, error) {
return _HopWrapper.Contract.HToken(&_HopWrapper.CallOpts)
}
// L2CanonicalToken is a free data retrieval call binding the contract method 0x1ee1bf67.
//
// Solidity: function l2CanonicalToken() view returns(address)
func (_HopWrapper *HopWrapperCaller) L2CanonicalToken(opts *bind.CallOpts) (common.Address, error) {
var out []interface{}
err := _HopWrapper.contract.Call(opts, &out, "l2CanonicalToken")
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// L2CanonicalToken is a free data retrieval call binding the contract method 0x1ee1bf67.
//
// Solidity: function l2CanonicalToken() view returns(address)
func (_HopWrapper *HopWrapperSession) L2CanonicalToken() (common.Address, error) {
return _HopWrapper.Contract.L2CanonicalToken(&_HopWrapper.CallOpts)
}
// L2CanonicalToken is a free data retrieval call binding the contract method 0x1ee1bf67.
//
// Solidity: function l2CanonicalToken() view returns(address)
func (_HopWrapper *HopWrapperCallerSession) L2CanonicalToken() (common.Address, error) {
return _HopWrapper.Contract.L2CanonicalToken(&_HopWrapper.CallOpts)
}
// L2CanonicalTokenIsEth is a free data retrieval call binding the contract method 0x28555125.
//
// Solidity: function l2CanonicalTokenIsEth() view returns(bool)
func (_HopWrapper *HopWrapperCaller) L2CanonicalTokenIsEth(opts *bind.CallOpts) (bool, error) {
var out []interface{}
err := _HopWrapper.contract.Call(opts, &out, "l2CanonicalTokenIsEth")
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// L2CanonicalTokenIsEth is a free data retrieval call binding the contract method 0x28555125.
//
// Solidity: function l2CanonicalTokenIsEth() view returns(bool)
func (_HopWrapper *HopWrapperSession) L2CanonicalTokenIsEth() (bool, error) {
return _HopWrapper.Contract.L2CanonicalTokenIsEth(&_HopWrapper.CallOpts)
}
// L2CanonicalTokenIsEth is a free data retrieval call binding the contract method 0x28555125.
//
// Solidity: function l2CanonicalTokenIsEth() view returns(bool)
func (_HopWrapper *HopWrapperCallerSession) L2CanonicalTokenIsEth() (bool, error) {
return _HopWrapper.Contract.L2CanonicalTokenIsEth(&_HopWrapper.CallOpts)
}
// AttemptSwap is a paid mutator transaction binding the contract method 0x676c5ef6.
//
// Solidity: function attemptSwap(address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline) returns()
func (_HopWrapper *HopWrapperTransactor) AttemptSwap(opts *bind.TransactOpts, recipient common.Address, amount *big.Int, amountOutMin *big.Int, deadline *big.Int) (*types.Transaction, error) {
return _HopWrapper.contract.Transact(opts, "attemptSwap", recipient, amount, amountOutMin, deadline)
}
// AttemptSwap is a paid mutator transaction binding the contract method 0x676c5ef6.
//
// Solidity: function attemptSwap(address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline) returns()
func (_HopWrapper *HopWrapperSession) AttemptSwap(recipient common.Address, amount *big.Int, amountOutMin *big.Int, deadline *big.Int) (*types.Transaction, error) {
return _HopWrapper.Contract.AttemptSwap(&_HopWrapper.TransactOpts, recipient, amount, amountOutMin, deadline)
}
// AttemptSwap is a paid mutator transaction binding the contract method 0x676c5ef6.
//
// Solidity: function attemptSwap(address recipient, uint256 amount, uint256 amountOutMin, uint256 deadline) returns()
func (_HopWrapper *HopWrapperTransactorSession) AttemptSwap(recipient common.Address, amount *big.Int, amountOutMin *big.Int, deadline *big.Int) (*types.Transaction, error) {
return _HopWrapper.Contract.AttemptSwap(&_HopWrapper.TransactOpts, recipient, amount, amountOutMin, deadline)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0xeea0d7b2.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, uint256 amountOutMin, uint256 deadline, uint256 destinationAmountOutMin, uint256 destinationDeadline) payable returns()
func (_HopWrapper *HopWrapperTransactor) SwapAndSend(opts *bind.TransactOpts, chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, amountOutMin *big.Int, deadline *big.Int, destinationAmountOutMin *big.Int, destinationDeadline *big.Int) (*types.Transaction, error) {
return _HopWrapper.contract.Transact(opts, "swapAndSend", chainId, recipient, amount, bonderFee, amountOutMin, deadline, destinationAmountOutMin, destinationDeadline)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0xeea0d7b2.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, uint256 amountOutMin, uint256 deadline, uint256 destinationAmountOutMin, uint256 destinationDeadline) payable returns()
func (_HopWrapper *HopWrapperSession) SwapAndSend(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, amountOutMin *big.Int, deadline *big.Int, destinationAmountOutMin *big.Int, destinationDeadline *big.Int) (*types.Transaction, error) {
return _HopWrapper.Contract.SwapAndSend(&_HopWrapper.TransactOpts, chainId, recipient, amount, bonderFee, amountOutMin, deadline, destinationAmountOutMin, destinationDeadline)
}
// SwapAndSend is a paid mutator transaction binding the contract method 0xeea0d7b2.
//
// Solidity: function swapAndSend(uint256 chainId, address recipient, uint256 amount, uint256 bonderFee, uint256 amountOutMin, uint256 deadline, uint256 destinationAmountOutMin, uint256 destinationDeadline) payable returns()
func (_HopWrapper *HopWrapperTransactorSession) SwapAndSend(chainId *big.Int, recipient common.Address, amount *big.Int, bonderFee *big.Int, amountOutMin *big.Int, deadline *big.Int, destinationAmountOutMin *big.Int, destinationDeadline *big.Int) (*types.Transaction, error) {
return _HopWrapper.Contract.SwapAndSend(&_HopWrapper.TransactOpts, chainId, recipient, amount, bonderFee, amountOutMin, deadline, destinationAmountOutMin, destinationDeadline)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_HopWrapper *HopWrapperTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) {
return _HopWrapper.contract.RawTransact(opts, nil) // calldata is disallowed for receive function
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_HopWrapper *HopWrapperSession) Receive() (*types.Transaction, error) {
return _HopWrapper.Contract.Receive(&_HopWrapper.TransactOpts)
}
// Receive is a paid mutator transaction binding the contract receive function.
//
// Solidity: receive() payable returns()
func (_HopWrapper *HopWrapperTransactorSession) Receive() (*types.Transaction, error) {
return _HopWrapper.Contract.Receive(&_HopWrapper.TransactOpts)
}

View File

@ -108,11 +108,11 @@ type Bridge interface {
// calculates the fees for the bridge and returns the amount BonderFee and TokenFee (used for bridges)
CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int) (*big.Int, *big.Int, error)
// Pack the method for sending tx and method call's data
PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error)
PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error)
EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)
CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)
Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (types.Hash, error)
GetContractAddress(network *params.Network, token *token.Token) *common.Address
GetContractAddress(network *params.Network, token *token.Token) (common.Address, error)
BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)
BuildTx(fromNetwork, toNetwork *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, bonderFee *big.Int) (*ethTypes.Transaction, error)
}

View File

@ -196,7 +196,7 @@ func (s *CBridge) CalculateFees(from, to *params.Network, token *token.Token, am
return big.NewInt(0), new(big.Int).Add(baseFee, percFee), nil
}
func (c *CBridge) PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
func (c *CBridge) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
abi, err := abi.JSON(strings.NewReader(celer.CelerABI))
if err != nil {
return []byte{}, err
@ -225,14 +225,14 @@ func (c *CBridge) PackTxInputData(fromNetwork *params.Network, toNetwork *params
func (s *CBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error) {
value := new(big.Int)
input, err := s.PackTxInputData(fromNetwork, toNetwork, from, to, token, amountIn)
input, err := s.PackTxInputData("", fromNetwork, toNetwork, from, to, token, amountIn)
if err != nil {
return 0, err
}
contractAddress := s.GetContractAddress(fromNetwork, nil)
if contractAddress == nil {
return 0, errors.New("contract not found")
contractAddress, err := s.GetContractAddress(fromNetwork, nil)
if err != nil {
return 0, err
}
ethClient, err := s.rpcClient.EthClient(fromNetwork.ChainID)
@ -242,15 +242,9 @@ func (s *CBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Net
ctx := context.Background()
if code, err := ethClient.PendingCodeAt(ctx, *contractAddress); err != nil {
return 0, err
} else if len(code) == 0 {
return 0, bind.ErrNoCode
}
msg := ethereum.CallMsg{
From: from,
To: contractAddress,
To: &contractAddress,
Value: value,
Data: input,
}
@ -284,23 +278,22 @@ func (s *CBridge) BuildTx(fromNetwork, toNetwork *params.Network, fromAddress co
return s.BuildTransaction(sendArgs)
}
func (s *CBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address {
func (s *CBridge) GetContractAddress(network *params.Network, token *token.Token) (common.Address, error) {
transferConfig, err := s.getTransferConfig(network.IsTest)
if err != nil {
return nil
return common.Address{}, err
}
if transferConfig.Err != nil {
return nil
return common.Address{}, errors.New(transferConfig.Err.Msg)
}
for _, chain := range transferConfig.Chains {
if uint64(chain.Id) == network.ChainID {
addr := common.HexToAddress(chain.ContractAddr)
return &addr
return common.HexToAddress(chain.ContractAddr), nil
}
}
return nil
return common.Address{}, errors.New("contract not found")
}
func (s *CBridge) sendOrBuild(sendArgs *TransactionBridge, signerFn bind.SignerFn) (*ethTypes.Transaction, error) {
@ -312,16 +305,16 @@ func (s *CBridge) sendOrBuild(sendArgs *TransactionBridge, signerFn bind.SignerF
if token == nil {
return nil, errors.New("token not found")
}
addrs := s.GetContractAddress(fromNetwork, nil)
if addrs == nil {
return nil, errors.New("contract not found")
addrs, err := s.GetContractAddress(fromNetwork, nil)
if err != nil {
return nil, err
}
backend, err := s.rpcClient.EthClient(sendArgs.ChainID)
if err != nil {
return nil, err
}
contract, err := celer.NewCeler(*addrs, backend)
contract, err := celer.NewCeler(addrs, backend)
if err != nil {
return nil, err
}

View File

@ -49,7 +49,7 @@ func (s *ERC1155TransferBridge) CalculateFees(from, to *params.Network, token *t
return big.NewInt(0), big.NewInt(0), nil
}
func (s *ERC1155TransferBridge) PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
func (s *ERC1155TransferBridge) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
abi, err := abi.JSON(strings.NewReader(ierc1155.Ierc1155ABI))
if err != nil {
return []byte{}, err
@ -77,7 +77,7 @@ func (s *ERC1155TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwo
value := new(big.Int)
input, err := s.PackTxInputData(fromNetwork, toNetwork, from, to, token, amountIn)
input, err := s.PackTxInputData("", fromNetwork, toNetwork, from, to, token, amountIn)
if err != nil {
return 0, err
}
@ -177,6 +177,6 @@ func (s *ERC1155TransferBridge) CalculateAmountOut(from, to *params.Network, amo
return amountIn, nil
}
func (s *ERC1155TransferBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address {
return &token.Address
func (s *ERC1155TransferBridge) GetContractAddress(network *params.Network, token *token.Token) (common.Address, error) {
return token.Address, nil
}

View File

@ -48,7 +48,7 @@ func (s *ERC721TransferBridge) CalculateFees(from, to *params.Network, token *to
return big.NewInt(0), big.NewInt(0), nil
}
func (s *ERC721TransferBridge) PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
func (s *ERC721TransferBridge) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
abi, err := abi.JSON(strings.NewReader(collectibles.CollectiblesMetaData.ABI))
if err != nil {
return []byte{}, err
@ -74,7 +74,7 @@ func (s *ERC721TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwor
value := new(big.Int)
input, err := s.PackTxInputData(fromNetwork, toNetwork, from, to, token, amountIn)
input, err := s.PackTxInputData("", fromNetwork, toNetwork, from, to, token, amountIn)
if err != nil {
return 0, err
}
@ -169,6 +169,6 @@ func (s *ERC721TransferBridge) CalculateAmountOut(from, to *params.Network, amou
return amountIn, nil
}
func (s *ERC721TransferBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address {
return &token.Address
func (s *ERC721TransferBridge) GetContractAddress(network *params.Network, token *token.Token) (common.Address, error) {
return token.Address, nil
}

View File

@ -8,7 +8,6 @@ import (
"math/big"
netUrl "net/url"
"strings"
"time"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
@ -19,11 +18,18 @@ import (
"github.com/status-im/status-go/account"
"github.com/status-im/status-go/contracts"
"github.com/status-im/status-go/contracts/hop"
hopBridge "github.com/status-im/status-go/contracts/hop/bridge"
hopWrapper "github.com/status-im/status-go/contracts/hop/wrapper"
hopL1CctpImplementation "github.com/status-im/status-go/contracts/hop/l1Contracts/l1CctpImplementation"
hopL1Erc20Bridge "github.com/status-im/status-go/contracts/hop/l1Contracts/l1Erc20Bridge"
hopL1EthBridge "github.com/status-im/status-go/contracts/hop/l1Contracts/l1EthBridge"
hopL1HopBridge "github.com/status-im/status-go/contracts/hop/l1Contracts/l1HopBridge"
hopL2AmmWrapper "github.com/status-im/status-go/contracts/hop/l2Contracts/l2AmmWrapper"
hopL2ArbitrumBridge "github.com/status-im/status-go/contracts/hop/l2Contracts/l2ArbitrumBridge"
hopL2CctpImplementation "github.com/status-im/status-go/contracts/hop/l2Contracts/l2CctpImplementation"
hopL2OptimismBridge "github.com/status-im/status-go/contracts/hop/l2Contracts/l2OptimismBridge"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/rpc"
"github.com/status-im/status-go/rpc/chain"
"github.com/status-im/status-go/services/wallet/bigint"
walletCommon "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/thirdparty"
@ -31,7 +37,10 @@ import (
"github.com/status-im/status-go/transactions"
)
const SevenDaysInSeconds = 604800
const (
SevenDaysInSeconds = 604800
hopSymbol = "HOP"
)
type HopTxArgs struct {
transactions.SendTxArgs
@ -119,66 +128,76 @@ func (h *HopBridge) Name() string {
}
func (h *HopBridge) AvailableFor(from, to *params.Network, token *token.Token, toToken *token.Token) (bool, error) {
if from.ChainID == to.ChainID || toToken != nil {
return false, nil
// We chcek if the contract is available on the network for the token
_, err := h.GetContractAddress(from, token)
// toToken is not nil only if the send type is Swap
return err == nil && toToken == nil, nil
}
// currently Hop bridge is not available for testnets
if from.IsTest || to.IsTest {
return false, nil
func (c *HopBridge) getAppropriateABI(contractType string, chainID uint64, token *token.Token) (abi.ABI, error) {
switch contractType {
case hop.CctpL1Bridge:
return abi.JSON(strings.NewReader(hopL1CctpImplementation.HopL1CctpImplementationABI))
case hop.L1Bridge:
if token.IsNative() {
return abi.JSON(strings.NewReader(hopL1EthBridge.HopL1EthBridgeABI))
}
if token.Symbol == hopSymbol {
return abi.JSON(strings.NewReader(hopL1HopBridge.HopL1HopBridgeABI))
}
return abi.JSON(strings.NewReader(hopL1Erc20Bridge.HopL1Erc20BridgeABI))
case hop.L2AmmWrapper:
return abi.JSON(strings.NewReader(hopL2AmmWrapper.HopL2AmmWrapperABI))
case hop.CctpL2Bridge:
return abi.JSON(strings.NewReader(hopL2CctpImplementation.HopL2CctpImplementationABI))
case hop.L2Bridge:
if chainID == walletCommon.OptimismMainnet ||
chainID == walletCommon.OptimismSepolia {
return abi.JSON(strings.NewReader(hopL2OptimismBridge.HopL2OptimismBridgeABI))
}
if chainID == walletCommon.ArbitrumMainnet ||
chainID == walletCommon.ArbitrumSepolia {
return abi.JSON(strings.NewReader(hopL2ArbitrumBridge.HopL2ArbitrumBridgeABI))
}
}
return true, nil
return abi.ABI{}, errors.New("not available for contract type")
}
func (h *HopBridge) PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
if fromNetwork.Layer == 1 {
ABI, err := abi.JSON(strings.NewReader(hopBridge.HopBridgeABI))
func (h *HopBridge) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
abi, err := h.getAppropriateABI(contractType, fromNetwork.ChainID, token)
if err != nil {
return []byte{}, err
}
return ABI.Pack("sendToL2",
big.NewInt(int64(toNetwork.ChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
common.HexToAddress("0x0"),
big.NewInt(0))
} else {
ABI, err := abi.JSON(strings.NewReader(hopWrapper.HopWrapperABI))
if err != nil {
return []byte{}, err
switch contractType {
case hop.CctpL1Bridge:
return h.packCctpL1BridgeTx(abi, toNetwork.ChainID, to)
case hop.L1Bridge:
return h.packL1BridgeTx(abi, toNetwork.ChainID, to)
case hop.L2AmmWrapper:
return h.packL2AmmWrapperTx(abi, toNetwork.ChainID, to)
case hop.CctpL2Bridge:
return h.packCctpL2BridgeTx(abi, toNetwork.ChainID, to)
case hop.L2Bridge:
return h.packL2BridgeTx(abi, toNetwork.ChainID, to)
}
return ABI.Pack("swapAndSend",
big.NewInt(int64(toNetwork.ChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
h.bonderFee.DestinationAmountOutMin.Int,
big.NewInt(h.bonderFee.DestinationDeadline))
}
return []byte{}, errors.New("contract type not supported yet")
}
func (h *HopBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error) {
value := new(big.Int)
value := big.NewInt(0)
if token.IsNative() {
value = amountIn
}
contractAddress := h.GetContractAddress(fromNetwork, token)
if contractAddress == nil {
return 0, errors.New("contract not found")
contractAddress, contractType, err := hop.GetContractAddress(fromNetwork.ChainID, token.Symbol)
if err != nil {
return 0, err
}
ctx := context.Background()
input, err := h.PackTxInputData(fromNetwork, toNetwork, from, to, token, amountIn)
input, err := h.PackTxInputData(contractType, fromNetwork, toNetwork, from, to, token, amountIn)
if err != nil {
return 0, err
}
@ -188,23 +207,18 @@ func (h *HopBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.N
return 0, err
}
if code, err := ethClient.PendingCodeAt(ctx, *contractAddress); err != nil {
return 0, err
} else if len(code) == 0 {
return 0, bind.ErrNoCode
}
msg := ethereum.CallMsg{
From: from,
To: contractAddress,
To: &contractAddress,
Value: value,
Data: input,
}
estimation, err := ethClient.EstimateGas(ctx, msg)
estimation, err := ethClient.EstimateGas(context.Background(), msg)
if err != nil {
return 0, err
}
increasedEstimation := float64(estimation) * IncreaseEstimatedGasFactor
return uint64(increasedEstimation), nil
}
@ -231,15 +245,9 @@ func (h *HopBridge) BuildTx(fromNetwork, toNetwork *params.Network, fromAddress
return h.BuildTransaction(sendArgs)
}
func (h *HopBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address {
var address common.Address
if network.Layer == 1 {
address, _ = hop.L1BridgeContractAddress(network.ChainID, token.Symbol)
} else {
address, _ = hop.L2AmmWrapperContractAddress(network.ChainID, token.Symbol)
}
return &address
func (h *HopBridge) GetContractAddress(network *params.Network, token *token.Token) (common.Address, error) {
address, _, err := hop.GetContractAddress(network.ChainID, token.Symbol)
return address, err
}
func (h *HopBridge) sendOrBuild(sendArgs *TransactionBridge, signerFn bind.SignerFn) (tx *ethTypes.Transaction, err error) {
@ -248,6 +256,8 @@ func (h *HopBridge) sendOrBuild(sendArgs *TransactionBridge, signerFn bind.Signe
return tx, fmt.Errorf("ChainID not supported %d", sendArgs.ChainID)
}
token := h.tokenManager.FindToken(fromNetwork, sendArgs.HopTx.Symbol)
nonce, err := h.transactor.NextNonce(h.contractMaker.RPCClient, fromNetwork.ChainID, sendArgs.HopTx.From)
if err != nil {
return tx, err
@ -256,12 +266,34 @@ func (h *HopBridge) sendOrBuild(sendArgs *TransactionBridge, signerFn bind.Signe
argNonce := hexutil.Uint64(nonce)
sendArgs.HopTx.Nonce = &argNonce
token := h.tokenManager.FindToken(fromNetwork, sendArgs.HopTx.Symbol)
if fromNetwork.Layer == 1 {
tx, err = h.sendToL2(sendArgs.ChainID, sendArgs.HopTx, signerFn, token)
txOpts := sendArgs.HopTx.ToTransactOpts(signerFn)
if token.IsNative() {
txOpts.Value = (*big.Int)(sendArgs.HopTx.Amount)
}
ethClient, err := h.contractMaker.RPCClient.EthClient(fromNetwork.ChainID)
if err != nil {
return tx, err
}
tx, err = h.swapAndSend(sendArgs.ChainID, sendArgs.HopTx, signerFn, token)
contractAddress, contractType, err := hop.GetContractAddress(fromNetwork.ChainID, sendArgs.HopTx.Symbol)
if err != nil {
return tx, err
}
switch contractType {
case hop.CctpL1Bridge:
return h.sendCctpL1BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts)
case hop.L1Bridge:
return h.sendL1BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, token)
case hop.L2AmmWrapper:
return h.sendL2AmmWrapperTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts)
case hop.CctpL2Bridge:
return h.sendCctpL2BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts)
case hop.L2Bridge:
return h.sendL2BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts)
}
return tx, err
}
@ -277,95 +309,6 @@ func (h *HopBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Tra
return h.sendOrBuild(sendArgs, nil)
}
func (h *HopBridge) sendToL2(chainID uint64, hopArgs *HopTxArgs, signerFn bind.SignerFn, token *token.Token) (tx *ethTypes.Transaction, err error) {
bridge, err := h.contractMaker.NewHopL1Bridge(chainID, hopArgs.Symbol)
if err != nil {
return tx, err
}
txOpts := hopArgs.ToTransactOpts(signerFn)
if token.IsNative() {
txOpts.Value = (*big.Int)(hopArgs.Amount)
}
var (
deadline *big.Int
amountOutMin *big.Int
)
if h.bonderFee != nil {
deadline = big.NewInt(h.bonderFee.Deadline)
amountOutMin = h.bonderFee.AmountOutMin.Int
} else {
now := time.Now()
deadline = big.NewInt(now.Unix() + SevenDaysInSeconds)
}
tx, err = bridge.SendToL2(
txOpts,
big.NewInt(int64(hopArgs.ChainID)),
hopArgs.Recipient,
hopArgs.Amount.ToInt(),
amountOutMin,
deadline,
common.HexToAddress("0x0"),
big.NewInt(0),
)
return tx, err
}
func (h *HopBridge) swapAndSend(chainID uint64, hopArgs *HopTxArgs, signerFn bind.SignerFn, token *token.Token) (tx *ethTypes.Transaction, err error) {
ammWrapper, err := h.contractMaker.NewHopL2AmmWrapper(chainID, hopArgs.Symbol)
if err != nil {
return tx, err
}
toNetwork := h.contractMaker.RPCClient.NetworkManager.Find(hopArgs.ChainID)
if toNetwork == nil {
return tx, err
}
txOpts := hopArgs.ToTransactOpts(signerFn)
if token.IsNative() {
txOpts.Value = (*big.Int)(hopArgs.Amount)
}
var deadline *big.Int
amountOutMin := big.NewInt(0)
destinationDeadline := big.NewInt(0)
destinationAmountOutMin := big.NewInt(0)
// https://docs.hop.exchange/v/developer-docs/smart-contracts/integration#l2-greater-than-l1-and-l2-greater-than-l2
// Do not set `destinationAmountOutMin` and `destinationDeadline` when sending to L1 because there is no AMM on L1,
// otherwise the computed transferId will be invalid and the transfer will be unbondable. These parameters should be set to 0 when sending to L1.
if h.bonderFee != nil {
deadline = big.NewInt(h.bonderFee.Deadline)
amountOutMin = h.bonderFee.AmountOutMin.Int
destinationDeadline = big.NewInt(h.bonderFee.DestinationDeadline)
destinationAmountOutMin = h.bonderFee.DestinationAmountOutMin.Int
} else {
now := time.Now()
deadline = big.NewInt(now.Unix() + SevenDaysInSeconds)
if toNetwork.Layer != 1 {
destinationDeadline = big.NewInt(now.Unix() + SevenDaysInSeconds)
}
}
tx, err = ammWrapper.SwapAndSend(
txOpts,
new(big.Int).SetUint64(hopArgs.ChainID),
hopArgs.Recipient,
hopArgs.Amount.ToInt(),
hopArgs.BonderFee.ToInt(),
amountOutMin,
deadline,
destinationAmountOutMin,
destinationDeadline,
)
return tx, err
}
func (h *HopBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int) (*big.Int, *big.Int, error) {
hopChainsMap := map[uint64]string{
walletCommon.EthereumMainnet: "ethereum",
@ -402,7 +345,10 @@ func (h *HopBridge) CalculateFees(from, to *params.Network, token *token.Token,
return nil, nil, err
}
tokenFee := new(big.Int).Sub(h.bonderFee.AmountIn.Int, h.bonderFee.EstimatedRecieved.Int)
// Remove token fee from bonder fee as said here:
// https://docs.hop.exchange/v/developer-docs/api/api#get-v1-quote
// `bonderFee` - The suggested bonder fee for the amount in. The bonder fee also includes the cost of the destination transaction fee.
tokenFee := big.NewInt(0) //new(big.Int).Sub(h.bonderFee.AmountIn.Int, h.bonderFee.EstimatedRecieved.Int)
return h.bonderFee.BonderFee.Int, tokenFee, nil
}
@ -410,3 +356,213 @@ func (h *HopBridge) CalculateFees(from, to *params.Network, token *token.Token,
func (h *HopBridge) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error) {
return h.bonderFee.EstimatedRecieved.Int, nil
}
func (h *HopBridge) packCctpL1BridgeTx(abi abi.ABI, toChainID uint64, to common.Address) ([]byte, error) {
return abi.Pack("send",
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int)
}
func (h *HopBridge) sendCctpL1BridgeTx(contractAddress common.Address, ethClient chain.ClientInterface, toChainID uint64, to common.Address, txOpts *bind.TransactOpts) (tx *ethTypes.Transaction, err error) {
contractInstance, err := hopL1CctpImplementation.NewHopL1CctpImplementation(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.Send(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int)
}
func (h *HopBridge) packL1BridgeTx(abi abi.ABI, toChainID uint64, to common.Address) ([]byte, error) {
return abi.Pack("sendToL2",
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
common.Address{},
big.NewInt(0))
}
func (h *HopBridge) sendL1BridgeTx(contractAddress common.Address, ethClient chain.ClientInterface, toChainID uint64, to common.Address, txOpts *bind.TransactOpts, token *token.Token) (tx *ethTypes.Transaction, err error) {
if token.IsNative() {
contractInstance, err := hopL1EthBridge.NewHopL1EthBridge(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.SendToL2(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
common.Address{},
big.NewInt(0))
}
if token.Symbol == hopSymbol {
contractInstance, err := hopL1HopBridge.NewHopL1HopBridge(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.SendToL2(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
common.Address{},
big.NewInt(0))
}
contractInstance, err := hopL1Erc20Bridge.NewHopL1Erc20Bridge(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.SendToL2(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
common.Address{},
big.NewInt(0))
}
func (h *HopBridge) packCctpL2BridgeTx(abi abi.ABI, toChainID uint64, to common.Address) ([]byte, error) {
return abi.Pack("send",
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int)
}
func (h *HopBridge) sendCctpL2BridgeTx(contractAddress common.Address, ethClient chain.ClientInterface, toChainID uint64, to common.Address, txOpts *bind.TransactOpts) (tx *ethTypes.Transaction, err error) {
contractInstance, err := hopL2CctpImplementation.NewHopL2CctpImplementation(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.Send(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
)
}
func (h *HopBridge) packL2AmmWrapperTx(abi abi.ABI, toChainID uint64, to common.Address) ([]byte, error) {
return abi.Pack("swapAndSend",
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
h.bonderFee.DestinationAmountOutMin.Int,
big.NewInt(h.bonderFee.DestinationDeadline))
}
func (h *HopBridge) sendL2AmmWrapperTx(contractAddress common.Address, ethClient chain.ClientInterface, toChainID uint64, to common.Address, txOpts *bind.TransactOpts) (tx *ethTypes.Transaction, err error) {
contractInstance, err := hopL2AmmWrapper.NewHopL2AmmWrapper(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.SwapAndSend(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline),
h.bonderFee.DestinationAmountOutMin.Int,
big.NewInt(h.bonderFee.DestinationDeadline))
}
func (h *HopBridge) packL2BridgeTx(abi abi.ABI, toChainID uint64, to common.Address) ([]byte, error) {
return abi.Pack("send",
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline))
}
func (h *HopBridge) sendL2BridgeTx(contractAddress common.Address, ethClient chain.ClientInterface, toChainID uint64, to common.Address, txOpts *bind.TransactOpts) (tx *ethTypes.Transaction, err error) {
fromChainID := ethClient.NetworkID()
if fromChainID == walletCommon.OptimismMainnet ||
fromChainID == walletCommon.OptimismSepolia {
contractInstance, err := hopL2OptimismBridge.NewHopL2OptimismBridge(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.Send(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline))
}
if fromChainID == walletCommon.ArbitrumMainnet ||
fromChainID == walletCommon.ArbitrumSepolia {
contractInstance, err := hopL2ArbitrumBridge.NewHopL2ArbitrumBridge(
contractAddress,
ethClient,
)
if err != nil {
return tx, err
}
return contractInstance.Send(
txOpts,
big.NewInt(int64(toChainID)),
to,
h.bonderFee.AmountIn.Int,
h.bonderFee.BonderFee.Int,
h.bonderFee.AmountOutMin.Int,
big.NewInt(h.bonderFee.Deadline))
}
return tx, errors.New("tx for chain not supported yet")
}

View File

@ -91,7 +91,7 @@ func (s *SwapParaswap) CalculateFees(from, to *params.Network, token *token.Toke
return big.NewInt(0), big.NewInt(0), nil
}
func (s *SwapParaswap) PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
func (s *SwapParaswap) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
// not sure what we can do here since we're using the api to build the transaction
return []byte{}, nil
}
@ -107,17 +107,17 @@ func (s *SwapParaswap) EstimateGas(fromNetwork *params.Network, toNetwork *param
return priceRoute.GasCost.Uint64(), nil
}
func (s *SwapParaswap) GetContractAddress(network *params.Network, token *token.Token) *common.Address {
var address common.Address
func (s *SwapParaswap) GetContractAddress(network *params.Network, token *token.Token) (address common.Address, err error) {
if network.ChainID == walletCommon.EthereumMainnet {
address = common.HexToAddress("0x216b4b4ba9f3e719726886d34a177484278bfcae")
} else if network.ChainID == walletCommon.ArbitrumMainnet {
address = common.HexToAddress("0x216b4b4ba9f3e719726886d34a177484278bfcae")
} else if network.ChainID == walletCommon.OptimismMainnet {
address = common.HexToAddress("0x216b4b4ba9f3e719726886d34a177484278bfcae")
} else {
err = errors.New("unsupported network")
}
return &address
return
}
func (s *SwapParaswap) BuildTx(network, _ *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, _ *big.Int) (*ethTypes.Transaction, error) {

View File

@ -40,7 +40,7 @@ func (s *TransferBridge) CalculateFees(from, to *params.Network, token *token.To
return big.NewInt(0), big.NewInt(0), nil
}
func (s *TransferBridge) PackTxInputData(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
func (s *TransferBridge) PackTxInputData(contractType string, fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, amountIn *big.Int) ([]byte, error) {
if token.Symbol == "ETH" {
return []byte("eth_sendRawTransaction"), nil
} else {
@ -59,7 +59,7 @@ func (s *TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *par
estimation := uint64(0)
var err error
input, err := s.PackTxInputData(fromNetwork, toNetwork, from, to, token, amountIn)
input, err := s.PackTxInputData("", fromNetwork, toNetwork, from, to, token, amountIn)
if err != nil {
return 0, err
}
@ -145,6 +145,6 @@ func (s *TransferBridge) CalculateAmountOut(from, to *params.Network, amountIn *
return amountIn, nil
}
func (s *TransferBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address {
return nil
func (s *TransferBridge) GetContractAddress(network *params.Network, token *token.Token) (common.Address, error) {
return common.Address{}, nil
}

View File

@ -600,15 +600,18 @@ func (r *Router) SuggestedRoutes(
gasLimit = sendType.EstimateGas(r.ensService, r.stickersService, network, addrFrom, tokenID)
}
approvalContractAddress := bridge.GetContractAddress(network, token)
approvalRequired, approvalAmountRequired, approvalGasLimit, l1ApprovalFee, err := r.requireApproval(ctx, sendType, approvalContractAddress, addrFrom, network, token, amountIn)
approvalContractAddress, err := bridge.GetContractAddress(network, token)
if err != nil {
continue
}
approvalRequired, approvalAmountRequired, approvalGasLimit, l1ApprovalFee, err := r.requireApproval(ctx, sendType, &approvalContractAddress, addrFrom, network, token, amountIn)
if err != nil {
continue
}
var l1GasFeeWei uint64
if sendType.needL1Fee() {
txInputData, err := bridge.PackTxInputData(network, dest, addrFrom, addrTo, token, amountIn)
txInputData, err := bridge.PackTxInputData("", network, dest, addrFrom, addrTo, token, amountIn)
if err != nil {
continue
}
@ -673,7 +676,7 @@ func (r *Router) SuggestedRoutes(
ApprovalRequired: approvalRequired,
ApprovalGasFees: approvalGasFees,
ApprovalAmountRequired: (*hexutil.Big)(approvalAmountRequired),
ApprovalContractAddress: approvalContractAddress,
ApprovalContractAddress: &approvalContractAddress,
})
mu.Unlock()
}

View File

@ -266,6 +266,8 @@ func findBestV2(routes [][]*PathV2, tokenPrice float64, nativeChainTokenPrice fl
for _, route := range routes {
currentCost := big.NewFloat(0)
for _, path := range route {
tokenDenominator := big.NewFloat(math.Pow(10, float64(path.FromToken.Decimals)))
path.requiredTokenBalance = new(big.Int).Set(path.AmountIn.ToInt())
path.requiredNativeBalance = big.NewInt(0)
@ -283,11 +285,11 @@ func findBestV2(routes [][]*PathV2, tokenPrice float64, nativeChainTokenPrice fl
}
if path.TxBonderFees != nil && path.TxBonderFees.ToInt().Cmp(zero) > 0 {
bonderFeeInWei := path.TxBonderFees.ToInt()
bonderFeeInEth := gweiToEth(weiToGwei(bonderFeeInWei))
path.requiredTokenBalance.Add(path.requiredTokenBalance, path.TxBonderFees.ToInt())
pathCost.Add(pathCost, new(big.Float).Mul(
new(big.Float).Quo(new(big.Float).SetInt(path.TxBonderFees.ToInt()), tokenDenominator),
new(big.Float).SetFloat64(tokenPrice)))
path.requiredNativeBalance.Add(path.requiredNativeBalance, bonderFeeInWei)
pathCost.Add(pathCost, new(big.Float).Mul(bonderFeeInEth, nativeTokenPrice))
}
if path.TxL1Fee != nil && path.TxL1Fee.ToInt().Cmp(zero) > 0 {
@ -301,7 +303,7 @@ func findBestV2(routes [][]*PathV2, tokenPrice float64, nativeChainTokenPrice fl
if path.TxTokenFees != nil && path.TxTokenFees.ToInt().Cmp(zero) > 0 && path.FromToken != nil {
path.requiredTokenBalance.Add(path.requiredTokenBalance, path.TxTokenFees.ToInt())
pathCost.Add(pathCost, new(big.Float).Mul(
new(big.Float).Quo(new(big.Float).SetInt(path.TxTokenFees.ToInt()), big.NewFloat(math.Pow(10, float64(path.FromToken.Decimals)))),
new(big.Float).Quo(new(big.Float).SetInt(path.TxTokenFees.ToInt()), tokenDenominator),
new(big.Float).SetFloat64(tokenPrice)))
}
@ -439,8 +441,11 @@ func (r *Router) SuggestedRoutesV2(ctx context.Context, input *RouteInputParams)
gasLimit = input.SendType.EstimateGas(r.ensService, r.stickersService, network, input.AddrFrom, input.TokenID)
}
approvalContractAddress := bridge.GetContractAddress(network, token)
approvalRequired, approvalAmountRequired, approvalGasLimit, l1ApprovalFee, err := r.requireApproval(ctx, input.SendType, approvalContractAddress, input.AddrFrom, network, token, amountToSend)
approvalContractAddress, err := bridge.GetContractAddress(network, token)
if err != nil {
continue
}
approvalRequired, approvalAmountRequired, approvalGasLimit, l1ApprovalFee, err := r.requireApproval(ctx, input.SendType, &approvalContractAddress, input.AddrFrom, network, token, amountToSend)
if err != nil {
continue
}
@ -448,7 +453,7 @@ func (r *Router) SuggestedRoutesV2(ctx context.Context, input *RouteInputParams)
var l1FeeWei uint64
if input.SendType.needL1Fee() {
txInputData, err := bridge.PackTxInputData(network, dest, input.AddrFrom, input.AddrTo, token, amountToSend)
txInputData, err := bridge.PackTxInputData("", network, dest, input.AddrFrom, input.AddrTo, token, amountToSend)
if err != nil {
continue
}
@ -505,7 +510,7 @@ func (r *Router) SuggestedRoutesV2(ctx context.Context, input *RouteInputParams)
ApprovalRequired: approvalRequired,
ApprovalAmountRequired: (*hexutil.Big)(approvalAmountRequired),
ApprovalContractAddress: approvalContractAddress,
ApprovalContractAddress: &approvalContractAddress,
ApprovalBaseFee: (*hexutil.Big)(baseFee),
ApprovalPriorityFee: (*hexutil.Big)(selctedPriorityFee),
ApprovalGasAmount: approvalGasLimit,