-
+
+
-
+
Balance A: {realTimeBalanceA.toFixed(2)}
-
+
Balance B: {realTimeBalanceB.toFixed(2)}
diff --git a/client/src/pool-types/reclamm/constants.ts b/client/src/pool-types/reclamm/constants.ts
index ed241da..cd32050 100644
--- a/client/src/pool-types/reclamm/constants.ts
+++ b/client/src/pool-types/reclamm/constants.ts
@@ -2,35 +2,35 @@ export const MIN_SWAP = 0.000001;
export const NETWORKS = [
{
- name: "Base",
- network: "base-mainnet",
+ name: 'Base',
+ network: 'base-mainnet',
},
{
- name: "Ethereum",
- network: "eth-mainnet",
+ name: 'Ethereum',
+ network: 'eth-mainnet',
},
{
- name: "Sepolia",
- network: "eth-sepolia",
+ name: 'Sepolia',
+ network: 'eth-sepolia',
},
{
- name: "OP Mainnet",
- network: "opt-mainnet",
+ name: 'OP Mainnet',
+ network: 'opt-mainnet',
},
{
- name: "Arbitrum",
- network: "arb-mainnet",
+ name: 'Arbitrum',
+ network: 'arb-mainnet',
},
{
- name: "Gnosis",
- network: "gnosis-mainnet",
+ name: 'Gnosis',
+ network: 'gnosis-mainnet',
},
{
- name: "Avalanche",
- network: "avax-mainnet",
+ name: 'Avalanche',
+ network: 'avax-mainnet',
},
{
- name: "Sonic",
- network: "sonic-mainnet",
+ name: 'Sonic',
+ network: 'sonic-mainnet',
},
];
diff --git a/client/src/pool-types/stable-pool/StableMath.ts b/client/src/pool-types/stable-pool/StableMath.ts
index 3092ece..88fad2a 100644
--- a/client/src/pool-types/stable-pool/StableMath.ts
+++ b/client/src/pool-types/stable-pool/StableMath.ts
@@ -20,7 +20,7 @@ export function stableInvariant(
for (let i = 0; i < totalCoins; i++) {
sum = sum + balances[i];
}
- if (sum == 0) {
+ if (sum === 0) {
return 0;
}
let prevInv = 0;
@@ -266,7 +266,7 @@ export function getTokenBalanceGivenInvariantAndAllOtherBalances(
let x = 0;
for (let i = 0; i < totalCoins; i++) {
nPowN = nPowN * totalCoins;
- if (i != tokenIndex) {
+ if (i !== tokenIndex) {
x = balances[i];
} else {
continue;
@@ -301,275 +301,3 @@ export function _solveAnalyticalBalance(
//Round up y
return c / 2;
}
-
-// //////////////////////
-// //// These functions have been added exclusively for the SORv2
-// //////////////////////
-
-// export function _poolDerivatives(
-// amp: BigNumber,
-// balances: OldBigNumber[],
-// tokenIndexIn: number,
-// tokenIndexOut: number,
-// is_first_derivative: boolean,
-// wrt_out: boolean
-// ): OldBigNumber {
-// const totalCoins = balances.length;
-// const D = _invariant(amp, balances);
-// let S = ZERO;
-// for (let i = 0; i < totalCoins; i++) {
-// if (i != tokenIndexIn && i != tokenIndexOut) {
-// S = S.plus(balances[i]);
-// }
-// }
-// const x = balances[tokenIndexIn];
-// const y = balances[tokenIndexOut];
-// // amp is passed as an ethers bignumber while maths uses bignumber.js
-// const ampAdjusted = bnum(formatFixed(amp, 3));
-// const a = ampAdjusted.times(totalCoins ** totalCoins); // = ampTimesNpowN
-// const b = S.minus(D).times(a).plus(D);
-// const twoaxy = bnum(2).times(a).times(x).times(y);
-// const partial_x = twoaxy.plus(a.times(y).times(y)).plus(b.times(y));
-// const partial_y = twoaxy.plus(a.times(x).times(x)).plus(b.times(x));
-// let ans;
-// if (is_first_derivative) {
-// ans = partial_x.div(partial_y);
-// } else {
-// const partial_xx = bnum(2).times(a).times(y);
-// const partial_yy = bnum(2).times(a).times(x);
-// const partial_xy = partial_xx.plus(partial_yy).plus(b);
-// const numerator = bnum(2)
-// .times(partial_x)
-// .times(partial_y)
-// .times(partial_xy)
-// .minus(partial_xx.times(partial_y.pow(2)))
-// .minus(partial_yy.times(partial_x.pow(2)));
-// const denominator = partial_x.pow(2).times(partial_y);
-// ans = numerator.div(denominator);
-// if (wrt_out) {
-// ans = ans.times(partial_y).div(partial_x);
-// }
-// }
-// return ans;
-// }
-
-// /////////
-// /// SpotPriceAfterSwap
-// /////////
-
-// export function _poolDerivativesBPT(
-// amp: BigNumber,
-// balances: OldBigNumber[],
-// bptSupply: OldBigNumber,
-// tokenIndexIn: number,
-// is_first_derivative: boolean,
-// is_BPT_out: boolean,
-// wrt_out: boolean
-// ): OldBigNumber {
-// const totalCoins = balances.length;
-// const D = _invariant(amp, balances);
-// let S = ZERO;
-// let D_P = D.div(totalCoins);
-// for (let i = 0; i < totalCoins; i++) {
-// if (i != tokenIndexIn) {
-// S = S.plus(balances[i]);
-// D_P = D_P.times(D).div(balances[i].times(totalCoins));
-// }
-// }
-// const x = balances[tokenIndexIn];
-// // amp is passed as an ethers bignumber while maths uses bignumber.js
-// const ampAdjusted = bnum(formatFixed(amp, 3));
-// const alpha = ampAdjusted.times(totalCoins ** totalCoins); // = ampTimesNpowN
-// const beta = alpha.times(S);
-// const gamma = ONE.minus(alpha);
-// const partial_x = bnum(2)
-// .times(alpha)
-// .times(x)
-// .plus(beta)
-// .plus(gamma.times(D));
-// const minus_partial_D = D_P.times(totalCoins + 1).minus(gamma.times(x));
-// const partial_D = ZERO.minus(minus_partial_D);
-// let ans;
-// if (is_first_derivative) {
-// ans = partial_x.div(minus_partial_D).times(bptSupply).div(D);
-// } else {
-// const partial_xx = bnum(2).times(alpha);
-// const partial_xD = gamma;
-// const n_times_nplusone = totalCoins * (totalCoins + 1);
-// const partial_DD = ZERO.minus(D_P.times(n_times_nplusone).div(D));
-// if (is_BPT_out) {
-// const term1 = partial_xx.times(partial_D).div(partial_x.pow(2));
-// const term2 = bnum(2).times(partial_xD).div(partial_x);
-// const term3 = partial_DD.div(partial_D);
-// ans = term1.minus(term2).plus(term3).times(D).div(bptSupply);
-// if (wrt_out) {
-// const D_prime = ZERO.minus(partial_x.div(partial_D));
-// ans = ans.div(D_prime).times(D).div(bptSupply);
-// }
-// } else {
-// ans = bnum(2)
-// .times(partial_xD)
-// .div(partial_D)
-// .minus(partial_DD.times(partial_x).div(partial_D.pow(2)))
-// .minus(partial_xx.div(partial_x));
-// if (wrt_out) {
-// ans = ans
-// .times(partial_x)
-// .div(minus_partial_D)
-// .times(bptSupply)
-// .div(D);
-// }
-// }
-// }
-// return ans;
-// }
-
-// // PairType = 'token->token'
-// // SwapType = 'swapExactIn'
-// export function _spotPriceAfterSwapExactTokenInForTokenOut(
-// amount: OldBigNumber,
-// poolPairData: StablePoolPairData
-// ): OldBigNumber {
-// const { amp, allBalances, tokenIndexIn, tokenIndexOut, swapFee } =
-// poolPairData;
-// const balances = [...allBalances];
-// balances[tokenIndexIn] = balances[tokenIndexIn].plus(
-// amount.times(EONE.sub(swapFee).toString()).div(EONE.toString())
-// );
-// balances[tokenIndexOut] = balances[tokenIndexOut].minus(
-// _exactTokenInForTokenOut(amount, poolPairData)
-// );
-// let ans = _poolDerivatives(
-// amp,
-// balances,
-// tokenIndexIn,
-// tokenIndexOut,
-// true,
-// false
-// );
-// ans = ONE.div(ans.times(EONE.sub(swapFee).toString()).div(EONE.toString()));
-// return ans;
-// }
-
-// // PairType = 'token->token'
-// // SwapType = 'swapExactOut'
-// export function _spotPriceAfterSwapTokenInForExactTokenOut(
-// amount: OldBigNumber,
-// poolPairData: StablePoolPairData
-// ): OldBigNumber {
-// const { amp, allBalances, tokenIndexIn, tokenIndexOut, swapFee } =
-// poolPairData;
-// const balances = [...allBalances];
-// const _in = _tokenInForExactTokenOut(amount, poolPairData)
-// .times(EONE.sub(swapFee).toString())
-// .div(EONE.toString());
-// balances[tokenIndexIn] = balances[tokenIndexIn].plus(_in);
-// balances[tokenIndexOut] = balances[tokenIndexOut].minus(amount);
-// let ans = _poolDerivatives(
-// amp,
-// balances,
-// tokenIndexIn,
-// tokenIndexOut,
-// true,
-// true
-// );
-// ans = ONE.div(ans.times(EONE.sub(swapFee).toString()).div(EONE.toString()));
-// return ans;
-// }
-
-// function _feeFactor(
-// balances: OldBigNumber[],
-// tokenIndex: number,
-// swapFee: BigNumber
-// ): OldBigNumber {
-// let sumBalances = ZERO;
-// for (let i = 0; i < balances.length; i++) {
-// sumBalances = sumBalances.plus(balances[i]);
-// }
-// const currentWeight = balances[tokenIndex].div(sumBalances);
-// const tokenBalancePercentageExcess = ONE.minus(currentWeight);
-// return ONE.minus(
-// tokenBalancePercentageExcess
-// .times(swapFee.toString())
-// .div(EONE.toString())
-// );
-// }
-
-// // PairType = 'token->BPT'
-// // SwapType = 'swapExactOut'
-// export function _spotPriceAfterSwapTokenInForExactBPTOut(
-// amount: OldBigNumber,
-// poolPairData: StablePoolPairData
-// ): OldBigNumber {
-// const { amp, allBalances, balanceOut, tokenIndexIn, decimalsOut, swapFee } =
-// poolPairData;
-// const balances = [...allBalances];
-// const _in = _tokenInForExactBPTOut(amount, poolPairData);
-// const feeFactor = _feeFactor(balances, tokenIndexIn, swapFee);
-// balances[tokenIndexIn] = balances[tokenIndexIn].plus(_in.times(feeFactor));
-// let ans = _poolDerivativesBPT(
-// amp,
-// balances,
-// bnum(formatFixed(balanceOut, decimalsOut)).plus(amount),
-// tokenIndexIn,
-// true,
-// true,
-// true
-// );
-// ans = ONE.div(ans.times(feeFactor));
-// return ans;
-// }
-
-// /////////
-// /// Derivatives of spotPriceAfterSwap
-// /////////
-
-// // PairType = 'token->token'
-// // SwapType = 'swapExactIn'
-// export function _derivativeSpotPriceAfterSwapExactTokenInForTokenOut(
-// amount: OldBigNumber,
-// poolPairData: StablePoolPairData
-// ): OldBigNumber {
-// const { amp, allBalances, tokenIndexIn, tokenIndexOut, swapFee } =
-// poolPairData;
-// const balances = [...allBalances];
-// balances[tokenIndexIn] = balances[tokenIndexIn].plus(
-// amount.times(EONE.sub(swapFee).toString()).div(EONE.toString())
-// );
-// balances[tokenIndexOut] = balances[tokenIndexOut].minus(
-// _exactTokenInForTokenOut(amount, poolPairData)
-// );
-// return _poolDerivatives(
-// amp,
-// balances,
-// tokenIndexIn,
-// tokenIndexOut,
-// false,
-// false
-// );
-// }
-
-// // PairType = 'token->token'
-// // SwapType = 'swapExactOut'
-// export function _derivativeSpotPriceAfterSwapTokenInForExactTokenOut(
-// amount: OldBigNumber,
-// poolPairData: StablePoolPairData
-// ): OldBigNumber {
-// const { amp, allBalances, tokenIndexIn, tokenIndexOut, swapFee } =
-// poolPairData;
-// const balances = [...allBalances];
-// const _in = _tokenInForExactTokenOut(amount, poolPairData)
-// .times(EONE.sub(swapFee).toString())
-// .div(EONE.toString());
-// balances[tokenIndexIn] = balances[tokenIndexIn].plus(_in);
-// balances[tokenIndexOut] = balances[tokenIndexOut].minus(amount);
-// const feeFactor = EONE.div(swapFee).toString();
-// return _poolDerivatives(
-// amp,
-// balances,
-// tokenIndexIn,
-// tokenIndexOut,
-// false,
-// true
-// ).div(feeFactor);
-// }
diff --git a/client/src/pool-types/stable-surge/StableSurge.tsx b/client/src/pool-types/stable-surge/StableSurge.tsx
index 0c6c1d4..b19375e 100644
--- a/client/src/pool-types/stable-surge/StableSurge.tsx
+++ b/client/src/pool-types/stable-surge/StableSurge.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useMemo } from "react";
+import React, { useState, useMemo } from 'react';
import {
Grid,
Paper,
@@ -9,12 +9,12 @@ import {
AccordionDetails,
TextField,
Button,
-} from "@mui/material";
-import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
-import { stableInvariant } from "../stable-pool/StableMath";
-import { StableSurgeChart } from "./StableSurgeChart";
-import { getTokenBalanceGivenInvariantAndAllOtherBalances } from "../stable-pool/StableMath";
-import { calculateImbalance, getSurgeFeePercentage } from "./StableSurgeHook";
+} from '@mui/material';
+import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
+import { stableInvariant } from '../stable-pool/StableMath';
+import { StableSurgeChart } from './StableSurgeChart';
+import { getTokenBalanceGivenInvariantAndAllOtherBalances } from '../stable-pool/StableMath';
+import { calculateImbalance, getSurgeFeePercentage } from './StableSurgeHook';
export default function StableSurge() {
const [inputBalances, setInputBalances] = useState
([1000, 1000]);
const [initialBalances, setInitialBalances] = useState([
@@ -24,7 +24,7 @@ export default function StableSurge() {
1000, 1000,
]);
const [totalFees, setTotalFees] = useState([0, 0]);
- const [tokenNames, setTokenNames] = useState(["A", "B", "C", "D"]);
+ const [tokenNames, setTokenNames] = useState(['A', 'B', 'C', 'D']);
const [inputTokenCount, setInputTokenCount] = useState(2);
const [tokenCount, setTokenCount] = useState(2);
@@ -355,7 +355,7 @@ export default function StableSurge() {
swapTokenOutIndex
);
setCurrentBalances(currentBalances);
- setTotalFees((prevFees) => {
+ setTotalFees(prevFees => {
const newFees = [...prevFees];
newFees[swapTokenInIndex] += fees;
return newFees;
@@ -369,16 +369,16 @@ export default function StableSurge() {
}>
- Initialize Pool
+ Initialize Pool
setInputTokenCount(Number(e.target.value))}
+ onChange={e => setInputTokenCount(Number(e.target.value))}
SelectProps={{
native: true,
}}
@@ -389,12 +389,12 @@ export default function StableSurge() {
- setInputBalances((prev) => {
+ onChange={e =>
+ setInputBalances(prev => {
const result = [...prev];
result[0] = Number(e.target.value);
return result;
@@ -403,12 +403,12 @@ export default function StableSurge() {
/>
- setInputBalances((prev) => {
+ onChange={e =>
+ setInputBalances(prev => {
const result = [...prev];
result[1] = Number(e.target.value);
return result;
@@ -418,12 +418,12 @@ export default function StableSurge() {
{inputTokenCount >= 3 && (
- setInputBalances((prev) => {
+ onChange={e =>
+ setInputBalances(prev => {
const result = [...prev];
result[2] = Number(e.target.value);
return result;
@@ -434,12 +434,12 @@ export default function StableSurge() {
{inputTokenCount >= 4 && (
- setInputBalances((prev) => {
+ onChange={e =>
+ setInputBalances(prev => {
const result = [...prev];
result[3] = Number(e.target.value);
return result;
@@ -448,42 +448,42 @@ export default function StableSurge() {
/>
)}
setInputAmplification(Number(e.target.value))}
+ onChange={e => setInputAmplification(Number(e.target.value))}
/>
setInputSwapFee(Number(e.target.value))}
- inputProps={{ step: "0.1", min: "0", max: "100" }}
+ onChange={e => setInputSwapFee(Number(e.target.value))}
+ inputProps={{ step: '0.1', min: '0', max: '100' }}
/>
setInputMaxSurgeFee(Number(e.target.value))}
- inputProps={{ step: "0.1", min: "0", max: "100" }}
+ onChange={e => setInputMaxSurgeFee(Number(e.target.value))}
+ inputProps={{ step: '0.1', min: '0', max: '100' }}
/>
setInputSurgeThreshold(Number(e.target.value))}
- inputProps={{ step: "0.1", min: "0", max: "100" }}
+ onChange={e => setInputSurgeThreshold(Number(e.target.value))}
+ inputProps={{ step: '0.1', min: '0', max: '100' }}
/>
}>
- Swap Exact In
+ Swap Exact In
setSwapTokenInIndex(Number(e.target.value))}
+ onChange={e => setSwapTokenInIndex(Number(e.target.value))}
SelectProps={{
native: true,
}}
@@ -516,11 +516,11 @@ export default function StableSurge() {
setSwapTokenOutIndex(Number(e.target.value))}
+ onChange={e => setSwapTokenOutIndex(Number(e.target.value))}
SelectProps={{
native: true,
}}
@@ -543,28 +543,28 @@ export default function StableSurge() {
)}
setSwapAmountIn(Number(e.target.value))}
+ onChange={e => setSwapAmountIn(Number(e.target.value))}
/>
- Amount Out {tokenNames[swapTokenOutIndex]}:{" "}
+ Amount Out {tokenNames[swapTokenOutIndex]}:{' '}
{swapPreview.amountOut > 0
? swapPreview.amountOut.toFixed(2)
- : "0"}
+ : '0'}
Surge Fee (%): {swapPreview.feePercentage.toFixed(2)}
- Fee: {swapPreview.fee > 0 ? swapPreview.fee.toFixed(2) : "0"}{" "}
+ Fee: {swapPreview.fee > 0 ? swapPreview.fee.toFixed(2) : '0'}{' '}
{tokenNames[swapTokenInIndex]}
}>
- Config
+ Config
- setTokenNames((prev) => {
+ onChange={e =>
+ setTokenNames(prev => {
const result = [...prev];
result[0] = e.target.value;
return result;
@@ -593,12 +593,12 @@ export default function StableSurge() {
}
/>
- setTokenNames((prev) => {
+ onChange={e =>
+ setTokenNames(prev => {
const result = [...prev];
result[1] = e.target.value;
return result;
@@ -607,12 +607,12 @@ export default function StableSurge() {
/>
{tokenCount >= 3 && (
- setTokenNames((prev) => {
+ onChange={e =>
+ setTokenNames(prev => {
const result = [...prev];
result[2] = e.target.value;
return result;
@@ -622,12 +622,12 @@ export default function StableSurge() {
)}
{tokenCount >= 4 && (
- setTokenNames((prev) => {
+ onChange={e =>
+ setTokenNames(prev => {
const result = [...prev];
result[3] = e.target.value;
return result;
@@ -641,8 +641,8 @@ export default function StableSurge() {
{/* Middle Column - Chart */}
-
-
+
+
}>
- Current Values
+ Current Values
-
+
Current Balance {tokenNames[0]}:
{currentBalances[0].toFixed(2)}
-
+
Current Balance {tokenNames[1]}:
{currentBalances[1].toFixed(2)}
{tokenCount >= 3 && (
Current Balance {tokenNames[2]}:
{currentBalances[2].toFixed(2)}
@@ -686,17 +686,17 @@ export default function StableSurge() {
)}
{tokenCount >= 4 && (
Current Balance {tokenNames[3]}:
{currentBalances[3].toFixed(2)}
)}
-
+
Current Invariant:
{currentInvariant.toFixed(2)}
-
+
Current Imbalance (%):
{calculateImbalance(currentBalances).toFixed(2)}
@@ -704,7 +704,7 @@ export default function StableSurge() {
{previewPoint && (
Post-Swap Imbalance (%):
@@ -720,22 +720,22 @@ export default function StableSurge() {
}>
- Pool Parameters
+ Pool Parameters
-
+
Amplification Factor:
{amplification.toFixed(2)}
-
+
Static Swap Fee (%):
{swapFee.toFixed(2)}
-
+
Surge Threshold (%):
{surgeThreshold.toFixed(2)}
-
+
Max Surge Fee (%):
{maxSurgeFee.toFixed(2)}
@@ -744,20 +744,20 @@ export default function StableSurge() {
}>
- Initial Values
+ Initial Values
-
+
Initial Balance {tokenNames[0]}:
{initialBalances[0].toFixed(2)}
-
+
Initial Balance {tokenNames[1]}:
{initialBalances[1].toFixed(2)}
{tokenCount >= 3 && (
Initial Balance {tokenNames[2]}:
{initialBalances[2].toFixed(2)}
@@ -765,13 +765,13 @@ export default function StableSurge() {
)}
{tokenCount >= 4 && (
Initial Balance {tokenNames[3]}:
{initialBalances[3].toFixed(2)}
)}
-
+
Initial Invariant:
{stableInvariant(amplification, initialBalances).toFixed(2)}
@@ -782,20 +782,20 @@ export default function StableSurge() {
}>
- Collected Fees
+ Collected Fees
-
+
{tokenNames[0]}:
{totalFees[0].toFixed(2)}
-
+
{tokenNames[1]}:
{totalFees[1].toFixed(2)}
{tokenCount >= 3 && (
{tokenNames[2]}:
{totalFees[2].toFixed(2)}
@@ -803,7 +803,7 @@ export default function StableSurge() {
)}
{tokenCount >= 4 && (
{tokenNames[3]}:
{totalFees[3].toFixed(2)}
diff --git a/client/src/pool-types/stable-surge/StableSurgeChart.tsx b/client/src/pool-types/stable-surge/StableSurgeChart.tsx
index f7f2c95..0490ff2 100644
--- a/client/src/pool-types/stable-surge/StableSurgeChart.tsx
+++ b/client/src/pool-types/stable-surge/StableSurgeChart.tsx
@@ -1,7 +1,7 @@
-import { useEffect, useRef } from "react";
+import { useEffect, useRef } from 'react';
// Add these imports at the top
-import * as d3 from "d3";
+import * as d3 from 'd3';
// Add this new component
export const StableSurgeChart: React.FC<{
@@ -22,8 +22,8 @@ export const StableSurgeChart: React.FC<{
previewPoint,
lowerImbalanceThreshold,
upperImbalanceThreshold,
- tokenInName = "Balance A",
- tokenOutName = "Balance B",
+ tokenInName = 'Balance A',
+ tokenOutName = 'Balance B',
}) => {
const svgRef = useRef
(null);
@@ -32,7 +32,7 @@ export const StableSurgeChart: React.FC<{
const renderChart = () => {
// Clear previous chart
- d3.select(svgRef.current).selectAll("*").remove();
+ d3.select(svgRef.current).selectAll('*').remove();
// Set up dimensions
const svgElement = svgRef.current;
@@ -47,173 +47,173 @@ export const StableSurgeChart: React.FC<{
const allPoints = [...curvePoints, ...(initialCurvePoints || [])];
const xScale = d3
.scaleLinear()
- .domain(d3.extent(allPoints, (d) => d.x) as [number, number])
+ .domain(d3.extent(allPoints, d => d.x) as [number, number])
.range([0, innerWidth])
.nice();
const yScale = d3
.scaleLinear()
- .domain(d3.extent(allPoints, (d) => d.y) as [number, number])
+ .domain(d3.extent(allPoints, d => d.y) as [number, number])
.range([innerHeight, 0])
.nice();
// Create SVG
const svg = d3
.select(svgRef.current)
- .attr("width", width)
- .attr("height", height)
- .append("g")
- .attr("transform", `translate(${margin.left},${margin.top})`);
+ .attr('width', width)
+ .attr('height', height)
+ .append('g')
+ .attr('transform', `translate(${margin.left},${margin.top})`);
// Add grid
svg
- .append("g")
- .attr("class", "grid")
- .attr("opacity", 0.1)
+ .append('g')
+ .attr('class', 'grid')
+ .attr('opacity', 0.1)
.call(
d3
.axisBottom(xScale)
.tickSize(innerHeight)
- .tickFormat(() => "")
+ .tickFormat(() => '')
)
- .call((g) => g.select(".domain").remove());
+ .call(g => g.select('.domain').remove());
svg
- .append("g")
- .attr("class", "grid")
- .attr("opacity", 0.1)
+ .append('g')
+ .attr('class', 'grid')
+ .attr('opacity', 0.1)
.call(
d3
.axisLeft(yScale)
.tickSize(-innerWidth)
- .tickFormat(() => "")
+ .tickFormat(() => '')
)
- .call((g) => g.select(".domain").remove());
+ .call(g => g.select('.domain').remove());
// Add axes
svg
- .append("g")
- .attr("transform", `translate(0,${innerHeight})`)
+ .append('g')
+ .attr('transform', `translate(0,${innerHeight})`)
.call(d3.axisBottom(xScale));
- svg.append("g").call(d3.axisLeft(yScale));
+ svg.append('g').call(d3.axisLeft(yScale));
// Add initial curve if it exists
if (initialCurvePoints) {
const initialLine = d3
.line()
- .x((d) => xScale(d.x))
- .y((d) => yScale(d.y));
+ .x(d => xScale(d.x))
+ .y(d => yScale(d.y));
svg
- .append("path")
+ .append('path')
.datum(initialCurvePoints)
- .attr("fill", "none")
- .attr("stroke", "#ff0000")
- .attr("stroke-width", 2)
- .attr("stroke-dasharray", "5,5")
- .attr("d", initialLine);
+ .attr('fill', 'none')
+ .attr('stroke', '#ff0000')
+ .attr('stroke-width', 2)
+ .attr('stroke-dasharray', '5,5')
+ .attr('d', initialLine);
}
// Add curve
const line = d3
.line()
- .x((d) => xScale(d.x))
- .y((d) => yScale(d.y));
+ .x(d => xScale(d.x))
+ .y(d => yScale(d.y));
svg
- .append("path")
+ .append('path')
.datum(curvePoints)
- .attr("fill", "none")
- .attr("stroke", "#8884d8")
- .attr("stroke-width", 2)
- .attr("d", line);
+ .attr('fill', 'none')
+ .attr('stroke', '#8884d8')
+ .attr('stroke-width', 2)
+ .attr('d', line);
// Add curve with fees
const lineWithFees = d3
.line()
- .x((d) => xScale(d.x))
- .y((d) => yScale(d.y));
+ .x(d => xScale(d.x))
+ .y(d => yScale(d.y));
svg
- .append("path")
+ .append('path')
.datum(curvePointsWithFees)
- .attr("fill", "none")
- .attr("stroke", "#000000")
- .attr("stroke-width", 2)
- .attr("d", lineWithFees);
+ .attr('fill', 'none')
+ .attr('stroke', '#000000')
+ .attr('stroke-width', 2)
+ .attr('d', lineWithFees);
// Add axis labels
svg
- .append("text")
- .attr("x", innerWidth / 2)
- .attr("y", innerHeight + 40)
- .attr("text-anchor", "middle")
+ .append('text')
+ .attr('x', innerWidth / 2)
+ .attr('y', innerHeight + 40)
+ .attr('text-anchor', 'middle')
.text(tokenInName);
svg
- .append("text")
- .attr("transform", "rotate(-90)")
- .attr("x", -innerHeight / 2)
- .attr("y", -40)
- .attr("text-anchor", "middle")
+ .append('text')
+ .attr('transform', 'rotate(-90)')
+ .attr('x', -innerHeight / 2)
+ .attr('y', -40)
+ .attr('text-anchor', 'middle')
.text(tokenOutName);
// After drawing the curve, add the current point if it exists
if (currentPoint) {
svg
- .append("circle")
- .attr("cx", xScale(currentPoint.x))
- .attr("cy", yScale(currentPoint.y))
- .attr("r", 6)
- .attr("fill", "#4CAF50") // Green color
- .attr("stroke", "white")
- .attr("stroke-width", 2);
+ .append('circle')
+ .attr('cx', xScale(currentPoint.x))
+ .attr('cy', yScale(currentPoint.y))
+ .attr('r', 6)
+ .attr('fill', '#4CAF50') // Green color
+ .attr('stroke', 'white')
+ .attr('stroke-width', 2);
}
// After drawing the current point, add the preview point if it exists
if (previewPoint) {
svg
- .append("circle")
- .attr("cx", xScale(previewPoint.x))
- .attr("cy", yScale(previewPoint.y))
- .attr("r", 6)
- .attr("fill", "#006400") // Changed from #000080 to #006400 (dark green)
- .attr("stroke", "white")
- .attr("stroke-width", 2);
+ .append('circle')
+ .attr('cx', xScale(previewPoint.x))
+ .attr('cy', yScale(previewPoint.y))
+ .attr('r', 6)
+ .attr('fill', '#006400') // Changed from #000080 to #006400 (dark green)
+ .attr('stroke', 'white')
+ .attr('stroke-width', 2);
}
// After drawing the preview point, add the imbalance threshold points
if (lowerImbalanceThreshold) {
svg
- .append("circle")
- .attr("cx", xScale(lowerImbalanceThreshold.x))
- .attr("cy", yScale(lowerImbalanceThreshold.y))
- .attr("r", 6)
- .attr("fill", "#ff0000") // Red color
- .attr("stroke", "white")
- .attr("stroke-width", 2);
+ .append('circle')
+ .attr('cx', xScale(lowerImbalanceThreshold.x))
+ .attr('cy', yScale(lowerImbalanceThreshold.y))
+ .attr('r', 6)
+ .attr('fill', '#ff0000') // Red color
+ .attr('stroke', 'white')
+ .attr('stroke-width', 2);
}
if (upperImbalanceThreshold) {
svg
- .append("circle")
- .attr("cx", xScale(upperImbalanceThreshold.x))
- .attr("cy", yScale(upperImbalanceThreshold.y))
- .attr("r", 6)
- .attr("fill", "#ff0000") // Red color
- .attr("stroke", "white")
- .attr("stroke-width", 2);
+ .append('circle')
+ .attr('cx', xScale(upperImbalanceThreshold.x))
+ .attr('cy', yScale(upperImbalanceThreshold.y))
+ .attr('r', 6)
+ .attr('fill', '#ff0000') // Red color
+ .attr('stroke', 'white')
+ .attr('stroke-width', 2);
}
// Add legend
const legendItems = [
- { color: "#8884d8", text: "Current Invariant" },
- { color: "#000000", text: "Invariant with Fees" },
- { color: "#ff0000", text: "Initial Invariant", isDashed: true },
- { color: "#4CAF50", text: "Current Balances" },
- { color: "#006400", text: "Post-Swap Balances" },
- { color: "#ff0000", text: "Imbalance Thresholds" },
+ { color: '#8884d8', text: 'Current Invariant' },
+ { color: '#000000', text: 'Invariant with Fees' },
+ { color: '#ff0000', text: 'Initial Invariant', isDashed: true },
+ { color: '#4CAF50', text: 'Current Balances' },
+ { color: '#006400', text: 'Post-Swap Balances' },
+ { color: '#ff0000', text: 'Imbalance Thresholds' },
];
const legendPadding = 10;
@@ -223,52 +223,52 @@ export const StableSurgeChart: React.FC<{
legendItems.length * legendItemHeight + legendPadding * 2;
const legend = svg
- .append("g")
- .attr("class", "legend")
- .attr("transform", `translate(${innerWidth - 200}, 20)`);
+ .append('g')
+ .attr('class', 'legend')
+ .attr('transform', `translate(${innerWidth - 200}, 20)`);
// Legend background - updated height
legend
- .append("rect")
- .attr("width", legendWidth)
- .attr("height", legendHeight)
- .attr("fill", "white")
- .attr("stroke", "#ccc")
- .attr("rx", 5);
+ .append('rect')
+ .attr('width', legendWidth)
+ .attr('height', legendHeight)
+ .attr('fill', 'white')
+ .attr('stroke', '#ccc')
+ .attr('rx', 5);
// Legend items
legendItems.forEach((item, i) => {
const g = legend
- .append("g")
+ .append('g')
.attr(
- "transform",
+ 'transform',
`translate(${2 * legendPadding}, ${
2 * legendPadding + i * legendItemHeight
})`
);
- if (item.isDashed || item.color === "#8884d8") {
- g.append("line")
- .attr("x1", -6)
- .attr("x2", 6)
- .attr("y1", 0)
- .attr("y2", 0)
- .attr("stroke", item.color)
- .attr("stroke-width", 2)
- .attr("stroke-dasharray", item.isDashed ? "5,5" : "none");
+ if (item.isDashed || item.color === '#8884d8') {
+ g.append('line')
+ .attr('x1', -6)
+ .attr('x2', 6)
+ .attr('y1', 0)
+ .attr('y2', 0)
+ .attr('stroke', item.color)
+ .attr('stroke-width', 2)
+ .attr('stroke-dasharray', item.isDashed ? '5,5' : 'none');
} else {
- g.append("circle")
- .attr("r", 6)
- .attr("fill", item.color)
- .attr("stroke", "white")
- .attr("stroke-width", 2);
+ g.append('circle')
+ .attr('r', 6)
+ .attr('fill', item.color)
+ .attr('stroke', 'white')
+ .attr('stroke-width', 2);
}
- g.append("text")
- .attr("x", 15)
- .attr("y", 5)
+ g.append('text')
+ .attr('x', 15)
+ .attr('y', 5)
.text(item.text)
- .style("font-size", "12px");
+ .style('font-size', '12px');
});
};
diff --git a/client/src/pool-types/stable-surge/StableSurgeHook.ts b/client/src/pool-types/stable-surge/StableSurgeHook.ts
index 39d62b9..dffbbd6 100644
--- a/client/src/pool-types/stable-surge/StableSurgeHook.ts
+++ b/client/src/pool-types/stable-surge/StableSurgeHook.ts
@@ -87,7 +87,7 @@ export function isSurging(
newTotalImbalance: number
): boolean {
// If we are balanced, or the balance has improved, do not surge: simply return the regular fee percentage.
- if (newTotalImbalance == 0) {
+ if (newTotalImbalance === 0) {
return false;
}
diff --git a/client/src/utils/Time.ts b/client/src/utils/Time.ts
index e481889..c0b575d 100644
--- a/client/src/utils/Time.ts
+++ b/client/src/utils/Time.ts
@@ -2,8 +2,8 @@ export const formatTime = (totalSeconds: number) => {
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
- return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds
+ return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds
.toFixed(0)
.toString()
- .padStart(2, "0")}`;
+ .padStart(2, '0')}`;
};