penumbra_dex/component/
flow.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::ops::{Deref, DerefMut};

use penumbra_num::Amount;

// Tuple represents:
// ((amount of asset 1 being exchanged for asset 2),
//  (amount of asset 2 being exchanged for asset 1))
#[derive(Default, Clone)]
pub struct SwapFlow((Amount, Amount));

impl Deref for SwapFlow {
    type Target = (Amount, Amount);

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for SwapFlow {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl From<(Amount, Amount)> for SwapFlow {
    fn from(tuple: (Amount, Amount)) -> Self {
        Self(tuple)
    }
}