openzeppelin_rs/contracts/
IERC3156FlashLender.rs

1pub use ierc3156_flash_lender::*;
2/// This module was auto-generated with ethers-rs Abigen.
3/// More information at: <https://github.com/gakonst/ethers-rs>
4#[allow(
5    clippy::enum_variant_names,
6    clippy::too_many_arguments,
7    clippy::upper_case_acronyms,
8    clippy::type_complexity,
9    dead_code,
10    non_camel_case_types,
11)]
12pub mod ierc3156_flash_lender {
13    #[rustfmt::skip]
14    const __ABI: &str = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\",\"components\":[]}],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"flashFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\",\"components\":[]}]},{\"inputs\":[{\"internalType\":\"contract IERC3156FlashBorrower\",\"name\":\"receiver\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\",\"components\":[]},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\",\"components\":[]}],\"stateMutability\":\"nonpayable\",\"type\":\"function\",\"name\":\"flashLoan\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\",\"components\":[]}],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"maxFlashLoan\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\",\"components\":[]}]}]";
15    ///The parsed JSON ABI of the contract.
16    pub static IERC3156FLASHLENDER_ABI: ::ethers_contract::Lazy<
17        ::ethers_core::abi::Abi,
18    > = ::ethers_contract::Lazy::new(|| {
19        ::ethers_core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid")
20    });
21    pub struct IERC3156FlashLender<M>(::ethers_contract::Contract<M>);
22    impl<M> ::core::clone::Clone for IERC3156FlashLender<M> {
23        fn clone(&self) -> Self {
24            Self(::core::clone::Clone::clone(&self.0))
25        }
26    }
27    impl<M> ::core::ops::Deref for IERC3156FlashLender<M> {
28        type Target = ::ethers_contract::Contract<M>;
29        fn deref(&self) -> &Self::Target {
30            &self.0
31        }
32    }
33    impl<M> ::core::ops::DerefMut for IERC3156FlashLender<M> {
34        fn deref_mut(&mut self) -> &mut Self::Target {
35            &mut self.0
36        }
37    }
38    impl<M> ::core::fmt::Debug for IERC3156FlashLender<M> {
39        fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
40            f.debug_tuple(stringify!(IERC3156FlashLender))
41                .field(&self.address())
42                .finish()
43        }
44    }
45    impl<M: ::ethers_providers::Middleware> IERC3156FlashLender<M> {
46        /// Creates a new contract instance with the specified `ethers` client at
47        /// `address`. The contract derefs to a `ethers::Contract` object.
48        pub fn new<T: Into<::ethers_core::types::Address>>(
49            address: T,
50            client: ::std::sync::Arc<M>,
51        ) -> Self {
52            Self(
53                ::ethers_contract::Contract::new(
54                    address.into(),
55                    IERC3156FLASHLENDER_ABI.clone(),
56                    client,
57                ),
58            )
59        }
60        ///Calls the contract's `flashFee` (0xd9d98ce4) function
61        pub fn flash_fee(
62            &self,
63            token: ::ethers_core::types::Address,
64            amount: ::ethers_core::types::U256,
65        ) -> ::ethers_contract::builders::ContractCall<M, ::ethers_core::types::U256> {
66            self.0
67                .method_hash([217, 217, 140, 228], (token, amount))
68                .expect("method not found (this should never happen)")
69        }
70        ///Calls the contract's `flashLoan` (0x5cffe9de) function
71        pub fn flash_loan(
72            &self,
73            receiver: ::ethers_core::types::Address,
74            token: ::ethers_core::types::Address,
75            amount: ::ethers_core::types::U256,
76            data: ::ethers_core::types::Bytes,
77        ) -> ::ethers_contract::builders::ContractCall<M, bool> {
78            self.0
79                .method_hash([92, 255, 233, 222], (receiver, token, amount, data))
80                .expect("method not found (this should never happen)")
81        }
82        ///Calls the contract's `maxFlashLoan` (0x613255ab) function
83        pub fn max_flash_loan(
84            &self,
85            token: ::ethers_core::types::Address,
86        ) -> ::ethers_contract::builders::ContractCall<M, ::ethers_core::types::U256> {
87            self.0
88                .method_hash([97, 50, 85, 171], token)
89                .expect("method not found (this should never happen)")
90        }
91    }
92    impl<M: ::ethers_providers::Middleware> From<::ethers_contract::Contract<M>>
93    for IERC3156FlashLender<M> {
94        fn from(contract: ::ethers_contract::Contract<M>) -> Self {
95            Self::new(contract.address(), contract.client())
96        }
97    }
98    ///Container type for all input parameters for the `flashFee` function with signature `flashFee(address,uint256)` and selector `0xd9d98ce4`
99    #[derive(
100        Clone,
101        ::ethers_contract::EthCall,
102        ::ethers_contract::EthDisplay,
103        Default,
104        Debug,
105        PartialEq,
106        Eq,
107        Hash
108    )]
109    #[ethcall(name = "flashFee", abi = "flashFee(address,uint256)")]
110    pub struct FlashFeeCall {
111        pub token: ::ethers_core::types::Address,
112        pub amount: ::ethers_core::types::U256,
113    }
114    ///Container type for all input parameters for the `flashLoan` function with signature `flashLoan(address,address,uint256,bytes)` and selector `0x5cffe9de`
115    #[derive(
116        Clone,
117        ::ethers_contract::EthCall,
118        ::ethers_contract::EthDisplay,
119        Default,
120        Debug,
121        PartialEq,
122        Eq,
123        Hash
124    )]
125    #[ethcall(name = "flashLoan", abi = "flashLoan(address,address,uint256,bytes)")]
126    pub struct FlashLoanCall {
127        pub receiver: ::ethers_core::types::Address,
128        pub token: ::ethers_core::types::Address,
129        pub amount: ::ethers_core::types::U256,
130        pub data: ::ethers_core::types::Bytes,
131    }
132    ///Container type for all input parameters for the `maxFlashLoan` function with signature `maxFlashLoan(address)` and selector `0x613255ab`
133    #[derive(
134        Clone,
135        ::ethers_contract::EthCall,
136        ::ethers_contract::EthDisplay,
137        Default,
138        Debug,
139        PartialEq,
140        Eq,
141        Hash
142    )]
143    #[ethcall(name = "maxFlashLoan", abi = "maxFlashLoan(address)")]
144    pub struct MaxFlashLoanCall {
145        pub token: ::ethers_core::types::Address,
146    }
147    ///Container type for all of the contract's call
148    #[derive(Clone, ::ethers_contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
149    pub enum IERC3156FlashLenderCalls {
150        FlashFee(FlashFeeCall),
151        FlashLoan(FlashLoanCall),
152        MaxFlashLoan(MaxFlashLoanCall),
153    }
154    impl ::ethers_core::abi::AbiDecode for IERC3156FlashLenderCalls {
155        fn decode(
156            data: impl AsRef<[u8]>,
157        ) -> ::core::result::Result<Self, ::ethers_core::abi::AbiError> {
158            let data = data.as_ref();
159            if let Ok(decoded)
160                = <FlashFeeCall as ::ethers_core::abi::AbiDecode>::decode(data) {
161                return Ok(Self::FlashFee(decoded));
162            }
163            if let Ok(decoded)
164                = <FlashLoanCall as ::ethers_core::abi::AbiDecode>::decode(data) {
165                return Ok(Self::FlashLoan(decoded));
166            }
167            if let Ok(decoded)
168                = <MaxFlashLoanCall as ::ethers_core::abi::AbiDecode>::decode(data) {
169                return Ok(Self::MaxFlashLoan(decoded));
170            }
171            Err(::ethers_core::abi::Error::InvalidData.into())
172        }
173    }
174    impl ::ethers_core::abi::AbiEncode for IERC3156FlashLenderCalls {
175        fn encode(self) -> Vec<u8> {
176            match self {
177                Self::FlashFee(element) => ::ethers_core::abi::AbiEncode::encode(element),
178                Self::FlashLoan(element) => {
179                    ::ethers_core::abi::AbiEncode::encode(element)
180                }
181                Self::MaxFlashLoan(element) => {
182                    ::ethers_core::abi::AbiEncode::encode(element)
183                }
184            }
185        }
186    }
187    impl ::core::fmt::Display for IERC3156FlashLenderCalls {
188        fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
189            match self {
190                Self::FlashFee(element) => ::core::fmt::Display::fmt(element, f),
191                Self::FlashLoan(element) => ::core::fmt::Display::fmt(element, f),
192                Self::MaxFlashLoan(element) => ::core::fmt::Display::fmt(element, f),
193            }
194        }
195    }
196    impl ::core::convert::From<FlashFeeCall> for IERC3156FlashLenderCalls {
197        fn from(value: FlashFeeCall) -> Self {
198            Self::FlashFee(value)
199        }
200    }
201    impl ::core::convert::From<FlashLoanCall> for IERC3156FlashLenderCalls {
202        fn from(value: FlashLoanCall) -> Self {
203            Self::FlashLoan(value)
204        }
205    }
206    impl ::core::convert::From<MaxFlashLoanCall> for IERC3156FlashLenderCalls {
207        fn from(value: MaxFlashLoanCall) -> Self {
208            Self::MaxFlashLoan(value)
209        }
210    }
211    ///Container type for all return fields from the `flashFee` function with signature `flashFee(address,uint256)` and selector `0xd9d98ce4`
212    #[derive(
213        Clone,
214        ::ethers_contract::EthAbiType,
215        ::ethers_contract::EthAbiCodec,
216        Default,
217        Debug,
218        PartialEq,
219        Eq,
220        Hash
221    )]
222    pub struct FlashFeeReturn(pub ::ethers_core::types::U256);
223    ///Container type for all return fields from the `flashLoan` function with signature `flashLoan(address,address,uint256,bytes)` and selector `0x5cffe9de`
224    #[derive(
225        Clone,
226        ::ethers_contract::EthAbiType,
227        ::ethers_contract::EthAbiCodec,
228        Default,
229        Debug,
230        PartialEq,
231        Eq,
232        Hash
233    )]
234    pub struct FlashLoanReturn(pub bool);
235    ///Container type for all return fields from the `maxFlashLoan` function with signature `maxFlashLoan(address)` and selector `0x613255ab`
236    #[derive(
237        Clone,
238        ::ethers_contract::EthAbiType,
239        ::ethers_contract::EthAbiCodec,
240        Default,
241        Debug,
242        PartialEq,
243        Eq,
244        Hash
245    )]
246    pub struct MaxFlashLoanReturn(pub ::ethers_core::types::U256);
247}