From 3a64f5630ce837b96ca3955a517668330b0fbf79 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 6 Oct 2025 12:00:07 -0400 Subject: [PATCH] UniswapV3Pool wrapper --- .../java/stream/contract/UniswapV3Pool.java | 965 ++++++++++++++++++ 1 file changed, 965 insertions(+) create mode 100644 src/main/java/stream/contract/UniswapV3Pool.java diff --git a/src/main/java/stream/contract/UniswapV3Pool.java b/src/main/java/stream/contract/UniswapV3Pool.java new file mode 100644 index 0000000..e3bbb98 --- /dev/null +++ b/src/main/java/stream/contract/UniswapV3Pool.java @@ -0,0 +1,965 @@ +package stream.contract; + +import io.reactivex.Flowable; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Callable; +import org.web3j.abi.EventEncoder; +import org.web3j.abi.TypeReference; +import org.web3j.abi.datatypes.Address; +import org.web3j.abi.datatypes.Bool; +import org.web3j.abi.datatypes.DynamicArray; +import org.web3j.abi.datatypes.Event; +import org.web3j.abi.datatypes.Function; +import org.web3j.abi.datatypes.Type; +import org.web3j.abi.datatypes.generated.Int128; +import org.web3j.abi.datatypes.generated.Int24; +import org.web3j.abi.datatypes.generated.Int256; +import org.web3j.abi.datatypes.generated.Int56; +import org.web3j.abi.datatypes.generated.Uint128; +import org.web3j.abi.datatypes.generated.Uint16; +import org.web3j.abi.datatypes.generated.Uint160; +import org.web3j.abi.datatypes.generated.Uint24; +import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.generated.Uint32; +import org.web3j.abi.datatypes.generated.Uint8; +import org.web3j.crypto.Credentials; +import org.web3j.protocol.Web3j; +import org.web3j.protocol.core.DefaultBlockParameter; +import org.web3j.protocol.core.RemoteFunctionCall; +import org.web3j.protocol.core.methods.request.EthFilter; +import org.web3j.protocol.core.methods.response.BaseEventResponse; +import org.web3j.protocol.core.methods.response.Log; +import org.web3j.protocol.core.methods.response.TransactionReceipt; +import org.web3j.tuples.generated.Tuple2; +import org.web3j.tuples.generated.Tuple3; +import org.web3j.tuples.generated.Tuple4; +import org.web3j.tuples.generated.Tuple5; +import org.web3j.tuples.generated.Tuple7; +import org.web3j.tuples.generated.Tuple8; +import org.web3j.tx.Contract; +import org.web3j.tx.TransactionManager; +import org.web3j.tx.gas.ContractGasProvider; + +/** + *

Auto generated code. + *

Do not modify! + *

Please use the web3j command line tools, + * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the + * codegen module to update. + * + *

Generated with web3j version 1.7.0. + */ +@SuppressWarnings("rawtypes") +public class UniswapV3Pool extends Contract { + public static final String BINARY = "Bin file was not provided"; + + public static final String FUNC_BURN = "burn"; + + public static final String FUNC_COLLECT = "collect"; + + public static final String FUNC_COLLECTPROTOCOL = "collectProtocol"; + + public static final String FUNC_FACTORY = "factory"; + + public static final String FUNC_FEE = "fee"; + + public static final String FUNC_FEEGROWTHGLOBAL0X128 = "feeGrowthGlobal0X128"; + + public static final String FUNC_FEEGROWTHGLOBAL1X128 = "feeGrowthGlobal1X128"; + + public static final String FUNC_FLASH = "flash"; + + public static final String FUNC_INCREASEOBSERVATIONCARDINALITYNEXT = "increaseObservationCardinalityNext"; + + public static final String FUNC_INITIALIZE = "initialize"; + + public static final String FUNC_LIQUIDITY = "liquidity"; + + public static final String FUNC_MAXLIQUIDITYPERTICK = "maxLiquidityPerTick"; + + public static final String FUNC_MINT = "mint"; + + public static final String FUNC_OBSERVATIONS = "observations"; + + public static final String FUNC_OBSERVE = "observe"; + + public static final String FUNC_POSITIONS = "positions"; + + public static final String FUNC_PROTOCOLFEES = "protocolFees"; + + public static final String FUNC_SETFEEPROTOCOL = "setFeeProtocol"; + + public static final String FUNC_SLOT0 = "slot0"; + + public static final String FUNC_SNAPSHOTCUMULATIVESINSIDE = "snapshotCumulativesInside"; + + public static final String FUNC_SWAP = "swap"; + + public static final String FUNC_TICKBITMAP = "tickBitmap"; + + public static final String FUNC_TICKSPACING = "tickSpacing"; + + public static final String FUNC_TICKS = "ticks"; + + public static final String FUNC_TOKEN0 = "token0"; + + public static final String FUNC_TOKEN1 = "token1"; + + public static final Event BURN_EVENT = new Event("Burn", + Arrays.>asList(new TypeReference

(true) {}, new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event COLLECT_EVENT = new Event("Collect", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
() {}, new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event COLLECTPROTOCOL_EVENT = new Event("CollectProtocol", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event FLASH_EVENT = new Event("Flash", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event INCREASEOBSERVATIONCARDINALITYNEXT_EVENT = new Event("IncreaseObservationCardinalityNext", + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event INITIALIZE_EVENT = new Event("Initialize", + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event MINT_EVENT = new Event("Mint", + Arrays.>asList(new TypeReference
() {}, new TypeReference
(true) {}, new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event SETFEEPROTOCOL_EVENT = new Event("SetFeeProtocol", + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + public static final Event SWAP_EVENT = new Event("Swap", + Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + ; + + @Deprecated + protected UniswapV3Pool(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, + BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + protected UniswapV3Pool(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, credentials, contractGasProvider); + } + + @Deprecated + protected UniswapV3Pool(String contractAddress, Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { + super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + protected UniswapV3Pool(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { + super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static List getBurnEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(BURN_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + BurnEventResponse typedResponse = new BurnEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.tickLower = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.tickUpper = (BigInteger) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static BurnEventResponse getBurnEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(BURN_EVENT, log); + BurnEventResponse typedResponse = new BurnEventResponse(); + typedResponse.log = log; + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.tickLower = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.tickUpper = (BigInteger) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable burnEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getBurnEventFromLog(log)); + } + + public Flowable burnEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(BURN_EVENT)); + return burnEventFlowable(filter); + } + + public static List getCollectEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(COLLECT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + CollectEventResponse typedResponse = new CollectEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.tickLower = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.tickUpper = (BigInteger) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.recipient = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static CollectEventResponse getCollectEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(COLLECT_EVENT, log); + CollectEventResponse typedResponse = new CollectEventResponse(); + typedResponse.log = log; + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.tickLower = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.tickUpper = (BigInteger) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.recipient = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + } + + public Flowable collectEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getCollectEventFromLog(log)); + } + + public Flowable collectEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(COLLECT_EVENT)); + return collectEventFlowable(filter); + } + + public static List getCollectProtocolEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(COLLECTPROTOCOL_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + CollectProtocolEventResponse typedResponse = new CollectProtocolEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.recipient = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static CollectProtocolEventResponse getCollectProtocolEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(COLLECTPROTOCOL_EVENT, log); + CollectProtocolEventResponse typedResponse = new CollectProtocolEventResponse(); + typedResponse.log = log; + typedResponse.sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.recipient = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable collectProtocolEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getCollectProtocolEventFromLog(log)); + } + + public Flowable collectProtocolEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(COLLECTPROTOCOL_EVENT)); + return collectProtocolEventFlowable(filter); + } + + public static List getFlashEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(FLASH_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + FlashEventResponse typedResponse = new FlashEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.recipient = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.paid0 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.paid1 = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static FlashEventResponse getFlashEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(FLASH_EVENT, log); + FlashEventResponse typedResponse = new FlashEventResponse(); + typedResponse.log = log; + typedResponse.sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.recipient = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.paid0 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.paid1 = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + return typedResponse; + } + + public Flowable flashEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getFlashEventFromLog(log)); + } + + public Flowable flashEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(FLASH_EVENT)); + return flashEventFlowable(filter); + } + + public static List getIncreaseObservationCardinalityNextEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(INCREASEOBSERVATIONCARDINALITYNEXT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + IncreaseObservationCardinalityNextEventResponse typedResponse = new IncreaseObservationCardinalityNextEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.observationCardinalityNextOld = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.observationCardinalityNextNew = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static IncreaseObservationCardinalityNextEventResponse getIncreaseObservationCardinalityNextEventFromLog( + Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(INCREASEOBSERVATIONCARDINALITYNEXT_EVENT, log); + IncreaseObservationCardinalityNextEventResponse typedResponse = new IncreaseObservationCardinalityNextEventResponse(); + typedResponse.log = log; + typedResponse.observationCardinalityNextOld = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.observationCardinalityNextNew = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable increaseObservationCardinalityNextEventFlowable( + EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getIncreaseObservationCardinalityNextEventFromLog(log)); + } + + public Flowable increaseObservationCardinalityNextEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(INCREASEOBSERVATIONCARDINALITYNEXT_EVENT)); + return increaseObservationCardinalityNextEventFlowable(filter); + } + + public static List getInitializeEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(INITIALIZE_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + InitializeEventResponse typedResponse = new InitializeEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.sqrtPriceX96 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.tick = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static InitializeEventResponse getInitializeEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(INITIALIZE_EVENT, log); + InitializeEventResponse typedResponse = new InitializeEventResponse(); + typedResponse.log = log; + typedResponse.sqrtPriceX96 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.tick = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + } + + public Flowable initializeEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getInitializeEventFromLog(log)); + } + + public Flowable initializeEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(INITIALIZE_EVENT)); + return initializeEventFlowable(filter); + } + + public static List getMintEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(MINT_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + MintEventResponse typedResponse = new MintEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.tickLower = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.tickUpper = (BigInteger) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.sender = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static MintEventResponse getMintEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(MINT_EVENT, log); + MintEventResponse typedResponse = new MintEventResponse(); + typedResponse.log = log; + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.tickLower = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.tickUpper = (BigInteger) eventValues.getIndexedValues().get(2).getValue(); + typedResponse.sender = (String) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + return typedResponse; + } + + public Flowable mintEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getMintEventFromLog(log)); + } + + public Flowable mintEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(MINT_EVENT)); + return mintEventFlowable(filter); + } + + public static List getSetFeeProtocolEvents( + TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(SETFEEPROTOCOL_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + SetFeeProtocolEventResponse typedResponse = new SetFeeProtocolEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.feeProtocol0Old = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.feeProtocol1Old = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.feeProtocol0New = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.feeProtocol1New = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static SetFeeProtocolEventResponse getSetFeeProtocolEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(SETFEEPROTOCOL_EVENT, log); + SetFeeProtocolEventResponse typedResponse = new SetFeeProtocolEventResponse(); + typedResponse.log = log; + typedResponse.feeProtocol0Old = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.feeProtocol1Old = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.feeProtocol0New = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.feeProtocol1New = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + return typedResponse; + } + + public Flowable setFeeProtocolEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getSetFeeProtocolEventFromLog(log)); + } + + public Flowable setFeeProtocolEventFlowable( + DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(SETFEEPROTOCOL_EVENT)); + return setFeeProtocolEventFlowable(filter); + } + + public static List getSwapEvents(TransactionReceipt transactionReceipt) { + List valueList = staticExtractEventParametersWithLog(SWAP_EVENT, transactionReceipt); + ArrayList responses = new ArrayList(valueList.size()); + for (Contract.EventValuesWithLog eventValues : valueList) { + SwapEventResponse typedResponse = new SwapEventResponse(); + typedResponse.log = eventValues.getLog(); + typedResponse.sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.recipient = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.sqrtPriceX96 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.liquidity = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + typedResponse.tick = (BigInteger) eventValues.getNonIndexedValues().get(4).getValue(); + responses.add(typedResponse); + } + return responses; + } + + public static SwapEventResponse getSwapEventFromLog(Log log) { + Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(SWAP_EVENT, log); + SwapEventResponse typedResponse = new SwapEventResponse(); + typedResponse.log = log; + typedResponse.sender = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.recipient = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.amount0 = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.amount1 = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.sqrtPriceX96 = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue(); + typedResponse.liquidity = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); + typedResponse.tick = (BigInteger) eventValues.getNonIndexedValues().get(4).getValue(); + return typedResponse; + } + + public Flowable swapEventFlowable(EthFilter filter) { + return web3j.ethLogFlowable(filter).map(log -> getSwapEventFromLog(log)); + } + + public Flowable swapEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { + EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); + filter.addSingleTopic(EventEncoder.encode(SWAP_EVENT)); + return swapEventFlowable(filter); + } + + public RemoteFunctionCall burn(BigInteger tickLower, BigInteger tickUpper, + BigInteger amount) { + final Function function = new Function( + FUNC_BURN, + Arrays.asList(new org.web3j.abi.datatypes.generated.Int24(tickLower), + new org.web3j.abi.datatypes.generated.Int24(tickUpper), + new org.web3j.abi.datatypes.generated.Uint128(amount)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall collect(String recipient, BigInteger tickLower, + BigInteger tickUpper, BigInteger amount0Requested, BigInteger amount1Requested) { + final Function function = new Function( + FUNC_COLLECT, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, recipient), + new org.web3j.abi.datatypes.generated.Int24(tickLower), + new org.web3j.abi.datatypes.generated.Int24(tickUpper), + new org.web3j.abi.datatypes.generated.Uint128(amount0Requested), + new org.web3j.abi.datatypes.generated.Uint128(amount1Requested)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall collectProtocol(String recipient, + BigInteger amount0Requested, BigInteger amount1Requested) { + final Function function = new Function( + FUNC_COLLECTPROTOCOL, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, recipient), + new org.web3j.abi.datatypes.generated.Uint128(amount0Requested), + new org.web3j.abi.datatypes.generated.Uint128(amount1Requested)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall factory() { + final Function function = new Function(FUNC_FACTORY, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall fee() { + final Function function = new Function(FUNC_FEE, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall feeGrowthGlobal0X128() { + final Function function = new Function(FUNC_FEEGROWTHGLOBAL0X128, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall feeGrowthGlobal1X128() { + final Function function = new Function(FUNC_FEEGROWTHGLOBAL1X128, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall flash(String recipient, BigInteger amount0, + BigInteger amount1, byte[] data) { + final Function function = new Function( + FUNC_FLASH, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, recipient), + new org.web3j.abi.datatypes.generated.Uint256(amount0), + new org.web3j.abi.datatypes.generated.Uint256(amount1), + new org.web3j.abi.datatypes.DynamicBytes(data)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall increaseObservationCardinalityNext( + BigInteger observationCardinalityNext) { + final Function function = new Function( + FUNC_INCREASEOBSERVATIONCARDINALITYNEXT, + Arrays.asList(new org.web3j.abi.datatypes.generated.Uint16(observationCardinalityNext)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall initialize(BigInteger sqrtPriceX96) { + final Function function = new Function( + FUNC_INITIALIZE, + Arrays.asList(new org.web3j.abi.datatypes.generated.Uint160(sqrtPriceX96)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall liquidity() { + final Function function = new Function(FUNC_LIQUIDITY, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall maxLiquidityPerTick() { + final Function function = new Function(FUNC_MAXLIQUIDITYPERTICK, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall mint(String recipient, BigInteger tickLower, + BigInteger tickUpper, BigInteger amount, byte[] data) { + final Function function = new Function( + FUNC_MINT, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, recipient), + new org.web3j.abi.datatypes.generated.Int24(tickLower), + new org.web3j.abi.datatypes.generated.Int24(tickUpper), + new org.web3j.abi.datatypes.generated.Uint128(amount), + new org.web3j.abi.datatypes.DynamicBytes(data)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall> observations( + BigInteger param0) { + final Function function = new Function(FUNC_OBSERVATIONS, + Arrays.asList(new org.web3j.abi.datatypes.generated.Uint256(param0)), + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple4 call() throws + Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple4( + (BigInteger) results.get(0).getValue(), + (BigInteger) results.get(1).getValue(), + (BigInteger) results.get(2).getValue(), + (Boolean) results.get(3).getValue()); + } + }); + } + + public RemoteFunctionCall, List>> observe( + List secondsAgos) { + final Function function = new Function(FUNC_OBSERVE, + Arrays.asList(new org.web3j.abi.datatypes.DynamicArray( + org.web3j.abi.datatypes.generated.Uint32.class, + org.web3j.abi.Utils.typeMap(secondsAgos, org.web3j.abi.datatypes.generated.Uint32.class))), + Arrays.>asList(new TypeReference>() {}, new TypeReference>() {})); + return new RemoteFunctionCall, List>>(function, + new Callable, List>>() { + @Override + public Tuple2, List> call() throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple2, List>( + convertToNative((List) results.get(0).getValue()), + convertToNative((List) results.get(1).getValue())); + } + }); + } + + public RemoteFunctionCall> positions( + byte[] param0) { + final Function function = new Function(FUNC_POSITIONS, + Arrays.asList(new org.web3j.abi.datatypes.generated.Bytes32(param0)), + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple5 call() + throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple5( + (BigInteger) results.get(0).getValue(), + (BigInteger) results.get(1).getValue(), + (BigInteger) results.get(2).getValue(), + (BigInteger) results.get(3).getValue(), + (BigInteger) results.get(4).getValue()); + } + }); + } + + public RemoteFunctionCall> protocolFees() { + final Function function = new Function(FUNC_PROTOCOLFEES, + Arrays.asList(), + Arrays.>asList(new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple2 call() throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple2( + (BigInteger) results.get(0).getValue(), + (BigInteger) results.get(1).getValue()); + } + }); + } + + public RemoteFunctionCall setFeeProtocol(BigInteger feeProtocol0, + BigInteger feeProtocol1) { + final Function function = new Function( + FUNC_SETFEEPROTOCOL, + Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(feeProtocol0), + new org.web3j.abi.datatypes.generated.Uint8(feeProtocol1)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall> slot0( + ) { + final Function function = new Function(FUNC_SLOT0, + Arrays.asList(), + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple7 call( + ) throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple7( + (BigInteger) results.get(0).getValue(), + (BigInteger) results.get(1).getValue(), + (BigInteger) results.get(2).getValue(), + (BigInteger) results.get(3).getValue(), + (BigInteger) results.get(4).getValue(), + (BigInteger) results.get(5).getValue(), + (Boolean) results.get(6).getValue()); + } + }); + } + + public RemoteFunctionCall> snapshotCumulativesInside( + BigInteger tickLower, BigInteger tickUpper) { + final Function function = new Function(FUNC_SNAPSHOTCUMULATIVESINSIDE, + Arrays.asList(new org.web3j.abi.datatypes.generated.Int24(tickLower), + new org.web3j.abi.datatypes.generated.Int24(tickUpper)), + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple3 call() throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple3( + (BigInteger) results.get(0).getValue(), + (BigInteger) results.get(1).getValue(), + (BigInteger) results.get(2).getValue()); + } + }); + } + + public RemoteFunctionCall swap(String recipient, Boolean zeroForOne, + BigInteger amountSpecified, BigInteger sqrtPriceLimitX96, byte[] data) { + final Function function = new Function( + FUNC_SWAP, + Arrays.asList(new org.web3j.abi.datatypes.Address(160, recipient), + new org.web3j.abi.datatypes.Bool(zeroForOne), + new org.web3j.abi.datatypes.generated.Int256(amountSpecified), + new org.web3j.abi.datatypes.generated.Uint160(sqrtPriceLimitX96), + new org.web3j.abi.datatypes.DynamicBytes(data)), + Collections.>emptyList()); + return executeRemoteCallTransaction(function); + } + + public RemoteFunctionCall tickBitmap(BigInteger param0) { + final Function function = new Function(FUNC_TICKBITMAP, + Arrays.asList(new org.web3j.abi.datatypes.generated.Int16(param0)), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall tickSpacing() { + final Function function = new Function(FUNC_TICKSPACING, + Arrays.asList(), + Arrays.>asList(new TypeReference() {})); + return executeRemoteCallSingleValueReturn(function, BigInteger.class); + } + + public RemoteFunctionCall> ticks( + BigInteger param0) { + final Function function = new Function(FUNC_TICKS, + Arrays.asList(new org.web3j.abi.datatypes.generated.Int24(param0)), + Arrays.>asList(new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); + return new RemoteFunctionCall>(function, + new Callable>() { + @Override + public Tuple8 call( + ) throws Exception { + List results = executeCallMultipleValueReturn(function); + return new Tuple8( + (BigInteger) results.get(0).getValue(), + (BigInteger) results.get(1).getValue(), + (BigInteger) results.get(2).getValue(), + (BigInteger) results.get(3).getValue(), + (BigInteger) results.get(4).getValue(), + (BigInteger) results.get(5).getValue(), + (BigInteger) results.get(6).getValue(), + (Boolean) results.get(7).getValue()); + } + }); + } + + public RemoteFunctionCall token0() { + final Function function = new Function(FUNC_TOKEN0, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + public RemoteFunctionCall token1() { + final Function function = new Function(FUNC_TOKEN1, + Arrays.asList(), + Arrays.>asList(new TypeReference
() {})); + return executeRemoteCallSingleValueReturn(function, String.class); + } + + @Deprecated + public static UniswapV3Pool load(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { + return new UniswapV3Pool(contractAddress, web3j, credentials, gasPrice, gasLimit); + } + + @Deprecated + public static UniswapV3Pool load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + return new UniswapV3Pool(contractAddress, web3j, transactionManager, gasPrice, gasLimit); + } + + public static UniswapV3Pool load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { + return new UniswapV3Pool(contractAddress, web3j, credentials, contractGasProvider); + } + + public static UniswapV3Pool load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + return new UniswapV3Pool(contractAddress, web3j, transactionManager, contractGasProvider); + } + + public static class BurnEventResponse extends BaseEventResponse { + public String owner; + + public BigInteger tickLower; + + public BigInteger tickUpper; + + public BigInteger amount; + + public BigInteger amount0; + + public BigInteger amount1; + } + + public static class CollectEventResponse extends BaseEventResponse { + public String owner; + + public BigInteger tickLower; + + public BigInteger tickUpper; + + public String recipient; + + public BigInteger amount0; + + public BigInteger amount1; + } + + public static class CollectProtocolEventResponse extends BaseEventResponse { + public String sender; + + public String recipient; + + public BigInteger amount0; + + public BigInteger amount1; + } + + public static class FlashEventResponse extends BaseEventResponse { + public String sender; + + public String recipient; + + public BigInteger amount0; + + public BigInteger amount1; + + public BigInteger paid0; + + public BigInteger paid1; + } + + public static class IncreaseObservationCardinalityNextEventResponse extends BaseEventResponse { + public BigInteger observationCardinalityNextOld; + + public BigInteger observationCardinalityNextNew; + } + + public static class InitializeEventResponse extends BaseEventResponse { + public BigInteger sqrtPriceX96; + + public BigInteger tick; + } + + public static class MintEventResponse extends BaseEventResponse { + public String owner; + + public BigInteger tickLower; + + public BigInteger tickUpper; + + public String sender; + + public BigInteger amount; + + public BigInteger amount0; + + public BigInteger amount1; + } + + public static class SetFeeProtocolEventResponse extends BaseEventResponse { + public BigInteger feeProtocol0Old; + + public BigInteger feeProtocol1Old; + + public BigInteger feeProtocol0New; + + public BigInteger feeProtocol1New; + } + + public static class SwapEventResponse extends BaseEventResponse { + public String sender; + + public String recipient; + + public BigInteger amount0; + + public BigInteger amount1; + + public BigInteger sqrtPriceX96; + + public BigInteger liquidity; + + public BigInteger tick; + } +}