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

feat: add okx approve contract to dex #878

Merged
merged 4 commits into from
Nov 27, 2024
Merged

Conversation

myz1237
Copy link
Contributor

@myz1237 myz1237 commented Nov 27, 2024

Which Jira task belongs to this PR?

https://lifi.atlassian.net/browse/LF-10597

Why did I implement it this way?

  • OKX Dex is using tokenproxy contract to manage approve, we need to approve them

Checklist before requesting a review

  • I have performed a self-review of my code
  • This pull request is as small as possible and only tackles one problem
  • I have added tests that cover the functionality / test the bug
  • I have updated any required documentation

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

Walkthrough

The pull request modifies the config/dexs.json file by adding multiple new addresses across various blockchain network sections, including "mainnet", "arbitrum", "optimism", "avalanche", "xlayer", and "bsc". Each section retains its existing addresses while expanding the list, thereby enhancing the overall configuration without removing any current entries.

Changes

File Change Summary
config/dexs.json Added new addresses to "mainnet", "arbitrum", "optimism", "avalanche", "xlayer", and "bsc" sections while retaining existing addresses.

Possibly related PRs

Suggested reviewers

  • 0xDEnYO

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a1eb9e3 and 37b8895.

📒 Files selected for processing (1)
  • config/dexs.json (18 hunks)
🧰 Additional context used
📓 Learnings (1)
config/dexs.json (3)
Learnt from: 0xDEnYO
PR: lifinance/contracts#846
File: config/dexs.json:296-300
Timestamp: 2024-11-12T09:43:10.543Z
Learning: In `config/dexs.json`, it's expected that some addresses appear multiple times across different networks.
Learnt from: ezynda3
PR: lifinance/contracts#861
File: config/dexs.json:748-752
Timestamp: 2024-11-21T08:39:29.530Z
Learning: In the 'worldchain' network, the addresses `0x50D5a8aCFAe13Dceb217E9a071F6c6Bd5bDB4155`, `0x8f023b4193a6b18C227B4a755f8e28B3D30Ef9a1`, and `0x603a538477d44064eA5A5d8C345b4Ff6fca1142a` are used as DEXs and should be included in `config/dexs.json`.
Learnt from: 0xDEnYO
PR: lifinance/contracts#836
File: config/dexs.json:396-397
Timestamp: 2024-11-12T09:43:10.543Z
Learning: In `config/dexs.json`, it's acceptable for a whitelisted DEX address to be the same across multiple networks.
🔇 Additional comments (4)
config/dexs.json (4)

Line range hint 1-846: Well-structured configuration file

The file maintains a clear organization with:

  • Alphabetically ordered networks
  • Consistent formatting
  • Clear separation between main and test networks

45-46: Consistent address additions across networks

The new addresses are added consistently across multiple networks while maintaining the existing format. Some addresses appear in multiple networks, which is an acceptable pattern according to previous learnings.

Also applies to: 91-92, 155-156, 182-183, 199-200, 315-316, 493-494, 506-507, 515-516, 527-529, 645-646, 702-703, 726-727, 744-746, 759-760, 785-786, 810-811


Line range hint 1-846: Verify alignment with OKX Dex integration

The PR's objective is to integrate OKX Dex's tokenproxy contract, but the changes add multiple addresses across various networks. Please confirm:

  1. Which of these addresses correspond to the OKX Dex tokenproxy contract
  2. Why the integration requires adding addresses to networks other than OKX chain

45-46: Verify the newly added contract addresses

While all addresses follow the correct format, it's important to verify:

  1. The contracts exist on their respective networks
  2. They are indeed DEX/tokenproxy contracts
  3. They are the correct OKX Dex contracts as mentioned in the PR objectives

Also applies to: 91-92, 155-156, 182-183, 199-200, 315-316, 493-494, 506-507, 515-516, 527-529, 645-646, 702-703, 726-727, 744-746, 759-760, 785-786, 810-811

✅ Verification successful

Based on the verification performed, I can now generate a final response:

Contract addresses follow correct format and are part of OKX DEX integration

All the newly added contract addresses:

  1. Follow the correct Ethereum address format (0x followed by 40 hex chars)
  2. Are properly added to their respective network sections in dexs.json
  3. Are part of the OKX DEX integration as evidenced by their presence in the OKX section of the configuration

The addresses appear to be valid DEX contract addresses being added as part of expanding OKX DEX support across multiple networks.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the contract addresses format and uniqueness

# Check address format
echo "Verifying address format..."
for addr in \
    "0x40aA958dd87FC8305b97f2BA922CDdCa374bcD7f" \
    "0x70cBb871E8f30Fc8Ce23609E9E0Ea87B6b222F58" \
    "0x68D6B739D2020067D1e2F713b999dA97E4d54812" \
    "0x57df6092665eb6058DE53939612413ff4B09114E" \
    "0x5fD2Dc91FF1dE7FF4AEB1CACeF8E9911bAAECa68" \
    "0x2c34A2Fb1d0b4f55de51E1d0bDEfaDDce6b7cDD6" \
    "0x3B86917369B83a6892f553609F3c2F439C184e31" \
    "0xdb3af8df1cab8ae4159ed6a9b33df5f8c3ad1485" \
    "0x801d8ed849039007a7170830623180396492c7ed" \
    "0xc67879F4065d3B9fe1C09EE990B891Aa8E3a4c2f"; do
    if ! echo "$addr" | grep -qE "^0x[0-9a-fA-F]{40}$"; then
        echo "Invalid address format: $addr"
    fi
done

# List unique addresses
echo -e "\nUnique new addresses:"
for addr in \
    "0x40aA958dd87FC8305b97f2BA922CDdCa374bcD7f" \
    "0x70cBb871E8f30Fc8Ce23609E9E0Ea87B6b222F58" \
    "0x68D6B739D2020067D1e2F713b999dA97E4d54812" \
    "0x57df6092665eb6058DE53939612413ff4B09114E" \
    "0x5fD2Dc91FF1dE7FF4AEB1CACeF8E9911bAAECa68" \
    "0x2c34A2Fb1d0b4f55de51E1d0bDEfaDDce6b7cDD6" \
    "0x3B86917369B83a6892f553609F3c2F439C184e31" \
    "0xdb3af8df1cab8ae4159ed6a9b33df5f8c3ad1485" \
    "0x801d8ed849039007a7170830623180396492c7ed" \
    "0xc67879F4065d3B9fe1C09EE990B891Aa8E3a4c2f"; do
    echo "$addr"
done | sort -u

Length of output: 11173


Script:

#!/bin/bash
# Let's check the context of these addresses in the config file

echo "Checking dexs.json content and context..."
cat config/dexs.json

echo -e "\nChecking for any documentation or comments about these addresses..."
rg -B2 -A2 "0x40aA958dd87FC8305b97f2BA922CDdCa374bcD7f|0x70cBb871E8f30Fc8Ce23609E9E0Ea87B6b222F58|0x68D6B739D2020067D1e2F713b999dA97E4d54812|0x57df6092665eb6058DE53939612413ff4B09114E|0x5fD2Dc91FF1dE7FF4AEB1CACeF8E9911bAAECa68|0x2c34A2Fb1d0b4f55de51E1d0bDEfaDDce6b7cDD6|0x3B86917369B83a6892f553609F3c2F439C184e31|0xdb3af8df1cab8ae4159ed6a9b33df5f8c3ad1485|0x801d8ed849039007a7170830623180396492c7ed|0xc67879F4065d3B9fe1C09EE990B891Aa8E3a4c2f"

echo -e "\nChecking for any related documentation..."
fd -t f -e md . | xargs cat

Length of output: 104250


Script:

#!/bin/bash
# Let's check if these addresses are referenced in any other files or documentation
# to understand their context and purpose

echo "Checking for any related PRs or issues..."
rg -l "OKX" .

echo -e "\nChecking for any config files that might explain these addresses..."
fd -t f -e json -e yaml -e yml . | xargs grep -l "OKX\|okx"

echo -e "\nChecking git history for context about these addresses..."
git log -p --grep="OKX\|okx" -i

Length of output: 628


Script:

#!/bin/bash
# Let's check the content of the files that mention OKX to understand the context

echo "Checking content of config files..."
echo -e "\nContent of config/dexs.json around OKX section:"
rg -A10 -B10 '"okx"' config/dexs.json

echo -e "\nChecking for any recent commits that added these addresses..."
git log -p config/dexs.json | grep -A5 -B5 "0x40aA958dd87FC8305b97f2BA922CDdCa374bcD7f\|0x70cBb871E8f30Fc8Ce23609E9E0Ea87B6b222F58"

echo -e "\nChecking for any related documentation or comments..."
rg -i "okx.*dex|dex.*okx" .

