Skip to content

Instantly share code, notes, and snippets.

@Sameerkash
Created April 6, 2023 04:08
Show Gist options
  • Save Sameerkash/d6f6020df2644e704fe4237589be3b67 to your computer and use it in GitHub Desktop.
Save Sameerkash/d6f6020df2644e704fe4237589be3b67 to your computer and use it in GitHub Desktop.
SushiRouter - Flutter issues
Encourntering following issues while interacting with the SushiRouter contract on polygon
```dart
// Fetch the price of Polygon Matic and NCT tokens
final inputAmount = BigInt.from(10); // Set the input amount
final tokenAddresses = [
EthereumAddress.fromHex(usdcAddress),
EthereumAddress.fromHex(nctAddress),
];
Future<void> getAmountsOut() async {
try {
final List<BigInt> amountsOut =
await sushiRouter.getAmountsOut(inputAmount, tokenAddresses);
emit(GetSwapPricesSuccess(amounts: amountsOut));
} catch (e, s) {
emit(
GetSwapPricesError(errorCode: '$e', message: '$s'),
);
}
}
```
the getAmountsOut fucntion is always returns an output as
```
result : 0x
```
Unclear why this is the case as the same call on polygon scan returns the proper response
```
6. getMountsOut
amountIn (uint256) : 10
path (address[]) : [0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174, 0xD838290e877E0188a4A44700463419ED96c16107]
amounts uint256[]
[ getAmountsOut method Response ]
amounts uint256[] : 10,4942106250519
```
Manually verified the encoding as well that is going in the contract call, it is the same for the inputs
```
https://abi.hashex.org/
d06ca61f000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000d838290e877e0188a4a44700463419ed96c16107
web3Dart
0xd06ca61f000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000d838290e877e0188a4a44700463419ed96c16107
```
Unsuere if 0x added to the encoding is casuing the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment