Skip to content

zcash_client_backend: Add Near Intents 1Click API as a cryptex source#1852

Draft
str4d wants to merge 1 commit intomainfrom
zcb-cryptex-near-intents
Draft

zcash_client_backend: Add Near Intents 1Click API as a cryptex source#1852
str4d wants to merge 1 commit intomainfrom
zcb-cryptex-near-intents

Conversation

@str4d
Copy link
Copy Markdown
Contributor

@str4d str4d commented Jul 14, 2025

No description provided.

Comment on lines +92 to +127
// 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(),
);
Copy link
Copy Markdown
Contributor Author

@str4d str4d Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

codecov bot commented Jul 14, 2025

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.59%. Comparing base (a1c9aa1) to head (987ccf4).
⚠️ Report is 980 commits behind head on main.

Files with missing lines Patch % Lines
zcash_client_backend/src/tor/http.rs 0.00% 15 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant