BibliothecaDAO / eternum

onchain eternal game
https://alpha-eternum.realms.world
MIT License
46 stars 34 forks source link

[contracts] Instant AMM #1023

Closed aymericdelab closed 3 months ago

aymericdelab commented 3 months ago

User description

  1. add LP: instant
  2. remove LP: 2x travel time because you need to pickup resources since you don't have donkeys at the bank (need to pickup)
  3. swap: instant in AMM, 2x travel time to for realm to get resources since you don't have donkeys at the bank (need to pickup)

also changed bank_systems, swap_systems, liquidity_systems to just bank, swap, liquidity


PR Type

Enhancement, Tests


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
7 files
bank.cairo
Remove `BankAccounts` struct from bank model.                       

contracts/src/models/bank/bank.cairo - Removed the `BankAccounts` struct.
+0/-10   
combat.cairo
Reformat comments and update mock functions in combat model.

contracts/src/models/combat.cairo
  • Reformatted comments for better readability.
  • Updated mock functions to use u64 instead of u32.
  • Added defence_army_lifetime and attack_army_lifetime to mock_battle.
  • +59/-42 
    contracts.cairo
    Rename bank, liquidity, and swap system modules.                 

    contracts/src/systems/bank/contracts.cairo
  • Renamed modules from bank_systems, liquidity_systems, and swap_systems
    to bank, liquidity, and swap.
  • +3/-3     
    bank.cairo
    Remove `open_account` and add `pickup_resources_from_bank` function.

    contracts/src/systems/bank/contracts/bank.cairo
  • Removed open_account function.
  • Added pickup_resources_from_bank function.
  • +32/-47 
    liquidity.cairo
    Update liquidity functions to include `entity_id`.             

    contracts/src/systems/bank/contracts/liquidity.cairo
  • Modified add and remove functions to include entity_id.
  • Updated liquidity event to use entity_id instead of
    bank_account_entity_id.
  • +47/-36 
    swap.cairo
    Update swap functions to include `entity_id`.                       

    contracts/src/systems/bank/contracts/swap.cairo
  • Modified buy and sell functions to include entity_id.
  • Updated swap event to use entity_id instead of bank_account_entity_id.

  • +51/-53 
    bank.cairo
    Remove `BankAccounts` creation in admin bank.                       

    contracts/src/systems/dev/contracts/bank.cairo - Removed `BankAccounts` creation in `create_admin_bank`.
    +4/-19   
    Tests
    3 files
    bank.cairo
    Remove `test_bank_create_account` test.                                   

    contracts/src/systems/bank/tests/bank.cairo - Removed `test_bank_create_account` test.
    +3/-21   
    liquidity.cairo
    Update liquidity tests and add donkey resource assertions.

    contracts/src/systems/bank/tests/liquidity.cairo
  • Updated tests to reflect changes in liquidity functions.
  • Added assertions for donkey resources.
  • +130/-132
    swap.cairo
    Update swap tests and add donkey resource assertions.       

    contracts/src/systems/bank/tests/swap.cairo
  • Updated tests to reflect changes in swap functions.
  • Added assertions for donkey resources.
  • +129/-71

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    vercel[bot] commented 3 months ago

    The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

    Name Status Preview Comments Updated (UTC)
    eternum โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback Jun 26, 2024 11:57am
    github-actions[bot] commented 3 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review [1-5] 4
    ๐Ÿงช Relevant tests Yes
    ๐Ÿ”’ Security concerns No
    โšก Key issues to review Possible Bug:
    The removal of BankAccounts struct and related functionality in various contracts might lead to issues if there are dependencies elsewhere in the code that expect these accounts to exist or be created. This needs thorough investigation to ensure that no other parts of the system are adversely affected by these changes.
    Refactoring Concern:
    The renaming of modules from bank_systems, liquidity_systems, and swap_systems to bank, liquidity, and swap could potentially lead to confusion or errors if not all references to these modules have been updated accordingly across the entire project.
    Data Handling:
    The changes in how resources are handled, especially with the introduction of pickup_resources_from_bank replacing open_account, need careful review to ensure that resource transactions are still handled securely and correctly.
    github-actions[bot] commented 3 months ago

    Failed to generate code suggestions for PR