From d623330a79e8867e658fc88b2395974eba4bc981 Mon Sep 17 00:00:00 2001 From: izyak Date: Tue, 21 Dec 2021 10:23:43 +0545 Subject: [PATCH 1/2] Add method to get BALN price from dex --- score/priceOracle/interfaces.py | 4 ++++ score/priceOracle/priceOracle.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/score/priceOracle/interfaces.py b/score/priceOracle/interfaces.py index 788321f9..1ad82b3d 100644 --- a/score/priceOracle/interfaces.py +++ b/score/priceOracle/interfaces.py @@ -24,6 +24,10 @@ def getPoolStats(self, _id: int) -> dict: def getPriceByName(self, _name: str) -> int: pass + @interface + def getBalnPrice(self) -> int: + pass + class TokenInterface(InterfaceScore): @interface diff --git a/score/priceOracle/priceOracle.py b/score/priceOracle/priceOracle.py index b5214ad8..f7bcffb7 100644 --- a/score/priceOracle/priceOracle.py +++ b/score/priceOracle/priceOracle.py @@ -56,6 +56,9 @@ def getOMMPool(self) -> str: def _get_price(self, _base: str, _quote) -> int: if _base in STABLE_TOKENS: return 1 * 10 ** 18 + if _base == "BALN": + dex = self.create_interface_score(self.getAddress(DEX), DataSourceInterface) + return dex.getBalnPrice() else: oracle = self.create_interface_score(self.getAddress(BAND_ORACLE), OracleInterface) price = oracle.get_reference_data(_base, _quote) From 67f6b16bf42436cd1d4dae2496c47ea87037f1e5 Mon Sep 17 00:00:00 2001 From: izyak Date: Tue, 21 Dec 2021 10:28:45 +0545 Subject: [PATCH 2/2] Use elif --- score/priceOracle/priceOracle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/score/priceOracle/priceOracle.py b/score/priceOracle/priceOracle.py index f7bcffb7..a207d63b 100644 --- a/score/priceOracle/priceOracle.py +++ b/score/priceOracle/priceOracle.py @@ -56,7 +56,7 @@ def getOMMPool(self) -> str: def _get_price(self, _base: str, _quote) -> int: if _base in STABLE_TOKENS: return 1 * 10 ** 18 - if _base == "BALN": + elif _base == "BALN": dex = self.create_interface_score(self.getAddress(DEX), DataSourceInterface) return dex.getBalnPrice() else: