fix: Bring back receiver address zero check
Add small docs and rename variables --- don't change below this line --- ENG-4314 Took 1 hour 39 minutes
This commit is contained in:
@@ -411,6 +411,9 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
|
|||||||
address receiver,
|
address receiver,
|
||||||
bytes calldata swaps
|
bytes calldata swaps
|
||||||
) internal returns (uint256 amountOut) {
|
) internal returns (uint256 amountOut) {
|
||||||
|
if (receiver == address(0)) {
|
||||||
|
revert TychoRouter__AddressZero();
|
||||||
|
}
|
||||||
if (minAmountOut == 0) {
|
if (minAmountOut == 0) {
|
||||||
revert TychoRouter__UndefinedMinAmountOut();
|
revert TychoRouter__UndefinedMinAmountOut();
|
||||||
}
|
}
|
||||||
@@ -462,6 +465,9 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
|
|||||||
address receiver,
|
address receiver,
|
||||||
bytes calldata swap_
|
bytes calldata swap_
|
||||||
) internal returns (uint256 amountOut) {
|
) internal returns (uint256 amountOut) {
|
||||||
|
if (receiver == address(0)) {
|
||||||
|
revert TychoRouter__AddressZero();
|
||||||
|
}
|
||||||
if (minAmountOut == 0) {
|
if (minAmountOut == 0) {
|
||||||
revert TychoRouter__UndefinedMinAmountOut();
|
revert TychoRouter__UndefinedMinAmountOut();
|
||||||
}
|
}
|
||||||
@@ -516,6 +522,9 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
|
|||||||
address receiver,
|
address receiver,
|
||||||
bytes calldata swaps
|
bytes calldata swaps
|
||||||
) internal returns (uint256 amountOut) {
|
) internal returns (uint256 amountOut) {
|
||||||
|
if (receiver == address(0)) {
|
||||||
|
revert TychoRouter__AddressZero();
|
||||||
|
}
|
||||||
if (minAmountOut == 0) {
|
if (minAmountOut == 0) {
|
||||||
revert TychoRouter__UndefinedMinAmountOut();
|
revert TychoRouter__UndefinedMinAmountOut();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ impl StrategyEncoder for SingleSwapStrategyEncoder {
|
|||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let receiver =
|
let swap_receiver =
|
||||||
if !unwrap { solution.receiver.clone() } else { self.router_address.clone() };
|
if !unwrap { solution.receiver.clone() } else { self.router_address.clone() };
|
||||||
|
|
||||||
let mut grouped_protocol_data: Vec<u8> = vec![];
|
let mut grouped_protocol_data: Vec<u8> = vec![];
|
||||||
@@ -136,7 +136,7 @@ impl StrategyEncoder for SingleSwapStrategyEncoder {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let encoding_context = EncodingContext {
|
let encoding_context = EncodingContext {
|
||||||
receiver: receiver.clone(),
|
receiver: swap_receiver.clone(),
|
||||||
exact_out: solution.exact_out,
|
exact_out: solution.exact_out,
|
||||||
router_address: Some(self.router_address.clone()),
|
router_address: Some(self.router_address.clone()),
|
||||||
group_token_in: grouped_swap.input_token.clone(),
|
group_token_in: grouped_swap.input_token.clone(),
|
||||||
@@ -300,7 +300,9 @@ impl StrategyEncoder for SequentialSwapStrategyEncoder {
|
|||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let receiver = if i == grouped_swaps.len() - 1 && !unwrap {
|
// if it is the last swap and there isn't an unwrap at the end, we can set the receiver
|
||||||
|
// to the final user
|
||||||
|
let swap_receiver = if i == grouped_swaps.len() - 1 && !unwrap {
|
||||||
solution.receiver.clone()
|
solution.receiver.clone()
|
||||||
} else {
|
} else {
|
||||||
self.router_address.clone()
|
self.router_address.clone()
|
||||||
@@ -318,7 +320,7 @@ impl StrategyEncoder for SequentialSwapStrategyEncoder {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let encoding_context = EncodingContext {
|
let encoding_context = EncodingContext {
|
||||||
receiver: receiver.clone(),
|
receiver: swap_receiver.clone(),
|
||||||
exact_out: solution.exact_out,
|
exact_out: solution.exact_out,
|
||||||
router_address: Some(self.router_address.clone()),
|
router_address: Some(self.router_address.clone()),
|
||||||
group_token_in: grouped_swap.input_token.clone(),
|
group_token_in: grouped_swap.input_token.clone(),
|
||||||
@@ -536,7 +538,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
|||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let receiver = if !unwrap && grouped_swap.output_token == solution.checked_token {
|
let swap_receiver = if !unwrap && grouped_swap.output_token == solution.checked_token {
|
||||||
solution.receiver.clone()
|
solution.receiver.clone()
|
||||||
} else {
|
} else {
|
||||||
self.router_address.clone()
|
self.router_address.clone()
|
||||||
@@ -554,7 +556,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let encoding_context = EncodingContext {
|
let encoding_context = EncodingContext {
|
||||||
receiver: receiver.clone(),
|
receiver: swap_receiver.clone(),
|
||||||
exact_out: solution.exact_out,
|
exact_out: solution.exact_out,
|
||||||
router_address: Some(self.router_address.clone()),
|
router_address: Some(self.router_address.clone()),
|
||||||
group_token_in: grouped_swap.input_token.clone(),
|
group_token_in: grouped_swap.input_token.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user