Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getOutputAmount for 1:1 swap contracts #33

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions contracts/swappa/PairOpenSumSwap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ contract PairOpenSumSwap is ISwappaPairV1 {
uint amountIn,
bytes calldata data
) external view override returns (uint amountOut) {
// no fees are taken
return amountIn;
IOpenSumSwap pool = IOpenSumSwap(parseData(data));
// no fees are taken if there's enough output token
if (!pool.paused() && ERC20(output).balanceOf(address(pool)) >= amountIn) {
amountOut = amountIn;
}
}
}
6 changes: 4 additions & 2 deletions contracts/swappa/PairSymmetricSwap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ contract PairSymmetricSwap is ISwappaPairV1 {
uint amountIn,
bytes calldata data
) external view override returns (uint amountOut) {
// no fees are taken
return amountIn;
// no fees are taken if there's enough output token
if (ERC20(output).balanceOf(parseData(data)) >= amountIn) {
amountOut = amountIn;
}
}
}