feat: Add APY display to webpage
All checks were successful
Build Docker / BuildImage (push) Successful in 38s

This commit is contained in:
Nathan Woodburn 2024-12-20 14:48:48 +11:00
parent a6b9cabddd
commit f066306679
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
21 changed files with 105 additions and 17 deletions

View File

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

View File

@ -1 +1 @@
{"timestamp": 1734061991.2298856, "result": 3937.58}
{"timestamp": 1734665098.7438407, "result": 3441.33}

View File

@ -1 +1 @@
{"timestamp": 1734061994.095057, "result": 1.11}
{"timestamp": 1734665226.31311, "result": 0.91095}

View File

@ -1 +1 @@
{"timestamp": 1734061866.2958038, "result": 4.26}
{"timestamp": 1734665100.8721943, "result": 4.19}

View File

@ -1 +1 @@
{"timestamp": 1734061865.2722552, "result": 708.68}
{"timestamp": 1734665101.9956987, "result": 674.48}

View File

@ -1 +1 @@
{"timestamp": 1734061867.4224386, "result": 242.12}
{"timestamp": 1734665099.7667217, "result": 211.17}

View File

@ -1 +1 @@
{"timestamp": 1734061992.9661698, "result": 4.67}
{"timestamp": 1734665165.4282856, "result": 4.11}

View File

@ -1 +1 @@
{"timestamp": 1734061861.964132, "result": 227.69}
{"timestamp": 1734665096.4856253, "result": 198.09}

View 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}]}

View File

@ -1 +1 @@
{"timestamp": 1734061992.046795, "result": 4.84}
{"timestamp": 1734665165.0885808, "result": 4.25}

View File

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

View File

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

View File

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

View File

@ -1 +1 @@
{"timestamp": 1734061929.4794042, "result": 99633}
{"timestamp": 1734665164.4040186, "result": 97458}

View File

@ -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"}]}

View File

@ -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"}]}

View File

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

View File

@ -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"}]}

View File

@ -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():

Binary file not shown.

View File

@ -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>
`;