-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(swaps): band-aid fix for gas estimates to disable multihop for et…
…h-ampl
- Loading branch information
1 parent
3050e96
commit e3b3d9e
Showing
2 changed files
with
37 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ChainId, Currency, ETHER, Token, WETH } from '@uniswap/sdk' | ||
|
||
function isEtherish(currency: Currency): boolean { | ||
return currency === ETHER || (currency instanceof Token && WETH[currency.chainId].equals(currency)) | ||
} | ||
|
||
const AMPL_TOKEN_ADDRESS = '0xD46bA6D942050d489DBd938a2C909A5d5039A161' | ||
|
||
/** | ||
* Band-aid on maxHops because some tokens seems to always fail with multihop swaps | ||
* @param currencyIn currency in | ||
* @param currencyOut currency out | ||
*/ | ||
export function maxHopsFor(currencyIn: Currency, currencyOut: Currency): number { | ||
if ( | ||
isEtherish(currencyIn) && | ||
currencyOut instanceof Token && | ||
currencyOut.chainId === ChainId.MAINNET && | ||
currencyOut.address === AMPL_TOKEN_ADDRESS | ||
) { | ||
return 1 | ||
} else if ( | ||
isEtherish(currencyOut) && | ||
currencyIn instanceof Token && | ||
currencyIn.chainId === ChainId.MAINNET && | ||
currencyIn.address === AMPL_TOKEN_ADDRESS | ||
) { | ||
return 1 | ||
} | ||
|
||
return 3 | ||
} |
e3b3d9e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: