feat: Add AUD prices and API route
All checks were successful
Build Docker / BuildImage (push) Successful in 35s

This commit is contained in:
Nathan Woodburn 2024-12-12 12:45:53 +11:00
parent 2a2ee04759
commit 9bc590bbcb
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
20 changed files with 49 additions and 18 deletions

View File

@ -0,0 +1 @@
{"timestamp": 1733967634.1158152, "result": 1.559551}

View File

@ -1 +1 @@
{"timestamp": 1733884155.1054926, "result": 3598.9}
{"timestamp": 1733966924.830747, "result": 3825.57}

View File

@ -1 +1 @@
{"timestamp": 1733884280.7491436, "result": 0.991137}
{"timestamp": 1733967053.8096626, "result": 1.086}

View File

@ -1 +1 @@
{"timestamp": 1733884156.764032, "result": 4.19}
{"timestamp": 1733966925.7328749, "result": 4.25}

View File

@ -1 +1 @@
{"timestamp": 1733884155.9249303, "result": 669.29}
{"timestamp": 1733966991.4253252, "result": 714.56}

View File

@ -1 +1 @@
{"timestamp": 1733884154.2864244, "result": 228.27}
{"timestamp": 1733966989.5834355, "result": 241.8}

View File

@ -1 +1 @@
{"timestamp": 1733884278.9056113, "result": 3.66}
{"timestamp": 1733967052.4412723, "result": 4.71}

View File

@ -1 +1 @@
{"timestamp": 1733884279.7248404, "result": 214.52}
{"timestamp": 1733966922.5820625, "result": 227.18}

View File

@ -1 +1 @@
{"timestamp": 1733884218.3883016, "result": 3.79}
{"timestamp": 1733966992.060965, "result": 4.88}

View File

@ -1 +1 @@
{"timestamp": 1733888344.0835865, "result": 524.345950296}
{"timestamp": 1733967743.2804618, "result": 555.700092455}

View File

@ -1 +1 @@
{"timestamp": 1733884279.315854, "result": 0.055517624}
{"timestamp": 1733966922.1927235, "result": 0.055517624}

View File

@ -1 +1 @@
{"timestamp": 1733884217.6712437, "result": 1.001}
{"timestamp": 1733966987.4329624, "result": 1.0}

View File

@ -1 +1 @@
{"timestamp": 1733884153.469039, "result": 96162}
{"timestamp": 1733966990.7103124, "result": 100661}

View File

@ -1 +1 @@
{"timestamp": 1733888235.6425185, "result": [{"mint": "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh", "balance": 0.00056828, "price": 96162, "value": 54.64694136, "name": "Wrapped BTC (Wormhole)", "symbol": "wbtc"}, {"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3598.9, "value": 9.203646915, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "balance": 1.0, "price": 1.001, "value": 1.001, "name": "USDC", "symbol": "usdc"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 19.88979, "price": 4.19, "value": 83.33822010000002, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}, {"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.239815492, "price": 228.27, "value": 54.74268235884, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa", "balance": 0.03683279, "price": 669.29, "value": 24.6518180191, "name": "Binance Coin (Wormhole)", "symbol": "bnb"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 3.79, "value": 86.61256728512001, "name": "Volo Staked SUI", "symbol": "vsui"}, {"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 3.66, "value": 3.30443139162, "name": "Sui", "symbol": "sui"}]}
{"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"}]}

View File

@ -1 +1 @@
{"timestamp": 1733888230.0162873, "result": [{"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 3.79, "value": 86.61256728512001, "name": "Volo Staked SUI", "symbol": "vsui"}, {"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 3.66, "value": 3.30443139162, "name": "Sui", "symbol": "sui"}]}
{"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"}]}

View File

@ -1 +1 @@
{"timestamp": 1733888110.2009592, "result": 82.815227}
{"timestamp": 1733967353.9372976, "result": 82.815227}

View File

@ -1 +1 @@
{"timestamp": 1733888294.8290596, "result": [{"name": "Kamino USDC Lending", "description": "Kamino USDC Lending", "apy": 26.85, "url": "https://app.kamino.finance/lending/reserve/DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek/Ga4rZytCpq1unD4DbEJ5bkHeUz9g3oh9AAFEi6vSauXp", "value": 50.03, "updated": "1733877495", "initial": 50, "bought": "1733717057", "type": "Lending"}, {"name": "dYdX MegaVault", "description": "dYdX MegaVault", "apy": 55, "url": "https://dydx.trade/vault", "value": 44.58, "updated": "1733877495", "initial": 44, "bought": "1733300000", "type": "Lending"}]}
{"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"}]}

View File

@ -122,7 +122,7 @@ def index():
vaultBalance = getVaultBalance()
vaultBalance = "{:.2f}".format(vaultBalance)
return render_template("index.html", value=tokenValue, supply=tokenSupply, vault=vaultBalance)
return render_template("index.html", value=tokenValue, supply=tokenSupply, vault=vaultBalance, vault_aud=usd_to_aud(vaultBalance), value_aud=usd_to_aud(tokenValue))
@app.route("/<path:path>")
@ -611,6 +611,36 @@ def api_vault():
return jsonify(vault)
@app.route("/api/v1/aud/<aud>")
def api_aud(aud):
aud = float(aud)
usd = aud / aud_to_usd_rate()
# Calculate the number of stWDBRN tokens
price = float(getTokenPrice())
return jsonify({
"aud": aud,
"usd": round(usd, 2),
"stWDBRN": round(usd / price,2)
})
def usd_to_aud(usd):
usd = float(usd)
value = usd * aud_to_usd_rate()
# Round value to 2 decimal places and ensure it shows 2 decimal places
value = "{:.2f}".format(value)
return value
@cache.file_cache(120)
def aud_to_usd_rate():
api_key = os.getenv("API_LAYER")
resp = requests.get(f"https://apilayer.net/api/live?access_key={api_key}&currencies=AUD&source=USD&format=1")
if resp.status_code != 200:
print("Error getting AUD price")
return -1
data = resp.json()
return data["quotes"]["USDAUD"]
@app.route("/api/v1/other")
@app.route("/api/v1/defi")
def api_other_investments():

Binary file not shown.

View File

@ -40,7 +40,7 @@
<div class="container">
<h1 class="masthead-heading mb-0">Woodburn Vault</h1>
<h2 class="masthead-subheading mb-0">An easy way to buy into a diverse crypto portfolio.</h2>
<p>Woodburn Vault Balance: {{vault}} USD<br>stWDBRN Token Supply: {{supply}}<br>Current Token Value: {{value}} USD</p>
<p>Woodburn Vault Balance: {{vault}} USD ({{vault_aud}} AUD)<br>stWDBRN Token Supply: {{supply}}<br>Current Token Value: {{value}} USD ({{value_aud}} AUD)</p>
</div>
</div>
<div class="bg-circle-1 bg-circle"></div>