diff --git a/cache.py b/cache.py index 6265ec9..4392937 100644 --- a/cache.py +++ b/cache.py @@ -33,7 +33,7 @@ def file_cache(ttl=3600): with open(cache_file, "w") as f: json.dump({"timestamp": time(), "result": result}, f) except Exception as e: - print(f"Error during cache refresh of {cache_file} (Name: {func.__name__}): {e}") + print(f"Error during cache refresh of {cache_file} (Name: {func.__name__}): {e}",flush=True) threading.Thread(target=refresh_loop).start() diff --git a/cache/154903f1c716802fd57eec282afe3cb8.json b/cache/154903f1c716802fd57eec282afe3cb8.json index 934abbc..66f016a 100644 --- a/cache/154903f1c716802fd57eec282afe3cb8.json +++ b/cache/154903f1c716802fd57eec282afe3cb8.json @@ -1 +1 @@ -{"timestamp": 1733967634.1158152, "result": 1.559551} \ No newline at end of file +{"timestamp": 1733984571.397818, "result": 1.56} \ No newline at end of file diff --git a/cache/1981e30de11cf0845e8b5affb4dc75e0.json b/cache/1981e30de11cf0845e8b5affb4dc75e0.json index 1a00624..b850886 100644 --- a/cache/1981e30de11cf0845e8b5affb4dc75e0.json +++ b/cache/1981e30de11cf0845e8b5affb4dc75e0.json @@ -1 +1 @@ -{"timestamp": 1733966924.830747, "result": 3825.57} \ No newline at end of file +{"timestamp": 1733984393.209031, "result": 3919.82} \ No newline at end of file diff --git a/cache/1ccff5c6f117409fea0c861aa44b8e62.json b/cache/1ccff5c6f117409fea0c861aa44b8e62.json index 45307ec..3db926d 100644 --- a/cache/1ccff5c6f117409fea0c861aa44b8e62.json +++ b/cache/1ccff5c6f117409fea0c861aa44b8e62.json @@ -1 +1 @@ -{"timestamp": 1733967053.8096626, "result": 1.086} \ No newline at end of file +{"timestamp": 1733984459.9825835, "result": 1.16} \ No newline at end of file diff --git a/cache/29409a8a40dd2d547a7a44b8f6758f54.json b/cache/29409a8a40dd2d547a7a44b8f6758f54.json index 0df66f1..69d75d0 100644 --- a/cache/29409a8a40dd2d547a7a44b8f6758f54.json +++ b/cache/29409a8a40dd2d547a7a44b8f6758f54.json @@ -1 +1 @@ -{"timestamp": 1733966925.7328749, "result": 4.25} \ No newline at end of file +{"timestamp": 1733984455.7730536, "result": 4.26} \ No newline at end of file diff --git a/cache/32fbffa989a7d6c0472092fc8982713b.json b/cache/32fbffa989a7d6c0472092fc8982713b.json index b799a81..5b745a9 100644 --- a/cache/32fbffa989a7d6c0472092fc8982713b.json +++ b/cache/32fbffa989a7d6c0472092fc8982713b.json @@ -1 +1 @@ -{"timestamp": 1733966991.4253252, "result": 714.56} \ No newline at end of file +{"timestamp": 1733984391.3738835, "result": 714.19} \ No newline at end of file diff --git a/cache/4104ed0427efe63d4ca0dead970a4391.json b/cache/4104ed0427efe63d4ca0dead970a4391.json index 06d8c3f..8dc0053 100644 --- a/cache/4104ed0427efe63d4ca0dead970a4391.json +++ b/cache/4104ed0427efe63d4ca0dead970a4391.json @@ -1 +1 @@ -{"timestamp": 1733966989.5834355, "result": 241.8} \ No newline at end of file +{"timestamp": 1733984394.8449333, "result": 244.6} \ No newline at end of file diff --git a/cache/46c1ec7f5edb30c070003dc54e072f41.json b/cache/46c1ec7f5edb30c070003dc54e072f41.json index b4c48f1..bac6bc1 100644 --- a/cache/46c1ec7f5edb30c070003dc54e072f41.json +++ b/cache/46c1ec7f5edb30c070003dc54e072f41.json @@ -1 +1 @@ -{"timestamp": 1733967052.4412723, "result": 4.71} \ No newline at end of file +{"timestamp": 1733984458.447024, "result": 4.81} \ No newline at end of file diff --git a/cache/598f5dbf97fb0d45cbc6e1a5b0a3b575.json b/cache/598f5dbf97fb0d45cbc6e1a5b0a3b575.json index 5b895dc..c941174 100644 --- a/cache/598f5dbf97fb0d45cbc6e1a5b0a3b575.json +++ b/cache/598f5dbf97fb0d45cbc6e1a5b0a3b575.json @@ -1 +1 @@ -{"timestamp": 1733966922.5820625, "result": 227.18} \ No newline at end of file +{"timestamp": 1733984388.7021904, "result": 230.14} \ No newline at end of file diff --git a/cache/6cc6c6a0b2d0654f551d33209c1fd824.json b/cache/6cc6c6a0b2d0654f551d33209c1fd824.json index a4d1c2b..0c54648 100644 --- a/cache/6cc6c6a0b2d0654f551d33209c1fd824.json +++ b/cache/6cc6c6a0b2d0654f551d33209c1fd824.json @@ -1 +1 @@ -{"timestamp": 1733966992.060965, "result": 4.88} \ No newline at end of file +{"timestamp": 1733984458.848101, "result": 4.99} \ No newline at end of file diff --git a/cache/6eec370e2713cfc84c84e1080b8a191a.json b/cache/6eec370e2713cfc84c84e1080b8a191a.json index b71ff60..fd8f0a1 100644 --- a/cache/6eec370e2713cfc84c84e1080b8a191a.json +++ b/cache/6eec370e2713cfc84c84e1080b8a191a.json @@ -1 +1 @@ -{"timestamp": 1733967743.2804618, "result": 555.700092455} \ No newline at end of file +{"timestamp": 1733984508.6156387, "result": 555.700092455} \ No newline at end of file diff --git a/cache/790b28a9a21cf694ad9577ef1072ac9e.json b/cache/790b28a9a21cf694ad9577ef1072ac9e.json index f738906..90c6ba3 100644 --- a/cache/790b28a9a21cf694ad9577ef1072ac9e.json +++ b/cache/790b28a9a21cf694ad9577ef1072ac9e.json @@ -1 +1 @@ -{"timestamp": 1733966922.1927235, "result": 0.055517624} \ No newline at end of file +{"timestamp": 1733984388.295368, "result": 0.055517624} \ No newline at end of file diff --git a/cache/a071d7bdda25c22e42ad7840f17c4b0e.json b/cache/a071d7bdda25c22e42ad7840f17c4b0e.json index 0f945c9..f4f882d 100644 --- a/cache/a071d7bdda25c22e42ad7840f17c4b0e.json +++ b/cache/a071d7bdda25c22e42ad7840f17c4b0e.json @@ -1 +1 @@ -{"timestamp": 1733966987.4329624, "result": 1.0} \ No newline at end of file +{"timestamp": 1733984394.028739, "result": 0.999406} \ No newline at end of file diff --git a/cache/a099e7e540e16a185b0279b9494e5099.json b/cache/a099e7e540e16a185b0279b9494e5099.json index 1452744..c9841ce 100644 --- a/cache/a099e7e540e16a185b0279b9494e5099.json +++ b/cache/a099e7e540e16a185b0279b9494e5099.json @@ -1 +1 @@ -{"timestamp": 1733966990.7103124, "result": 100661} \ No newline at end of file +{"timestamp": 1733984457.517185, "result": 100311} \ No newline at end of file diff --git a/cache/a0ee60913ba556f39d128e7d7249e788.json b/cache/a0ee60913ba556f39d128e7d7249e788.json index c5b3f66..ad6bbd9 100644 --- a/cache/a0ee60913ba556f39d128e7d7249e788.json +++ b/cache/a0ee60913ba556f39d128e7d7249e788.json @@ -1 +1 @@ -{"timestamp": 1733967746.2846203, "result": [{"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3825.57, "value": 9.7833214395, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 23.664735, "price": 4.25, "value": 100.57512375, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}, {"mint": "9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa", "balance": 0.03683279, "price": 714.56, "value": 26.319238422399994, "name": "Binance Coin (Wormhole)", "symbol": "bnb"}, {"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "balance": 1.0, "price": 1.0, "value": 1.0, "name": "USDC", "symbol": "usdc"}, {"mint": "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh", "balance": 0.00056828, "price": 100661, "value": 57.20363308, "name": "Wrapped BTC (Wormhole)", "symbol": "wbtc"}, {"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.239815492, "price": 241.8, "value": 57.9873859656, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.71, "value": 4.25242400397, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.88, "value": 111.52225022464, "name": "Volo Staked SUI", "symbol": "vsui"}]} \ No newline at end of file +{"timestamp": 1733984458.8509336, "result": [{"mint": "9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa", "balance": 0.03683279, "price": 714.19, "value": 26.3056102901, "name": "Binance Coin (Wormhole)", "symbol": "bnb"}, {"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3919.82, "value": 10.024351677, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "balance": 1.0, "price": 0.999406, "value": 0.999406, "name": "USDC", "symbol": "usdc"}, {"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.239815492, "price": 244.6, "value": 58.658869343199996, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 23.664735, "price": 4.26, "value": 100.8117711, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}, {"mint": "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh", "balance": 0.00056828, "price": 100311, "value": 57.00473508, "name": "Wrapped BTC (Wormhole)", "symbol": "wbtc"}, {"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.81, "value": 4.34270901467, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.99, "value": 114.03607143872001, "name": "Volo Staked SUI", "symbol": "vsui"}]} \ No newline at end of file diff --git a/cache/c652e896f57f598d23e3dbebdb815ef6.json b/cache/c652e896f57f598d23e3dbebdb815ef6.json index 19192d3..6e84d64 100644 --- a/cache/c652e896f57f598d23e3dbebdb815ef6.json +++ b/cache/c652e896f57f598d23e3dbebdb815ef6.json @@ -1 +1 @@ -{"timestamp": 1733967567.9433823, "result": [{"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.71, "value": 4.25242400397, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.88, "value": 111.52225022464, "name": "Volo Staked SUI", "symbol": "vsui"}]} \ No newline at end of file +{"timestamp": 1733984458.8504496, "result": [{"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.81, "value": 4.34270901467, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.99, "value": 114.03607143872001, "name": "Volo Staked SUI", "symbol": "vsui"}]} \ No newline at end of file diff --git a/cache/ccf2a009e56f1b05d471a55d9c9ea8ea.json b/cache/ccf2a009e56f1b05d471a55d9c9ea8ea.json index ed7e100..8a06b61 100644 --- a/cache/ccf2a009e56f1b05d471a55d9c9ea8ea.json +++ b/cache/ccf2a009e56f1b05d471a55d9c9ea8ea.json @@ -1 +1 @@ -{"timestamp": 1733967353.9372976, "result": 82.815227} \ No newline at end of file +{"timestamp": 1733984459.5628948, "result": 82.815227} \ No newline at end of file diff --git a/cache/d4e81748ee91683b2c48adaa5cf95187.json b/cache/d4e81748ee91683b2c48adaa5cf95187.json index a29ba0c..66b06c4 100644 --- a/cache/d4e81748ee91683b2c48adaa5cf95187.json +++ b/cache/d4e81748ee91683b2c48adaa5cf95187.json @@ -1 +1 @@ -{"timestamp": 1733967918.3903854, "result": [{"name": "Kamino USDC Lending", "description": "Kamino USDC Lending", "apy": 16.49, "url": "https://app.kamino.finance/lending/reserve/DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek/Ga4rZytCpq1unD4DbEJ5bkHeUz9g3oh9AAFEi6vSauXp", "value": 50.04, "updated": "1733877495", "initial": 50, "bought": "1733717057", "type": "Lending"}, {"name": "dYdX MegaVault", "description": "dYdX MegaVault", "apy": 55, "url": "https://dydx.trade/vault", "value": 60.44, "updated": "1733966269", "initial": 60, "bought": "1733300000", "type": "Lending"}]} \ No newline at end of file +{"timestamp": 1733984522.6454546, "result": [{"name": "Kamino USDC Lending", "description": "Kamino USDC Lending", "apy": 16.49, "url": "https://app.kamino.finance/lending/reserve/DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek/Ga4rZytCpq1unD4DbEJ5bkHeUz9g3oh9AAFEi6vSauXp", "value": 50.05, "updated": "1733969728", "initial": 50, "bought": "1733717057", "type": "Lending"}, {"name": "dYdX MegaVault", "description": "dYdX MegaVault", "apy": 55, "url": "https://dydx.trade/vault", "value": 60.44, "updated": "1733966269", "initial": 60, "bought": "1733300000", "type": "Lending"}]} \ No newline at end of file diff --git a/server.py b/server.py index 49abc30..600586d 100644 --- a/server.py +++ b/server.py @@ -56,8 +56,8 @@ vault_sui_address = "0x7e4fa1592e4fad084789f9fe1a4d7631a2e6477b658e777ae95351681 fiat = "USD" -usd_to_fiat = 1 stablecoins = ["usdc", "usdt", "dai"] +usd_to_aud_backup = 1.56 coingecko_client = CoinGeckoAPI() @@ -155,7 +155,7 @@ def get_coin_price(coin_id): try: if coin_id in stablecoins: - return 1 * usd_to_fiat + return 1 price = coingecko_client.get_price(ids=coin_id, vs_currencies=fiat) @@ -631,14 +631,21 @@ def usd_to_aud(usd): value = "{:.2f}".format(value) return value -@cache.file_cache(120) +@cache.file_cache(1800) def aud_to_usd_rate(): api_key = os.getenv("API_LAYER") resp = requests.get(f"https://apilayer.net/api/live?access_key={api_key}¤cies=AUD&source=USD&format=1") if resp.status_code != 200: print("Error getting AUD price") - return -1 + return usd_to_aud_backup data = resp.json() + if "quotes" not in data: + print("Error getting AUD price") + return usd_to_aud_backup + if "USDAUD" not in data["quotes"]: + print("Error getting AUD price") + return usd_to_aud_backup + return data["quotes"]["USDAUD"] @app.route("/api/v1/other")