Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions third_party/agent_runner/agent_state/Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion third_party/agent_runner/nix-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let
gtk3
libsoup
webkitgtk
appimagekit
# appimagekit
librsvg
cargo
rustc
Expand Down
2 changes: 1 addition & 1 deletion third_party/agent_runner/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third_party/agent_runner/src/components/types/src_tauri.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Generated by typeshare 1.9.2
Generated by typeshare 1.13.2
*/

export enum AgentStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export async function generateAlignedPriceMatrix() {
</div>
<div class="text-green-300 text-lg font-bold font-mono">
{currentDerolasVolume24h.toLocaleString('en-US', { style: 'currency', currency: 'USD' })}
<!-- {(epochRewards / 1e18).toFixed(2)} OLAS each epoch -->
<!-- {(roundRewards / 1e18).toFixed(2)} OLAS each round -->
</div>
</div>

Expand Down
101 changes: 89 additions & 12 deletions third_party/agent_runner/src/lib/components/Metrics.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { HandCoins, Clock, Users, Gift, DollarSign, CircleDollarSign, Info, Timer, BrainCircuit, TimerReset, Sparkles, Flame, SeparatorVertical, StopCircle } from "lucide-svelte";
import { HandCoins, Clock, Users, Gift, DollarSign, CircleDollarSign, Info, Timer, BrainCircuit, TimerReset, Sparkles, Flame, SeparatorVertical, StopCircle, Coins } from "lucide-svelte";
import * as Card from "$lib/components/ui/card";
import { onMount } from 'svelte';
import * as echarts from 'echarts';
Expand All @@ -8,13 +8,19 @@
let chartDivTVL: HTMLElement | null | undefined;
let chartDivSharePrice: HTMLElement | null | undefined;
let chartDivFees: HTMLElement | null | undefined;
let chartDivShares: HTMLElement | null | undefined;

let currentAPR: number = 0;
let currentTrades24h: number = 0;
let currentFees24h: number = 0;
let currentTVL: number = 0;
let currentShares: number = 0;
let currentSharePrice: number = 0;
let initialSharePrice: number = 0;


import dayjs from 'dayjs';
import { parse } from "svelte/compiler";
// struuct for exchanges
interface Exchange {
name: string;
Expand Down Expand Up @@ -214,9 +220,17 @@ export async function generateAlignedPriceMatrix() {
currentFees24h = parseFloat(snapshot.fees24h);
currentTVL = parseFloat(snapshot.totalLiquidity);
currentAPR = (parseFloat(snapshot.fees24h) * 365 / parseFloat(snapshot.totalLiquidity)) * 100;


// current shares is the total shares in the pool
currentShares = parseFloat(snapshot.totalShares);
}
// Set initial share price based on the first snapshot
if (derolaPrices.length > 0) {
initialSharePrice = parseFloat(derolaPrices[0].sharePrice);
currentSharePrice = parseFloat(derolaPrices[derolaPrices.length - 1].sharePrice);
} else {
initialSharePrice = 0;
currentSharePrice = 0;
}

// Filter timestamps to shared minimum
const allSymbols = [...SYMBOLS, "DEROLAS"];
Expand All @@ -238,13 +252,12 @@ export async function generateAlignedPriceMatrix() {





let chartRoi: echarts.ECharts;
let chartTVL: echarts.ECharts;
let chart24hFees: echarts.ECharts;

let chartSharePrice: echarts.ECharts;
let chartShares: echarts.ECharts;


onMount(() => {
Expand Down Expand Up @@ -299,7 +312,7 @@ let chartSharePrice: echarts.ECharts;
// We do need to make suer the label is called "TVL" and not "_DEROLAS_META"
return tokens.map(symbol => ({
name: "TVL",
type: "bar",
type: "line",
showSymbol: false,
emphasis: { focus: 'series' },
data: matrix.map(row => [
Expand Down Expand Up @@ -334,7 +347,7 @@ let chartSharePrice: echarts.ECharts;
// We do need to make suer the label is called "TVL" and not "_DEROLAS_META"
return tokens.map(symbol => ({
name: "Fees",
type: "bar",
type: "line",
showSymbol: false,
emphasis: { focus: 'series' },
data: matrix.map(row => [
Expand Down Expand Up @@ -428,20 +441,50 @@ data.then((seriesData) => {
console.log("Matrix:", matrix);
console.log("Data:", data);

chartShares = echarts.init(chartDivShares, darkGreenTheme, { renderer: 'canvas' });
data = matrix.then((matrix) => {
const tokens = Object.keys(matrix[0]).filter(k => k === "_DEROLAS_META");
return tokens.map(symbol => ({
type: "line",
showSymbol: false,
emphasis: { focus: 'series' },
data: matrix.map(row => [
row.timestamp,
typeof row[symbol] === 'object' && 'totalShares' in row[symbol] ? row[symbol].totalShares : 0
]),
label: {
show: false,
position: 'top',
textStyle: {
color: '#00ff00',
fontSize: 10,
}
},
}));
});
data.then((data) => {
pltData(data, chartShares);
});

const observer = new ResizeObserver(() => {
chartTVL?.resize();
chart24hFees?.resize();
chartSharePrice?.resize();
chartRoi?.resize();
chartShares?.resize();

});
if (chartDivTVL && chartDivFees && chartDivSharePrice && chartDivRoi) {

// we now plot the shares chart
if (chartDivTVL && chartDivFees && chartDivSharePrice && chartDivRoi && chartDivShares) {
observer.observe(chartDivTVL);
observer.observe(chartDivFees);
observer.observe(chartDivSharePrice);
observer.observe(chartDivRoi);
observer.observe(chartDivShares);
}
});

});


function pltData(data: any, chart: any) {
Expand Down Expand Up @@ -519,6 +562,7 @@ function pltData(data: any, chart: any) {
</Card.Content>
</Card.Root>


<div class="grid text-center grid-cols-1 sm:grid-cols-2 gap-6">

<div class="bg-green-950 border border-green-700 rounded-lg p-3 flex flex-col gap-1">
Expand All @@ -538,18 +582,18 @@ function pltData(data: any, chart: any) {
</div>
<div class="text-green-300 text-lg font-bold font-mono">
${currentFees24h.toFixed(2)}
<!-- {(epochRewards / 1e18).toFixed(2)} OLAS each epoch -->
<!-- {(roundRewards / 1e18).toFixed(2)} OLAS each round -->
</div>
</div>

<!-- Total Swaps -->
<div class="bg-green-950 border border-green-700 rounded-lg p-3 flex flex-col gap-1">
<div class="flex items-center gap-2 text-green-500 text-xs font-bold uppercase tracking-wide">
<Flame class="w-4 h-4" />
Total Swaps 24h
Total Shares
</div>
<div class="text-green-300 text-lg font-bold font-mono">
{currentTrades24h}
{currentShares.toFixed(2)}
</div>
</div>

Expand All @@ -565,8 +609,34 @@ function pltData(data: any, chart: any) {
</div>
</div>

<div class="bg-green-950 border border-green-700 rounded-lg p-3 flex flex-col gap-1">
<div class="flex items-center gap-2 text-green-500 text-xs font-bold uppercase tracking-wide">
<Coins class="w-4 h-4" />
Current Share Price
</div>
<div class="text-green-300 text-lg font-bold font-mono">
${currentShares > 0 ? (currentTVL / currentShares).toFixed(2) : "N/A"}
</div>
</div>


<div class="bg-green-950 border border-green-700 rounded-lg p-3 flex flex-col gap-1">
<div class="flex items-center gap-2 text-green-500 text-xs font-bold uppercase tracking-wide">
<Coins class="w-4 h-4" />
Current ROI
</div>
<div class="text-green-300 text-lg font-bold font-mono">
{currentSharePrice > 0 ? ((currentSharePrice - initialSharePrice) / initialSharePrice * 100).toFixed(2) : "N/A"}%
</div>
</div>



</div>
<!-- Shares Price and ROI -->
<div class="flex flex-col gap-4 w-full p-0">

</div>
<Card.Root class="flex-1 min-w-0">
<Card.Content>
<Card.Title>Cumulative ROI of Assets in Bundle.</Card.Title>
Expand All @@ -592,4 +662,11 @@ function pltData(data: any, chart: any) {
</Card.Root>
</div>

<Card.Root class="flex-1 min-w-0 p-0">
<Card.Content>
<Card.Title>Derolas LP Shares.</Card.Title>
<div bind:this={chartDivShares} class="w-full h-[150px] p-0 m-0"></div>
</Card.Content>
</Card.Root>

</div>
Loading
Loading