diff --git a/Makefile b/Makefile index 3d8acab..36eda37 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # with Go source code. If you know what GOPATH is then you probably # don't need to bother with make. -.PHONY: mkdir oracle-server conf-file e2e-test-stuffs forex-plugins dex-plugins amm-plugins cex-plugins autoracle test e2e_test clean lint dep all +.PHONY: mkdir oracle-server conf-file e2e-test-stuffs forex-plugins amm-plugins cex-plugins autoracle test e2e_test clean lint dep all LINTER = ./bin/golangci-lint GOLANGCI_LINT_VERSION = v1.62.0 # Change this to the desired version @@ -78,9 +78,8 @@ e2e-test-stuffs: go build -o $(E2E_TEST_PRD_PLUGIN_DIR)/binance $(PLUGIN_SRC_DIR)/binance/binance.go chmod +x $(E2E_TEST_PRD_PLUGIN_DIR)/binance - # build amm and dex plugins for e2e test. + # build amm plugin for e2e test. go build -o $(E2E_TEST_CRYPTO_PLUGIN_DIR)/crypto_uniswap $(PLUGIN_SRC_DIR)/crypto_uniswap/uniswap_usdcx/crypto_uniswap_usdcx.go - go build -o $(E2E_TEST_CRYPTO_PLUGIN_DIR)/crypto_airswap $(PLUGIN_SRC_DIR)/crypto_airswap/crypto_airswap.go chmod +x $(E2E_TEST_CRYPTO_PLUGIN_DIR)/* # build bakerloo simulator plugin for e2e test. @@ -116,11 +115,6 @@ cex-plugins: go build -o $(PLUGIN_DIR)/crypto_kraken $(PLUGIN_SRC_DIR)/crypto_kraken/crypto_kraken.go chmod +x $(PLUGIN_DIR)/* -# dex plugins are not officially release yet. -dex-plugins: - go build -o $(PLUGIN_DIR)/crypto_airswap $(PLUGIN_SRC_DIR)/crypto_airswap/crypto_airswap.go - chmod +x $(PLUGIN_DIR)/* - # amm plugins are not officially release yet. amm-plugins: go build -o $(PLUGIN_DIR)/crypto_uniswap $(PLUGIN_SRC_DIR)/crypto_uniswap/uniswap_usdcx/crypto_uniswap_usdcx.go diff --git a/README.md b/README.md index d0eb490..bf620cc 100644 --- a/README.md +++ b/README.md @@ -78,12 +78,12 @@ confidenceStrategy: 0 # 0: linear, 1: fixed # # The crypto data plugins are used to fetch market prices for the crypto currency pairs: ATN-USDC, NTN-USDC, NTN-ATN and # USDC-USD. USDC liquidity is bridged to the Autonity public testnet from the Polygon Amoy testnet via a bridge service. -# Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. NTN-ATN market price is derived from -# that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and NTN-USD prices are then submitted on-chain. -# To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin and `crypto_airswap` plugin in your plugin directory. -# Oracle server can then discover and load them. Configuring the `crypto_uniswap` and `crypto_airswap` plugin does not +# Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. +# NTN-ATN market price is derived from that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and NTN-USD +# prices are then submitted on-chain. To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin plugin in your plugin directory. +# Oracle server can then discover and load them. Configuring the `crypto_uniswap` plugin does not # require an API key, it is an open and free data source of a standard EVM RPC websocket service endpoint. The -# end user can connect to specific EVM RPC endpoint base on the blockchain which hosts the uniswap and airswap contracts. +# end user can connect to specific EVM RPC endpoint base on the blockchain which hosts the uniswap contract. # USDC-USD prices are required by the protocol to convert the ATN-USDC and NTN-USDC to ATN-USD and NTN-USD. This enables # the reporting of ATN and NTN prices in USD to the ASM. Three plugins are implemented to source the USDC-USD datapoint diff --git a/config/config_for_test.yml b/config/config_for_test.yml index 54cb0f7..8469ca8 100644 --- a/config/config_for_test.yml +++ b/config/config_for_test.yml @@ -35,12 +35,12 @@ confidenceStrategy: 0 # 0: linear, 1: fixed # # The crypto data plugins are used to fetch market prices for the crypto currency pairs: ATN-USDC, NTN-USDC, NTN-ATN and # USDC-USD. USDC liquidity is bridged to the Autonity public testnet from the Polygon Amoy testnet via a bridge service. -# Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. NTN-ATN market price is derived from -# that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and NTN-USD prices are then submitted on-chain. -# To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin and `crypto_airswap` plugin in your plugin directory. -# Oracle server can then discover and load them. Configuring the `crypto_uniswap` and `crypto_airswap` plugin does not -# require an API key, it is an open and free data source of a standard EVM RPC websocket service endpoint. The -# end user can connect to specific EVM RPC endpoint base on the blockchain which hosts the uniswap and airswap contracts. +# Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. +# NTN-ATN market price is derived from that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and +# NTN-USD prices are then submitted on-chain. To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin in your plugin directory. +# Oracle server can then discover and load them. Configuring the `crypto_uniswap` plugin does not require an API key, +# it is an open and free data source of a standard EVM RPC websocket service endpoint. The end user can connect to specific +# EVM RPC endpoint base on the blockchain which hosts the uniswap contract. # USDC-USD prices are required by the protocol to convert the ATN-USDC and NTN-USDC to ATN-USD and NTN-USD. This enables # the reporting of ATN and NTN prices in USD to the ASM. Three plugins are implemented to source the USDC-USD datapoint diff --git a/config/oracle_config.yml b/config/oracle_config.yml index 68d1800..cf8230f 100644 --- a/config/oracle_config.yml +++ b/config/oracle_config.yml @@ -36,12 +36,11 @@ confidenceStrategy: 0 # 0: linear, 1: fixed # The crypto data plugins are used to fetch market prices for the crypto currency pairs: ATN-USDC, NTN-USDC, NTN-ATN and # USDC-USD. USDC liquidity is bridged to the Autonity public testnet from the Polygon Amoy testnet via a bridge service. # Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. -# NTN-ATN market price is derived from that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and NTN-USD -# prices are then submitted on-chain. To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin and `crypto_airswap` -# plugin in your plugin directory. Oracle server can then discover and load them. Configuring the `crypto_uniswap` and -#`crypto_airswap` plugin does not require an API key, it is an open and free data source of a standard EVM RPC websocket -# service endpoint. The end user can connect to specific EVM RPC endpoint base on the blockchain which hosts the uniswap -# and airswap contracts. +# NTN-ATN market price is derived from that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and +# NTN-USD prices are then submitted on-chain. To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin in your plugin directory. +# Oracle server can then discover and load them. Configuring the `crypto_uniswap` plugin does not require an API key, +# it is an open and free data source of a standard EVM RPC websocket service endpoint. The end user can connect to specific +# EVM RPC endpoint base on the blockchain which hosts the uniswap contract. # USDC-USD prices are required by the protocol to convert the ATN-USDC and NTN-USDC to ATN-USD and NTN-USD. This enables # the reporting of ATN and NTN prices in USD to the ASM. Three plugins are implemented to source the USDC-USD datapoint diff --git a/plugins/crypto_airswap/erc20/IERC20.abi b/e2e_test/contracts/erc20/IERC20.abi similarity index 100% rename from plugins/crypto_airswap/erc20/IERC20.abi rename to e2e_test/contracts/erc20/IERC20.abi diff --git a/plugins/crypto_airswap/erc20/IERC20.go b/e2e_test/contracts/erc20/IERC20.go similarity index 100% rename from plugins/crypto_airswap/erc20/IERC20.go rename to e2e_test/contracts/erc20/IERC20.go diff --git a/plugins/crypto_airswap/erc20/IERC20.sol b/e2e_test/contracts/erc20/IERC20.sol similarity index 100% rename from plugins/crypto_airswap/erc20/IERC20.sol rename to e2e_test/contracts/erc20/IERC20.sol diff --git a/e2e_test/e2e_test.go b/e2e_test/e2e_test.go index 0d372a3..7411bee 100644 --- a/e2e_test/e2e_test.go +++ b/e2e_test/e2e_test.go @@ -4,8 +4,8 @@ import ( "autonity-oracle/config" contract "autonity-oracle/contract_binder/contract" autonity "autonity-oracle/e2e_test/contracts" + "autonity-oracle/e2e_test/contracts/erc20" "autonity-oracle/helpers" - "autonity-oracle/plugins/crypto_airswap/erc20" "autonity-oracle/types" "context" "crypto/ecdsa" diff --git a/plugins/crypto_airswap/crypto_airswap.go b/plugins/crypto_airswap/crypto_airswap.go deleted file mode 100644 index cc9c1a9..0000000 --- a/plugins/crypto_airswap/crypto_airswap.go +++ /dev/null @@ -1,471 +0,0 @@ -package main - -import ( - "autonity-oracle/config" - "autonity-oracle/plugins/common" - "autonity-oracle/plugins/crypto_airswap/erc20" - swaperc20 "autonity-oracle/plugins/crypto_airswap/swap_erc20" - "autonity-oracle/types" - "context" - "errors" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ecommon "github.com/ethereum/go-ethereum/common" - types2 "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/ethereum/go-ethereum/event" - "github.com/hashicorp/go-hclog" - ring "github.com/zfjagann/golang-ring" - "math" - "math/big" - "os" - "sync" - "time" -) - -var ( - orderBookCapacity = 64 - version = "v0.2.0" - ATNUSDC = "ATN-USDC" - NTNUSDC = "NTN-USDC" - supportedSymbols = common.DefaultCryptoSymbols - NTNTokenAddress = types.AutonityContractAddress // Autonity contract is the protocol contract of NTN token -) - -// todo: airswap DEX plugin is not going to be released for the coming release. -var defaultConfig = config.PluginConfig{ - Name: "crypto_airswap", - Scheme: "wss", - Endpoint: "rpc-internal-1.piccadilly.autonity.org/ws", - Timeout: 10, // 10s - - // As DEX price can move very quickly, thus we prefer price sampling without any delay to reduce the risk of slashing. - DataUpdateInterval: common.DefaultAMMDataUpdateInterval, // 1s, rate limit is not required as DEX data is sourced from operator's own node. - - NTNTokenAddress: NTNTokenAddress.Hex(), // Same as 0xBd770416a3345F91E4B34576cb804a576fa48EB1, Autonity contract address. - ATNTokenAddress: "0xcE17e51cE4F0417A1aB31a3c5d6831ff3BbFa1d2", // Wrapped ATN ERC20 contract address on the target blockchain. - USDCTokenAddress: "0xB855D5e83363A4494e09f0Bb3152A70d3f161940", // USDCx ERC20 contract address on the target blockchain. - SwapAddress: "0x28363983213F88C759b501E3a5888458178cD5E7", // todo: config this once AirSwap SwapERC20 contract created. -} - -type Order struct { - cryptoToken ecommon.Address - cryptoAmount *big.Int - usdcAmount *big.Int -} - -// aggregatePrice compute the VWAP of the input orders, and return the total accumulating volumes. -func aggregatePrice(orderBook *ring.Ring, order Order) (*big.Rat, *big.Int, error) { - orderBook.Enqueue(order) - recentOrders := orderBook.Values() - return volumeWeightedPrice(recentOrders) -} - -// volumeWeightedPrice return the volume-weighted exchange ratio of ATN or NTN to USDC, and the total volumes. -func volumeWeightedPrice(orders []interface{}) (*big.Rat, *big.Int, error) { - // Initialize total crypto and USDC amounts - totalCrypto := new(big.Int) - totalUSDC := new(big.Int) - - // Iterate through the orders to sum up the amounts - for _, orderInterface := range orders { - // Type assert to Order - order, ok := orderInterface.(Order) - if !ok { - return nil, nil, fmt.Errorf("invalid order type") - } - - totalCrypto.Add(totalCrypto, order.cryptoAmount) - totalUSDC.Add(totalUSDC, order.usdcAmount) - } - - // Check if totalUSDC is zero to avoid division by zero - if totalUSDC.Cmp(common.Zero) == 0 { - return nil, nil, fmt.Errorf("total USDC amount is zero, cannot compute ratio") - } - - // Scale the totals according to their decimals - scaledTotalCrypto := new(big.Int).Mul(totalCrypto, big.NewInt(int64(math.Pow(10, float64(common.USDCDecimals))))) - scaledTotalUSDC := new(big.Int).Mul(totalUSDC, big.NewInt(int64(math.Pow(10, float64(common.AutonityCryptoDecimals))))) - - // Calculate the weighted ratio as a fraction - if scaledTotalUSDC.Cmp(common.Zero) == 0 { - return nil, nil, fmt.Errorf("scaled total USDC amount is zero, cannot compute ratio") - } - - weightedRatio := new(big.Rat).SetFrac(scaledTotalCrypto, scaledTotalUSDC) - return weightedRatio, totalUSDC, nil -} - -type AirswapClient struct { - conf *config.PluginConfig - client *ethclient.Client - logger hclog.Logger - - atnAddress ecommon.Address - usdcAddress ecommon.Address - ntnAddress ecommon.Address - - // ERC20 Transfer event parser. - erc20LogParser *erc20.Erc20 - - // SwapERC20 event watcher and log parser. - swapContract *swaperc20.Swaperc20 - - chSwapEvent chan *swaperc20.Swaperc20SwapERC20 - subSwapEvent event.Subscription - - doneCh chan struct{} - ticker *time.Ticker // the clock interval to recover L1 connectivity. - lostSync bool - - ntnOrderBooks ring.Ring - - atnOrderBooks ring.Ring - - priceMutex sync.RWMutex - - lastAggregatedPrices map[ecommon.Address]common.Price -} - -func NewAirswapClient(conf *config.PluginConfig) (*AirswapClient, error) { - logger := hclog.New(&hclog.LoggerOptions{ - Name: conf.Name, - Level: hclog.Info, - Output: os.Stdout, - }) - - url := conf.Scheme + "://" + conf.Endpoint - client, err := ethclient.Dial(url) - if err != nil { - logger.Error("cannot dial to L1 node", "error", err) - return nil, err - } - - swapContract, err := swaperc20.NewSwaperc20(ecommon.HexToAddress(conf.SwapAddress), client) - if err != nil { - logger.Error("cannot bind airswapERC20 contract", "error", err) - return nil, err - } - - erc20LogParser, err := erc20.NewErc20(NTNTokenAddress, client) - if err != nil { - logger.Error("cannot bind NTN ERC20 contract", "error", err) - return nil, err - } - - ac := &AirswapClient{ - conf: conf, - client: client, - logger: logger, - atnAddress: ecommon.HexToAddress(conf.ATNTokenAddress), - ntnAddress: NTNTokenAddress, - usdcAddress: ecommon.HexToAddress(conf.USDCTokenAddress), - erc20LogParser: erc20LogParser, - swapContract: swapContract, - doneCh: make(chan struct{}), - ticker: time.NewTicker(time.Minute), - lastAggregatedPrices: make(map[ecommon.Address]common.Price), - } - - ac.atnOrderBooks.SetCapacity(orderBookCapacity) - ac.ntnOrderBooks.SetCapacity(orderBookCapacity) - - if err = ac.EventSubscription(); err != nil { - return nil, err - } - - return ac, nil -} - -func (e *AirswapClient) EventSubscription() error { - // subscribe on-chain swap event of SwapERC20. - chSwapEvent := make(chan *swaperc20.Swaperc20SwapERC20) - subSwapEvent, err := e.swapContract.WatchSwapERC20(new(bind.WatchOpts), chSwapEvent, nil, nil) - if err != nil { - e.logger.Error("cannot watch swap event", "error", err) - return err - } - e.chSwapEvent = chSwapEvent - e.subSwapEvent = subSwapEvent - return nil -} - -func (e *AirswapClient) StartWatcher() { - for { - select { - case <-e.doneCh: - e.ticker.Stop() - e.logger.Info("air-swap events watcher stopped") - return - case err := <-e.subSwapEvent.Err(): - if err != nil { - e.logger.Info("subscription error of swap event", "error", err) - e.handleConnectivityError() - e.subSwapEvent.Unsubscribe() - } - case airSwapEvent := <-e.chSwapEvent: - e.logger.Debug("receiving a SwapERC20 event", "event", airSwapEvent, "nonce", airSwapEvent.Nonce.Uint64()) - if err := e.handleSwapEvent(airSwapEvent.Raw.TxHash, airSwapEvent); err != nil { - e.logger.Error("handle swap event failed", "error", err) - continue - } - - case <-e.ticker.C: - e.checkHealth() - } - } -} - -// handleSwapEvent, handles a single swap event at a time, if a txn contains multiple swap events, this function will -// be called with multiple times as the client subscribe every single swap event from L1. Processing one event at a -// time also make the logic simple and clear. -func (e *AirswapClient) handleSwapEvent(txnHash ecommon.Hash, swapEvent *swaperc20.Swaperc20SwapERC20) error { - // pull the logs of the txn which issues the swap event. - txnReceipt, err := e.client.TransactionReceipt(context.Background(), txnHash) - if err != nil { - e.logger.Error("cannot get transaction receipt", "error", err, "txnHash", txnHash) - return err - } - - logs := txnReceipt.Logs - order, err := e.extractOrder(logs, swapEvent) - if err != nil { - e.logger.Error("failed to extract the exchanges from txn receipts", "error", err, "txnHash", txnHash) - return err - } - - // then do the computing of price of ATN-USDC or NTN-USDC - var orderBook *ring.Ring - if order.cryptoToken == e.atnAddress { - orderBook = &e.atnOrderBooks - } else { - orderBook = &e.ntnOrderBooks - } - - lastAggregatedPrice, volumes, err := aggregatePrice(orderBook, order) - if err != nil { - e.logger.Error("failed to compute new price", "error", err, "txnHash", txnHash, "order", order) - return err - } - - // update the last aggregated price. - e.updatePrice(order.cryptoToken, lastAggregatedPrice.FloatString(common.CryptoToUsdcDecimals), volumes) - return nil -} - -// extract order of the SwapERC20(nonce, signerWallet) event from the logs, as the functions which emits SwapERC20 -// event can be called from any other contracts, thus it is not doable to parse the TXN's input -// data to get the direct inputs of the swap functions, thus we have to parse the ERC20 transfer events correspond to -// the airswap.SwapERC20(nonce, signerWallet) event to collect the exchange info. -// please visit: -// https://github.com/airswap/airswap-protocols/blob/develop/source/swap-erc20/contracts/SwapERC20.sol to find -// the details of the atomic swap between the two parties. The ERC20 and SwapERC20 events emitting follow in below -// patterns: -/* -log1: event: senderToken.Transfer(from: msg.sender, to: signerWallet, value: senderAmount); -log2: event: signerToken.Transfer(from: signerWallet, to: recipient/msg.sender, value: signerAmount); -log3, optional depends on if the fee > 0: - if bonus > 0: - event: signerToken.Transfer(from: signerWallet, to: msg.sender, bonus); // if the msg.sender is a staking node. - event: signerToken.Transfer(from: signerWallet, to: protocolFeeWallet, fee-bonus); - else: - event: signerToken.Transfer(from: signerWallet, to: protocolFeeWallet, fee); -log4, optional if swapEvent is emitted by a swapLight(): - event: signerToken.Transfer(from: signerWallet, to: protocolFeeWallet, lightFee); -log5, event: airswapERC20.SwapERC20(nonce, signerWallet); -*/ -// From the pattern listed, we can see that log1 and log2 are the exchange of the two tokens, while log5 is the swap -// event that we subscribed, in between log2 and log5 there are multiple optional signerToken.Transfer events to pay -// the service fee/bonus in signerToken from signerWallet account to other parties (protocolFeeWallet, msg.Sender). As -// the fee/bonus are a small fraction of the signerAmount in signerToken of the exchange, thus we can filter out them -// from the log, and finally paired the log2 with log1 events as the exchange. With the signerWallet address is emitted -// by the SwapErc20(nonce, signerWallet) event, we can get the senderAmount of senderToken received by signerWallet, and -// the signerAmount of signerToken transfer by the signerWallet to get the exchange. In this plugin, we only care about -// the NTN token and the USDC token as our targeting liquidity market. -func (e *AirswapClient) extractOrder(logs []*types2.Log, targetSwapEvent *swaperc20.Swaperc20SwapERC20) (Order, error) { - var order Order - - // todo: Jason, refine this implementation once the comment of https://github.com/airswap/airswap-protocols/issues/1341 is resolved. - // iterate the logs to address the subscribed swapEvent, - index := -1 - for i := len(logs) - 1; i >= 0; i-- { - // Check for the SwapERC20 event - parsedSwap, err := e.swapContract.ParseSwapERC20(*logs[i]) - if err != nil { - e.logger.Debug("failed to parse log with swap event", "error", err) - continue - } - - // as the nonce is unique, check with nonce and signer wallet. - if parsedSwap.Nonce.Cmp(targetSwapEvent.Nonce) == 0 && parsedSwap.SignerWallet == targetSwapEvent.SignerWallet { - index = i - break - } - } - - if index == -1 { - return order, errors.New("failed to find matching swap in receipt") - } - - var signerTokenAmount *big.Int - var signerTokenAddress ecommon.Address - var senderTokenAmount *big.Int - var senderTokenAddress ecommon.Address - - // swap event is addressed, find the signerToken.Transfers and the senderToken.Transfer close to it. - for i := index - 1; i >= 0; i-- { - // just parse the ERC20 transfer events, the events could be ATN, NTN or USDC transfer events. - transfer, err := e.erc20LogParser.ParseTransfer(*logs[i]) - if err != nil { - e.logger.Debug("failed to parse log with ERC20 transfer", "error", err) - continue - } - - eventEmitter := transfer.Raw.Address - if eventEmitter != e.usdcAddress && eventEmitter != e.ntnAddress && eventEmitter != e.atnAddress { - e.logger.Debug("skip none ATN, NTN & USDC swap event") - return order, errors.New("skip none ATN, NTN & USDC swap event") - } - - // now only transfers of ATN, NTN or USDC token can come to here. - if transfer.From == targetSwapEvent.SignerWallet { - if signerTokenAmount == nil || transfer.Value.Cmp(signerTokenAmount) > 0 { - signerTokenAmount = transfer.Value - signerTokenAddress = eventEmitter - } - } else { - if transfer.To == targetSwapEvent.SignerWallet { - senderTokenAmount = transfer.Value - senderTokenAddress = eventEmitter - break - } - } - } - - if signerTokenAmount == nil || senderTokenAmount == nil { - return order, errors.New("skip none ATN, NTN & USDC swap event") - } - - if (signerTokenAddress == e.usdcAddress && senderTokenAddress == e.atnAddress) || - (signerTokenAddress == e.atnAddress && senderTokenAddress == e.usdcAddress) { - order.cryptoToken = e.atnAddress - if senderTokenAddress == e.atnAddress { - order.cryptoAmount = senderTokenAmount - order.usdcAmount = signerTokenAmount - } else { - order.cryptoAmount = signerTokenAmount - order.usdcAmount = senderTokenAmount - } - return order, nil - } - - if (signerTokenAddress == e.usdcAddress && senderTokenAddress == e.ntnAddress) || - (signerTokenAddress == e.ntnAddress && senderTokenAddress == e.usdcAddress) { - order.cryptoToken = e.ntnAddress - if senderTokenAddress == e.ntnAddress { - order.cryptoAmount = senderTokenAmount - order.usdcAmount = signerTokenAmount - } else { - order.cryptoAmount = signerTokenAmount - order.usdcAmount = senderTokenAmount - } - return order, nil - } - - // exchange of ATN and NTN is not watched, we skip the order. - return order, errors.New("skip process swap event of ATN and NTN from airswap") -} - -func (e *AirswapClient) updatePrice(tokenAddress ecommon.Address, price string, volumes *big.Int) { - e.priceMutex.Lock() - defer e.priceMutex.Unlock() - - symbol := ATNUSDC - if tokenAddress == e.ntnAddress { - symbol = NTNUSDC - } - - e.lastAggregatedPrices[tokenAddress] = common.Price{ - Symbol: symbol, - Price: price, - Volume: volumes.String(), - } -} - -func (e *AirswapClient) checkHealth() { - if e.lostSync { - err := e.EventSubscription() - if err != nil { - e.logger.Info("rebuilding WS connectivity with L1 node", "error", err) - return - } - e.lostSync = false - return - } - - e.logger.Debug("checking heart beat", "alive", !e.lostSync) -} - -func (e *AirswapClient) handleConnectivityError() { - e.lostSync = true -} - -func (e *AirswapClient) KeyRequired() bool { - return false -} - -func (e *AirswapClient) FetchPrice(_ []string) (common.Prices, error) { - e.priceMutex.RLock() - defer e.priceMutex.RUnlock() - var prices common.Prices - - for _, p := range e.lastAggregatedPrices { - prices = append(prices, p) - } - - if len(prices) == 0 { - return prices, errors.New("dex-pluign hasn't receive any realtime swap event yet") - } - - // both ATN-USDC and NTN-USDC price are collected, compute NTN-ATN price. - if len(prices) == 2 { - atnPrice := e.lastAggregatedPrices[e.atnAddress] - ntnPrice := e.lastAggregatedPrices[e.ntnAddress] - ntnATNPrice, err := common.ComputeDerivedPrice(ntnPrice.Price, atnPrice.Price) - if err != nil { - e.logger.Error("cannot compute NTN-ATN price", "error", err.Error()) - return prices, nil - } - ntnATNPrice.Volume = atnPrice.Volume - prices = append(prices, ntnATNPrice) - } - return prices, nil -} - -func (e *AirswapClient) AvailableSymbols() ([]string, error) { - return supportedSymbols, nil -} - -func (e *AirswapClient) Close() { - if e.client != nil { - e.client.Close() - } - e.subSwapEvent.Unsubscribe() - e.doneCh <- struct{}{} -} - -func main() { - conf := common.ResolveConf(os.Args[0], &defaultConfig) - client, err := NewAirswapClient(conf) - if err != nil { - return - } - - // start the SwapERC20 event watching for price aggregation of NTN-USDC & ATN-USDC - go client.StartWatcher() - - adapter := common.NewPlugin(conf, client, version, types.SrcAFQ, common.ChainIDPiccadilly) - defer adapter.Close() - common.PluginServe(adapter) -} diff --git a/plugins/crypto_airswap/crypto_airswap_test.go b/plugins/crypto_airswap/crypto_airswap_test.go deleted file mode 100644 index 8f51182..0000000 --- a/plugins/crypto_airswap/crypto_airswap_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package main - -import ( - swaperc20 "autonity-oracle/plugins/crypto_airswap/swap_erc20" - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" - "math/big" - "testing" -) - -// todo: Jason, the best way to test this could be dump the swap event logs into a json file, then we can remove the -// network dependency of piccadilly to test this component by taking event logs from this test-data.json. -func TestAirswapClientWithPiccadilly(t *testing.T) { - config := defaultConfig - config.Endpoint = "rpc2.piccadilly.autonity.org/ws" - - client, err := NewAirswapClient(&config) - require.NoError(t, err) - defer client.client.Close() - defer client.subSwapEvent.Unsubscribe() - - swapEvents := []struct { - txn common.Hash - swapEvent *swaperc20.Swaperc20SwapERC20 - expectErr bool - symbol string - ratio string - }{ - { - txn: common.HexToHash("0xc75b9ec0dd99a224bab9d0ee894cb5bb26ae44a915a60c202371598997fddb18"), - swapEvent: &swaperc20.Swaperc20SwapERC20{ - Nonce: new(big.Int).SetUint64(1719327692657), - SignerWallet: common.HexToAddress("0x5eb2f7511405b0cb0f24abdc77412fa1dfe68f3e"), - }, - expectErr: true, // it is a swap between NTN and ATN, should rise an error to skip it. - }, - { - txn: common.HexToHash("0x29ff16bbddf531b86c627932cff2f0e8f15e81b2a76e161d878f8f98ab7a2148"), - swapEvent: &swaperc20.Swaperc20SwapERC20{ - Nonce: new(big.Int).SetUint64(1719328735436), - SignerWallet: common.HexToAddress("0xf47fdd88c8f6f80239e177386cc5ae3d6bcdeeea"), - }, - expectErr: true, // it is a swap between NTN and ATN, should rise an error to skip it. - }, - { - txn: common.HexToHash("0x32979c314f61cf95c045feb51bbf5eef72657cc03bfcf15f95df54fb262dca27"), - swapEvent: &swaperc20.Swaperc20SwapERC20{ - Nonce: new(big.Int).SetUint64(1719617957284), - SignerWallet: common.HexToAddress("0x4a2f43996d1fc03b054d89963f395c6ebff02cad"), - }, - expectErr: false, - symbol: NTNUSDC, - ratio: "0.100200400801603206", - }, - - { - txn: common.HexToHash("0x6a6477aed203b0f95d0f5f72ba780a528bbaac2db905d53dc317e0c0c9004723"), - swapEvent: &swaperc20.Swaperc20SwapERC20{ - Nonce: new(big.Int).SetUint64(1719803346312), - SignerWallet: common.HexToAddress("0x4a2f43996d1fc03b054d89963f395c6ebff02cad"), - }, - expectErr: false, - symbol: NTNUSDC, - ratio: "0.111093347776012320", - }, - } - - for _, swaps := range swapEvents { - err = client.handleSwapEvent(swaps.txn, swaps.swapEvent) - if swaps.expectErr { - require.Error(t, err) - continue - } else { - require.NoError(t, err) - } - prices, err := client.FetchPrice(nil) - require.NoError(t, err) - require.Equal(t, 1, len(prices)) - require.Equal(t, swaps.symbol, prices[0].Symbol) - require.Equal(t, swaps.ratio, prices[0].Price) - } -} diff --git a/plugins/crypto_airswap/swap_erc20/ISwapERC20.abi b/plugins/crypto_airswap/swap_erc20/ISwapERC20.abi deleted file mode 100644 index 7108136..0000000 --- a/plugins/crypto_airswap/swap_erc20/ISwapERC20.abi +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"address","name":"signerWallet","type":"address"}],"name":"Authorize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"address","name":"signerWallet","type":"address"}],"name":"Cancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"address","name":"signerWallet","type":"address"}],"name":"Revoke","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"bonusMax","type":"uint256"}],"name":"SetBonusMax","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"bonusScale","type":"uint256"}],"name":"SetBonusScale","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"protocolFee","type":"uint256"}],"name":"SetProtocolFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"protocolFeeLight","type":"uint256"}],"name":"SetProtocolFeeLight","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"feeWallet","type":"address"}],"name":"SetProtocolFeeWallet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staking","type":"address"}],"name":"SetStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"address","name":"signerWallet","type":"address"}],"name":"SwapERC20","type":"event"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"authorize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"authorized","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"calculateProtocolFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"nonces","type":"uint256[]"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"senderWallet","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"address","name":"signerWallet","type":"address"},{"internalType":"address","name":"signerToken","type":"address"},{"internalType":"uint256","name":"signerAmount","type":"uint256"},{"internalType":"address","name":"senderToken","type":"address"},{"internalType":"uint256","name":"senderAmount","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"check","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"nonceUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revoke","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"address","name":"signerWallet","type":"address"},{"internalType":"address","name":"signerToken","type":"address"},{"internalType":"uint256","name":"signerAmount","type":"uint256"},{"internalType":"address","name":"senderToken","type":"address"},{"internalType":"uint256","name":"senderAmount","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"address","name":"signerWallet","type":"address"},{"internalType":"address","name":"signerToken","type":"address"},{"internalType":"uint256","name":"signerAmount","type":"uint256"},{"internalType":"address","name":"senderToken","type":"address"},{"internalType":"uint256","name":"senderAmount","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"swapAnySender","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"address","name":"signerWallet","type":"address"},{"internalType":"address","name":"signerToken","type":"address"},{"internalType":"uint256","name":"signerAmount","type":"uint256"},{"internalType":"address","name":"senderToken","type":"address"},{"internalType":"uint256","name":"senderAmount","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"swapLight","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/plugins/crypto_airswap/swap_erc20/ISwapERC20.go b/plugins/crypto_airswap/swap_erc20/ISwapERC20.go deleted file mode 100644 index d3166cc..0000000 --- a/plugins/crypto_airswap/swap_erc20/ISwapERC20.go +++ /dev/null @@ -1,1897 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package swaperc20 - -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 -) - -// Swaperc20MetaData contains all meta data concerning the Swaperc20 contract. -var Swaperc20MetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"}],\"name\":\"Authorize\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"}],\"name\":\"Cancel\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signer\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"}],\"name\":\"Revoke\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bonusMax\",\"type\":\"uint256\"}],\"name\":\"SetBonusMax\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bonusScale\",\"type\":\"uint256\"}],\"name\":\"SetBonusScale\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"protocolFee\",\"type\":\"uint256\"}],\"name\":\"SetProtocolFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"protocolFeeLight\",\"type\":\"uint256\"}],\"name\":\"SetProtocolFeeLight\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"feeWallet\",\"type\":\"address\"}],\"name\":\"SetProtocolFeeWallet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"staking\",\"type\":\"address\"}],\"name\":\"SetStaking\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"}],\"name\":\"SwapERC20\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"authorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"authorized\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"calculateProtocolFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"nonces\",\"type\":\"uint256[]\"}],\"name\":\"cancel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"senderWallet\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"signerToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signerAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"senderAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"check\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"nonceUsed\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"revoke\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"signerToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signerAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"senderAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"swap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"signerToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signerAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"senderAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"swapAnySender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expiry\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"signerWallet\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"signerToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"signerAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"senderAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"swapLight\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// Swaperc20ABI is the input ABI used to generate the binding from. -// Deprecated: Use Swaperc20MetaData.ABI instead. -var Swaperc20ABI = Swaperc20MetaData.ABI - -// Swaperc20 is an auto generated Go binding around an Ethereum contract. -type Swaperc20 struct { - Swaperc20Caller // Read-only binding to the contract - Swaperc20Transactor // Write-only binding to the contract - Swaperc20Filterer // Log filterer for contract events -} - -// Swaperc20Caller is an auto generated read-only Go binding around an Ethereum contract. -type Swaperc20Caller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// Swaperc20Transactor is an auto generated write-only Go binding around an Ethereum contract. -type Swaperc20Transactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// Swaperc20Filterer is an auto generated log filtering Go binding around an Ethereum contract events. -type Swaperc20Filterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// Swaperc20Session is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type Swaperc20Session struct { - Contract *Swaperc20 // 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 -} - -// Swaperc20CallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type Swaperc20CallerSession struct { - Contract *Swaperc20Caller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// Swaperc20TransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type Swaperc20TransactorSession struct { - Contract *Swaperc20Transactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// Swaperc20Raw is an auto generated low-level Go binding around an Ethereum contract. -type Swaperc20Raw struct { - Contract *Swaperc20 // Generic contract binding to access the raw methods on -} - -// Swaperc20CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type Swaperc20CallerRaw struct { - Contract *Swaperc20Caller // Generic read-only contract binding to access the raw methods on -} - -// Swaperc20TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type Swaperc20TransactorRaw struct { - Contract *Swaperc20Transactor // Generic write-only contract binding to access the raw methods on -} - -// NewSwaperc20 creates a new instance of Swaperc20, bound to a specific deployed contract. -func NewSwaperc20(address common.Address, backend bind.ContractBackend) (*Swaperc20, error) { - contract, err := bindSwaperc20(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &Swaperc20{Swaperc20Caller: Swaperc20Caller{contract: contract}, Swaperc20Transactor: Swaperc20Transactor{contract: contract}, Swaperc20Filterer: Swaperc20Filterer{contract: contract}}, nil -} - -// NewSwaperc20Caller creates a new read-only instance of Swaperc20, bound to a specific deployed contract. -func NewSwaperc20Caller(address common.Address, caller bind.ContractCaller) (*Swaperc20Caller, error) { - contract, err := bindSwaperc20(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &Swaperc20Caller{contract: contract}, nil -} - -// NewSwaperc20Transactor creates a new write-only instance of Swaperc20, bound to a specific deployed contract. -func NewSwaperc20Transactor(address common.Address, transactor bind.ContractTransactor) (*Swaperc20Transactor, error) { - contract, err := bindSwaperc20(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &Swaperc20Transactor{contract: contract}, nil -} - -// NewSwaperc20Filterer creates a new log filterer instance of Swaperc20, bound to a specific deployed contract. -func NewSwaperc20Filterer(address common.Address, filterer bind.ContractFilterer) (*Swaperc20Filterer, error) { - contract, err := bindSwaperc20(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &Swaperc20Filterer{contract: contract}, nil -} - -// bindSwaperc20 binds a generic wrapper to an already deployed contract. -func bindSwaperc20(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(Swaperc20ABI)) - 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 (_Swaperc20 *Swaperc20Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _Swaperc20.Contract.Swaperc20Caller.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 (_Swaperc20 *Swaperc20Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Swaperc20.Contract.Swaperc20Transactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Swaperc20 *Swaperc20Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Swaperc20.Contract.Swaperc20Transactor.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 (_Swaperc20 *Swaperc20CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _Swaperc20.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 (_Swaperc20 *Swaperc20TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Swaperc20.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Swaperc20 *Swaperc20TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Swaperc20.Contract.contract.Transact(opts, method, params...) -} - -// Authorized is a free data retrieval call binding the contract method 0xb9181611. -// -// Solidity: function authorized(address ) view returns(address) -func (_Swaperc20 *Swaperc20Caller) Authorized(opts *bind.CallOpts, arg0 common.Address) (common.Address, error) { - var out []interface{} - err := _Swaperc20.contract.Call(opts, &out, "authorized", arg0) - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Authorized is a free data retrieval call binding the contract method 0xb9181611. -// -// Solidity: function authorized(address ) view returns(address) -func (_Swaperc20 *Swaperc20Session) Authorized(arg0 common.Address) (common.Address, error) { - return _Swaperc20.Contract.Authorized(&_Swaperc20.CallOpts, arg0) -} - -// Authorized is a free data retrieval call binding the contract method 0xb9181611. -// -// Solidity: function authorized(address ) view returns(address) -func (_Swaperc20 *Swaperc20CallerSession) Authorized(arg0 common.Address) (common.Address, error) { - return _Swaperc20.Contract.Authorized(&_Swaperc20.CallOpts, arg0) -} - -// ProtocolFeeWallet is a free data retrieval call binding the contract method 0xcbf7c6c3. -// -// Solidity: function protocolFeeWallet() view returns(address) -func (_Swaperc20 *Swaperc20Caller) ProtocolFeeWallet(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _Swaperc20.contract.Call(opts, &out, "protocolFeeWallet") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// ProtocolFeeWallet is a free data retrieval call binding the contract method 0xcbf7c6c3. -// -// Solidity: function protocolFeeWallet() view returns(address) -func (_Swaperc20 *Swaperc20Session) ProtocolFeeWallet() (common.Address, error) { - return _Swaperc20.Contract.ProtocolFeeWallet(&_Swaperc20.CallOpts) -} - -// ProtocolFeeWallet is a free data retrieval call binding the contract method 0xcbf7c6c3. -// -// Solidity: function protocolFeeWallet() view returns(address) -func (_Swaperc20 *Swaperc20CallerSession) ProtocolFeeWallet() (common.Address, error) { - return _Swaperc20.Contract.ProtocolFeeWallet(&_Swaperc20.CallOpts) -} - -// CalculateProtocolFee is a free data retrieval call binding the contract method 0x52c5f1f5. -// -// Solidity: function calculateProtocolFee(address , uint256 ) view returns(uint256) -func (_Swaperc20 *Swaperc20Caller) CalculateProtocolFee(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (*big.Int, error) { - var out []interface{} - err := _Swaperc20.contract.Call(opts, &out, "calculateProtocolFee", arg0, arg1) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// CalculateProtocolFee is a free data retrieval call binding the contract method 0x52c5f1f5. -// -// Solidity: function calculateProtocolFee(address , uint256 ) view returns(uint256) -func (_Swaperc20 *Swaperc20Session) CalculateProtocolFee(arg0 common.Address, arg1 *big.Int) (*big.Int, error) { - return _Swaperc20.Contract.CalculateProtocolFee(&_Swaperc20.CallOpts, arg0, arg1) -} - -// CalculateProtocolFee is a free data retrieval call binding the contract method 0x52c5f1f5. -// -// Solidity: function calculateProtocolFee(address , uint256 ) view returns(uint256) -func (_Swaperc20 *Swaperc20CallerSession) CalculateProtocolFee(arg0 common.Address, arg1 *big.Int) (*big.Int, error) { - return _Swaperc20.Contract.CalculateProtocolFee(&_Swaperc20.CallOpts, arg0, arg1) -} - -// Check is a free data retrieval call binding the contract method 0xb9cb01b0. -// -// Solidity: function check(address senderWallet, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) view returns(bytes32[]) -func (_Swaperc20 *Swaperc20Caller) Check(opts *bind.CallOpts, senderWallet common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) ([][32]byte, error) { - var out []interface{} - err := _Swaperc20.contract.Call(opts, &out, "check", senderWallet, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) - - if err != nil { - return *new([][32]byte), err - } - - out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) - - return out0, err - -} - -// Check is a free data retrieval call binding the contract method 0xb9cb01b0. -// -// Solidity: function check(address senderWallet, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) view returns(bytes32[]) -func (_Swaperc20 *Swaperc20Session) Check(senderWallet common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) ([][32]byte, error) { - return _Swaperc20.Contract.Check(&_Swaperc20.CallOpts, senderWallet, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// Check is a free data retrieval call binding the contract method 0xb9cb01b0. -// -// Solidity: function check(address senderWallet, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) view returns(bytes32[]) -func (_Swaperc20 *Swaperc20CallerSession) Check(senderWallet common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) ([][32]byte, error) { - return _Swaperc20.Contract.Check(&_Swaperc20.CallOpts, senderWallet, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// NonceUsed is a free data retrieval call binding the contract method 0x1647795e. -// -// Solidity: function nonceUsed(address , uint256 ) view returns(bool) -func (_Swaperc20 *Swaperc20Caller) NonceUsed(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (bool, error) { - var out []interface{} - err := _Swaperc20.contract.Call(opts, &out, "nonceUsed", arg0, arg1) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// NonceUsed is a free data retrieval call binding the contract method 0x1647795e. -// -// Solidity: function nonceUsed(address , uint256 ) view returns(bool) -func (_Swaperc20 *Swaperc20Session) NonceUsed(arg0 common.Address, arg1 *big.Int) (bool, error) { - return _Swaperc20.Contract.NonceUsed(&_Swaperc20.CallOpts, arg0, arg1) -} - -// NonceUsed is a free data retrieval call binding the contract method 0x1647795e. -// -// Solidity: function nonceUsed(address , uint256 ) view returns(bool) -func (_Swaperc20 *Swaperc20CallerSession) NonceUsed(arg0 common.Address, arg1 *big.Int) (bool, error) { - return _Swaperc20.Contract.NonceUsed(&_Swaperc20.CallOpts, arg0, arg1) -} - -// Authorize is a paid mutator transaction binding the contract method 0xb6a5d7de. -// -// Solidity: function authorize(address sender) returns() -func (_Swaperc20 *Swaperc20Transactor) Authorize(opts *bind.TransactOpts, sender common.Address) (*types.Transaction, error) { - return _Swaperc20.contract.Transact(opts, "authorize", sender) -} - -// Authorize is a paid mutator transaction binding the contract method 0xb6a5d7de. -// -// Solidity: function authorize(address sender) returns() -func (_Swaperc20 *Swaperc20Session) Authorize(sender common.Address) (*types.Transaction, error) { - return _Swaperc20.Contract.Authorize(&_Swaperc20.TransactOpts, sender) -} - -// Authorize is a paid mutator transaction binding the contract method 0xb6a5d7de. -// -// Solidity: function authorize(address sender) returns() -func (_Swaperc20 *Swaperc20TransactorSession) Authorize(sender common.Address) (*types.Transaction, error) { - return _Swaperc20.Contract.Authorize(&_Swaperc20.TransactOpts, sender) -} - -// Cancel is a paid mutator transaction binding the contract method 0x2e340823. -// -// Solidity: function cancel(uint256[] nonces) returns() -func (_Swaperc20 *Swaperc20Transactor) Cancel(opts *bind.TransactOpts, nonces []*big.Int) (*types.Transaction, error) { - return _Swaperc20.contract.Transact(opts, "cancel", nonces) -} - -// Cancel is a paid mutator transaction binding the contract method 0x2e340823. -// -// Solidity: function cancel(uint256[] nonces) returns() -func (_Swaperc20 *Swaperc20Session) Cancel(nonces []*big.Int) (*types.Transaction, error) { - return _Swaperc20.Contract.Cancel(&_Swaperc20.TransactOpts, nonces) -} - -// Cancel is a paid mutator transaction binding the contract method 0x2e340823. -// -// Solidity: function cancel(uint256[] nonces) returns() -func (_Swaperc20 *Swaperc20TransactorSession) Cancel(nonces []*big.Int) (*types.Transaction, error) { - return _Swaperc20.Contract.Cancel(&_Swaperc20.TransactOpts, nonces) -} - -// Revoke is a paid mutator transaction binding the contract method 0xb6549f75. -// -// Solidity: function revoke() returns() -func (_Swaperc20 *Swaperc20Transactor) Revoke(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Swaperc20.contract.Transact(opts, "revoke") -} - -// Revoke is a paid mutator transaction binding the contract method 0xb6549f75. -// -// Solidity: function revoke() returns() -func (_Swaperc20 *Swaperc20Session) Revoke() (*types.Transaction, error) { - return _Swaperc20.Contract.Revoke(&_Swaperc20.TransactOpts) -} - -// Revoke is a paid mutator transaction binding the contract method 0xb6549f75. -// -// Solidity: function revoke() returns() -func (_Swaperc20 *Swaperc20TransactorSession) Revoke() (*types.Transaction, error) { - return _Swaperc20.Contract.Revoke(&_Swaperc20.TransactOpts) -} - -// Swap is a paid mutator transaction binding the contract method 0x98956069. -// -// Solidity: function swap(address recipient, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20Transactor) Swap(opts *bind.TransactOpts, recipient common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.contract.Transact(opts, "swap", recipient, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// Swap is a paid mutator transaction binding the contract method 0x98956069. -// -// Solidity: function swap(address recipient, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20Session) Swap(recipient common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.Contract.Swap(&_Swaperc20.TransactOpts, recipient, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// Swap is a paid mutator transaction binding the contract method 0x98956069. -// -// Solidity: function swap(address recipient, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20TransactorSession) Swap(recipient common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.Contract.Swap(&_Swaperc20.TransactOpts, recipient, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// SwapAnySender is a paid mutator transaction binding the contract method 0x3eb1af24. -// -// Solidity: function swapAnySender(address recipient, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20Transactor) SwapAnySender(opts *bind.TransactOpts, recipient common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.contract.Transact(opts, "swapAnySender", recipient, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// SwapAnySender is a paid mutator transaction binding the contract method 0x3eb1af24. -// -// Solidity: function swapAnySender(address recipient, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20Session) SwapAnySender(recipient common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.Contract.SwapAnySender(&_Swaperc20.TransactOpts, recipient, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// SwapAnySender is a paid mutator transaction binding the contract method 0x3eb1af24. -// -// Solidity: function swapAnySender(address recipient, uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20TransactorSession) SwapAnySender(recipient common.Address, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.Contract.SwapAnySender(&_Swaperc20.TransactOpts, recipient, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// SwapLight is a paid mutator transaction binding the contract method 0x46e4480d. -// -// Solidity: function swapLight(uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20Transactor) SwapLight(opts *bind.TransactOpts, nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.contract.Transact(opts, "swapLight", nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// SwapLight is a paid mutator transaction binding the contract method 0x46e4480d. -// -// Solidity: function swapLight(uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20Session) SwapLight(nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.Contract.SwapLight(&_Swaperc20.TransactOpts, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// SwapLight is a paid mutator transaction binding the contract method 0x46e4480d. -// -// Solidity: function swapLight(uint256 nonce, uint256 expiry, address signerWallet, address signerToken, uint256 signerAmount, address senderToken, uint256 senderAmount, uint8 v, bytes32 r, bytes32 s) returns() -func (_Swaperc20 *Swaperc20TransactorSession) SwapLight(nonce *big.Int, expiry *big.Int, signerWallet common.Address, signerToken common.Address, signerAmount *big.Int, senderToken common.Address, senderAmount *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _Swaperc20.Contract.SwapLight(&_Swaperc20.TransactOpts, nonce, expiry, signerWallet, signerToken, signerAmount, senderToken, senderAmount, v, r, s) -} - -// Swaperc20AuthorizeIterator is returned from FilterAuthorize and is used to iterate over the raw logs and unpacked data for Authorize events raised by the Swaperc20 contract. -type Swaperc20AuthorizeIterator struct { - Event *Swaperc20Authorize // 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 *Swaperc20AuthorizeIterator) 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(Swaperc20Authorize) - 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(Swaperc20Authorize) - 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 *Swaperc20AuthorizeIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20AuthorizeIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20Authorize represents a Authorize event raised by the Swaperc20 contract. -type Swaperc20Authorize struct { - Signer common.Address - SignerWallet common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterAuthorize is a free log retrieval operation binding the contract event 0x30468de898bda644e26bab66e5a2241a3aa6aaf527257f5ca54e0f65204ba14a. -// -// Solidity: event Authorize(address indexed signer, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) FilterAuthorize(opts *bind.FilterOpts, signer []common.Address, signerWallet []common.Address) (*Swaperc20AuthorizeIterator, error) { - - var signerRule []interface{} - for _, signerItem := range signer { - signerRule = append(signerRule, signerItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "Authorize", signerRule, signerWalletRule) - if err != nil { - return nil, err - } - return &Swaperc20AuthorizeIterator{contract: _Swaperc20.contract, event: "Authorize", logs: logs, sub: sub}, nil -} - -// WatchAuthorize is a free log subscription operation binding the contract event 0x30468de898bda644e26bab66e5a2241a3aa6aaf527257f5ca54e0f65204ba14a. -// -// Solidity: event Authorize(address indexed signer, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) WatchAuthorize(opts *bind.WatchOpts, sink chan<- *Swaperc20Authorize, signer []common.Address, signerWallet []common.Address) (event.Subscription, error) { - - var signerRule []interface{} - for _, signerItem := range signer { - signerRule = append(signerRule, signerItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "Authorize", signerRule, signerWalletRule) - 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(Swaperc20Authorize) - if err := _Swaperc20.contract.UnpackLog(event, "Authorize", 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 -} - -// ParseAuthorize is a log parse operation binding the contract event 0x30468de898bda644e26bab66e5a2241a3aa6aaf527257f5ca54e0f65204ba14a. -// -// Solidity: event Authorize(address indexed signer, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) ParseAuthorize(log types.Log) (*Swaperc20Authorize, error) { - event := new(Swaperc20Authorize) - if err := _Swaperc20.contract.UnpackLog(event, "Authorize", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20CancelIterator is returned from FilterCancel and is used to iterate over the raw logs and unpacked data for Cancel events raised by the Swaperc20 contract. -type Swaperc20CancelIterator struct { - Event *Swaperc20Cancel // 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 *Swaperc20CancelIterator) 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(Swaperc20Cancel) - 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(Swaperc20Cancel) - 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 *Swaperc20CancelIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20CancelIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20Cancel represents a Cancel event raised by the Swaperc20 contract. -type Swaperc20Cancel struct { - Nonce *big.Int - SignerWallet common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterCancel is a free log retrieval operation binding the contract event 0x8dd3c361eb2366ff27c2db0eb07b9261f1d052570742ab8c9a0c326f37aa576d. -// -// Solidity: event Cancel(uint256 indexed nonce, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) FilterCancel(opts *bind.FilterOpts, nonce []*big.Int, signerWallet []common.Address) (*Swaperc20CancelIterator, error) { - - var nonceRule []interface{} - for _, nonceItem := range nonce { - nonceRule = append(nonceRule, nonceItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "Cancel", nonceRule, signerWalletRule) - if err != nil { - return nil, err - } - return &Swaperc20CancelIterator{contract: _Swaperc20.contract, event: "Cancel", logs: logs, sub: sub}, nil -} - -// WatchCancel is a free log subscription operation binding the contract event 0x8dd3c361eb2366ff27c2db0eb07b9261f1d052570742ab8c9a0c326f37aa576d. -// -// Solidity: event Cancel(uint256 indexed nonce, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) WatchCancel(opts *bind.WatchOpts, sink chan<- *Swaperc20Cancel, nonce []*big.Int, signerWallet []common.Address) (event.Subscription, error) { - - var nonceRule []interface{} - for _, nonceItem := range nonce { - nonceRule = append(nonceRule, nonceItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "Cancel", nonceRule, signerWalletRule) - 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(Swaperc20Cancel) - if err := _Swaperc20.contract.UnpackLog(event, "Cancel", 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 -} - -// ParseCancel is a log parse operation binding the contract event 0x8dd3c361eb2366ff27c2db0eb07b9261f1d052570742ab8c9a0c326f37aa576d. -// -// Solidity: event Cancel(uint256 indexed nonce, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) ParseCancel(log types.Log) (*Swaperc20Cancel, error) { - event := new(Swaperc20Cancel) - if err := _Swaperc20.contract.UnpackLog(event, "Cancel", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20RevokeIterator is returned from FilterRevoke and is used to iterate over the raw logs and unpacked data for Revoke events raised by the Swaperc20 contract. -type Swaperc20RevokeIterator struct { - Event *Swaperc20Revoke // 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 *Swaperc20RevokeIterator) 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(Swaperc20Revoke) - 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(Swaperc20Revoke) - 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 *Swaperc20RevokeIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20RevokeIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20Revoke represents a Revoke event raised by the Swaperc20 contract. -type Swaperc20Revoke struct { - Signer common.Address - SignerWallet common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRevoke is a free log retrieval operation binding the contract event 0xd7426110292f20fe59e73ccf52124e0f5440a756507c91c7b0a6c50e1eb1a23a. -// -// Solidity: event Revoke(address indexed signer, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) FilterRevoke(opts *bind.FilterOpts, signer []common.Address, signerWallet []common.Address) (*Swaperc20RevokeIterator, error) { - - var signerRule []interface{} - for _, signerItem := range signer { - signerRule = append(signerRule, signerItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "Revoke", signerRule, signerWalletRule) - if err != nil { - return nil, err - } - return &Swaperc20RevokeIterator{contract: _Swaperc20.contract, event: "Revoke", logs: logs, sub: sub}, nil -} - -// WatchRevoke is a free log subscription operation binding the contract event 0xd7426110292f20fe59e73ccf52124e0f5440a756507c91c7b0a6c50e1eb1a23a. -// -// Solidity: event Revoke(address indexed signer, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) WatchRevoke(opts *bind.WatchOpts, sink chan<- *Swaperc20Revoke, signer []common.Address, signerWallet []common.Address) (event.Subscription, error) { - - var signerRule []interface{} - for _, signerItem := range signer { - signerRule = append(signerRule, signerItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "Revoke", signerRule, signerWalletRule) - 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(Swaperc20Revoke) - if err := _Swaperc20.contract.UnpackLog(event, "Revoke", 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 -} - -// ParseRevoke is a log parse operation binding the contract event 0xd7426110292f20fe59e73ccf52124e0f5440a756507c91c7b0a6c50e1eb1a23a. -// -// Solidity: event Revoke(address indexed signer, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) ParseRevoke(log types.Log) (*Swaperc20Revoke, error) { - event := new(Swaperc20Revoke) - if err := _Swaperc20.contract.UnpackLog(event, "Revoke", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SetBonusMaxIterator is returned from FilterSetBonusMax and is used to iterate over the raw logs and unpacked data for SetBonusMax events raised by the Swaperc20 contract. -type Swaperc20SetBonusMaxIterator struct { - Event *Swaperc20SetBonusMax // 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 *Swaperc20SetBonusMaxIterator) 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(Swaperc20SetBonusMax) - 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(Swaperc20SetBonusMax) - 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 *Swaperc20SetBonusMaxIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SetBonusMaxIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SetBonusMax represents a SetBonusMax event raised by the Swaperc20 contract. -type Swaperc20SetBonusMax struct { - BonusMax *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSetBonusMax is a free log retrieval operation binding the contract event 0xb113403a9e8b9f0173354acc3a5d210c86be40bb7259c19c55cea02227c5026f. -// -// Solidity: event SetBonusMax(uint256 bonusMax) -func (_Swaperc20 *Swaperc20Filterer) FilterSetBonusMax(opts *bind.FilterOpts) (*Swaperc20SetBonusMaxIterator, error) { - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SetBonusMax") - if err != nil { - return nil, err - } - return &Swaperc20SetBonusMaxIterator{contract: _Swaperc20.contract, event: "SetBonusMax", logs: logs, sub: sub}, nil -} - -// WatchSetBonusMax is a free log subscription operation binding the contract event 0xb113403a9e8b9f0173354acc3a5d210c86be40bb7259c19c55cea02227c5026f. -// -// Solidity: event SetBonusMax(uint256 bonusMax) -func (_Swaperc20 *Swaperc20Filterer) WatchSetBonusMax(opts *bind.WatchOpts, sink chan<- *Swaperc20SetBonusMax) (event.Subscription, error) { - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SetBonusMax") - 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(Swaperc20SetBonusMax) - if err := _Swaperc20.contract.UnpackLog(event, "SetBonusMax", 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 -} - -// ParseSetBonusMax is a log parse operation binding the contract event 0xb113403a9e8b9f0173354acc3a5d210c86be40bb7259c19c55cea02227c5026f. -// -// Solidity: event SetBonusMax(uint256 bonusMax) -func (_Swaperc20 *Swaperc20Filterer) ParseSetBonusMax(log types.Log) (*Swaperc20SetBonusMax, error) { - event := new(Swaperc20SetBonusMax) - if err := _Swaperc20.contract.UnpackLog(event, "SetBonusMax", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SetBonusScaleIterator is returned from FilterSetBonusScale and is used to iterate over the raw logs and unpacked data for SetBonusScale events raised by the Swaperc20 contract. -type Swaperc20SetBonusScaleIterator struct { - Event *Swaperc20SetBonusScale // 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 *Swaperc20SetBonusScaleIterator) 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(Swaperc20SetBonusScale) - 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(Swaperc20SetBonusScale) - 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 *Swaperc20SetBonusScaleIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SetBonusScaleIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SetBonusScale represents a SetBonusScale event raised by the Swaperc20 contract. -type Swaperc20SetBonusScale struct { - BonusScale *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSetBonusScale is a free log retrieval operation binding the contract event 0xcc5b12dfbda3644d5f3190b40ad8215d4aaac870df5c8112735085679d7cc333. -// -// Solidity: event SetBonusScale(uint256 bonusScale) -func (_Swaperc20 *Swaperc20Filterer) FilterSetBonusScale(opts *bind.FilterOpts) (*Swaperc20SetBonusScaleIterator, error) { - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SetBonusScale") - if err != nil { - return nil, err - } - return &Swaperc20SetBonusScaleIterator{contract: _Swaperc20.contract, event: "SetBonusScale", logs: logs, sub: sub}, nil -} - -// WatchSetBonusScale is a free log subscription operation binding the contract event 0xcc5b12dfbda3644d5f3190b40ad8215d4aaac870df5c8112735085679d7cc333. -// -// Solidity: event SetBonusScale(uint256 bonusScale) -func (_Swaperc20 *Swaperc20Filterer) WatchSetBonusScale(opts *bind.WatchOpts, sink chan<- *Swaperc20SetBonusScale) (event.Subscription, error) { - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SetBonusScale") - 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(Swaperc20SetBonusScale) - if err := _Swaperc20.contract.UnpackLog(event, "SetBonusScale", 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 -} - -// ParseSetBonusScale is a log parse operation binding the contract event 0xcc5b12dfbda3644d5f3190b40ad8215d4aaac870df5c8112735085679d7cc333. -// -// Solidity: event SetBonusScale(uint256 bonusScale) -func (_Swaperc20 *Swaperc20Filterer) ParseSetBonusScale(log types.Log) (*Swaperc20SetBonusScale, error) { - event := new(Swaperc20SetBonusScale) - if err := _Swaperc20.contract.UnpackLog(event, "SetBonusScale", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SetProtocolFeeIterator is returned from FilterSetProtocolFee and is used to iterate over the raw logs and unpacked data for SetProtocolFee events raised by the Swaperc20 contract. -type Swaperc20SetProtocolFeeIterator struct { - Event *Swaperc20SetProtocolFee // 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 *Swaperc20SetProtocolFeeIterator) 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(Swaperc20SetProtocolFee) - 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(Swaperc20SetProtocolFee) - 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 *Swaperc20SetProtocolFeeIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SetProtocolFeeIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SetProtocolFee represents a SetProtocolFee event raised by the Swaperc20 contract. -type Swaperc20SetProtocolFee struct { - ProtocolFee *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSetProtocolFee is a free log retrieval operation binding the contract event 0xdc0410a296e1e33943a772020d333d5f99319d7fcad932a484c53889f7aaa2b1. -// -// Solidity: event SetProtocolFee(uint256 protocolFee) -func (_Swaperc20 *Swaperc20Filterer) FilterSetProtocolFee(opts *bind.FilterOpts) (*Swaperc20SetProtocolFeeIterator, error) { - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SetProtocolFee") - if err != nil { - return nil, err - } - return &Swaperc20SetProtocolFeeIterator{contract: _Swaperc20.contract, event: "SetProtocolFee", logs: logs, sub: sub}, nil -} - -// WatchSetProtocolFee is a free log subscription operation binding the contract event 0xdc0410a296e1e33943a772020d333d5f99319d7fcad932a484c53889f7aaa2b1. -// -// Solidity: event SetProtocolFee(uint256 protocolFee) -func (_Swaperc20 *Swaperc20Filterer) WatchSetProtocolFee(opts *bind.WatchOpts, sink chan<- *Swaperc20SetProtocolFee) (event.Subscription, error) { - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SetProtocolFee") - 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(Swaperc20SetProtocolFee) - if err := _Swaperc20.contract.UnpackLog(event, "SetProtocolFee", 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 -} - -// ParseSetProtocolFee is a log parse operation binding the contract event 0xdc0410a296e1e33943a772020d333d5f99319d7fcad932a484c53889f7aaa2b1. -// -// Solidity: event SetProtocolFee(uint256 protocolFee) -func (_Swaperc20 *Swaperc20Filterer) ParseSetProtocolFee(log types.Log) (*Swaperc20SetProtocolFee, error) { - event := new(Swaperc20SetProtocolFee) - if err := _Swaperc20.contract.UnpackLog(event, "SetProtocolFee", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SetProtocolFeeLightIterator is returned from FilterSetProtocolFeeLight and is used to iterate over the raw logs and unpacked data for SetProtocolFeeLight events raised by the Swaperc20 contract. -type Swaperc20SetProtocolFeeLightIterator struct { - Event *Swaperc20SetProtocolFeeLight // 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 *Swaperc20SetProtocolFeeLightIterator) 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(Swaperc20SetProtocolFeeLight) - 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(Swaperc20SetProtocolFeeLight) - 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 *Swaperc20SetProtocolFeeLightIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SetProtocolFeeLightIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SetProtocolFeeLight represents a SetProtocolFeeLight event raised by the Swaperc20 contract. -type Swaperc20SetProtocolFeeLight struct { - ProtocolFeeLight *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSetProtocolFeeLight is a free log retrieval operation binding the contract event 0x312cc1a9b7287129a22395b9572a3c9ed09ce456f02b519efb34e12bb429eed0. -// -// Solidity: event SetProtocolFeeLight(uint256 protocolFeeLight) -func (_Swaperc20 *Swaperc20Filterer) FilterSetProtocolFeeLight(opts *bind.FilterOpts) (*Swaperc20SetProtocolFeeLightIterator, error) { - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SetProtocolFeeLight") - if err != nil { - return nil, err - } - return &Swaperc20SetProtocolFeeLightIterator{contract: _Swaperc20.contract, event: "SetProtocolFeeLight", logs: logs, sub: sub}, nil -} - -// WatchSetProtocolFeeLight is a free log subscription operation binding the contract event 0x312cc1a9b7287129a22395b9572a3c9ed09ce456f02b519efb34e12bb429eed0. -// -// Solidity: event SetProtocolFeeLight(uint256 protocolFeeLight) -func (_Swaperc20 *Swaperc20Filterer) WatchSetProtocolFeeLight(opts *bind.WatchOpts, sink chan<- *Swaperc20SetProtocolFeeLight) (event.Subscription, error) { - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SetProtocolFeeLight") - 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(Swaperc20SetProtocolFeeLight) - if err := _Swaperc20.contract.UnpackLog(event, "SetProtocolFeeLight", 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 -} - -// ParseSetProtocolFeeLight is a log parse operation binding the contract event 0x312cc1a9b7287129a22395b9572a3c9ed09ce456f02b519efb34e12bb429eed0. -// -// Solidity: event SetProtocolFeeLight(uint256 protocolFeeLight) -func (_Swaperc20 *Swaperc20Filterer) ParseSetProtocolFeeLight(log types.Log) (*Swaperc20SetProtocolFeeLight, error) { - event := new(Swaperc20SetProtocolFeeLight) - if err := _Swaperc20.contract.UnpackLog(event, "SetProtocolFeeLight", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SetProtocolFeeWalletIterator is returned from FilterSetProtocolFeeWallet and is used to iterate over the raw logs and unpacked data for SetProtocolFeeWallet events raised by the Swaperc20 contract. -type Swaperc20SetProtocolFeeWalletIterator struct { - Event *Swaperc20SetProtocolFeeWallet // 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 *Swaperc20SetProtocolFeeWalletIterator) 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(Swaperc20SetProtocolFeeWallet) - 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(Swaperc20SetProtocolFeeWallet) - 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 *Swaperc20SetProtocolFeeWalletIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SetProtocolFeeWalletIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SetProtocolFeeWallet represents a SetProtocolFeeWallet event raised by the Swaperc20 contract. -type Swaperc20SetProtocolFeeWallet struct { - FeeWallet common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSetProtocolFeeWallet is a free log retrieval operation binding the contract event 0x8b2a800ce9e2e7ccdf4741ae0e41b1f16983192291080ae3b78ac4296ddf598a. -// -// Solidity: event SetProtocolFeeWallet(address indexed feeWallet) -func (_Swaperc20 *Swaperc20Filterer) FilterSetProtocolFeeWallet(opts *bind.FilterOpts, feeWallet []common.Address) (*Swaperc20SetProtocolFeeWalletIterator, error) { - - var feeWalletRule []interface{} - for _, feeWalletItem := range feeWallet { - feeWalletRule = append(feeWalletRule, feeWalletItem) - } - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SetProtocolFeeWallet", feeWalletRule) - if err != nil { - return nil, err - } - return &Swaperc20SetProtocolFeeWalletIterator{contract: _Swaperc20.contract, event: "SetProtocolFeeWallet", logs: logs, sub: sub}, nil -} - -// WatchSetProtocolFeeWallet is a free log subscription operation binding the contract event 0x8b2a800ce9e2e7ccdf4741ae0e41b1f16983192291080ae3b78ac4296ddf598a. -// -// Solidity: event SetProtocolFeeWallet(address indexed feeWallet) -func (_Swaperc20 *Swaperc20Filterer) WatchSetProtocolFeeWallet(opts *bind.WatchOpts, sink chan<- *Swaperc20SetProtocolFeeWallet, feeWallet []common.Address) (event.Subscription, error) { - - var feeWalletRule []interface{} - for _, feeWalletItem := range feeWallet { - feeWalletRule = append(feeWalletRule, feeWalletItem) - } - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SetProtocolFeeWallet", feeWalletRule) - 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(Swaperc20SetProtocolFeeWallet) - if err := _Swaperc20.contract.UnpackLog(event, "SetProtocolFeeWallet", 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 -} - -// ParseSetProtocolFeeWallet is a log parse operation binding the contract event 0x8b2a800ce9e2e7ccdf4741ae0e41b1f16983192291080ae3b78ac4296ddf598a. -// -// Solidity: event SetProtocolFeeWallet(address indexed feeWallet) -func (_Swaperc20 *Swaperc20Filterer) ParseSetProtocolFeeWallet(log types.Log) (*Swaperc20SetProtocolFeeWallet, error) { - event := new(Swaperc20SetProtocolFeeWallet) - if err := _Swaperc20.contract.UnpackLog(event, "SetProtocolFeeWallet", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SetStakingIterator is returned from FilterSetStaking and is used to iterate over the raw logs and unpacked data for SetStaking events raised by the Swaperc20 contract. -type Swaperc20SetStakingIterator struct { - Event *Swaperc20SetStaking // 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 *Swaperc20SetStakingIterator) 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(Swaperc20SetStaking) - 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(Swaperc20SetStaking) - 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 *Swaperc20SetStakingIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SetStakingIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SetStaking represents a SetStaking event raised by the Swaperc20 contract. -type Swaperc20SetStaking struct { - Staking common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSetStaking is a free log retrieval operation binding the contract event 0x58fd5d9c33114e6edf8ea5d30956f8d1a4ab112b004f99928b4bcf1b87d66662. -// -// Solidity: event SetStaking(address indexed staking) -func (_Swaperc20 *Swaperc20Filterer) FilterSetStaking(opts *bind.FilterOpts, staking []common.Address) (*Swaperc20SetStakingIterator, error) { - - var stakingRule []interface{} - for _, stakingItem := range staking { - stakingRule = append(stakingRule, stakingItem) - } - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SetStaking", stakingRule) - if err != nil { - return nil, err - } - return &Swaperc20SetStakingIterator{contract: _Swaperc20.contract, event: "SetStaking", logs: logs, sub: sub}, nil -} - -// WatchSetStaking is a free log subscription operation binding the contract event 0x58fd5d9c33114e6edf8ea5d30956f8d1a4ab112b004f99928b4bcf1b87d66662. -// -// Solidity: event SetStaking(address indexed staking) -func (_Swaperc20 *Swaperc20Filterer) WatchSetStaking(opts *bind.WatchOpts, sink chan<- *Swaperc20SetStaking, staking []common.Address) (event.Subscription, error) { - - var stakingRule []interface{} - for _, stakingItem := range staking { - stakingRule = append(stakingRule, stakingItem) - } - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SetStaking", stakingRule) - 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(Swaperc20SetStaking) - if err := _Swaperc20.contract.UnpackLog(event, "SetStaking", 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 -} - -// ParseSetStaking is a log parse operation binding the contract event 0x58fd5d9c33114e6edf8ea5d30956f8d1a4ab112b004f99928b4bcf1b87d66662. -// -// Solidity: event SetStaking(address indexed staking) -func (_Swaperc20 *Swaperc20Filterer) ParseSetStaking(log types.Log) (*Swaperc20SetStaking, error) { - event := new(Swaperc20SetStaking) - if err := _Swaperc20.contract.UnpackLog(event, "SetStaking", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// Swaperc20SwapERC20Iterator is returned from FilterSwapERC20 and is used to iterate over the raw logs and unpacked data for SwapERC20 events raised by the Swaperc20 contract. -type Swaperc20SwapERC20Iterator struct { - Event *Swaperc20SwapERC20 // 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 *Swaperc20SwapERC20Iterator) 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(Swaperc20SwapERC20) - 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(Swaperc20SwapERC20) - 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 *Swaperc20SwapERC20Iterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Swaperc20SwapERC20Iterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Swaperc20SwapERC20 represents a SwapERC20 event raised by the Swaperc20 contract. -type Swaperc20SwapERC20 struct { - Nonce *big.Int - SignerWallet common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSwapERC20 is a free log retrieval operation binding the contract event 0x4294f3cfba9ff22cfa9cb602947f7656aa160c0a6c8fa406a28e12bed6bf2093. -// -// Solidity: event SwapERC20(uint256 indexed nonce, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) FilterSwapERC20(opts *bind.FilterOpts, nonce []*big.Int, signerWallet []common.Address) (*Swaperc20SwapERC20Iterator, error) { - - var nonceRule []interface{} - for _, nonceItem := range nonce { - nonceRule = append(nonceRule, nonceItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.FilterLogs(opts, "SwapERC20", nonceRule, signerWalletRule) - if err != nil { - return nil, err - } - return &Swaperc20SwapERC20Iterator{contract: _Swaperc20.contract, event: "SwapERC20", logs: logs, sub: sub}, nil -} - -// WatchSwapERC20 is a free log subscription operation binding the contract event 0x4294f3cfba9ff22cfa9cb602947f7656aa160c0a6c8fa406a28e12bed6bf2093. -// -// Solidity: event SwapERC20(uint256 indexed nonce, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) WatchSwapERC20(opts *bind.WatchOpts, sink chan<- *Swaperc20SwapERC20, nonce []*big.Int, signerWallet []common.Address) (event.Subscription, error) { - - var nonceRule []interface{} - for _, nonceItem := range nonce { - nonceRule = append(nonceRule, nonceItem) - } - var signerWalletRule []interface{} - for _, signerWalletItem := range signerWallet { - signerWalletRule = append(signerWalletRule, signerWalletItem) - } - - logs, sub, err := _Swaperc20.contract.WatchLogs(opts, "SwapERC20", nonceRule, signerWalletRule) - 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(Swaperc20SwapERC20) - if err := _Swaperc20.contract.UnpackLog(event, "SwapERC20", 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 -} - -// ParseSwapERC20 is a log parse operation binding the contract event 0x4294f3cfba9ff22cfa9cb602947f7656aa160c0a6c8fa406a28e12bed6bf2093. -// -// Solidity: event SwapERC20(uint256 indexed nonce, address indexed signerWallet) -func (_Swaperc20 *Swaperc20Filterer) ParseSwapERC20(log types.Log) (*Swaperc20SwapERC20, error) { - event := new(Swaperc20SwapERC20) - if err := _Swaperc20.contract.UnpackLog(event, "SwapERC20", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/plugins/crypto_airswap/swap_erc20/ISwapERC20.sol b/plugins/crypto_airswap/swap_erc20/ISwapERC20.sol deleted file mode 100644 index 13e4a70..0000000 --- a/plugins/crypto_airswap/swap_erc20/ISwapERC20.sol +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.2; - -interface ISwapERC20 { - struct OrderERC20 { - uint256 nonce; // Unique number per signatory per order - uint256 expiry; // Expiry time (seconds since unix epoch) - address signerWallet; // Party to the swap that sets terms - address signerToken; // ERC20 token address transferred from signer - uint256 signerAmount; // Amount of tokens transferred from signer - address senderWallet; // Party to the swap that accepts terms - address senderToken; // ERC20 token address transferred from sender - uint256 senderAmount; // Amount of tokens transferred from sender - uint8 v; // ECDSA - bytes32 r; - bytes32 s; - } - - event SwapERC20(uint256 indexed nonce, address indexed signerWallet); - - event Cancel(uint256 indexed nonce, address indexed signerWallet); - event Authorize(address indexed signer, address indexed signerWallet); - event Revoke(address indexed signer, address indexed signerWallet); - event SetProtocolFee(uint256 protocolFee); - event SetProtocolFeeLight(uint256 protocolFeeLight); - event SetProtocolFeeWallet(address indexed feeWallet); - event SetBonusScale(uint256 bonusScale); - event SetBonusMax(uint256 bonusMax); - event SetStaking(address indexed staking); - - function swap( - address recipient, - uint256 nonce, - uint256 expiry, - address signerWallet, - address signerToken, - uint256 signerAmount, - address senderToken, - uint256 senderAmount, - uint8 v, - bytes32 r, - bytes32 s - ) external; - - function swapAnySender( - address recipient, - uint256 nonce, - uint256 expiry, - address signerWallet, - address signerToken, - uint256 signerAmount, - address senderToken, - uint256 senderAmount, - uint8 v, - bytes32 r, - bytes32 s - ) external; - - function swapLight( - uint256 nonce, - uint256 expiry, - address signerWallet, - address signerToken, - uint256 signerAmount, - address senderToken, - uint256 senderAmount, - uint8 v, - bytes32 r, - bytes32 s - ) external; - - function authorize(address sender) external; - - function revoke() external; - - function cancel(uint256[] calldata nonces) external; - - function check( - address senderWallet, - uint256 nonce, - uint256 expiry, - address signerWallet, - address signerToken, - uint256 signerAmount, - address senderToken, - uint256 senderAmount, - uint8 v, - bytes32 r, - bytes32 s - ) external view returns (bytes32[] memory); - - function nonceUsed(address, uint256) external view returns (bool); - - function authorized(address) external view returns (address); - - function calculateProtocolFee( - address, - uint256 - ) external view returns (uint256); -} \ No newline at end of file diff --git a/test_data/oracle_config.yml b/test_data/oracle_config.yml index 357918a..ecdf762 100644 --- a/test_data/oracle_config.yml +++ b/test_data/oracle_config.yml @@ -35,12 +35,12 @@ confidenceStrategy: 0 # 0: linear, 1: fixed # # The crypto data plugins are used to fetch market prices for the crypto currency pairs: ATN-USDC, NTN-USDC, NTN-ATN and # USDC-USD. USDC liquidity is bridged to the Autonity public testnet from the Polygon Amoy testnet via a bridge service. -# Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. NTN-ATN market price is derived from -# that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and NTN-USD prices are then submitted on-chain. -# To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin and `crypto_airswap` plugin in your plugin directory. -# Oracle server can then discover and load them. Configuring the `crypto_uniswap` and `crypto_airswap` plugin does not -# require an API key, it is an open and free data source of a standard EVM RPC websocket service endpoint. The -# end user can connect to specific EVM RPC endpoint base on the blockchain which hosts the uniswap and airswap contracts. +# Out-the-box plugins for collecting ATN-USDC and NTN-USDC market data are available for UniSwap V2 and AirSwap protocols. +# NTN-ATN market price is derived from that market data, and USDC pricing is converted to USD. ATN-NTN, ATN-USD, and +# NTN-USD prices are then submitted on-chain. To retrieve ATN and NTN prices, put the `crypto_uniswap` plugin in your plugin directory. +# Oracle server can then discover and load them. Configuring the `crypto_uniswap` plugin does not require an API key, +# it is an open and free data source of a standard EVM RPC websocket service endpoint. The end user can connect to specific +# EVM RPC endpoint base on the blockchain which hosts the uniswap contract. # USDC-USD prices are required by the protocol to convert the ATN-USDC and NTN-USDC to ATN-USD and NTN-USD. This enables # the reporting of ATN and NTN prices in USD to the ASM. Three plugins are implemented to source the USDC-USD datapoint