Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions market/amberdata-cefi-defi-arbitrage-strategy/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#.env file
AMBER_DATA_API_SECRET_KEY_n = "<input api key here>"

Choose a reason for hiding this comment

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

medium

The environment variable name AMBER_DATA_API_SECRET_KEY_n appears to have a typo with the _n suffix. This is unconventional and could lead to confusion. It's recommended to remove the suffix for clarity and to follow common naming conventions. Note that this change would require updating where this variable is used.

AMBER_DATA_API_SECRET_KEY = "<input api key here>"

424,228 changes: 424,228 additions & 0 deletions market/amberdata-cefi-defi-arbitrage-strategy/amber_merge_data_new.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

94,858 changes: 94,858 additions & 0 deletions market/amberdata-cefi-defi-arbitrage-strategy/output/trade_record.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@



#swap_amount_eth_to_usdc( eth_amountIn = 2, usdc_reserve = 102819284 , eth_reserve = 27978, fee_tier = 0.003)
Comment on lines +1 to +4

Choose a reason for hiding this comment

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

medium

This file has some formatting issues at the top:

  • The leading blank lines on lines 1-3 are unnecessary and should be removed.
  • The commented-out code on line 4 should be removed or placed inside a docstring as a usage example.


def swap_amount_eth_to_usdc( eth_amountIn, usdc_reserve , eth_reserve , fee_tier = 0.003,):

eth_amountInWithFee = eth_amountIn * ( 1 - fee_tier)

numerator = eth_amountInWithFee * usdc_reserve
denominator = eth_reserve + eth_amountInWithFee

usdc_amount_out = numerator * 1.00 / denominator

return usdc_amount_out


def swap_amount_usdc_to_eth( usdc_amountIn, usdc_reserve , eth_reserve, fee_tier = 0.003):

usdc_amountInWithFee = usdc_amountIn * ( 1 - fee_tier)

numerator = usdc_amountInWithFee * eth_reserve
denominator = usdc_reserve + usdc_amountInWithFee

eth_amount_out = numerator * 1.00 / denominator

return eth_amount_out
Comment on lines +6 to +27

Choose a reason for hiding this comment

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

medium

The two functions swap_amount_eth_to_usdc and swap_amount_usdc_to_eth are nearly identical. To improve maintainability and reduce code duplication, you can refactor them into a single, more generic function. This would also resolve minor styling issues like inconsistent spacing, trailing commas, and redundant float conversion.

Here's an example of a generic function:

def get_amount_out(amount_in, reserve_in, reserve_out, fee_tier=0.003):
    """Calculates the output amount for a given input amount based on Uniswap v2 formula."""
    amount_in_with_fee = amount_in * (1 - fee_tier)
    numerator = amount_in_with_fee * reserve_out
    denominator = reserve_in + amount_in_with_fee
    return numerator / denominator

You could then replace the existing functions with this one, or have them call this generic function.

Choose a reason for hiding this comment

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

medium

According to the PEP 8 style guide, a file should end with a single newline character.

Suggested change
return eth_amount_out
return eth_amount_out