Skip to content

Commit

Permalink
App: remove unused code (liquity#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpierre authored Jan 30, 2025
1 parent 00355c6 commit 6a793b2
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 163 deletions.
4 changes: 0 additions & 4 deletions frontend/app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ export const INTEREST_RATE_MAX = 25; // 25% annualized
export const INTEREST_RATE_DEFAULT = 10;
export const INTEREST_RATE_INCREMENT = 0.1;

export const ONE_DAY_IN_SECONDS = 24n * 60n * 60n;
export const ONE_YEAR_IN_SECONDS = 365n * ONE_DAY_IN_SECONDS;
export const UPFRONT_INTEREST_PERIOD = 7n * ONE_DAY_IN_SECONDS;

export const SP_YIELD_SPLIT = 75n * 10n ** 16n; // 75%

export const DATA_REFRESH_INTERVAL = 30_000;
Expand Down
88 changes: 1 addition & 87 deletions frontend/app/src/liquity-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useGovernanceInitiatives } from "@/src/subgraph-hooks";
import { vAddress } from "@/src/valibot-utils";
import { useQuery } from "@tanstack/react-query";
import * as v from "valibot";
import { useConfig as useWagmiConfig, useReadContract, useReadContracts } from "wagmi";
import { useConfig as useWagmiConfig, useReadContracts } from "wagmi";
import { readContract, readContracts } from "wagmi/actions";

export type InitiativeStatus =
Expand Down Expand Up @@ -124,25 +124,6 @@ export function useInitiativeState(initiativeAddress: Address | null) {
});
}

export function useUserStates(account: Address | null) {
const Governance = getProtocolContract("Governance");
const userStates = useReadContract({
...Governance,
functionName: "userStates",
args: [account ?? "0x"],
query: {
enabled: account !== null,
select: (userStates) => ({
allocatedLQTY: userStates[2],
allocatedOffset: userStates[3],
unallocatedLQTY: userStates[0],
unallocatedOffset: userStates[1],
}),
},
});
return userStates;
}

export async function getUserStates(
wagmiConfig: WagmiConfig,
account: Address,
Expand Down Expand Up @@ -252,70 +233,3 @@ export function useKnownInitiatives() {
enabled: KNOWN_INITIATIVES_URL !== undefined,
});
}

// const INITIATIVES_STATIC: Initiative[] = [
// {
// address: "0x0000000000000000000000000000000000000001",
// name: "WETH-BOLD 0.3%",
// protocol: "Uniswap V4",
// tvl: dn.from(2_420_000, 18),
// pairVolume: dn.from(1_420_000, 18),
// votesDistribution: dn.from(0.35, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000002",
// name: "WETH-BOLD 0.3%",
// protocol: "Uniswap V4",
// tvl: dn.from(2_420_000, 18),
// pairVolume: dn.from(1_420_000, 18),
// votesDistribution: dn.from(0.20, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000003",
// name: "crvUSD-BOLD 0.01%",
// protocol: "Curve V2",
// tvl: dn.from(2_420_000, 18),
// pairVolume: dn.from(1_420_000, 18),
// votesDistribution: dn.from(0.15, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000004",
// name: "3pool-BOLD 0.01%",
// protocol: "Curve V2",
// tvl: dn.from(2_420_000, 18),
// pairVolume: dn.from(1_420_000, 18),
// votesDistribution: dn.from(0.10, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000005",
// name: "3pool-BOLD 0.01%",
// protocol: "Curve V2",
// tvl: dn.from(2_420_000, 18),
// pairVolume: dn.from(1_420_000, 18),
// votesDistribution: dn.from(0.10, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000006",
// name: "3pool-BOLD 0.01%",
// protocol: "Curve V2",
// tvl: dn.from(2_420_000, 18),
// pairVolume: dn.from(1_420_000, 18),
// votesDistribution: dn.from(0.05, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000007",
// name: "DeFi Collective: BOLD incentives on Euler",
// protocol: "0x5305...1418",
// tvl: dn.from(0, 18),
// pairVolume: dn.from(0, 18),
// votesDistribution: dn.from(0.025, 18),
// },
// {
// address: "0x0000000000000000000000000000000000000008",
// name: "DeFi Collective: BOLD-USDC on Balancer",
// protocol: "0x7179...9f8f",
// tvl: dn.from(0, 18),
// pairVolume: dn.from(0, 18),
// votesDistribution: dn.from(0, 18),
// },
// ];
18 changes: 1 addition & 17 deletions frontend/app/src/liquity-math.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import type { LoanDetails, RiskLevel } from "@/src/types";
import type { Dnum } from "dnum";

import {
LTV_RISK,
MAX_LTV_ALLOWED_RATIO,
ONE_YEAR_IN_SECONDS,
REDEMPTION_RISK,
UPFRONT_INTEREST_PERIOD,
} from "@/src/constants";
import { LTV_RISK, MAX_LTV_ALLOWED_RATIO, REDEMPTION_RISK } from "@/src/constants";
import * as dn from "dnum";
import { match, P } from "ts-pattern";

Expand Down Expand Up @@ -184,13 +178,3 @@ export function getLoanDetails(
status,
};
}

// from LiquityBase.sol’s _calcInterest()
export function calcInterest(weightedDebt: bigint, period: bigint): bigint {
return weightedDebt * period / ONE_YEAR_IN_SECONDS / (10n ** 18n);
}

// from BorrowerOperations.sol’s _calcUpfrontFee()
export function calcUpfrontFee(debt: bigint, avgInterestRate: bigint): bigint {
return calcInterest(debt * avgInterestRate, UPFRONT_INTEREST_PERIOD);
}
24 changes: 1 addition & 23 deletions frontend/app/src/liquity-stability-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type DepositParameters = {
BFromEpochScalePlusOne: bigint;
};

export function useSpYieldGainParameters(symbol: CollateralSymbol | null) {
function useSpYieldGainParameters(symbol: CollateralSymbol | null) {
const ActivePool = getCollateralContract(symbol, "ActivePool");
const StabilityPool = getCollateralContract(symbol, "StabilityPool");

Expand Down Expand Up @@ -219,28 +219,6 @@ function getDepositorYieldGainWithPending(
return initialDeposit * (firstPortion + secondPortion) / snapshotsP / DECIMAL_PRECISION;
}

export function calculateStabilityPoolApr(
spYieldGainParams: SPYieldGainParameters,
) {
const { aggWeightedDebtSum, totalBoldDeposits, lastAggUpdateTime, yieldGainsPending } = spYieldGainParams;

if (totalBoldDeposits === 0n) {
return null;
}

const now = BigInt(Date.now());

const pendingSPYield = calcPendingSPYield(
aggWeightedDebtSum,
lastAggUpdateTime * 1000n,
now,
) + yieldGainsPending;

const annualizedYield = (pendingSPYield * ONE_YEAR) / (now - (lastAggUpdateTime * 1000n));

return dnum18((annualizedYield * DECIMAL_PRECISION) / totalBoldDeposits);
}

// activePool.calcPendingSPYield()
function calcPendingSPYield(
aggWeightedDebtSum: bigint,
Expand Down
32 changes: 0 additions & 32 deletions frontend/app/src/liquity-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,38 +337,6 @@ export function useAverageInterestRate(collIndex: null | CollIndex) {
};
}

const EMPTY_TROVE_CHANGE = {
appliedRedistBoldDebtGain: 0n,
appliedRedistCollGain: 0n,
collIncrease: 0n,
collDecrease: 0n,
debtIncrease: 0n,
debtDecrease: 0n,
newWeightedRecordedDebt: 0n,
oldWeightedRecordedDebt: 0n,
upfrontFee: 0n,
batchAccruedManagementFee: 0n,
newWeightedRecordedBatchManagementFee: 0n,
oldWeightedRecordedBatchManagementFee: 0n,
} as const;

export function useAverageInterestRateFromActivePool(collIndex: null | CollIndex) {
const ActivePool = getCollateralContract(collIndex, "ActivePool");
const result = useReadContract(
!ActivePool ? {} : {
address: ActivePool.address,
abi: ActivePool.abi,
functionName: "getNewApproxAvgInterestRateFromTroveChange",
args: [EMPTY_TROVE_CHANGE],
query: {
enabled: ActivePool !== null,
refetchInterval: DATA_REFRESH_INTERVAL,
},
},
);
return result;
}

export function useInterestRateChartData(collIndex: null | CollIndex) {
const brackets = useInterestRateBrackets(collIndex);

Expand Down

0 comments on commit 6a793b2

Please sign in to comment.