osmosis
osmosis copied to clipboard
Cannot Estimate Swap in v12
Background
- We cannot estimate a swap in the latest version. Our project is using the v12 version of the osmosis chain and sdk on testnet and we get a very generic error trying to query for an estimated swap amount. It looks like a lot changed in the API in the latest version and we cannot find a working example.
- We've tried porting implementations like this one, in addition to several other examples: https://github.com/marsthechocolatebar/osmosis-sample-smc/blob/e523349ba1ac23efeaa2af623f9299b69d11d03e/contracts/executor/src/contract.rs#L72
- The error we get is very generic. It looks like this:
Error: rpc error: code = InvalidArgument desc = Generic error: Querier contract error: codespace: sdk, code: 5: query wasm contract failed: invalid request
If you could at least point us in the right direction, it would be greatly appreciated. I've looked through all the docs and implementations that I could find, and only am writing as a last resort. If you need additional info/context I can provide it. Thank you in advance.
The current EstimateSwap implementation requires the sender account to have balance of the asset you're trying to estimate. This should be getting fixed in the next upgrade, the PR is currently up in https://github.com/osmosis-labs/osmosis/pull/2764
@mattverse That you so much for this, that was the missing link.
One more question - we cant cast to the EstimatePriceResponse struct after querying. Says that it cant find the amount field. Is this another API change or something you guys know about?
We get this: Error: rpc error: code = InvalidArgument desc = Error parsing into type osmo_bindings::query::EstimatePriceResponse: missing field `amount`: query wasm contract failed: invalid request
what's the repo or the source of the osmo_bindings package you were using?
osmo_bindings are at 0.5.1 - is there a different one we need to use?
osmosis_std is at 0.12.0 as well.
Source is just a rust crate, we dont pull from git.
Update: Tried the latest version from the repo instead of from crates. Looks like you guys took out or renamed the EstimatePriceResponse struct? We still get the same error with that version, even for spot pricing. But that reponse type isnt there anymore.
@mattverse Is there anything you can point us to? We're still stuck on this... I've tried just about everything I can think of.
If you have a moment I'd be very grateful!
@mattverse Hey, we're still stuck on this. I've tried everything. Same error as above.
If there's any way you could point us in the right direction that would be a lifesaver. Thanks
Hey srry for the late reply on this. @iboss-ptk do you have an idea of the osmo_bindings and osmosis_std?
can you try these msgs instead see if it works?
https://github.com/osmosis-labs/osmosis-rust/blob/28ffd12efce20ee36bb78505e5af136b26344b70/packages/osmosis-std/src/types/osmosis/gamm/v1beta1.rs#L801-L886
hello. @samsheff did you solve this problem in v13? we also stucked in same issue. and faced following error.
Error: Query failed with (18): Generic error: Querier contract error: codespace: sdk, code: 5: query wasm contract failed: invalid request
at QueryClient.queryUnverified (/Users/agrajak/.npm/_npx/ea2a98de724f1c93/node_modules/@cosmjs/stargate/build/queryclient/queryclient.js:106:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.queryContractSmart (/Users/agrajak/.npm/_npx/ea2a98de724f1c93/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js:59:34)
at async CosmWasmClient.queryContractSmart (/Users/agrajak/.npm/_npx/ea2a98de724f1c93/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js:302:20)