@@ -155,11 +155,11 @@ def get_debt_ratio(self) -> float:
155155
156156 return borrow_credit / collateral_credit
157157
158- def get_position_value (self ):
158+ def get_position_value (self ) -> tuple [ float , float , float , float , float , float ] :
159159 """
160160 Get equity, debt, and total position value in AVAX and USD.
161161
162- :return: (dict )
162+ :return: (tuple )
163163 - equity_avax (float)
164164 - equity_usd (float)
165165 - debt_avax (float)
@@ -212,72 +212,11 @@ def get_position_value(self):
212212 total_equity_avax = position_value_avax - debt_value_avax
213213 total_equity_usd = position_value_usd - debt_value_usd
214214
215- return {"equity_avax" : total_equity_avax , "equity_usd" : total_equity_usd ,
216- "debt_avax" : debt_value_avax , "debt_usd" : debt_value_usd ,
217- "position_avax" : position_value_avax , "position_usd" : position_value_usd }
218-
219- # Deprecated but left temporarily for backup and reference:
220- # def get_position_value(self):
221- # """
222- # Get equity value, debt value, and total position value in AVAX and USD.
223- #
224- # :return: (dict)
225- # - equity_avax (float)
226- # - equity_usd (float)
227- # - debt_avax (float)
228- # - debt_usd (float)
229- # - position_avax (float)
230- # - position_usd (float)
231- # """
232- # pool_info = self.get_pool_info()
233- # underlying_token_data = [get_token_info_from_ref(token) for token in self.get_pool_info()['tokens']]
234- # lp_address = pool_info['lpTokenAddress']
235- # avax_price = get_token_price("AVAX")
236- #
237- # pool_instance = self.platform.get_lp_contract(lp_address)
238- #
239- # collateral_size = self.get_position_info()[-1]
240- #
241- # r0, r1, last_block_time = pool_instance.functions.getReserves().call()
242- # supply = pool_instance.functions.totalSupply().call()
243- #
244- # token0_amount = (r0 * collateral_size / supply) / 10 ** int(underlying_token_data[0]['precision'])
245- # token1_amount = (r1 * collateral_size / supply) / 10 ** int(underlying_token_data[1]['precision'])
246-
247- # position_value_usd = token0_amount + (token1_amount * avax_price)
248- # position_value_avax = position_value_usd * (1 / avax_price)
249- #
250- # print("Position Value:", position_value_usd)
251- #
252- # # Get debts for underlying tokens:
253- # total_debt_usd = 0.0
254- # total_debt_avax = 0.0
255- # for i, token in enumerate(pool_info['tokens']):
256- # borrow_bal = self.homora_bank.functions.borrowBalanceCurrent(self.pos_id,
257- # Web3.toChecksumAddress(token)).call()
258- # mtd = get_token_info_from_ref(token)
259- # if mtd is None:
260- # raise ValueError(f"Could not locate token metadata for {token}")
261- #
262- # token_price_usd = get_token_price(mtd['symbol'])
263- #
264- # bbal_in_token = borrow_bal / 10 ** int(mtd['precision'])
265- # bbal_in_usd = bbal_in_token * token_price_usd
266- # bbal_in_avax = bbal_in_token / get_token_price('AVAX')
267- #
268- # total_debt_usd += bbal_in_usd
269- # total_debt_avax += bbal_in_avax
270- #
271- # print(f"{mtd['symbol']} | "
272- # f"token{i}_amount: {[token0_amount, token1_amount][i]} | "
273- # f"r{i}: {[r0, r1][i]}")
274- #
275- # equity_avax = position_value_avax - total_debt_avax
276- # equity_usd = position_value_usd - total_debt_usd
277- #
278- # return {"equity_avax": equity_avax, "equity_usd": equity_usd,
279- # "debt_avax": total_debt_avax, "debt_usd": total_debt_usd,
280- # "position_avax": position_value_avax, "position_usd": position_value_usd}
215+ return total_equity_avax , total_equity_usd , debt_value_avax , debt_value_usd , position_value_avax , position_value_usd
216+ # return {"equity_avax": total_equity_avax, "equity_usd": total_equity_usd,
217+ # "debt_avax": debt_value_avax, "debt_usd": debt_value_usd,
218+ # "position_avax": position_value_avax, "position_usd": position_value_usd}
219+
281220
282221 """ ------------------------------------------ UTILITY ------------------------------------------ """
283222 def get_platform (self , identifier : str ) -> SpellClient :
0 commit comments