diff --git a/pkg/parser/paraswap_taker/abi.json b/pkg/parser/paraswap_taker/abi.json new file mode 100644 index 0000000..89a6eed --- /dev/null +++ b/pkg/parser/paraswap_taker/abi.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"uint256","name":"_partnerSharePercent","type":"uint256"},{"internalType":"uint256","name":"_maxFeePercent","type":"uint256"},{"internalType":"uint256","name":"_paraswapReferralShare","type":"uint256"},{"internalType":"uint256","name":"_paraswapSlippageShare","type":"uint256"},{"internalType":"contract IFeeClaimer","name":"_feeClaimer","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes16","name":"uuid","type":"bytes16"},{"indexed":false,"internalType":"address","name":"partner","type":"address"},{"indexed":false,"internalType":"uint256","name":"feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiator","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"srcToken","type":"address"},{"indexed":true,"internalType":"address","name":"destToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmount","type":"uint256"}],"name":"BoughtV3","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes16","name":"uuid","type":"bytes16"},{"indexed":false,"internalType":"address","name":"partner","type":"address"},{"indexed":false,"internalType":"uint256","name":"feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"enum DirectSwap.DirectSwapKind","name":"kind","type":"uint8"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"srcToken","type":"address"},{"indexed":true,"internalType":"address","name":"destToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmount","type":"uint256"}],"name":"SwappedDirect","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes16","name":"uuid","type":"bytes16"},{"indexed":false,"internalType":"address","name":"partner","type":"address"},{"indexed":false,"internalType":"uint256","name":"feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiator","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"srcToken","type":"address"},{"indexed":true,"internalType":"address","name":"destToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmount","type":"uint256"}],"name":"SwappedV3","type":"event"},{"inputs":[],"name":"ROUTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELISTED_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"assetInIndex","type":"uint256"},{"internalType":"uint256","name":"assetOutIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IBalancerV2Vault.BatchSwapStep[]","name":"swaps","type":"tuple[]"},{"internalType":"address[]","name":"assets","type":"address[]"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IBalancerV2Vault.FundManagement","name":"funds","type":"tuple"},{"internalType":"int256[]","name":"limits","type":"int256[]"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"address","name":"vault","type":"address"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.DirectBalancerV2","name":"data","type":"tuple"}],"name":"directBalancerV2GivenInSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"assetInIndex","type":"uint256"},{"internalType":"uint256","name":"assetOutIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IBalancerV2Vault.BatchSwapStep[]","name":"swaps","type":"tuple[]"},{"internalType":"address[]","name":"assets","type":"address[]"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IBalancerV2Vault.FundManagement","name":"funds","type":"tuple"},{"internalType":"int256[]","name":"limits","type":"int256[]"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"address","name":"vault","type":"address"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.DirectBalancerV2","name":"data","type":"tuple"}],"name":"directBalancerV2GivenOutSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"int128","name":"i","type":"int128"},{"internalType":"int128","name":"j","type":"int128"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"},{"internalType":"enum Utils.CurveSwapType","name":"swapType","type":"uint8"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"bool","name":"needWrapNative","type":"bool"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.DirectCurveV1","name":"data","type":"tuple"}],"name":"directCurveV1Swap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"},{"internalType":"enum Utils.CurveSwapType","name":"swapType","type":"uint8"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"bool","name":"needWrapNative","type":"bool"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.DirectCurveV2","name":"data","type":"tuple"}],"name":"directCurveV2Swap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.DirectUniV3","name":"data","type":"tuple"}],"name":"directUniV3Buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"toAmount","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"feePercent","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address payable","name":"partner","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes16","name":"uuid","type":"bytes16"}],"internalType":"struct Utils.DirectUniV3","name":"data","type":"tuple"}],"name":"directUniV3Swap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeClaimer","outputs":[{"internalType":"contract IFeeClaimer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"maxFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paraswapReferralShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paraswapSlippageShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"partnerSharePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/pkg/parser/paraswap_taker/gen.sh b/pkg/parser/paraswap_taker/gen.sh new file mode 100755 index 0000000..b9d2f58 --- /dev/null +++ b/pkg/parser/paraswap_taker/gen.sh @@ -0,0 +1 @@ +abigen --abi=abi.json --pkg=ps_taker --out=ps_taker.go -type ps_taker diff --git a/pkg/parser/paraswap_taker/parser.go b/pkg/parser/paraswap_taker/parser.go new file mode 100644 index 0000000..e068e11 --- /dev/null +++ b/pkg/parser/paraswap_taker/parser.go @@ -0,0 +1,129 @@ +package pstaker + +import ( + "strings" + + "github.com/KyberNetwork/tradelogs/pkg/parser" + "github.com/KyberNetwork/tradelogs/pkg/storage" + tradingTypes "github.com/KyberNetwork/tradelogs/pkg/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" +) + +const ( + SwapEvent = "SwappedV3" + SwapDirect = "SwappedDirect" +) + +type Parser struct { + abi *abi.ABI + ps *PsTakerFilterer + eventHash string + directEventHash string +} + +func MustNewParser() *Parser { + ps, err := NewPsTakerFilterer(common.Address{}, nil) + if err != nil { + panic(err) + } + ab, err := PsTakerMetaData.GetAbi() + if err != nil { + panic(err) + } + event, ok := ab.Events[SwapEvent] + if !ok { + panic("no such event: SwappedV3") + } + directEvent, ok := ab.Events[SwapDirect] + if !ok { + panic("no such event: SwappedDirect") + } + return &Parser{ + ps: ps, + abi: ab, + eventHash: event.ID.String(), + directEventHash: directEvent.ID.String(), + } +} + +func (p *Parser) Topics() []string { + return []string{ + p.eventHash, + p.directEventHash, + } +} + +func (p *Parser) Parse(log types.Log, blockTime uint64) (storage.TradeLog, error) { + if len(log.Topics) == 0 { + return storage.TradeLog{}, parser.ErrInvalidTopic + } + + if log.Topics[0].Hex() == p.eventHash { + e, err := p.ps.ParseSwappedV3(log) + if err != nil { + return storage.TradeLog{}, err + } + res := storage.TradeLog{ + Taker: e.Beneficiary.String(), + MakerToken: e.DestToken.String(), + TakerToken: e.SrcToken.String(), + MakerTokenAmount: e.ReceivedAmount.String(), + TakerTokenAmount: e.SrcAmount.String(), + ContractAddress: e.Raw.Address.String(), + BlockNumber: e.Raw.BlockNumber, + TxHash: e.Raw.TxHash.String(), + LogIndex: uint64(e.Raw.Index), + Timestamp: blockTime * 1000, + EventHash: p.eventHash, + } + return res, nil + } + if log.Topics[0].Hex() == p.directEventHash { + e, err := p.ps.ParseSwappedDirect(log) + if err != nil { + return storage.TradeLog{}, err + } + res := storage.TradeLog{ + Taker: e.Initiator.String(), + MakerToken: e.DestToken.String(), + TakerToken: e.SrcToken.String(), + MakerTokenAmount: e.ReceivedAmount.String(), + TakerTokenAmount: e.SrcAmount.String(), + ContractAddress: e.Raw.Address.String(), + BlockNumber: e.Raw.BlockNumber, + TxHash: e.Raw.TxHash.String(), + LogIndex: uint64(e.Raw.Index), + Timestamp: blockTime * 1000, + EventHash: p.directEventHash, + } + return res, nil + } + return storage.TradeLog{}, parser.ErrInvalidTopic +} + +func (p *Parser) Exchange() string { + return parser.ExParaswapTaker +} + +func (p *Parser) UseTraceCall() bool { + return false +} + +func (p *Parser) ParseWithCallFrame( + callFrame tradingTypes.CallFrame, + log types.Log, + blockTime uint64, +) (storage.TradeLog, error) { + return p.Parse(log, blockTime) +} + +func (p *Parser) LogFromExchange(log types.Log) bool { + return strings.EqualFold(log.Address.String(), parser.AddrParaswapTaker) && + len(log.Topics) > 0 && (strings.EqualFold(log.Topics[0].String(), p.eventHash) || strings.EqualFold(log.Topics[0].String(), p.directEventHash)) +} + +func (p *Parser) Address() string { + return parser.AddrParaswapTaker +} diff --git a/pkg/parser/paraswap_taker/ps_taker.go b/pkg/parser/paraswap_taker/ps_taker.go new file mode 100644 index 0000000..77ab5d8 --- /dev/null +++ b/pkg/parser/paraswap_taker/ps_taker.go @@ -0,0 +1,1218 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package pstaker + +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 +) + +// IBalancerV2VaultBatchSwapStep is an auto generated low-level Go binding around an user-defined struct. +type IBalancerV2VaultBatchSwapStep struct { + PoolId [32]byte + AssetInIndex *big.Int + AssetOutIndex *big.Int + Amount *big.Int + UserData []byte +} + +// IBalancerV2VaultFundManagement is an auto generated low-level Go binding around an user-defined struct. +type IBalancerV2VaultFundManagement struct { + Sender common.Address + FromInternalBalance bool + Recipient common.Address + ToInternalBalance bool +} + +// UtilsDirectBalancerV2 is an auto generated low-level Go binding around an user-defined struct. +type UtilsDirectBalancerV2 struct { + Swaps []IBalancerV2VaultBatchSwapStep + Assets []common.Address + Funds IBalancerV2VaultFundManagement + Limits []*big.Int + FromAmount *big.Int + ToAmount *big.Int + ExpectedAmount *big.Int + Deadline *big.Int + FeePercent *big.Int + Vault common.Address + Partner common.Address + IsApproved bool + Beneficiary common.Address + Permit []byte + Uuid [16]byte +} + +// UtilsDirectCurveV1 is an auto generated low-level Go binding around an user-defined struct. +type UtilsDirectCurveV1 struct { + FromToken common.Address + ToToken common.Address + Exchange common.Address + FromAmount *big.Int + ToAmount *big.Int + ExpectedAmount *big.Int + FeePercent *big.Int + I *big.Int + J *big.Int + Partner common.Address + IsApproved bool + SwapType uint8 + Beneficiary common.Address + NeedWrapNative bool + Permit []byte + Uuid [16]byte +} + +// UtilsDirectCurveV2 is an auto generated low-level Go binding around an user-defined struct. +type UtilsDirectCurveV2 struct { + FromToken common.Address + ToToken common.Address + Exchange common.Address + PoolAddress common.Address + FromAmount *big.Int + ToAmount *big.Int + ExpectedAmount *big.Int + FeePercent *big.Int + I *big.Int + J *big.Int + Partner common.Address + IsApproved bool + SwapType uint8 + Beneficiary common.Address + NeedWrapNative bool + Permit []byte + Uuid [16]byte +} + +// UtilsDirectUniV3 is an auto generated low-level Go binding around an user-defined struct. +type UtilsDirectUniV3 struct { + FromToken common.Address + ToToken common.Address + Exchange common.Address + FromAmount *big.Int + ToAmount *big.Int + ExpectedAmount *big.Int + FeePercent *big.Int + Deadline *big.Int + Partner common.Address + IsApproved bool + Beneficiary common.Address + Path []byte + Permit []byte + Uuid [16]byte +} + +// PsTakerMetaData contains all meta data concerning the PsTaker contract. +var PsTakerMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_weth\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_partnerSharePercent\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxFeePercent\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_paraswapReferralShare\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_paraswapSlippageShare\",\"type\":\"uint256\"},{\"internalType\":\"contractIFeeClaimer\",\"name\":\"_feeClaimer\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"partner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"srcToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"receivedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"}],\"name\":\"BoughtV3\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"partner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"enumDirectSwap.DirectSwapKind\",\"name\":\"kind\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"srcToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"receivedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"}],\"name\":\"SwappedDirect\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"partner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"srcToken\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"destToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"receivedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"}],\"name\":\"SwappedV3\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"ROUTER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"WHITELISTED_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"assetInIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assetOutIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"userData\",\"type\":\"bytes\"}],\"internalType\":\"structIBalancerV2Vault.BatchSwapStep[]\",\"name\":\"swaps\",\"type\":\"tuple[]\"},{\"internalType\":\"address[]\",\"name\":\"assets\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"fromInternalBalance\",\"type\":\"bool\"},{\"internalType\":\"addresspayable\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"toInternalBalance\",\"type\":\"bool\"}],\"internalType\":\"structIBalancerV2Vault.FundManagement\",\"name\":\"funds\",\"type\":\"tuple\"},{\"internalType\":\"int256[]\",\"name\":\"limits\",\"type\":\"int256[]\"},{\"internalType\":\"uint256\",\"name\":\"fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"partner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isApproved\",\"type\":\"bool\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"},{\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"}],\"internalType\":\"structUtils.DirectBalancerV2\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"directBalancerV2GivenInSwap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"assetInIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assetOutIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"userData\",\"type\":\"bytes\"}],\"internalType\":\"structIBalancerV2Vault.BatchSwapStep[]\",\"name\":\"swaps\",\"type\":\"tuple[]\"},{\"internalType\":\"address[]\",\"name\":\"assets\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"fromInternalBalance\",\"type\":\"bool\"},{\"internalType\":\"addresspayable\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"toInternalBalance\",\"type\":\"bool\"}],\"internalType\":\"structIBalancerV2Vault.FundManagement\",\"name\":\"funds\",\"type\":\"tuple\"},{\"internalType\":\"int256[]\",\"name\":\"limits\",\"type\":\"int256[]\"},{\"internalType\":\"uint256\",\"name\":\"fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"partner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isApproved\",\"type\":\"bool\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"},{\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"}],\"internalType\":\"structUtils.DirectBalancerV2\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"directBalancerV2GivenOutSwap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"toToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"exchange\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"internalType\":\"int128\",\"name\":\"i\",\"type\":\"int128\"},{\"internalType\":\"int128\",\"name\":\"j\",\"type\":\"int128\"},{\"internalType\":\"addresspayable\",\"name\":\"partner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isApproved\",\"type\":\"bool\"},{\"internalType\":\"enumUtils.CurveSwapType\",\"name\":\"swapType\",\"type\":\"uint8\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"needWrapNative\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"},{\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"}],\"internalType\":\"structUtils.DirectCurveV1\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"directCurveV1Swap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"toToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"exchange\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"i\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"j\",\"type\":\"uint256\"},{\"internalType\":\"addresspayable\",\"name\":\"partner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isApproved\",\"type\":\"bool\"},{\"internalType\":\"enumUtils.CurveSwapType\",\"name\":\"swapType\",\"type\":\"uint8\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"needWrapNative\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"},{\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"}],\"internalType\":\"structUtils.DirectCurveV2\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"directCurveV2Swap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"toToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"exchange\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"addresspayable\",\"name\":\"partner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isApproved\",\"type\":\"bool\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"},{\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"}],\"internalType\":\"structUtils.DirectUniV3\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"directUniV3Buy\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"toToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"exchange\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePercent\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"addresspayable\",\"name\":\"partner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isApproved\",\"type\":\"bool\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"},{\"internalType\":\"bytes16\",\"name\":\"uuid\",\"type\":\"bytes16\"}],\"internalType\":\"structUtils.DirectUniV3\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"directUniV3Swap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeClaimer\",\"outputs\":[{\"internalType\":\"contractIFeeClaimer\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getKey\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxFeePercent\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paraswapReferralShare\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paraswapSlippageShare\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"partnerSharePercent\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"weth\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// PsTakerABI is the input ABI used to generate the binding from. +// Deprecated: Use PsTakerMetaData.ABI instead. +var PsTakerABI = PsTakerMetaData.ABI + +// PsTaker is an auto generated Go binding around an Ethereum contract. +type PsTaker struct { + PsTakerCaller // Read-only binding to the contract + PsTakerTransactor // Write-only binding to the contract + PsTakerFilterer // Log filterer for contract events +} + +// PsTakerCaller is an auto generated read-only Go binding around an Ethereum contract. +type PsTakerCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PsTakerTransactor is an auto generated write-only Go binding around an Ethereum contract. +type PsTakerTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PsTakerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type PsTakerFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PsTakerSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type PsTakerSession struct { + Contract *PsTaker // 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 +} + +// PsTakerCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type PsTakerCallerSession struct { + Contract *PsTakerCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// PsTakerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type PsTakerTransactorSession struct { + Contract *PsTakerTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PsTakerRaw is an auto generated low-level Go binding around an Ethereum contract. +type PsTakerRaw struct { + Contract *PsTaker // Generic contract binding to access the raw methods on +} + +// PsTakerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type PsTakerCallerRaw struct { + Contract *PsTakerCaller // Generic read-only contract binding to access the raw methods on +} + +// PsTakerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type PsTakerTransactorRaw struct { + Contract *PsTakerTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewPsTaker creates a new instance of PsTaker, bound to a specific deployed contract. +func NewPsTaker(address common.Address, backend bind.ContractBackend) (*PsTaker, error) { + contract, err := bindPsTaker(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &PsTaker{PsTakerCaller: PsTakerCaller{contract: contract}, PsTakerTransactor: PsTakerTransactor{contract: contract}, PsTakerFilterer: PsTakerFilterer{contract: contract}}, nil +} + +// NewPsTakerCaller creates a new read-only instance of PsTaker, bound to a specific deployed contract. +func NewPsTakerCaller(address common.Address, caller bind.ContractCaller) (*PsTakerCaller, error) { + contract, err := bindPsTaker(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &PsTakerCaller{contract: contract}, nil +} + +// NewPsTakerTransactor creates a new write-only instance of PsTaker, bound to a specific deployed contract. +func NewPsTakerTransactor(address common.Address, transactor bind.ContractTransactor) (*PsTakerTransactor, error) { + contract, err := bindPsTaker(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &PsTakerTransactor{contract: contract}, nil +} + +// NewPsTakerFilterer creates a new log filterer instance of PsTaker, bound to a specific deployed contract. +func NewPsTakerFilterer(address common.Address, filterer bind.ContractFilterer) (*PsTakerFilterer, error) { + contract, err := bindPsTaker(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &PsTakerFilterer{contract: contract}, nil +} + +// bindPsTaker binds a generic wrapper to an already deployed contract. +func bindPsTaker(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := PsTakerMetaData.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 (_PsTaker *PsTakerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PsTaker.Contract.PsTakerCaller.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 (_PsTaker *PsTakerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PsTaker.Contract.PsTakerTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PsTaker *PsTakerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PsTaker.Contract.PsTakerTransactor.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 (_PsTaker *PsTakerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PsTaker.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 (_PsTaker *PsTakerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PsTaker.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PsTaker *PsTakerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PsTaker.Contract.contract.Transact(opts, method, params...) +} + +// ROUTERROLE is a free data retrieval call binding the contract method 0x30d643b5. +// +// Solidity: function ROUTER_ROLE() view returns(bytes32) +func (_PsTaker *PsTakerCaller) ROUTERROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "ROUTER_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ROUTERROLE is a free data retrieval call binding the contract method 0x30d643b5. +// +// Solidity: function ROUTER_ROLE() view returns(bytes32) +func (_PsTaker *PsTakerSession) ROUTERROLE() ([32]byte, error) { + return _PsTaker.Contract.ROUTERROLE(&_PsTaker.CallOpts) +} + +// ROUTERROLE is a free data retrieval call binding the contract method 0x30d643b5. +// +// Solidity: function ROUTER_ROLE() view returns(bytes32) +func (_PsTaker *PsTakerCallerSession) ROUTERROLE() ([32]byte, error) { + return _PsTaker.Contract.ROUTERROLE(&_PsTaker.CallOpts) +} + +// WHITELISTEDROLE is a free data retrieval call binding the contract method 0x7a3226ec. +// +// Solidity: function WHITELISTED_ROLE() view returns(bytes32) +func (_PsTaker *PsTakerCaller) WHITELISTEDROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "WHITELISTED_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// WHITELISTEDROLE is a free data retrieval call binding the contract method 0x7a3226ec. +// +// Solidity: function WHITELISTED_ROLE() view returns(bytes32) +func (_PsTaker *PsTakerSession) WHITELISTEDROLE() ([32]byte, error) { + return _PsTaker.Contract.WHITELISTEDROLE(&_PsTaker.CallOpts) +} + +// WHITELISTEDROLE is a free data retrieval call binding the contract method 0x7a3226ec. +// +// Solidity: function WHITELISTED_ROLE() view returns(bytes32) +func (_PsTaker *PsTakerCallerSession) WHITELISTEDROLE() ([32]byte, error) { + return _PsTaker.Contract.WHITELISTEDROLE(&_PsTaker.CallOpts) +} + +// FeeClaimer is a free data retrieval call binding the contract method 0x81cbd3ea. +// +// Solidity: function feeClaimer() view returns(address) +func (_PsTaker *PsTakerCaller) FeeClaimer(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "feeClaimer") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// FeeClaimer is a free data retrieval call binding the contract method 0x81cbd3ea. +// +// Solidity: function feeClaimer() view returns(address) +func (_PsTaker *PsTakerSession) FeeClaimer() (common.Address, error) { + return _PsTaker.Contract.FeeClaimer(&_PsTaker.CallOpts) +} + +// FeeClaimer is a free data retrieval call binding the contract method 0x81cbd3ea. +// +// Solidity: function feeClaimer() view returns(address) +func (_PsTaker *PsTakerCallerSession) FeeClaimer() (common.Address, error) { + return _PsTaker.Contract.FeeClaimer(&_PsTaker.CallOpts) +} + +// GetKey is a free data retrieval call binding the contract method 0x82678dd6. +// +// Solidity: function getKey() pure returns(bytes32) +func (_PsTaker *PsTakerCaller) GetKey(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "getKey") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetKey is a free data retrieval call binding the contract method 0x82678dd6. +// +// Solidity: function getKey() pure returns(bytes32) +func (_PsTaker *PsTakerSession) GetKey() ([32]byte, error) { + return _PsTaker.Contract.GetKey(&_PsTaker.CallOpts) +} + +// GetKey is a free data retrieval call binding the contract method 0x82678dd6. +// +// Solidity: function getKey() pure returns(bytes32) +func (_PsTaker *PsTakerCallerSession) GetKey() ([32]byte, error) { + return _PsTaker.Contract.GetKey(&_PsTaker.CallOpts) +} + +// Initialize is a free data retrieval call binding the contract method 0x439fab91. +// +// Solidity: function initialize(bytes ) pure returns() +func (_PsTaker *PsTakerCaller) Initialize(opts *bind.CallOpts, arg0 []byte) error { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "initialize", arg0) + + if err != nil { + return err + } + + return err + +} + +// Initialize is a free data retrieval call binding the contract method 0x439fab91. +// +// Solidity: function initialize(bytes ) pure returns() +func (_PsTaker *PsTakerSession) Initialize(arg0 []byte) error { + return _PsTaker.Contract.Initialize(&_PsTaker.CallOpts, arg0) +} + +// Initialize is a free data retrieval call binding the contract method 0x439fab91. +// +// Solidity: function initialize(bytes ) pure returns() +func (_PsTaker *PsTakerCallerSession) Initialize(arg0 []byte) error { + return _PsTaker.Contract.Initialize(&_PsTaker.CallOpts, arg0) +} + +// MaxFeePercent is a free data retrieval call binding the contract method 0xd830a05b. +// +// Solidity: function maxFeePercent() view returns(uint256) +func (_PsTaker *PsTakerCaller) MaxFeePercent(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "maxFeePercent") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MaxFeePercent is a free data retrieval call binding the contract method 0xd830a05b. +// +// Solidity: function maxFeePercent() view returns(uint256) +func (_PsTaker *PsTakerSession) MaxFeePercent() (*big.Int, error) { + return _PsTaker.Contract.MaxFeePercent(&_PsTaker.CallOpts) +} + +// MaxFeePercent is a free data retrieval call binding the contract method 0xd830a05b. +// +// Solidity: function maxFeePercent() view returns(uint256) +func (_PsTaker *PsTakerCallerSession) MaxFeePercent() (*big.Int, error) { + return _PsTaker.Contract.MaxFeePercent(&_PsTaker.CallOpts) +} + +// ParaswapReferralShare is a free data retrieval call binding the contract method 0xd555d4f9. +// +// Solidity: function paraswapReferralShare() view returns(uint256) +func (_PsTaker *PsTakerCaller) ParaswapReferralShare(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "paraswapReferralShare") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ParaswapReferralShare is a free data retrieval call binding the contract method 0xd555d4f9. +// +// Solidity: function paraswapReferralShare() view returns(uint256) +func (_PsTaker *PsTakerSession) ParaswapReferralShare() (*big.Int, error) { + return _PsTaker.Contract.ParaswapReferralShare(&_PsTaker.CallOpts) +} + +// ParaswapReferralShare is a free data retrieval call binding the contract method 0xd555d4f9. +// +// Solidity: function paraswapReferralShare() view returns(uint256) +func (_PsTaker *PsTakerCallerSession) ParaswapReferralShare() (*big.Int, error) { + return _PsTaker.Contract.ParaswapReferralShare(&_PsTaker.CallOpts) +} + +// ParaswapSlippageShare is a free data retrieval call binding the contract method 0xc25ff026. +// +// Solidity: function paraswapSlippageShare() view returns(uint256) +func (_PsTaker *PsTakerCaller) ParaswapSlippageShare(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "paraswapSlippageShare") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ParaswapSlippageShare is a free data retrieval call binding the contract method 0xc25ff026. +// +// Solidity: function paraswapSlippageShare() view returns(uint256) +func (_PsTaker *PsTakerSession) ParaswapSlippageShare() (*big.Int, error) { + return _PsTaker.Contract.ParaswapSlippageShare(&_PsTaker.CallOpts) +} + +// ParaswapSlippageShare is a free data retrieval call binding the contract method 0xc25ff026. +// +// Solidity: function paraswapSlippageShare() view returns(uint256) +func (_PsTaker *PsTakerCallerSession) ParaswapSlippageShare() (*big.Int, error) { + return _PsTaker.Contract.ParaswapSlippageShare(&_PsTaker.CallOpts) +} + +// PartnerSharePercent is a free data retrieval call binding the contract method 0x12070a41. +// +// Solidity: function partnerSharePercent() view returns(uint256) +func (_PsTaker *PsTakerCaller) PartnerSharePercent(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "partnerSharePercent") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PartnerSharePercent is a free data retrieval call binding the contract method 0x12070a41. +// +// Solidity: function partnerSharePercent() view returns(uint256) +func (_PsTaker *PsTakerSession) PartnerSharePercent() (*big.Int, error) { + return _PsTaker.Contract.PartnerSharePercent(&_PsTaker.CallOpts) +} + +// PartnerSharePercent is a free data retrieval call binding the contract method 0x12070a41. +// +// Solidity: function partnerSharePercent() view returns(uint256) +func (_PsTaker *PsTakerCallerSession) PartnerSharePercent() (*big.Int, error) { + return _PsTaker.Contract.PartnerSharePercent(&_PsTaker.CallOpts) +} + +// Weth is a free data retrieval call binding the contract method 0x3fc8cef3. +// +// Solidity: function weth() view returns(address) +func (_PsTaker *PsTakerCaller) Weth(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PsTaker.contract.Call(opts, &out, "weth") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Weth is a free data retrieval call binding the contract method 0x3fc8cef3. +// +// Solidity: function weth() view returns(address) +func (_PsTaker *PsTakerSession) Weth() (common.Address, error) { + return _PsTaker.Contract.Weth(&_PsTaker.CallOpts) +} + +// Weth is a free data retrieval call binding the contract method 0x3fc8cef3. +// +// Solidity: function weth() view returns(address) +func (_PsTaker *PsTakerCallerSession) Weth() (common.Address, error) { + return _PsTaker.Contract.Weth(&_PsTaker.CallOpts) +} + +// DirectBalancerV2GivenInSwap is a paid mutator transaction binding the contract method 0xb22f4db8. +// +// Solidity: function directBalancerV2GivenInSwap(((bytes32,uint256,uint256,uint256,bytes)[],address[],(address,bool,address,bool),int256[],uint256,uint256,uint256,uint256,uint256,address,address,bool,address,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactor) DirectBalancerV2GivenInSwap(opts *bind.TransactOpts, data UtilsDirectBalancerV2) (*types.Transaction, error) { + return _PsTaker.contract.Transact(opts, "directBalancerV2GivenInSwap", data) +} + +// DirectBalancerV2GivenInSwap is a paid mutator transaction binding the contract method 0xb22f4db8. +// +// Solidity: function directBalancerV2GivenInSwap(((bytes32,uint256,uint256,uint256,bytes)[],address[],(address,bool,address,bool),int256[],uint256,uint256,uint256,uint256,uint256,address,address,bool,address,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerSession) DirectBalancerV2GivenInSwap(data UtilsDirectBalancerV2) (*types.Transaction, error) { + return _PsTaker.Contract.DirectBalancerV2GivenInSwap(&_PsTaker.TransactOpts, data) +} + +// DirectBalancerV2GivenInSwap is a paid mutator transaction binding the contract method 0xb22f4db8. +// +// Solidity: function directBalancerV2GivenInSwap(((bytes32,uint256,uint256,uint256,bytes)[],address[],(address,bool,address,bool),int256[],uint256,uint256,uint256,uint256,uint256,address,address,bool,address,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactorSession) DirectBalancerV2GivenInSwap(data UtilsDirectBalancerV2) (*types.Transaction, error) { + return _PsTaker.Contract.DirectBalancerV2GivenInSwap(&_PsTaker.TransactOpts, data) +} + +// DirectBalancerV2GivenOutSwap is a paid mutator transaction binding the contract method 0x19fc5be0. +// +// Solidity: function directBalancerV2GivenOutSwap(((bytes32,uint256,uint256,uint256,bytes)[],address[],(address,bool,address,bool),int256[],uint256,uint256,uint256,uint256,uint256,address,address,bool,address,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactor) DirectBalancerV2GivenOutSwap(opts *bind.TransactOpts, data UtilsDirectBalancerV2) (*types.Transaction, error) { + return _PsTaker.contract.Transact(opts, "directBalancerV2GivenOutSwap", data) +} + +// DirectBalancerV2GivenOutSwap is a paid mutator transaction binding the contract method 0x19fc5be0. +// +// Solidity: function directBalancerV2GivenOutSwap(((bytes32,uint256,uint256,uint256,bytes)[],address[],(address,bool,address,bool),int256[],uint256,uint256,uint256,uint256,uint256,address,address,bool,address,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerSession) DirectBalancerV2GivenOutSwap(data UtilsDirectBalancerV2) (*types.Transaction, error) { + return _PsTaker.Contract.DirectBalancerV2GivenOutSwap(&_PsTaker.TransactOpts, data) +} + +// DirectBalancerV2GivenOutSwap is a paid mutator transaction binding the contract method 0x19fc5be0. +// +// Solidity: function directBalancerV2GivenOutSwap(((bytes32,uint256,uint256,uint256,bytes)[],address[],(address,bool,address,bool),int256[],uint256,uint256,uint256,uint256,uint256,address,address,bool,address,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactorSession) DirectBalancerV2GivenOutSwap(data UtilsDirectBalancerV2) (*types.Transaction, error) { + return _PsTaker.Contract.DirectBalancerV2GivenOutSwap(&_PsTaker.TransactOpts, data) +} + +// DirectCurveV1Swap is a paid mutator transaction binding the contract method 0x3865bde6. +// +// Solidity: function directCurveV1Swap((address,address,address,uint256,uint256,uint256,uint256,int128,int128,address,bool,uint8,address,bool,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactor) DirectCurveV1Swap(opts *bind.TransactOpts, data UtilsDirectCurveV1) (*types.Transaction, error) { + return _PsTaker.contract.Transact(opts, "directCurveV1Swap", data) +} + +// DirectCurveV1Swap is a paid mutator transaction binding the contract method 0x3865bde6. +// +// Solidity: function directCurveV1Swap((address,address,address,uint256,uint256,uint256,uint256,int128,int128,address,bool,uint8,address,bool,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerSession) DirectCurveV1Swap(data UtilsDirectCurveV1) (*types.Transaction, error) { + return _PsTaker.Contract.DirectCurveV1Swap(&_PsTaker.TransactOpts, data) +} + +// DirectCurveV1Swap is a paid mutator transaction binding the contract method 0x3865bde6. +// +// Solidity: function directCurveV1Swap((address,address,address,uint256,uint256,uint256,uint256,int128,int128,address,bool,uint8,address,bool,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactorSession) DirectCurveV1Swap(data UtilsDirectCurveV1) (*types.Transaction, error) { + return _PsTaker.Contract.DirectCurveV1Swap(&_PsTaker.TransactOpts, data) +} + +// DirectCurveV2Swap is a paid mutator transaction binding the contract method 0x58f15100. +// +// Solidity: function directCurveV2Swap((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,address,bool,uint8,address,bool,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactor) DirectCurveV2Swap(opts *bind.TransactOpts, data UtilsDirectCurveV2) (*types.Transaction, error) { + return _PsTaker.contract.Transact(opts, "directCurveV2Swap", data) +} + +// DirectCurveV2Swap is a paid mutator transaction binding the contract method 0x58f15100. +// +// Solidity: function directCurveV2Swap((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,address,bool,uint8,address,bool,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerSession) DirectCurveV2Swap(data UtilsDirectCurveV2) (*types.Transaction, error) { + return _PsTaker.Contract.DirectCurveV2Swap(&_PsTaker.TransactOpts, data) +} + +// DirectCurveV2Swap is a paid mutator transaction binding the contract method 0x58f15100. +// +// Solidity: function directCurveV2Swap((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,address,bool,uint8,address,bool,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactorSession) DirectCurveV2Swap(data UtilsDirectCurveV2) (*types.Transaction, error) { + return _PsTaker.Contract.DirectCurveV2Swap(&_PsTaker.TransactOpts, data) +} + +// DirectUniV3Buy is a paid mutator transaction binding the contract method 0x87a63926. +// +// Solidity: function directUniV3Buy((address,address,address,uint256,uint256,uint256,uint256,uint256,address,bool,address,bytes,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactor) DirectUniV3Buy(opts *bind.TransactOpts, data UtilsDirectUniV3) (*types.Transaction, error) { + return _PsTaker.contract.Transact(opts, "directUniV3Buy", data) +} + +// DirectUniV3Buy is a paid mutator transaction binding the contract method 0x87a63926. +// +// Solidity: function directUniV3Buy((address,address,address,uint256,uint256,uint256,uint256,uint256,address,bool,address,bytes,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerSession) DirectUniV3Buy(data UtilsDirectUniV3) (*types.Transaction, error) { + return _PsTaker.Contract.DirectUniV3Buy(&_PsTaker.TransactOpts, data) +} + +// DirectUniV3Buy is a paid mutator transaction binding the contract method 0x87a63926. +// +// Solidity: function directUniV3Buy((address,address,address,uint256,uint256,uint256,uint256,uint256,address,bool,address,bytes,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactorSession) DirectUniV3Buy(data UtilsDirectUniV3) (*types.Transaction, error) { + return _PsTaker.Contract.DirectUniV3Buy(&_PsTaker.TransactOpts, data) +} + +// DirectUniV3Swap is a paid mutator transaction binding the contract method 0xa6886da9. +// +// Solidity: function directUniV3Swap((address,address,address,uint256,uint256,uint256,uint256,uint256,address,bool,address,bytes,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactor) DirectUniV3Swap(opts *bind.TransactOpts, data UtilsDirectUniV3) (*types.Transaction, error) { + return _PsTaker.contract.Transact(opts, "directUniV3Swap", data) +} + +// DirectUniV3Swap is a paid mutator transaction binding the contract method 0xa6886da9. +// +// Solidity: function directUniV3Swap((address,address,address,uint256,uint256,uint256,uint256,uint256,address,bool,address,bytes,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerSession) DirectUniV3Swap(data UtilsDirectUniV3) (*types.Transaction, error) { + return _PsTaker.Contract.DirectUniV3Swap(&_PsTaker.TransactOpts, data) +} + +// DirectUniV3Swap is a paid mutator transaction binding the contract method 0xa6886da9. +// +// Solidity: function directUniV3Swap((address,address,address,uint256,uint256,uint256,uint256,uint256,address,bool,address,bytes,bytes,bytes16) data) payable returns() +func (_PsTaker *PsTakerTransactorSession) DirectUniV3Swap(data UtilsDirectUniV3) (*types.Transaction, error) { + return _PsTaker.Contract.DirectUniV3Swap(&_PsTaker.TransactOpts, data) +} + +// PsTakerBoughtV3Iterator is returned from FilterBoughtV3 and is used to iterate over the raw logs and unpacked data for BoughtV3 events raised by the PsTaker contract. +type PsTakerBoughtV3Iterator struct { + Event *PsTakerBoughtV3 // 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 *PsTakerBoughtV3Iterator) 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(PsTakerBoughtV3) + 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(PsTakerBoughtV3) + 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 *PsTakerBoughtV3Iterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PsTakerBoughtV3Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PsTakerBoughtV3 represents a BoughtV3 event raised by the PsTaker contract. +type PsTakerBoughtV3 struct { + Uuid [16]byte + Partner common.Address + FeePercent *big.Int + Initiator common.Address + Beneficiary common.Address + SrcToken common.Address + DestToken common.Address + SrcAmount *big.Int + ReceivedAmount *big.Int + ExpectedAmount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBoughtV3 is a free log retrieval operation binding the contract event 0x4cc7e95e48af62690313a0733e93308ac9a73326bc3c29f1788b1191c376d5b6. +// +// Solidity: event BoughtV3(bytes16 uuid, address partner, uint256 feePercent, address initiator, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) FilterBoughtV3(opts *bind.FilterOpts, beneficiary []common.Address, srcToken []common.Address, destToken []common.Address) (*PsTakerBoughtV3Iterator, error) { + + var beneficiaryRule []interface{} + for _, beneficiaryItem := range beneficiary { + beneficiaryRule = append(beneficiaryRule, beneficiaryItem) + } + var srcTokenRule []interface{} + for _, srcTokenItem := range srcToken { + srcTokenRule = append(srcTokenRule, srcTokenItem) + } + var destTokenRule []interface{} + for _, destTokenItem := range destToken { + destTokenRule = append(destTokenRule, destTokenItem) + } + + logs, sub, err := _PsTaker.contract.FilterLogs(opts, "BoughtV3", beneficiaryRule, srcTokenRule, destTokenRule) + if err != nil { + return nil, err + } + return &PsTakerBoughtV3Iterator{contract: _PsTaker.contract, event: "BoughtV3", logs: logs, sub: sub}, nil +} + +// WatchBoughtV3 is a free log subscription operation binding the contract event 0x4cc7e95e48af62690313a0733e93308ac9a73326bc3c29f1788b1191c376d5b6. +// +// Solidity: event BoughtV3(bytes16 uuid, address partner, uint256 feePercent, address initiator, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) WatchBoughtV3(opts *bind.WatchOpts, sink chan<- *PsTakerBoughtV3, beneficiary []common.Address, srcToken []common.Address, destToken []common.Address) (event.Subscription, error) { + + var beneficiaryRule []interface{} + for _, beneficiaryItem := range beneficiary { + beneficiaryRule = append(beneficiaryRule, beneficiaryItem) + } + var srcTokenRule []interface{} + for _, srcTokenItem := range srcToken { + srcTokenRule = append(srcTokenRule, srcTokenItem) + } + var destTokenRule []interface{} + for _, destTokenItem := range destToken { + destTokenRule = append(destTokenRule, destTokenItem) + } + + logs, sub, err := _PsTaker.contract.WatchLogs(opts, "BoughtV3", beneficiaryRule, srcTokenRule, destTokenRule) + 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(PsTakerBoughtV3) + if err := _PsTaker.contract.UnpackLog(event, "BoughtV3", 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 +} + +// ParseBoughtV3 is a log parse operation binding the contract event 0x4cc7e95e48af62690313a0733e93308ac9a73326bc3c29f1788b1191c376d5b6. +// +// Solidity: event BoughtV3(bytes16 uuid, address partner, uint256 feePercent, address initiator, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) ParseBoughtV3(log types.Log) (*PsTakerBoughtV3, error) { + event := new(PsTakerBoughtV3) + if err := _PsTaker.contract.UnpackLog(event, "BoughtV3", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PsTakerSwappedDirectIterator is returned from FilterSwappedDirect and is used to iterate over the raw logs and unpacked data for SwappedDirect events raised by the PsTaker contract. +type PsTakerSwappedDirectIterator struct { + Event *PsTakerSwappedDirect // 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 *PsTakerSwappedDirectIterator) 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(PsTakerSwappedDirect) + 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(PsTakerSwappedDirect) + 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 *PsTakerSwappedDirectIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PsTakerSwappedDirectIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PsTakerSwappedDirect represents a SwappedDirect event raised by the PsTaker contract. +type PsTakerSwappedDirect struct { + Uuid [16]byte + Partner common.Address + FeePercent *big.Int + Initiator common.Address + Kind uint8 + Beneficiary common.Address + SrcToken common.Address + DestToken common.Address + SrcAmount *big.Int + ReceivedAmount *big.Int + ExpectedAmount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSwappedDirect is a free log retrieval operation binding the contract event 0xd2d73da2b5fd52cd654d8fd1b514ad57355bad741de639e3a1c3a20dd9f17347. +// +// Solidity: event SwappedDirect(bytes16 uuid, address partner, uint256 feePercent, address initiator, uint8 kind, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) FilterSwappedDirect(opts *bind.FilterOpts, beneficiary []common.Address, srcToken []common.Address, destToken []common.Address) (*PsTakerSwappedDirectIterator, error) { + + var beneficiaryRule []interface{} + for _, beneficiaryItem := range beneficiary { + beneficiaryRule = append(beneficiaryRule, beneficiaryItem) + } + var srcTokenRule []interface{} + for _, srcTokenItem := range srcToken { + srcTokenRule = append(srcTokenRule, srcTokenItem) + } + var destTokenRule []interface{} + for _, destTokenItem := range destToken { + destTokenRule = append(destTokenRule, destTokenItem) + } + + logs, sub, err := _PsTaker.contract.FilterLogs(opts, "SwappedDirect", beneficiaryRule, srcTokenRule, destTokenRule) + if err != nil { + return nil, err + } + return &PsTakerSwappedDirectIterator{contract: _PsTaker.contract, event: "SwappedDirect", logs: logs, sub: sub}, nil +} + +// WatchSwappedDirect is a free log subscription operation binding the contract event 0xd2d73da2b5fd52cd654d8fd1b514ad57355bad741de639e3a1c3a20dd9f17347. +// +// Solidity: event SwappedDirect(bytes16 uuid, address partner, uint256 feePercent, address initiator, uint8 kind, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) WatchSwappedDirect(opts *bind.WatchOpts, sink chan<- *PsTakerSwappedDirect, beneficiary []common.Address, srcToken []common.Address, destToken []common.Address) (event.Subscription, error) { + + var beneficiaryRule []interface{} + for _, beneficiaryItem := range beneficiary { + beneficiaryRule = append(beneficiaryRule, beneficiaryItem) + } + var srcTokenRule []interface{} + for _, srcTokenItem := range srcToken { + srcTokenRule = append(srcTokenRule, srcTokenItem) + } + var destTokenRule []interface{} + for _, destTokenItem := range destToken { + destTokenRule = append(destTokenRule, destTokenItem) + } + + logs, sub, err := _PsTaker.contract.WatchLogs(opts, "SwappedDirect", beneficiaryRule, srcTokenRule, destTokenRule) + 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(PsTakerSwappedDirect) + if err := _PsTaker.contract.UnpackLog(event, "SwappedDirect", 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 +} + +// ParseSwappedDirect is a log parse operation binding the contract event 0xd2d73da2b5fd52cd654d8fd1b514ad57355bad741de639e3a1c3a20dd9f17347. +// +// Solidity: event SwappedDirect(bytes16 uuid, address partner, uint256 feePercent, address initiator, uint8 kind, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) ParseSwappedDirect(log types.Log) (*PsTakerSwappedDirect, error) { + event := new(PsTakerSwappedDirect) + if err := _PsTaker.contract.UnpackLog(event, "SwappedDirect", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PsTakerSwappedV3Iterator is returned from FilterSwappedV3 and is used to iterate over the raw logs and unpacked data for SwappedV3 events raised by the PsTaker contract. +type PsTakerSwappedV3Iterator struct { + Event *PsTakerSwappedV3 // 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 *PsTakerSwappedV3Iterator) 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(PsTakerSwappedV3) + 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(PsTakerSwappedV3) + 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 *PsTakerSwappedV3Iterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PsTakerSwappedV3Iterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PsTakerSwappedV3 represents a SwappedV3 event raised by the PsTaker contract. +type PsTakerSwappedV3 struct { + Uuid [16]byte + Partner common.Address + FeePercent *big.Int + Initiator common.Address + Beneficiary common.Address + SrcToken common.Address + DestToken common.Address + SrcAmount *big.Int + ReceivedAmount *big.Int + ExpectedAmount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSwappedV3 is a free log retrieval operation binding the contract event 0xe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0. +// +// Solidity: event SwappedV3(bytes16 uuid, address partner, uint256 feePercent, address initiator, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) FilterSwappedV3(opts *bind.FilterOpts, beneficiary []common.Address, srcToken []common.Address, destToken []common.Address) (*PsTakerSwappedV3Iterator, error) { + + var beneficiaryRule []interface{} + for _, beneficiaryItem := range beneficiary { + beneficiaryRule = append(beneficiaryRule, beneficiaryItem) + } + var srcTokenRule []interface{} + for _, srcTokenItem := range srcToken { + srcTokenRule = append(srcTokenRule, srcTokenItem) + } + var destTokenRule []interface{} + for _, destTokenItem := range destToken { + destTokenRule = append(destTokenRule, destTokenItem) + } + + logs, sub, err := _PsTaker.contract.FilterLogs(opts, "SwappedV3", beneficiaryRule, srcTokenRule, destTokenRule) + if err != nil { + return nil, err + } + return &PsTakerSwappedV3Iterator{contract: _PsTaker.contract, event: "SwappedV3", logs: logs, sub: sub}, nil +} + +// WatchSwappedV3 is a free log subscription operation binding the contract event 0xe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0. +// +// Solidity: event SwappedV3(bytes16 uuid, address partner, uint256 feePercent, address initiator, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) WatchSwappedV3(opts *bind.WatchOpts, sink chan<- *PsTakerSwappedV3, beneficiary []common.Address, srcToken []common.Address, destToken []common.Address) (event.Subscription, error) { + + var beneficiaryRule []interface{} + for _, beneficiaryItem := range beneficiary { + beneficiaryRule = append(beneficiaryRule, beneficiaryItem) + } + var srcTokenRule []interface{} + for _, srcTokenItem := range srcToken { + srcTokenRule = append(srcTokenRule, srcTokenItem) + } + var destTokenRule []interface{} + for _, destTokenItem := range destToken { + destTokenRule = append(destTokenRule, destTokenItem) + } + + logs, sub, err := _PsTaker.contract.WatchLogs(opts, "SwappedV3", beneficiaryRule, srcTokenRule, destTokenRule) + 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(PsTakerSwappedV3) + if err := _PsTaker.contract.UnpackLog(event, "SwappedV3", 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 +} + +// ParseSwappedV3 is a log parse operation binding the contract event 0xe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0. +// +// Solidity: event SwappedV3(bytes16 uuid, address partner, uint256 feePercent, address initiator, address indexed beneficiary, address indexed srcToken, address indexed destToken, uint256 srcAmount, uint256 receivedAmount, uint256 expectedAmount) +func (_PsTaker *PsTakerFilterer) ParseSwappedV3(log types.Log) (*PsTakerSwappedV3, error) { + event := new(PsTakerSwappedV3) + if err := _PsTaker.contract.UnpackLog(event, "SwappedV3", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/parser/paraswap_taker/ps_taker_test.go b/pkg/parser/paraswap_taker/ps_taker_test.go new file mode 100644 index 0000000..339a40e --- /dev/null +++ b/pkg/parser/paraswap_taker/ps_taker_test.go @@ -0,0 +1,81 @@ +package pstaker //nolint: testpackage + +import ( + "context" + "encoding/json" + "math/big" + "testing" + "time" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/test-go/testify/require" +) + +func TestFetchEvent(t *testing.T) { + t.Skip() + p := MustNewParser() + require.Equal(t, p.abi.Events[SwapEvent].ID, common.HexToHash("0xe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0")) + client, err := ethclient.Dial("") + require.NoError(t, err) + logs, err := client.FilterLogs(context.Background(), ethereum.FilterQuery{ + BlockHash: nil, + FromBlock: big.NewInt(17538476), + ToBlock: big.NewInt(17538476), + Addresses: nil, + Topics: [][]common.Hash{{p.abi.Events[SwapEvent].ID}}, + }) + require.NoError(t, err) + d, err := json.Marshal(logs) + require.NoError(t, err) + t.Log(string(d)) +} + +func TestParseEvent(t *testing.T) { + eventRaw := `{ + "address":"0xdef171fe48cf0115b1d80b88dc8eab59176fee57","topics":["0xe00361d207b252a464323eb23d45d42583e391f2031acdd2e9fa36efddd43cb0","0x0000000000000000000000003a9b02c14d967333ce68e353a64653e258da2baa","0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"],"data":"0x32598393fe124476a72c13ece9ad2a7d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000040000000000000000000000000003a9b02c14d967333ce68e353a64653e258da2baa00000000000000000000000000000000000000000000006318989ad746100000000000000000000000000000000000000000000000000057bf1e61ab00fb472b000000000000000000000000000000000000000000000057bf1e61ab00fb472b","blockNumber":"0x10b9dac","transactionHash":"0x6ff0fee62b3dc8a59e64a2df0ff810e2e5b594f593cbba98c12f621c9d594e3a","transactionIndex":"0x6a","blockHash":"0x9bdfdf6247f1969fb9c9096352bb004c0d5c66b537818def499d744eb9a54748","logIndex":"0xe4","removed":false + }` + event := types.Log{} + err := json.Unmarshal([]byte(eventRaw), &event) + require.NoError(t, err) + p := MustNewParser() + log, err := p.Parse(event, uint64(time.Now().Unix())) + require.NoError(t, err) + require.Equal(t, log.EventHash, p.eventHash) + t.Log(log) +} + +func TestFetchDirectEvent(t *testing.T) { + t.Skip() + p := MustNewParser() + require.Equal(t, p.abi.Events[SwapDirect].ID, common.HexToHash("0xd2d73da2b5fd52cd654d8fd1b514ad57355bad741de639e3a1c3a20dd9f17347")) + client, err := ethclient.Dial("") + require.NoError(t, err) + logs, err := client.FilterLogs(context.Background(), ethereum.FilterQuery{ + BlockHash: nil, + FromBlock: big.NewInt(18743024), + ToBlock: big.NewInt(18743024), + Addresses: nil, + Topics: [][]common.Hash{{p.abi.Events[SwapDirect].ID}}, + }) + require.NoError(t, err) + d, err := json.Marshal(logs) + require.NoError(t, err) + t.Log(string(d)) +} + +func TestParseDirectEvent(t *testing.T) { + eventRaw := `{ + "address":"0xdef171fe48cf0115b1d80b88dc8eab59176fee57","topics":["0xd2d73da2b5fd52cd654d8fd1b514ad57355bad741de639e3a1c3a20dd9f17347","0x0000000000000000000000003a9b02c14d967333ce68e353a64653e258da2baa","0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0","0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"],"data":"0x915958345a264710bbd844f9e5d98a8d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000040000000000000000000000000003a9b02c14d967333ce68e353a64653e258da2baa0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000015df8c7137e65d000000000000000000000000000000000000000000000000001922b86271d97b33a400000000000000000000000000000000000000000000001922b86271d97b33a4","blockNumber":"0x11dfef0","transactionHash":"0x819dc882c6f853673ea7f8d1c194df885e0dfc22aa6f1e47897b1c9e3faa1392","transactionIndex":"0x81","blockHash":"0x2f6799f7438ebb22dffaa55401de03ce86cffba156f636fad46a4a9b135573ce","logIndex":"0xce","removed":false + }` + event := types.Log{} + err := json.Unmarshal([]byte(eventRaw), &event) + require.NoError(t, err) + p := MustNewParser() + log, err := p.Parse(event, uint64(time.Now().Unix())) + require.NoError(t, err) + require.Equal(t, log.EventHash, p.directEventHash) + t.Log(log) +}