-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(exchange): wip refactoring internal methods of the mod
- Loading branch information
Showing
7 changed files
with
161 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
use crate::config::network::Network; | ||
|
||
use self::config::ExchangeConfig; | ||
use crate::config::Config; | ||
|
||
pub mod config; | ||
|
||
pub mod swap_eth_for_tokens; | ||
pub mod swap_tokens_for_tokens; | ||
use anyhow::Context; | ||
|
||
use self::config::ExchangeConfig; | ||
|
||
pub struct Exchange { | ||
config: ExchangeConfig, | ||
network: Network, | ||
} | ||
|
||
impl Exchange { | ||
pub fn new(config: &ExchangeConfig) -> Self { | ||
let network = config.get_network(); | ||
Self { | ||
config: config.clone(), | ||
network: network.clone(), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<(&Config, &String)> for Exchange { | ||
type Error = anyhow::Error; | ||
fn try_from(t: (&Config, &String)) -> Result<Self, Self::Error> { | ||
let config = | ||
t.0.exchanges | ||
.get(t.1) | ||
.context(format!("exchange '{}' not found", t.1))?; | ||
Ok(Exchange::new(config)) | ||
} | ||
} |