diff --git a/.gitmodules b/.gitmodules index 2bdadfa..fa7e465 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,9 @@ [submodule "contracts/utils/lib/solmate"] path = contracts/utils/lib/solmate url = https://github.com/transmissions11/solmate +[submodule "lib/v4-core"] + path = lib/v4-core + url = https://github.com/uniswap/v4-core +[submodule "contracts/utils/lib/v4-core"] + path = contracts/utils/lib/v4-core + url = https://github.com/uniswap/v4-core diff --git a/contracts/utils/lib/v4-core b/contracts/utils/lib/v4-core new file mode 160000 index 0000000..799dd2c --- /dev/null +++ b/contracts/utils/lib/v4-core @@ -0,0 +1 @@ +Subproject commit 799dd2cb980319a8d3b827b6a7aa59a606634553 diff --git a/contracts/utils/src/Fetcher.sol b/contracts/utils/src/Fetcher.sol new file mode 100644 index 0000000..cfffce3 --- /dev/null +++ b/contracts/utils/src/Fetcher.sol @@ -0,0 +1,40 @@ +pragma solidity ^0.8.10; + +import {PoolId} from "v4-core/types/PoolId.sol"; +import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol"; +import {Position} from "v4-core/libraries/Position.sol"; + +// This contract is a compact version of StateLibrary, which can be found below. +// https://github.com/Uniswap/v4-core/blob/799dd2cb980319a8d3b827b6a7aa59a606634553/src/libraries/StateLibrary.sol +contract Fetcher { + bytes32 public constant POOLS_SLOT = bytes32(uint256(6)); + + function _getPoolStateSlot(PoolId poolId) internal pure returns (bytes32) { + return keccak256(abi.encodePacked(PoolId.unwrap(poolId), POOLS_SLOT)); + } + + function getSlot0(IPoolManager manager, PoolId poolId) + external + view + returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee) + { + // slot key of Pool.State value: `pools[poolId]` + bytes32 stateSlot = _getPoolStateSlot(poolId); + + bytes32 data = manager.extsload(stateSlot); + + // 24 bits |24bits|24bits |24 bits|160 bits + // 0x000000 |000bb8|000000 |ffff75 |0000000000000000fe3aa841ba359daa0ea9eff7 + // ---------- | fee |protocolfee | tick | sqrtPriceX96 + assembly ("memory-safe") { + // bottom 160 bits of data + sqrtPriceX96 := and(data, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + // next 24 bits of data + tick := signextend(2, shr(160, data)) + // next 24 bits of data + protocolFee := and(shr(184, data), 0xFFFFFF) + // last 24 bits of data + lpFee := and(shr(208, data), 0xFFFFFF) + } + } +} \ No newline at end of file diff --git a/src/bindings/fetcher.rs b/src/bindings/fetcher.rs new file mode 100644 index 0000000..d8c6425 --- /dev/null +++ b/src/bindings/fetcher.rs @@ -0,0 +1,800 @@ +/** + +Generated by the following Solidity interface... +```solidity +interface Fetcher { + type PoolId is bytes32; + + function POOLS_SLOT() external view returns (bytes32); + function getSlot0(address manager, PoolId poolId) external view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee); +} +``` + +...which was generated by the following JSON ABI: +```json +[ + { + "type": "function", + "name": "POOLS_SLOT", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getSlot0", + "inputs": [ + { + "name": "manager", + "type": "address", + "internalType": "contract IPoolManager" + }, + { + "name": "poolId", + "type": "bytes32", + "internalType": "PoolId" + } + ], + "outputs": [ + { + "name": "sqrtPriceX96", + "type": "uint160", + "internalType": "uint160" + }, + { + "name": "tick", + "type": "int24", + "internalType": "int24" + }, + { + "name": "protocolFee", + "type": "uint24", + "internalType": "uint24" + }, + { + "name": "lpFee", + "type": "uint24", + "internalType": "uint24" + } + ], + "stateMutability": "view" + } +] +```*/ +#[allow(non_camel_case_types, non_snake_case, clippy::style)] +pub mod Fetcher { + use super::*; + use alloy::sol_types as alloy_sol_types; + /// The creation / init bytecode of the contract. + /// + /// ```text + ///0x6080604052348015600f57600080fd5b5061021d8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806357eb1da71461003b578063e631bcbf14610056575b600080fd5b610043600681565b6040519081526020015b60405180910390f35b610069610064366004610196565b6100a1565b604080516001600160a01b03909516855260029390930b602085015262ffffff9182169284019290925216606082015260800161004d565b60008060008060006100b286610159565b604051631e2eaeaf60e01b8152600481018290529091506000906001600160a01b03891690631e2eaeaf90602401602060405180830381865afa1580156100fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012191906101ce565b90506001600160a01b03811695508060a01c60020b945062ffffff8160b81c16935062ffffff8160d01c169250505092959194509250565b604051600090610179908390600690602001918252602082015260400190565b604051602081830303815290604052805190602001209050919050565b600080604083850312156101a957600080fd5b82356001600160a01b03811681146101c057600080fd5b946020939093013593505050565b6000602082840312156101e057600080fd5b505191905056fea264697066735822122067f87cf69f85fffc4d67c1e7263ede1e06ed37607224dd0b5f09542d1f31904664736f6c634300081a0033 + /// ``` + #[rustfmt::skip] + pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( + b"`\x80`@R4\x80\x15`\x0FW`\0\x80\xFD[Pa\x02\x1D\x80a\0\x1F`\09`\0\xF3\xFE`\x80`@R4\x80\x15a\0\x10W`\0\x80\xFD[P`\x046\x10a\x006W`\x005`\xE0\x1C\x80cW\xEB\x1D\xA7\x14a\0;W\x80c\xE61\xBC\xBF\x14a\0VW[`\0\x80\xFD[a\0C`\x06\x81V[`@Q\x90\x81R` \x01[`@Q\x80\x91\x03\x90\xF3[a\0ia\0d6`\x04a\x01\x96V[a\0\xA1V[`@\x80Q`\x01`\x01`\xA0\x1B\x03\x90\x95\x16\x85R`\x02\x93\x90\x93\x0B` \x85\x01Rb\xFF\xFF\xFF\x91\x82\x16\x92\x84\x01\x92\x90\x92R\x16``\x82\x01R`\x80\x01a\0MV[`\0\x80`\0\x80`\0a\0\xB2\x86a\x01YV[`@Qc\x1E.\xAE\xAF`\xE0\x1B\x81R`\x04\x81\x01\x82\x90R\x90\x91P`\0\x90`\x01`\x01`\xA0\x1B\x03\x89\x16\x90c\x1E.\xAE\xAF\x90`$\x01` `@Q\x80\x83\x03\x81\x86Z\xFA\x15\x80\x15a\0\xFDW=`\0\x80>=`\0\xFD[PPPP`@Q=`\x1F\x19`\x1F\x82\x01\x16\x82\x01\x80`@RP\x81\x01\x90a\x01!\x91\x90a\x01\xCEV[\x90P`\x01`\x01`\xA0\x1B\x03\x81\x16\x95P\x80`\xA0\x1C`\x02\x0B\x94Pb\xFF\xFF\xFF\x81`\xB8\x1C\x16\x93Pb\xFF\xFF\xFF\x81`\xD0\x1C\x16\x92PPP\x92\x95\x91\x94P\x92PV[`@Q`\0\x90a\x01y\x90\x83\x90`\x06\x90` \x01\x91\x82R` \x82\x01R`@\x01\x90V[`@Q` \x81\x83\x03\x03\x81R\x90`@R\x80Q\x90` \x01 \x90P\x91\x90PV[`\0\x80`@\x83\x85\x03\x12\x15a\x01\xA9W`\0\x80\xFD[\x825`\x01`\x01`\xA0\x1B\x03\x81\x16\x81\x14a\x01\xC0W`\0\x80\xFD[\x94` \x93\x90\x93\x015\x93PPPV[`\0` \x82\x84\x03\x12\x15a\x01\xE0W`\0\x80\xFD[PQ\x91\x90PV\xFE\xA2dipfsX\"\x12 g\xF8|\xF6\x9F\x85\xFF\xFCMg\xC1\xE7&>\xDE\x1E\x06\xED7`r$\xDD\x0B_\tT-\x1F1\x90FdsolcC\0\x08\x1A\x003", + ); + /// The runtime bytecode of the contract, as deployed on the network. + /// + /// ```text + ///0x608060405234801561001057600080fd5b50600436106100365760003560e01c806357eb1da71461003b578063e631bcbf14610056575b600080fd5b610043600681565b6040519081526020015b60405180910390f35b610069610064366004610196565b6100a1565b604080516001600160a01b03909516855260029390930b602085015262ffffff9182169284019290925216606082015260800161004d565b60008060008060006100b286610159565b604051631e2eaeaf60e01b8152600481018290529091506000906001600160a01b03891690631e2eaeaf90602401602060405180830381865afa1580156100fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061012191906101ce565b90506001600160a01b03811695508060a01c60020b945062ffffff8160b81c16935062ffffff8160d01c169250505092959194509250565b604051600090610179908390600690602001918252602082015260400190565b604051602081830303815290604052805190602001209050919050565b600080604083850312156101a957600080fd5b82356001600160a01b03811681146101c057600080fd5b946020939093013593505050565b6000602082840312156101e057600080fd5b505191905056fea264697066735822122067f87cf69f85fffc4d67c1e7263ede1e06ed37607224dd0b5f09542d1f31904664736f6c634300081a0033 + /// ``` + #[rustfmt::skip] + pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( + b"`\x80`@R4\x80\x15a\0\x10W`\0\x80\xFD[P`\x046\x10a\x006W`\x005`\xE0\x1C\x80cW\xEB\x1D\xA7\x14a\0;W\x80c\xE61\xBC\xBF\x14a\0VW[`\0\x80\xFD[a\0C`\x06\x81V[`@Q\x90\x81R` \x01[`@Q\x80\x91\x03\x90\xF3[a\0ia\0d6`\x04a\x01\x96V[a\0\xA1V[`@\x80Q`\x01`\x01`\xA0\x1B\x03\x90\x95\x16\x85R`\x02\x93\x90\x93\x0B` \x85\x01Rb\xFF\xFF\xFF\x91\x82\x16\x92\x84\x01\x92\x90\x92R\x16``\x82\x01R`\x80\x01a\0MV[`\0\x80`\0\x80`\0a\0\xB2\x86a\x01YV[`@Qc\x1E.\xAE\xAF`\xE0\x1B\x81R`\x04\x81\x01\x82\x90R\x90\x91P`\0\x90`\x01`\x01`\xA0\x1B\x03\x89\x16\x90c\x1E.\xAE\xAF\x90`$\x01` `@Q\x80\x83\x03\x81\x86Z\xFA\x15\x80\x15a\0\xFDW=`\0\x80>=`\0\xFD[PPPP`@Q=`\x1F\x19`\x1F\x82\x01\x16\x82\x01\x80`@RP\x81\x01\x90a\x01!\x91\x90a\x01\xCEV[\x90P`\x01`\x01`\xA0\x1B\x03\x81\x16\x95P\x80`\xA0\x1C`\x02\x0B\x94Pb\xFF\xFF\xFF\x81`\xB8\x1C\x16\x93Pb\xFF\xFF\xFF\x81`\xD0\x1C\x16\x92PPP\x92\x95\x91\x94P\x92PV[`@Q`\0\x90a\x01y\x90\x83\x90`\x06\x90` \x01\x91\x82R` \x82\x01R`@\x01\x90V[`@Q` \x81\x83\x03\x03\x81R\x90`@R\x80Q\x90` \x01 \x90P\x91\x90PV[`\0\x80`@\x83\x85\x03\x12\x15a\x01\xA9W`\0\x80\xFD[\x825`\x01`\x01`\xA0\x1B\x03\x81\x16\x81\x14a\x01\xC0W`\0\x80\xFD[\x94` \x93\x90\x93\x015\x93PPPV[`\0` \x82\x84\x03\x12\x15a\x01\xE0W`\0\x80\xFD[PQ\x91\x90PV\xFE\xA2dipfsX\"\x12 g\xF8|\xF6\x9F\x85\xFF\xFCMg\xC1\xE7&>\xDE\x1E\x06\xED7`r$\xDD\x0B_\tT-\x1F1\x90FdsolcC\0\x08\x1A\x003", + ); + #[allow(non_camel_case_types, non_snake_case)] + #[derive(Clone)] + pub struct PoolId(alloy::sol_types::private::FixedBytes<32>); + const _: () = { + use alloy::sol_types as alloy_sol_types; + #[automatically_derived] + impl alloy_sol_types::private::SolTypeValue + for alloy::sol_types::private::FixedBytes<32> { + #[inline] + fn stv_to_tokens( + &self, + ) -> as alloy_sol_types::SolType>::Token<'_> { + alloy_sol_types::private::SolTypeValue::< + alloy::sol_types::sol_data::FixedBytes<32>, + >::stv_to_tokens(self) + } + #[inline] + fn stv_eip712_data_word(&self) -> alloy_sol_types::Word { + as alloy_sol_types::SolType>::tokenize(self) + .0 + } + #[inline] + fn stv_abi_encode_packed_to( + &self, + out: &mut alloy_sol_types::private::Vec, + ) { + as alloy_sol_types::SolType>::abi_encode_packed_to(self, out) + } + } + #[automatically_derived] + impl PoolId { + /// The Solidity type name. + pub const NAME: &'static str = stringify!(@ name); + /// Convert from the underlying value type. + #[inline] + pub const fn from(value: alloy::sol_types::private::FixedBytes<32>) -> Self { + Self(value) + } + /// Return the underlying value. + #[inline] + pub const fn into(self) -> alloy::sol_types::private::FixedBytes<32> { + self.0 + } + /// Return the single encoding of this value, delegating to the + /// underlying type. + #[inline] + pub fn abi_encode(&self) -> alloy_sol_types::private::Vec { + ::abi_encode(&self.0) + } + /// Return the packed encoding of this value, delegating to the + /// underlying type. + #[inline] + pub fn abi_encode_packed(&self) -> alloy_sol_types::private::Vec { + ::abi_encode_packed(&self.0) + } + } + #[automatically_derived] + impl alloy_sol_types::SolType for PoolId { + type RustType = alloy::sol_types::private::FixedBytes<32>; + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SOL_NAME: &'static str = Self::NAME; + const ENCODED_SIZE: Option = as alloy_sol_types::SolType>::ENCODED_SIZE; + #[inline] + fn valid_token(token: &Self::Token<'_>) -> bool { + Self::type_check(token).is_ok() + } + #[inline] + fn type_check(token: &Self::Token<'_>) -> alloy_sol_types::Result<()> { + as alloy_sol_types::SolType>::type_check(token) + } + #[inline] + fn detokenize(token: Self::Token<'_>) -> Self::RustType { + as alloy_sol_types::SolType>::detokenize(token) + } + } + #[automatically_derived] + impl alloy_sol_types::EventTopic for PoolId { + #[inline] + fn topic_preimage_length(rust: &Self::RustType) -> usize { + as alloy_sol_types::EventTopic>::topic_preimage_length(rust) + } + #[inline] + fn encode_topic_preimage( + rust: &Self::RustType, + out: &mut alloy_sol_types::private::Vec, + ) { + as alloy_sol_types::EventTopic>::encode_topic_preimage(rust, out) + } + #[inline] + fn encode_topic( + rust: &Self::RustType, + ) -> alloy_sol_types::abi::token::WordToken { + as alloy_sol_types::EventTopic>::encode_topic(rust) + } + } + }; + /**Function with signature `POOLS_SLOT()` and selector `0x57eb1da7`. +```solidity +function POOLS_SLOT() external view returns (bytes32); +```*/ + #[allow(non_camel_case_types, non_snake_case)] + #[derive(Clone)] + pub struct POOLS_SLOTCall {} + ///Container type for the return parameters of the [`POOLS_SLOT()`](POOLS_SLOTCall) function. + #[allow(non_camel_case_types, non_snake_case)] + #[derive(Clone)] + pub struct POOLS_SLOTReturn { + pub _0: alloy::sol_types::private::FixedBytes<32>, + } + #[allow(non_camel_case_types, non_snake_case, clippy::style)] + const _: () = { + use alloy::sol_types as alloy_sol_types; + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: POOLS_SLOTCall) -> Self { + () + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for POOLS_SLOTCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self {} + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::FixedBytes<32>,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (alloy::sol_types::private::FixedBytes<32>,); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: POOLS_SLOTReturn) -> Self { + (value._0,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for POOLS_SLOTReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { _0: tuple.0 } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for POOLS_SLOTCall { + type Parameters<'a> = (); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = POOLS_SLOTReturn; + type ReturnTuple<'a> = (alloy::sol_types::sol_data::FixedBytes<32>,); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "POOLS_SLOT()"; + const SELECTOR: [u8; 4] = [87u8, 235u8, 29u8, 167u8]; + #[inline] + fn new<'a>( + tuple: as alloy_sol_types::SolType>::RustType, + ) -> Self { + tuple.into() + } + #[inline] + fn tokenize(&self) -> Self::Token<'_> { + () + } + #[inline] + fn abi_decode_returns( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + as alloy_sol_types::SolType>::abi_decode_sequence(data, validate) + .map(Into::into) + } + } + }; + /**Function with signature `getSlot0(address,bytes32)` and selector `0xe631bcbf`. +```solidity +function getSlot0(address manager, PoolId poolId) external view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee); +```*/ + #[allow(non_camel_case_types, non_snake_case)] + #[derive(Clone)] + pub struct getSlot0Call { + pub manager: alloy::sol_types::private::Address, + pub poolId: ::RustType, + } + ///Container type for the return parameters of the [`getSlot0(address,bytes32)`](getSlot0Call) function. + #[allow(non_camel_case_types, non_snake_case)] + #[derive(Clone)] + pub struct getSlot0Return { + pub sqrtPriceX96: as alloy::sol_types::SolType>::RustType, + pub tick: as alloy::sol_types::SolType>::RustType, + pub protocolFee: as alloy::sol_types::SolType>::RustType, + pub lpFee: as alloy::sol_types::SolType>::RustType, + } + #[allow(non_camel_case_types, non_snake_case, clippy::style)] + const _: () = { + use alloy::sol_types as alloy_sol_types; + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Address, PoolId); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = ( + alloy::sol_types::private::Address, + ::RustType, + ); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: getSlot0Call) -> Self { + (value.manager, value.poolId) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getSlot0Call { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { + manager: tuple.0, + poolId: tuple.1, + } + } + } + } + { + #[doc(hidden)] + type UnderlyingSolTuple<'a> = ( + alloy::sol_types::sol_data::Uint<160>, + alloy::sol_types::sol_data::Int<24>, + alloy::sol_types::sol_data::Uint<24>, + alloy::sol_types::sol_data::Uint<24>, + ); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = ( + as alloy::sol_types::SolType>::RustType, + as alloy::sol_types::SolType>::RustType, + as alloy::sol_types::SolType>::RustType, + as alloy::sol_types::SolType>::RustType, + ); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: getSlot0Return) -> Self { + (value.sqrtPriceX96, value.tick, value.protocolFee, value.lpFee) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for getSlot0Return { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { + sqrtPriceX96: tuple.0, + tick: tuple.1, + protocolFee: tuple.2, + lpFee: tuple.3, + } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for getSlot0Call { + type Parameters<'a> = (alloy::sol_types::sol_data::Address, PoolId); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = getSlot0Return; + type ReturnTuple<'a> = ( + alloy::sol_types::sol_data::Uint<160>, + alloy::sol_types::sol_data::Int<24>, + alloy::sol_types::sol_data::Uint<24>, + alloy::sol_types::sol_data::Uint<24>, + ); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "getSlot0(address,bytes32)"; + const SELECTOR: [u8; 4] = [230u8, 49u8, 188u8, 191u8]; + #[inline] + fn new<'a>( + tuple: as alloy_sol_types::SolType>::RustType, + ) -> Self { + tuple.into() + } + #[inline] + fn tokenize(&self) -> Self::Token<'_> { + ( + ::tokenize( + &self.manager, + ), + ::tokenize(&self.poolId), + ) + } + #[inline] + fn abi_decode_returns( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + as alloy_sol_types::SolType>::abi_decode_sequence(data, validate) + .map(Into::into) + } + } + }; + ///Container for all the [`Fetcher`](self) function calls. + pub enum FetcherCalls { + POOLS_SLOT(POOLS_SLOTCall), + getSlot0(getSlot0Call), + } + #[automatically_derived] + impl FetcherCalls { + /// All the selectors of this enum. + /// + /// Note that the selectors might not be in the same order as the variants. + /// No guarantees are made about the order of the selectors. + /// + /// Prefer using `SolInterface` methods instead. + pub const SELECTORS: &'static [[u8; 4usize]] = &[ + [87u8, 235u8, 29u8, 167u8], + [230u8, 49u8, 188u8, 191u8], + ]; + } + #[automatically_derived] + impl alloy_sol_types::SolInterface for FetcherCalls { + const NAME: &'static str = "FetcherCalls"; + const MIN_DATA_LENGTH: usize = 0usize; + const COUNT: usize = 2usize; + #[inline] + fn selector(&self) -> [u8; 4] { + match self { + Self::POOLS_SLOT(_) => { + ::SELECTOR + } + Self::getSlot0(_) => ::SELECTOR, + } + } + #[inline] + fn selector_at(i: usize) -> ::core::option::Option<[u8; 4]> { + Self::SELECTORS.get(i).copied() + } + #[inline] + fn valid_selector(selector: [u8; 4]) -> bool { + Self::SELECTORS.binary_search(&selector).is_ok() + } + #[inline] + #[allow(unsafe_code, non_snake_case)] + fn abi_decode_raw( + selector: [u8; 4], + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + static DECODE_SHIMS: &[fn( + &[u8], + bool, + ) -> alloy_sol_types::Result] = &[ + { + fn POOLS_SLOT( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(FetcherCalls::POOLS_SLOT) + } + POOLS_SLOT + }, + { + fn getSlot0( + data: &[u8], + validate: bool, + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + validate, + ) + .map(FetcherCalls::getSlot0) + } + getSlot0 + }, + ]; + let Ok(idx) = Self::SELECTORS.binary_search(&selector) else { + return Err( + alloy_sol_types::Error::unknown_selector( + ::NAME, + selector, + ), + ); + }; + (unsafe { DECODE_SHIMS.get_unchecked(idx) })(data, validate) + } + #[inline] + fn abi_encoded_size(&self) -> usize { + match self { + Self::POOLS_SLOT(inner) => { + ::abi_encoded_size(inner) + } + Self::getSlot0(inner) => { + ::abi_encoded_size(inner) + } + } + } + #[inline] + fn abi_encode_raw(&self, out: &mut alloy_sol_types::private::Vec) { + match self { + Self::POOLS_SLOT(inner) => { + ::abi_encode_raw( + inner, + out, + ) + } + Self::getSlot0(inner) => { + ::abi_encode_raw( + inner, + out, + ) + } + } + } + } + use alloy::contract as alloy_contract; + /**Creates a new wrapper around an on-chain [`Fetcher`](self) contract instance. + +See the [wrapper's documentation](`FetcherInstance`) for more details.*/ + #[inline] + pub const fn new< + T: alloy_contract::private::Transport + ::core::clone::Clone, + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + >( + address: alloy_sol_types::private::Address, + provider: P, + ) -> FetcherInstance { + FetcherInstance::::new(address, provider) + } + /**Deploys this contract using the given `provider` and constructor arguments, if any. + +Returns a new instance of the contract, if the deployment was successful. + +For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ + #[inline] + pub fn deploy< + T: alloy_contract::private::Transport + ::core::clone::Clone, + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + >( + provider: P, + ) -> impl ::core::future::Future< + Output = alloy_contract::Result>, + > { + FetcherInstance::::deploy(provider) + } + /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` +and constructor arguments, if any. + +This is a simple wrapper around creating a `RawCallBuilder` with the data set to +the bytecode concatenated with the constructor's ABI-encoded arguments.*/ + #[inline] + pub fn deploy_builder< + T: alloy_contract::private::Transport + ::core::clone::Clone, + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + >(provider: P) -> alloy_contract::RawCallBuilder { + FetcherInstance::::deploy_builder(provider) + } + /**A [`Fetcher`](self) instance. + +Contains type-safe methods for interacting with an on-chain instance of the +[`Fetcher`](self) contract located at a given `address`, using a given +provider `P`. + +If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) +documentation on how to provide it), the `deploy` and `deploy_builder` methods can +be used to deploy a new instance of the contract. + +See the [module-level documentation](self) for all the available methods.*/ + #[derive(Clone)] + pub struct FetcherInstance { + address: alloy_sol_types::private::Address, + provider: P, + _network_transport: ::core::marker::PhantomData<(N, T)>, + } + #[automatically_derived] + impl ::core::fmt::Debug for FetcherInstance { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_tuple("FetcherInstance").field(&self.address).finish() + } + } + /// Instantiation and getters/setters. + #[automatically_derived] + impl< + T: alloy_contract::private::Transport + ::core::clone::Clone, + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + > FetcherInstance { + /**Creates a new wrapper around an on-chain [`Fetcher`](self) contract instance. + +See the [wrapper's documentation](`FetcherInstance`) for more details.*/ + #[inline] + pub const fn new( + address: alloy_sol_types::private::Address, + provider: P, + ) -> Self { + Self { + address, + provider, + _network_transport: ::core::marker::PhantomData, + } + } + /**Deploys this contract using the given `provider` and constructor arguments, if any. + +Returns a new instance of the contract, if the deployment was successful. + +For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ + #[inline] + pub async fn deploy( + provider: P, + ) -> alloy_contract::Result> { + let call_builder = Self::deploy_builder(provider); + let contract_address = call_builder.deploy().await?; + Ok(Self::new(contract_address, call_builder.provider)) + } + /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` +and constructor arguments, if any. + +This is a simple wrapper around creating a `RawCallBuilder` with the data set to +the bytecode concatenated with the constructor's ABI-encoded arguments.*/ + #[inline] + pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { + alloy_contract::RawCallBuilder::new_raw_deploy( + provider, + ::core::clone::Clone::clone(&BYTECODE), + ) + } + /// Returns a reference to the address. + #[inline] + pub const fn address(&self) -> &alloy_sol_types::private::Address { + &self.address + } + /// Sets the address. + #[inline] + pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { + self.address = address; + } + /// Sets the address and returns `self`. + pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { + self.set_address(address); + self + } + /// Returns a reference to the provider. + #[inline] + pub const fn provider(&self) -> &P { + &self.provider + } + } + impl FetcherInstance { + /// Clones the provider and returns a new instance with the cloned provider. + #[inline] + pub fn with_cloned_provider(self) -> FetcherInstance { + FetcherInstance { + address: self.address, + provider: ::core::clone::Clone::clone(&self.provider), + _network_transport: ::core::marker::PhantomData, + } + } + } + /// Function calls. + #[automatically_derived] + impl< + T: alloy_contract::private::Transport + ::core::clone::Clone, + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + > FetcherInstance { + /// Creates a new call builder using this contract instance's provider and address. + /// + /// Note that the call can be any function call, not just those defined in this + /// contract. Prefer using the other methods for building type-safe contract calls. + pub fn call_builder( + &self, + call: &C, + ) -> alloy_contract::SolCallBuilder { + alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) + } + ///Creates a new call builder for the [`POOLS_SLOT`] function. + pub fn POOLS_SLOT( + &self, + ) -> alloy_contract::SolCallBuilder { + self.call_builder(&POOLS_SLOTCall {}) + } + ///Creates a new call builder for the [`getSlot0`] function. + pub fn getSlot0( + &self, + manager: alloy::sol_types::private::Address, + poolId: ::RustType, + ) -> alloy_contract::SolCallBuilder { + self.call_builder(&getSlot0Call { manager, poolId }) + } + } + /// Event filters. + #[automatically_derived] + impl< + T: alloy_contract::private::Transport + ::core::clone::Clone, + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + > FetcherInstance { + /// Creates a new event filter using this contract instance's provider and address. + /// + /// Note that the type can be any event, not just those defined in this contract. + /// Prefer using the other methods for building type-safe event filters. + pub fn event_filter( + &self, + ) -> alloy_contract::Event { + alloy_contract::Event::new_sol(&self.provider, &self.address) + } + } +}