pub struct Flashloan {
pub loan_amount: String,
pub liquidity_provider_address: String,
pub protocol_adapter_address: String,
pub receiver_address: String,
pub token_address: String,
}Expand description
Flash loan metadata.
Embedded in Metadata when the order uses a flash loan for execution.
Records the loan amount, liquidity provider, protocol adapter, receiver,
and token address so the settlement contract and solvers can reconstruct
the flash-loan flow.
§Example
use cow_app_data::types::Flashloan;
let fl = Flashloan::new(
"1000000000000000000", // 1 ETH in wei
"0xLiquidityProvider",
"0xTokenAddress",
)
.with_protocol_adapter("0xAdapterAddress")
.with_receiver("0xReceiverAddress");Fields§
§loan_amount: StringLoan amount in token atoms (decimal string).
liquidity_provider_address: StringAddress of the liquidity provider.
protocol_adapter_address: StringAddress of the protocol adapter contract.
receiver_address: StringAddress that receives the flash loan proceeds.
token_address: StringAddress of the token being flash-loaned.
Implementations§
Source§impl Flashloan
impl Flashloan
Sourcepub fn new(
loan_amount: impl Into<String>,
liquidity_provider_address: impl Into<String>,
token_address: impl Into<String>,
) -> Self
pub fn new( loan_amount: impl Into<String>, liquidity_provider_address: impl Into<String>, token_address: impl Into<String>, ) -> Self
Construct a Flashloan record with the core required fields.
protocol_adapter_address and receiver_address default to empty
strings; set them via with_protocol_adapter
and with_receiver.
§Parameters
loan_amount— the flash-loan amount in token atoms (decimal string, e.g."1000000000000000000"for 1 ETH).liquidity_provider_address—0x-prefixed address of the liquidity pool providing the flash loan.token_address—0x-prefixed address of the token being flash-loaned.
§Returns
A new Flashloan with adapter and receiver addresses empty.
§Example
use cow_app_data::types::Flashloan;
let fl = Flashloan::new("1000000000000000000", "0xPool", "0xToken")
.with_protocol_adapter("0xAdapter")
.with_receiver("0xReceiver");
assert_eq!(fl.loan_amount, "1000000000000000000");
assert_eq!(fl.protocol_adapter_address, "0xAdapter");Sourcepub fn with_protocol_adapter(self, address: impl Into<String>) -> Self
pub fn with_protocol_adapter(self, address: impl Into<String>) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Flashloan
impl<'de> Deserialize<'de> for Flashloan
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Flashloan
impl RefUnwindSafe for Flashloan
impl Send for Flashloan
impl Sync for Flashloan
impl Unpin for Flashloan
impl UnsafeUnpin for Flashloan
impl UnwindSafe for Flashloan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.