feat: Add converter to the main page
All checks were successful
Build Docker / BuildImage (push) Successful in 38s

This commit is contained in:
Nathan Woodburn 2024-12-21 17:29:09 +11:00
parent f066306679
commit ba32272a53
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
31 changed files with 2781 additions and 25 deletions

View File

@ -1 +1 @@
{"timestamp": 1734665228.5681558, "result": 1.56}
{"timestamp": 1734761171.8015382, "result": 1.56}

View File

@ -1 +1 @@
{"timestamp": 1734665098.7438407, "result": 3441.33}
{"timestamp": 1734761044.8159094, "result": 3524.19}

View File

@ -1 +1 @@
{"timestamp": 1734665226.31311, "result": 0.91095}
{"timestamp": 1734761168.669664, "result": 0.973388}

View File

@ -1 +1 @@
{"timestamp": 1734665100.8721943, "result": 4.19}
{"timestamp": 1734761041.3223195, "result": 4.24}

View File

@ -1 +1 @@
{"timestamp": 1734665101.9956987, "result": 674.48}
{"timestamp": 1734761043.8674088, "result": 689.19}

View File

@ -1 +1 @@
{"timestamp": 1734665099.7667217, "result": 211.17}
{"timestamp": 1734761042.346921, "result": 210.71}

View File

@ -1 +1 @@
{"timestamp": 1734665165.4282856, "result": 4.11}
{"timestamp": 1734761167.2952592, "result": 4.81}

View File

@ -1 +1 @@
{"timestamp": 1734665096.4856253, "result": 198.09}
{"timestamp": 1734761039.8468008, "result": 199.15}

View File

@ -1 +1 @@
{"timestamp": 1734666507.7607884, "result": [{"name": "Jupiter Perpetuals Liquidity Provider Token", "apy": 33.97, "url": "https://jup.ag/perps-earn", "updated": 1734665686}, {"name": "Volo Staked SUI", "apy": 2.71, "url": "https://stake.volosui.com/", "updated": 1734665831}, {"name": "Cardano", "apy": 2.92, "url": "https://adastat.net/pools/08f05bcfaada3bb5c038b8c88c6b502ceabfd9978973159458c6535b", "updated": 1734666096}, {"name": "Jupiter Staked Solana", "apy": 11.39, "url": "https://solanacompass.com/stake-pools/8VpRhuxa7sUUepdY3kQiTmX9rS5vx4WgaXiAnXq4KCtr", "updated": 1734666296}]}
{"timestamp": 1734762489.5969255, "result": [{"name": "Jupiter Perpetuals Liquidity Provider Token", "apy": 33.97, "url": "https://jup.ag/perps-earn", "updated": 1734665686}, {"name": "Volo Staked SUI", "apy": 2.71, "url": "https://stake.volosui.com/", "updated": 1734665831}, {"name": "Cardano", "apy": 2.92, "url": "https://adastat.net/pools/08f05bcfaada3bb5c038b8c88c6b502ceabfd9978973159458c6535b", "updated": 1734666096}, {"name": "Jupiter Staked Solana", "apy": 11.39, "url": "https://solanacompass.com/stake-pools/8VpRhuxa7sUUepdY3kQiTmX9rS5vx4WgaXiAnXq4KCtr", "updated": 1734666296}]}

View File

@ -1 +1 @@
{"timestamp": 1734665165.0885808, "result": 4.25}
{"timestamp": 1734761166.9944582, "result": 4.97}

View File

@ -1 +1 @@
{"timestamp": 1734666500.387535, "result": 555.700092455}
{"timestamp": 1734762527.4779243, "result": 555.700092455}

View File

@ -1 +1 @@
{"timestamp": 1734665096.1381726, "result": 0.004517624000000005}
{"timestamp": 1734761039.4978867, "result": 0.004517624000000005}

View File

@ -1 +1 @@
{"timestamp": 1734665103.2234812, "result": 1.0}
{"timestamp": 1734761105.7489936, "result": 1.001}

View File

@ -1 +1 @@
{"timestamp": 1734665164.4040186, "result": 97458}
{"timestamp": 1734761043.1488986, "result": 98269}

View File

@ -1 +1 @@
{"timestamp": 1734666408.133519, "result": [{"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3441.33, "value": 8.8006852755, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 23.664735, "price": 4.19, "value": 99.15523965000001, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}, {"mint": "9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa", "balance": 0.03683279, "price": 674.48, "value": 24.8429801992, "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": 97458, "value": 55.38343224, "name": "Wrapped BTC (Wormhole)", "symbol": "wbtc"}, {"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.239815492, "price": 211.17, "value": 50.64183744563999, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.11, "value": 3.71071393977, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.25, "value": 97.124910544, "name": "Volo Staked SUI", "symbol": "vsui"}]}
{"timestamp": 1734762432.2559032, "result": [{"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 23.664735, "price": 4.24, "value": 100.3384764, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}, {"mint": "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh", "balance": 0.00056828, "price": 98269, "value": 55.84430732, "name": "Wrapped BTC (Wormhole)", "symbol": "wbtc"}, {"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.239815492, "price": 210.71, "value": 50.53152231932, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa", "balance": 0.03683279, "price": 689.19, "value": 25.3847905401, "name": "Binance Coin (Wormhole)", "symbol": "bnb"}, {"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3524.19, "value": 9.0125872965, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "balance": 1.0, "price": 1.001, "value": 1.001, "name": "USDC", "symbol": "usdc"}, {"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.97, "value": 113.57901303615999, "name": "Volo Staked SUI", "symbol": "vsui"}]}

View File

@ -1 +1 @@
{"timestamp": 1734666502.8474553, "result": [{"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.11, "value": 3.71071393977, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.25, "value": 97.124910544, "name": "Volo Staked SUI", "symbol": "vsui"}]}
{"timestamp": 1734762529.1204565, "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.97, "value": 113.57901303615999, "name": "Volo Staked SUI", "symbol": "vsui"}]}

View File

@ -1 +1 @@
{"balance": 82.815227}
{"balance": 82.83633}

View File

@ -1 +1 @@
{"timestamp": 1734666376.3832316, "result": 82.815227}
{"timestamp": 1734762344.403439, "result": 82.83633}

View File

@ -1 +1 @@
{"timestamp": 1734666509.0925655, "result": [{"name": "Kamino USDC Lending", "description": "Kamino USDC Lending", "apy": 10.19, "url": "https://app.kamino.finance/lending/reserve/DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek/Ga4rZytCpq1unD4DbEJ5bkHeUz9g3oh9AAFEi6vSauXp", "value": 50.26, "updated": "1734652178", "initial": 50, "bought": "1733717057", "type": "Lending"}, {"name": "dYdX MegaVault", "description": "dYdX MegaVault", "apy": 46, "url": "https://dydx.trade/vault", "value": 61.54, "updated": "1734652205", "initial": 60, "bought": "1733300000", "type": "Lending"}]}
{"timestamp": 1734762543.2454257, "result": [{"name": "Kamino USDC Lending", "description": "Kamino USDC Lending", "apy": 12.16, "url": "https://app.kamino.finance/lending/reserve/DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek/Ga4rZytCpq1unD4DbEJ5bkHeUz9g3oh9AAFEi6vSauXp", "value": 50.28, "updated": "1734756585", "initial": 50, "bought": "1733717057", "type": "Lending"}, {"name": "dYdX MegaVault", "description": "dYdX MegaVault", "apy": 44, "url": "https://dydx.trade/vault", "value": 61.62, "updated": "1734756650", "initial": 60, "bought": "1733300000", "type": "Lending"}]}

View File

@ -639,6 +639,15 @@ def api_vault():
return jsonify(vault)
@app.route("/api/v1/usd/<usd>")
def api_usd(usd):
usd = float(usd)
# Calculate the number of stWDBRN tokens
price = float(getTokenPrice())
return jsonify({
"usd": usd,
"stWDBRN": round(usd / price,2)
})
@app.route("/api/v1/aud/<aud>")
def api_aud(aud):
@ -652,6 +661,19 @@ def api_aud(aud):
"stWDBRN": round(usd / price,2)
})
@app.route("/api/v1/token/<amount>")
def api_token_amount(amount):
amount = float(amount)
# Calculate the number of stWDBRN tokens
price = float(getTokenPrice())
return jsonify({
"amount": amount,
"tokenPrice": price,
"usd": amount * price,
"aud": usd_to_aud(amount * price)
})
def usd_to_aud(usd):
usd = float(usd)
value = usd * aud_to_usd_rate()

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,14 +7,14 @@
<title>Vault | Woodburn</title>
<meta name="theme-color" content="#ffffff">
<meta name="twitter:description" content="Woodburn Vault">
<meta name="twitter:image" content="https://vault.woodburn.au/assets/img/favicon.png">
<meta name="twitter:image" content="https://sol.woodburn.au/assets/img/favicon.png">
<meta property="og:description" content="Woodburn Vault">
<meta property="og:type" content="website">
<meta property="og:title" content="Vault | Woodburn">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Vault | Woodburn">
<meta name="description" content="Woodburn Vault">
<meta property="og:image" content="https://vault.woodburn.au/assets/img/favicon.png">
<meta property="og:image" content="https://sol.woodburn.au/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/img/favicon-192.png">
<link rel="icon" type="image/png" sizes="512x512" href="assets/img/favicon.png">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">

View File

@ -7,20 +7,20 @@
<title>Vault | Woodburn</title>
<meta name="theme-color" content="#ffffff">
<meta name="twitter:description" content="Woodburn Vault">
<meta name="twitter:image" content="https://vault.woodburn.au/assets/img/favicon.png">
<meta name="twitter:image" content="https://sol.woodburn.au/assets/img/favicon.png">
<meta property="og:description" content="Woodburn Vault">
<meta property="og:type" content="website">
<meta property="og:title" content="Vault | Woodburn">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Vault | Woodburn">
<meta name="description" content="Woodburn Vault">
<meta property="og:image" content="https://vault.woodburn.au/assets/img/favicon.png">
<meta property="og:image" content="https://sol.woodburn.au/assets/img/favicon.png">
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name": "Vault | Woodburn",
"url": "https://vault.woodburn.au"
"url": "https://sol.woodburn.au"
}
</script>
<link rel="icon" type="image/png" sizes="192x192" href="assets/img/favicon-192.png">
@ -29,6 +29,7 @@
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900&amp;display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i&amp;display=swap">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
</head>
<body>
@ -41,6 +42,64 @@
<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 ({{vault_aud}} AUD)<br>stWDBRN Token Supply: {{supply}}<br>Current Token Value: {{value}} USD ({{value_aud}} AUD)</p>
<div style="display: inline-flex;">
<div class="input-group" style="width: fit-content;margin: 10px;"><span class="input-group-text">USD</span><input class="form-control" type="text" id="fiat-input" name="fiat" oninput="convert(&#39;fiat&#39;)" value="1"><button class="btn btn-primary" id="toggle-currency" type="button" onclick="toggleCurrency()">AUD</button></div><span class="fs-1 text-center d-xl-flex align-items-xl-center"><i class="fa fa-arrows-h"></i></span>
<div class="input-group" style="width: fit-content;margin: 10px;"><span class="input-group-text">stWDBRN</span><input class="form-control" type="text" id="stwdbrn-input" name="stwdbrn" oninput="convert(&#39;stwdbrn&#39;)"></div><script>
let currentFiat = 'USD';
function toggleCurrency() {
document.getElementById('toggle-currency').textContent = currentFiat;
currentFiat = currentFiat === 'USD' ? 'AUD' : 'USD';
document.querySelector('.input-group span').textContent = currentFiat;
convert('fiat');
}
async function convert(source) {
const fiatInput = document.getElementById('fiat-input');
const stwdbrnInput = document.getElementById('stwdbrn-input');
let endpoint = '';
if (source === 'fiat') {
const fiatAmount = parseFloat(fiatInput.value);
if (isNaN(fiatAmount) || fiatAmount <= 0) {
stwdbrnInput.value = '';
return;
}
endpoint = `/api/v1/${currentFiat.toLowerCase()}/${fiatAmount}`;
} else if (source === 'stwdbrn') {
const stwdbrnAmount = parseFloat(stwdbrnInput.value);
if (isNaN(stwdbrnAmount) || stwdbrnAmount <= 0) {
fiatInput.value = '';
return;
}
endpoint = `/api/v1/token/${stwdbrnAmount}`;
} else {
return;
}
try {
const response = await fetch(endpoint);
if (!response.ok) {
throw new Error('Error fetching data');
}
const data = await response.json();
if (source === 'fiat') {
stwdbrnInput.value = parseFloat(data.stWDBRN).toFixed(2);
} else if (source === 'stwdbrn') {
fiatInput.value = parseFloat(data[currentFiat.toLowerCase()]).toFixed(2);
}
} catch (error) {
console.error('Failed to fetch conversion data:', error);
}
}
// on window load set the initial value of the input fields
convert('fiat');
</script>
</div>
</div>
</div>
<div class="bg-circle-1 bg-circle"></div>

View File

@ -1 +1 @@
{"short_name":"Vault | Woodburn","name":"Vault | Woodburn","icons":[{"src":"https://vault.woodburn.au/assets/img/favicon-192.png","type":"image/png","sizes":"192x192","purpose":"any maskable"},{"src":"https://vault.woodburn.au/assets/img/favicon.png","type":"image/png","sizes":"512x512","purpose":"any maskable"}],"start_url":"/","background_color":"#000000","theme_color":"#ffffff","display":"fullscreen"}
{"short_name":"Vault | Woodburn","name":"Vault | Woodburn","icons":[{"src":"https://sol.woodburn.au/assets/img/favicon-192.png","type":"image/png","sizes":"192x192","purpose":"any maskable"},{"src":"https://sol.woodburn.au/assets/img/favicon.png","type":"image/png","sizes":"512x512","purpose":"any maskable"}],"start_url":"/","background_color":"#000000","theme_color":"#ffffff","display":"fullscreen"}