Skip to content

Commit

Permalink
Added caching for GY calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
theeldermillenial committed Dec 5, 2024
1 parent b516297 commit a92d62f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/charli3_dendrite/dexs/ob/geniusyield.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
from dataclasses import dataclass
from dataclasses import field
from functools import lru_cache
from math import ceil
from typing import Dict
from typing import List
Expand Down Expand Up @@ -477,6 +478,7 @@ def post_init(cls, values: dict[str, ...]):

return values

@lru_cache(64)
def get_amount_out(self, asset: Assets, precise=True) -> tuple[Assets, float]:
amount_out, slippage = super().get_amount_out(asset=asset, precise=precise)

Expand All @@ -497,6 +499,7 @@ def get_amount_out(self, asset: Assets, precise=True) -> tuple[Assets, float]:

return amount_out, slippage

@lru_cache(64)
def get_amount_in(self, asset: Assets, precise=False) -> tuple[Assets, float]:
fee = self.fee
self.fee *= 1.003
Expand Down

0 comments on commit a92d62f

Please sign in to comment.