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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use sp_runtime::BoundedVec;

use serai_primitives::*;

type PoolId = ExternalCoin;
type MaxSwapPathLength = sp_core::ConstU32<3>;

#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Call {
  add_liquidity {
    coin: ExternalCoin,
    coin_desired: SubstrateAmount,
    sri_desired: SubstrateAmount,
    coin_min: SubstrateAmount,
    sri_min: SubstrateAmount,
    mint_to: SeraiAddress,
  },
  remove_liquidity {
    coin: ExternalCoin,
    lp_token_burn: SubstrateAmount,
    coin_min_receive: SubstrateAmount,
    sri_min_receive: SubstrateAmount,
    withdraw_to: SeraiAddress,
  },
  swap_exact_tokens_for_tokens {
    path: BoundedVec<Coin, MaxSwapPathLength>,
    amount_in: SubstrateAmount,
    amount_out_min: SubstrateAmount,
    send_to: SeraiAddress,
  },
  swap_tokens_for_exact_tokens {
    path: BoundedVec<Coin, MaxSwapPathLength>,
    amount_out: SubstrateAmount,
    amount_in_max: SubstrateAmount,
    send_to: SeraiAddress,
  },
}

#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(all(feature = "std", feature = "serde"), derive(serde::Deserialize))]
pub enum Event {
  PoolCreated {
    pool_id: PoolId,
    pool_account: SeraiAddress,
  },

  LiquidityAdded {
    who: SeraiAddress,
    mint_to: SeraiAddress,
    pool_id: PoolId,
    coin_amount: SubstrateAmount,
    sri_amount: SubstrateAmount,
    lp_token_minted: SubstrateAmount,
  },

  LiquidityRemoved {
    who: SeraiAddress,
    withdraw_to: SeraiAddress,
    pool_id: PoolId,
    coin_amount: SubstrateAmount,
    sri_amount: SubstrateAmount,
    lp_token_burned: SubstrateAmount,
  },

  SwapExecuted {
    who: SeraiAddress,
    send_to: SeraiAddress,
    path: BoundedVec<Coin, MaxSwapPathLength>,
    amount_in: SubstrateAmount,
    amount_out: SubstrateAmount,
  },
}