zcash_client_backend: Add Near Intents 1Click API as a cryptex source#1852
zcash_client_backend: Add Near Intents 1Click API as a cryptex source#1852
Conversation
| // API documentation: | ||
| // https://docs.near-intents.org/near-intents/integration/distribution-channels/1click-api | ||
| #[allow(non_snake_case)] | ||
| let request_quote = |swapType: String, | ||
| originAsset: String, | ||
| destinationAsset: String, | ||
| refundTo: String, | ||
| recipient: String| QuoteRequest { | ||
| dry: true, | ||
| swapType, | ||
| slippageTolerance: 50, | ||
| originAsset, | ||
| depositType: "ORIGIN_CHAIN".into(), | ||
| destinationAsset, | ||
| amount: ONE_ZEC_IN_ZATOSHIS.into(), | ||
| refundTo, | ||
| refundType: "ORIGIN_CHAIN".into(), | ||
| recipient, | ||
| recipientType: "DESTINATION_CHAIN".into(), | ||
| deadline: (time::OffsetDateTime::now_utc() + Duration::from_secs(75 * 40)) | ||
| .format(&Rfc3339) | ||
| .expect("valid"), | ||
| referral: None, | ||
| quoteWaitingTimeMs: None, | ||
| appFees: None, | ||
| }; | ||
|
|
||
| // Request a quote for selling 1 ZEC, which gives us a bid price (what the DEX | ||
| // will pay for ZEC). | ||
| let bid_request = request_quote( | ||
| "EXACT_INPUT".into(), | ||
| ZEC_ASSET.into(), | ||
| USDT_ASSET.into(), | ||
| DUMMY_ZCASH_MAINNET_ADDR.into(), | ||
| DUMMY_USDT_ADDR.into(), | ||
| ); |
There was a problem hiding this comment.
When submitting this, I get a 400 Bad Request error with the following message (newlines inserted for readability):
dry should not be empty,
dry must be a boolean value,
swapType should not be empty,
swapType must be one of the following values: EXACT_INPUT, EXACT_OUTPUT,
slippageTolerance should not be empty,
slippageTolerance must not be greater than 10000,
slippageTolerance must not be less than 0,
slippageTolerance must be an integer number,
originAsset should not be empty,
originAsset must be a string,
depositType should not be empty,
depositType must be one of the following values: ORIGIN_CHAIN, INTENTS,
destinationAsset should not be empty,
destinationAsset must be a string,
amount should not be empty,
amount must be a number string,
refundTo should not be empty,
refundTo must be a string,
refundType should not be empty,
refundType must be one of the following values: ORIGIN_CHAIN, INTENTS,
recipient should not be empty,
recipient must be a string,
recipientType should not be empty,
recipientType must be one of the following values: DESTINATION_CHAIN, INTENTS,
deadline must be a valid ISO 8601 date string
As far as I can tell, all of these conditions are satisfied by the above. The only one that I can see might be ambiguous is deadline must be a valid ISO 8601 date string, but that would imply the Near Intents 1Click API is not allowing some kinds of valid ISO 8601 date strings. Alternatively, the API might be performing additional validation and is returning the wrong (or a generic) error message.
There was a problem hiding this comment.
The actual JSON being POSTed for bid is (newlines inserted for readability):
{
"dry": true,
"swapType": "EXACT_OUTPUT",
"slippageTolerance": 50,
"originAsset": "usdt.tether-token.near",
"depositType": "ORIGIN_CHAIN",
"destinationAsset": "zec.omft.near",
"amount": "100000000",
"refundTo": "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb",
"refundType": "ORIGIN_CHAIN",
"recipient": "t1Hsc1LR8yKnbbe3twRp88p6vFfC5t7DLbs",
"recipientType": "DESTINATION_CHAIN",
"deadline": "2025-07-14T20:00:58.112864Z"
}
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1852 +/- ##
==========================================
- Coverage 57.63% 57.59% -0.04%
==========================================
Files 181 181
Lines 21963 21978 +15
==========================================
Hits 12659 12659
- Misses 9304 9319 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.