Skip to content
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

Fix OKX integration approve transaction #104

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mstrug
Copy link
Collaborator

@mstrug mstrug commented Jan 24, 2025

Description

Added implementation for getting OKX smart contract address which is used during swap of a particular token handled by the OKX dex. This address needs to be used to set allowances (returned in dex::Swap::allowance).

Implementation

OKX smart contract address is taken from /approve-transaction endpoint (documentation) for particular sell token. From my observations I saw at least two different smart contract addresses returned by this endpoint (for different tokens, for one token always same address was returned).

Added generic function send() which handles preparation, http roundtrip and errors handling for different OKX API calls.

Map of: token address <=> OKX smart contract address for that token is stored in non-persistent LRU cache (size of 1000 items). Rust interior mutability pattern was used to simplify the implementation over the whole application (only changes to the okx module was needed).

Tests

Updated tests with additional endpoint requests mocks, added assert to api call test which verifies that allowance address.

@mstrug mstrug marked this pull request as ready for review January 24, 2025 14:21
@mstrug
Copy link
Collaborator Author

mstrug commented Jan 24, 2025

Was tested on base-staging (image sha256:33c21d18e9e59bc6f681639307d38c8d7540829468e2a33ac54068cd470c17b0).

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