From a92d62feecba80e96e62c8625e42de3d3f032f67 Mon Sep 17 00:00:00 2001 From: Elder Millenial Date: Thu, 5 Dec 2024 13:48:34 -0500 Subject: [PATCH] Added caching for GY calculations --- src/charli3_dendrite/dexs/ob/geniusyield.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/charli3_dendrite/dexs/ob/geniusyield.py b/src/charli3_dendrite/dexs/ob/geniusyield.py index 5a92ff2..c393211 100644 --- a/src/charli3_dendrite/dexs/ob/geniusyield.py +++ b/src/charli3_dendrite/dexs/ob/geniusyield.py @@ -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 @@ -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) @@ -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