-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add optional account to swap query #398
Comments
ObstacleThe swap query throws error if you add b-sdk/src/entities/swap/swaps/v3/index.ts Lines 105 to 128 in f4ce57f
> npx tsx ./examples/lib/executeExample.ts "./examples/swaps/customSwap.ts"
Input token: 0xe8d4e9fc8257b77acb9eb80b5e8176f4f0cbcebc, Amount: 10000000000000000000
Output token: 0xf0bab79d87f51a249afe316a580c1cdfc111be10, Amount: 990000000000000000
account 0x5036388C540994Ed7b74b82F71175a441F85BdA1
/home/matthu/Desktop/Balancer/b-sdk/node_modules/.pnpm/viem@2.12.1_typescript@5.3.3/node_modules/viem/utils/errors/getContractError.ts:72
return new ContractFunctionExecutionError(cause as BaseError, {
^
ContractFunctionExecutionError: The contract function "querySwapSingleTokenExactIn" reverted with the following signature:
0x67f84ab2
Unable to decode signature "0x67f84ab2" as it was not found on the provided ABI.
Make sure you are using the correct ABI and that the error exists on it.
You can look up the decoded signature here: https://openchain.xyz/signatures?query=0x67f84ab2.
Contract Call:
address: 0xDd10aDF05379D7C0Ee4bC9c72ecc5C01c40E25b8
function: querySwapSingleTokenExactIn(address pool, address tokenIn, address tokenOut, uint256 exactAmountIn, bytes userData)
args: (0x6D9656174205876897A9f526CCDcD3aE725ffEFF, 0xE8d4E9Fc8257B77Acb9eb80B5e8176F4f0cBCeBC, 0xF0Bab79D87F51a249AFe316a580C1cDFC111bE10, 10000000000000000000, 0x)
sender: 0x5036388C540994Ed7b74b82F71175a441F85BdA1
|
UpdateManaged to decode the error using viem and the Not entirely sure why because of assumption that viem's b-sdk/src/entities/swap/swaps/v3/index.ts Lines 117 to 130 in f4ce57f
|
I tried this directly on Tenderly and it doesn't seem possible. I also tried using an address for a swap through a pool without a hook and it also throws. MkFlow confirmed that |
Juani suggested doing a static call to actual function (with the account address) which will simulate the write and return the result. The biggest issue with this approach is it needs the account to actually have balance, etc but this is potentially ok I think because we wouldn't really be interested otherwise. @MattPereira could you give this a try? If it works maybe we can switch the method used in |
Currently swap queries don't have an associated account. This means we can't query a swap that includes a hook that relies on specific account data (e.g. veBal balance discount fee).
Investigate following as possible solution:
account
param toquery
await routerContract.simulate.query...
is called addaccount
in params beside blockNumberThere might be a better way to do this.
The text was updated successfully, but these errors were encountered: