Skip to main content

Flashloan

Struct Flashloan 

Source
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: String

Loan amount in token atoms (decimal string).

§liquidity_provider_address: String

Address of the liquidity provider.

§protocol_adapter_address: String

Address of the protocol adapter contract.

§receiver_address: String

Address that receives the flash loan proceeds.

§token_address: String

Address of the token being flash-loaned.

Implementations§

Source§

impl Flashloan

Source

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_address0x-prefixed address of the liquidity pool providing the flash loan.
  • token_address0x-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");
Source

pub fn with_protocol_adapter(self, address: impl Into<String>) -> Self

Set the protocol adapter contract address.

The adapter contract mediates between the settlement contract and the flash-loan liquidity provider.

§Parameters
  • address0x-prefixed Ethereum address.
§Returns

self with protocol_adapter_address set.

Source

pub fn with_receiver(self, address: impl Into<String>) -> Self

Set the receiver address for flash loan proceeds.

§Parameters
  • address0x-prefixed Ethereum address that receives the borrowed tokens.
§Returns

self with receiver_address set.

Trait Implementations§

Source§

impl Clone for Flashloan

Source§

fn clone(&self) -> Flashloan

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Flashloan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Flashloan

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Flashloan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Flashloan

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,