feat: Allow for token_in_already_in_router
--- don't change below this line --- ENG-4446 Took 31 minutes Took 26 seconds
This commit is contained in:
@@ -21,6 +21,7 @@ pub struct TychoRouterEncoderBuilder {
|
||||
chain: Option<Chain>,
|
||||
executors_file_path: Option<String>,
|
||||
router_address: Option<Bytes>,
|
||||
token_in_already_in_router: Option<bool>,
|
||||
}
|
||||
|
||||
impl Default for TychoRouterEncoderBuilder {
|
||||
@@ -36,6 +37,7 @@ impl TychoRouterEncoderBuilder {
|
||||
chain: None,
|
||||
executors_file_path: None,
|
||||
router_address: None,
|
||||
token_in_already_in_router: None,
|
||||
}
|
||||
}
|
||||
pub fn chain(mut self, chain: TychoCommonChain) -> Self {
|
||||
@@ -62,6 +64,16 @@ impl TychoRouterEncoderBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
// Sets the `token_in_already_in_router` flag.
|
||||
// If set to true, the encoder will assume that the token in is already in the router.
|
||||
// WARNING: this is an advanced feature and should be used with caution. Make sure you have
|
||||
// checks to make sure that your tokens won't be lost. The Router is not considered safe to hold
|
||||
// tokens, so if this is not done within the same transaction you will lose your tokens.
|
||||
pub fn token_in_already_in_router(mut self, token_in_already_in_router: bool) -> Self {
|
||||
self.token_in_already_in_router = Some(token_in_already_in_router);
|
||||
self
|
||||
}
|
||||
|
||||
/// Builds the `TychoRouterEncoder` instance using the configured chain.
|
||||
/// Returns an error if either the chain has not been set.
|
||||
pub fn build(self) -> Result<Box<dyn TychoEncoder>, EncodingError> {
|
||||
@@ -88,6 +100,8 @@ impl TychoRouterEncoderBuilder {
|
||||
swap_encoder_registry,
|
||||
self.swapper_pk,
|
||||
tycho_router_address,
|
||||
self.token_in_already_in_router
|
||||
.unwrap_or(false),
|
||||
)?))
|
||||
} else {
|
||||
Err(EncodingError::FatalError(
|
||||
|
||||
Reference in New Issue
Block a user