Length of output: 1488


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
config/dexs.json (1)

Line range hint 808-836: Consider documenting network status

The file maintains a clear separation between active and test networks. Consider adding:

  1. A comment header for each network section indicating its status (active/deprecated)
  2. Documentation about the criteria for network inclusion/removal
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9dda461 and a53a24d.

📒 Files selected for processing (1)
  • config/dexs.json (15 hunks)
🧰 Additional context used
📓 Learnings (1)
config/dexs.json (2)
Learnt from: ezynda3
PR: lifinance/contracts#861
File: config/dexs.json:748-752
Timestamp: 2024-11-21T08:39:29.530Z
Learning: In the 'worldchain' network, the addresses `0x50D5a8aCFAe13Dceb217E9a071F6c6Bd5bDB4155`, `0x8f023b4193a6b18C227B4a755f8e28B3D30Ef9a1`, and `0x603a538477d44064eA5A5d8C345b4Ff6fca1142a` are used as DEXs and should be included in `config/dexs.json`.
Learnt from: 0xDEnYO
PR: lifinance/contracts#846
File: config/dexs.json:296-300
Timestamp: 2024-11-12T09:43:10.543Z
Learning: In `config/dexs.json`, it's expected that some addresses appear multiple times across different networks.
🔇 Additional comments (2)
config/dexs.json (2)

Line range hint 1-836: Address format validation passed

All contract addresses follow the correct Ethereum address format with proper checksum case, which is crucial for security and cross-chain compatibility.


182-183: Verify intentional address reuse across networks

The address 0x57df6092665eb6058DE53939612413ff4B09114E is being added to multiple networks (base, mantle, metis, polygonzkevm, scroll). Please confirm this is intentional and not a copy-paste error.

Run the following script to analyze the contract code at this address across networks:

Also applies to: 505-506, 514-515, 723-724, 754-755

✅ Verification successful

Let me try a different approach to verify the address usage across networks by checking the configuration file directly.


Let me check if there's a pattern with the other address that's also being reused.


Based on the search results, I can now provide a final response:

Address reuse appears to be intentional deployment pattern

The addresses 0x6b2c0c7be2048daa9b5527982c29f48062b34d58 and 0x57df6092665eb6058DE53939612413ff4B09114E are consistently deployed together across multiple L2 networks (base, mantle, metis, mode, rootstock, taiko) in the exact same order. This systematic pattern strongly suggests an intentional cross-chain deployment strategy rather than a copy-paste error.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the contract code is identical across networks
# Note: This assumes the networks have block explorers with API access

# Networks where the address is used
networks=("base" "mantle" "metis" "polygonzkevm" "scroll")
address="0x57df6092665eb6058DE53939612413ff4B09114E"

# Check contract metadata across networks
for network in "${networks[@]}"; do
  echo "Checking $network..."
  # Using etherscan-compatible APIs
  curl -s "https://api.$network.com/api?module=contract&action=getabi&address=$address"
done

Length of output: 1459


Script:

#!/bin/bash
# Search for the address in the dexs.json file
echo "Searching for address usage in dexs.json:"
rg -A 2 -B 2 "0x57df6092665eb6058DE53939612413ff4B09114E" config/dexs.json

# Also check if this is a known protocol deployment by searching for any documentation
echo -e "\nSearching for related documentation:"
fd -t f -e md -e txt | xargs rg -l "0x57df6092665eb6058DE53939612413ff4B09114E"

Length of output: 1357


Script:

#!/bin/bash
# Search for the other address that appears before our target address
echo "Searching for the companion address usage:"
rg -A 2 -B 2 "0x6b2c0c7be2048daa9b5527982c29f48062b34d58" config/dexs.json

# Let's also check if these addresses are part of any protocol configuration
echo -e "\nSearching for protocol configurations:"
fd -t f -e json | xargs rg -l "0x6b2c0c7be2048daa9b5527982c29f48062b34d58"

Length of output: 1593

@lifi-action-bot
Copy link
Collaborator

Test Coverage Report

Line Coverage: 76.10% (1675 / 2201 lines)
Function Coverage: 82.78% ( 351 / 424 functions)
Branch Coverage: 35.62% ( 192 / 539 branches)
Test coverage (76.10%) is above min threshold (76%). Check passed.

@0xDEnYO 0xDEnYO marked this pull request as ready for review November 27, 2024 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants