generated from nathanwoodburn/python-webserver-template
feat: Add APY display to webpage
All checks were successful
Build Docker / BuildImage (push) Successful in 38s
All checks were successful
Build Docker / BuildImage (push) Successful in 38s
This commit is contained in:
parent
a6b9cabddd
commit
f066306679
2
cache/154903f1c716802fd57eec282afe3cb8.json
vendored
2
cache/154903f1c716802fd57eec282afe3cb8.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061996.4144263, "result": 1.56}
|
||||
{"timestamp": 1734665228.5681558, "result": 1.56}
|
2
cache/1981e30de11cf0845e8b5affb4dc75e0.json
vendored
2
cache/1981e30de11cf0845e8b5affb4dc75e0.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061991.2298856, "result": 3937.58}
|
||||
{"timestamp": 1734665098.7438407, "result": 3441.33}
|
2
cache/1ccff5c6f117409fea0c861aa44b8e62.json
vendored
2
cache/1ccff5c6f117409fea0c861aa44b8e62.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061994.095057, "result": 1.11}
|
||||
{"timestamp": 1734665226.31311, "result": 0.91095}
|
2
cache/29409a8a40dd2d547a7a44b8f6758f54.json
vendored
2
cache/29409a8a40dd2d547a7a44b8f6758f54.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061866.2958038, "result": 4.26}
|
||||
{"timestamp": 1734665100.8721943, "result": 4.19}
|
2
cache/32fbffa989a7d6c0472092fc8982713b.json
vendored
2
cache/32fbffa989a7d6c0472092fc8982713b.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061865.2722552, "result": 708.68}
|
||||
{"timestamp": 1734665101.9956987, "result": 674.48}
|
2
cache/4104ed0427efe63d4ca0dead970a4391.json
vendored
2
cache/4104ed0427efe63d4ca0dead970a4391.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061867.4224386, "result": 242.12}
|
||||
{"timestamp": 1734665099.7667217, "result": 211.17}
|
2
cache/46c1ec7f5edb30c070003dc54e072f41.json
vendored
2
cache/46c1ec7f5edb30c070003dc54e072f41.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061992.9661698, "result": 4.67}
|
||||
{"timestamp": 1734665165.4282856, "result": 4.11}
|
2
cache/598f5dbf97fb0d45cbc6e1a5b0a3b575.json
vendored
2
cache/598f5dbf97fb0d45cbc6e1a5b0a3b575.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061861.964132, "result": 227.69}
|
||||
{"timestamp": 1734665096.4856253, "result": 198.09}
|
1
cache/60265613786b14e87a2dfba823dac3e7.json
vendored
Normal file
1
cache/60265613786b14e87a2dfba823dac3e7.json
vendored
Normal file
@ -0,0 +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}]}
|
2
cache/6cc6c6a0b2d0654f551d33209c1fd824.json
vendored
2
cache/6cc6c6a0b2d0654f551d33209c1fd824.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061992.046795, "result": 4.84}
|
||||
{"timestamp": 1734665165.0885808, "result": 4.25}
|
2
cache/6eec370e2713cfc84c84e1080b8a191a.json
vendored
2
cache/6eec370e2713cfc84c84e1080b8a191a.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734067291.7404134, "result": 555.700092455}
|
||||
{"timestamp": 1734666500.387535, "result": 555.700092455}
|
2
cache/790b28a9a21cf694ad9577ef1072ac9e.json
vendored
2
cache/790b28a9a21cf694ad9577ef1072ac9e.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734067370.2811341, "result": 0.004517624000000005}
|
||||
{"timestamp": 1734665096.1381726, "result": 0.004517624000000005}
|
2
cache/a071d7bdda25c22e42ad7840f17c4b0e.json
vendored
2
cache/a071d7bdda25c22e42ad7840f17c4b0e.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061868.239039, "result": 1.001}
|
||||
{"timestamp": 1734665103.2234812, "result": 1.0}
|
2
cache/a099e7e540e16a185b0279b9494e5099.json
vendored
2
cache/a099e7e540e16a185b0279b9494e5099.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734061929.4794042, "result": 99633}
|
||||
{"timestamp": 1734665164.4040186, "result": 97458}
|
2
cache/a0ee60913ba556f39d128e7d7249e788.json
vendored
2
cache/a0ee60913ba556f39d128e7d7249e788.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734067296.8730075, "result": [{"mint": "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh", "balance": 0.00056828, "price": 99633, "value": 56.61944124, "name": "Wrapped BTC (Wormhole)", "symbol": "wbtc"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 23.664735, "price": 4.26, "value": 100.8117711, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}, {"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "balance": 1.0, "price": 1.001, "value": 1.001, "name": "USDC", "symbol": "usdc"}, {"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.239815492, "price": 242.12, "value": 58.06412692304, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3937.58, "value": 10.069770213, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa", "balance": 0.03683279, "price": 708.68, "value": 26.102661617199995, "name": "Binance Coin (Wormhole)", "symbol": "bnb"}, {"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.67, "value": 4.21630999969, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.84, "value": 110.60813341952, "name": "Volo Staked SUI", "symbol": "vsui"}]}
|
||||
{"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"}]}
|
2
cache/c652e896f57f598d23e3dbebdb815ef6.json
vendored
2
cache/c652e896f57f598d23e3dbebdb815ef6.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734067296.8724802, "result": [{"mint": "0x2::sui::SUI", "balance": 0.902850107, "price": 4.67, "value": 4.21630999969, "name": "Sui", "symbol": "sui"}, {"mint": "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", "balance": 22.852920128, "price": 4.84, "value": 110.60813341952, "name": "Volo Staked SUI", "symbol": "vsui"}]}
|
||||
{"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"}]}
|
2
cache/ccf2a009e56f1b05d471a55d9c9ea8ea.json
vendored
2
cache/ccf2a009e56f1b05d471a55d9c9ea8ea.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734067111.2072852, "result": 82.815227}
|
||||
{"timestamp": 1734666376.3832316, "result": 82.815227}
|
2
cache/d4e81748ee91683b2c48adaa5cf95187.json
vendored
2
cache/d4e81748ee91683b2c48adaa5cf95187.json
vendored
@ -1 +1 @@
|
||||
{"timestamp": 1734067405.2362168, "result": [{"name": "Kamino USDC Lending", "description": "Kamino USDC Lending", "apy": 16.49, "url": "https://app.kamino.finance/lending/reserve/DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek/Ga4rZytCpq1unD4DbEJ5bkHeUz9g3oh9AAFEi6vSauXp", "value": 50.08, "updated": "1734049470", "initial": 50, "bought": "1733717057", "type": "Lending"}, {"name": "dYdX MegaVault", "description": "dYdX MegaVault", "apy": 55, "url": "https://dydx.trade/vault", "value": 60.58, "updated": "1734063147", "initial": 60, "bought": "1733300000", "type": "Lending"}]}
|
||||
{"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"}]}
|
10
server.py
10
server.py
@ -467,6 +467,11 @@ def getOtherInvestments():
|
||||
data = requests.get("https://cloud.woodburn.au/s/stwdbrn_other/download/other_investments.json")
|
||||
return data.json()
|
||||
|
||||
@cache.file_cache(60)
|
||||
def getAPYInvestments():
|
||||
data = requests.get("https://cloud.woodburn.au/s/YiTnzEMi2njFSRz/download/apy.json")
|
||||
return data.json()
|
||||
|
||||
def getOtherInvestmentTypes():
|
||||
data = getOtherInvestments()
|
||||
types = {}
|
||||
@ -676,6 +681,11 @@ def aud_to_usd_rate():
|
||||
def api_other_investments():
|
||||
data = getOtherInvestments()
|
||||
return jsonify(data)
|
||||
|
||||
@app.route("/api/v1/apy")
|
||||
def api_apy_investments():
|
||||
data = getAPYInvestments()
|
||||
return jsonify(data)
|
||||
|
||||
@app.route("/api/v1/deposit",methods=["POST"])
|
||||
def api_deposit():
|
||||
|
BIN
stWDBRN.bsdesign
BIN
stWDBRN.bsdesign
Binary file not shown.
@ -424,6 +424,7 @@
|
||||
<th>Initial Value</th>
|
||||
<th>Date bought</th>
|
||||
<th>Current Value</th>
|
||||
<th>APY</th>
|
||||
<th>Info</th>
|
||||
<th>Last Updated</th>
|
||||
</tr>
|
||||
@ -434,6 +435,7 @@
|
||||
<td>$0</td>
|
||||
<td>00/00/00</td>
|
||||
<td>$0</td>
|
||||
<td>0%</td>
|
||||
<td>Find out more</td>
|
||||
<td>00/00/00</td>
|
||||
</tr>
|
||||
@ -478,6 +480,81 @@
|
||||
<td>$${item.initial}</td>
|
||||
<td>${formatDate(item.bought)}</td>
|
||||
<td>$${item.value}</td>
|
||||
<td>~${item.apy}%</td>
|
||||
<td><a href="${item.url}" target="_blank">Find out more</a></td>
|
||||
<td>${formatDate(item.updated)}</td>
|
||||
`;
|
||||
|
||||
tableBody.appendChild(row);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching or injecting data:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Set on page load event listener
|
||||
window.addEventListener('load', fetchAndInjectDefiData);
|
||||
</script>
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<h2 class="display-4">Other</h2>
|
||||
<div class="table-responsive" id="other-table">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Asset</th>
|
||||
<th>APY</th>
|
||||
<th>Info</th>
|
||||
<th>Last Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Asset Name</td>
|
||||
<td>0%</td>
|
||||
<td>Find out more</td>
|
||||
<td>00/00/00</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><script type="text/javascript">
|
||||
async function fetchAndInjectDefiData() {
|
||||
try {
|
||||
// Fetch data from the API
|
||||
const response = await fetch('/api/v1/apy');
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok' + response.statusText);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Locate the table where the data will be injected
|
||||
const tableBody = document.querySelector('#other-table tbody');
|
||||
|
||||
if (!tableBody) {
|
||||
console.error('Table body not found. Make sure your table has an id "other-table" with a <tbody> element.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear existing rows (optional, depending on use case)
|
||||
tableBody.innerHTML = '';
|
||||
|
||||
const formatDate = (timestamp) => {
|
||||
const date = new Date(timestamp * 1000); // Convert seconds to milliseconds
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
|
||||
const year = String(date.getFullYear()).slice(-2); // Get last two digits of the year
|
||||
return `${day}/${month}/${year}`;
|
||||
};
|
||||
|
||||
// Iterate over the data and create table rows
|
||||
data.forEach(item => {
|
||||
const row = document.createElement('tr');
|
||||
|
||||
row.innerHTML = `
|
||||
<td>${item.name}</td>
|
||||
<td>~${item.apy}%</td>
|
||||
<td><a href="${item.url}" target="_blank">Find out more</a></td>
|
||||
<td>${formatDate(item.updated)}</td>
|
||||
`;
|
||||
|
Loading…
Reference in New Issue
Block a user