Skip to content

Commit

Permalink
Chore/multiply (#663)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Pierre Bertet <[email protected]>
  • Loading branch information
ColinPlatt and bpierre authored Dec 20, 2024
1 parent 689e49c commit 0860975
Show file tree
Hide file tree
Showing 28 changed files with 65 additions and 65 deletions.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions frontend/app/src/comps/ActionCard/ActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ActionIcon } from "./ActionIcon";
export function ActionCard({
type,
}: {
type: "borrow" | "leverage" | "earn" | "stake";
type: "borrow" | "multiply" | "earn" | "stake";
}) {
const [hint, setHint] = useState(false);
const [active, setActive] = useState(false);
Expand Down Expand Up @@ -44,15 +44,15 @@ export function ActionCard({
path: "/borrow",
title: ac.borrow.title,
}))
.with("leverage", () => ({
.with("multiply", () => ({
colors: {
background: token("colors.brandGreen"),
foreground: token("colors.brandGreenContent"),
foregroundAlt: token("colors.brandGreenContentAlt"),
},
description: ac.leverage.description,
path: "/leverage",
title: ac.leverage.title,
description: ac.multiply.description,
path: "/multiply",
title: ac.multiply.title,
}))
.with("earn", () => ({
colors: {
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/comps/ActionCard/ActionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export function ActionIcon({
background: string;
foreground: string;
};
iconType: "borrow" | "leverage" | "earn" | "stake";
iconType: "borrow" | "multiply" | "earn" | "stake";
state: IconProps["state"];
}) {
const Icon = match(iconType)
.with("borrow", () => ActionIconBorrow)
.with("leverage", () => ActionIconLeverage)
.with("multiply", () => ActionIconLeverage)
.with("earn", () => ActionIconEarn)
.with("stake", () => ActionIconStake)
.exhaustive();
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/comps/LeverageField/LeverageField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function LeverageField({
),
end: (
<HFlex gap={8}>
Leverage {
Multiply {
<span
style={{
color: liquidationRisk === "high"
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/src/comps/Positions/NewPositionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ const actionAttributes = {
path: "/borrow",
title: "Borrow",
},
leverage: {
multiply: {
colors: {
background: token("colors.brandGreen"),
foreground: token("colors.brandGreenContent"),
foregroundAlt: token("colors.brandGreenContentAlt"),
},
description: contentActions.leverage.description,
path: "/leverage",
title: "Leverage",
description: contentActions.multiply.description,
path: "/multiply",
title: "Multiply",
},
earn: {
colors: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/comps/Positions/PositionCardLeverage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function PositionCardLeverage({
color: "positionContent",
})}
>
<div>Leverage loan</div>
<div>Multiply position</div>
{statusTag}
</div>,
]}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/comps/Positions/PositionCardLoan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function PositionCardLoan(
const prefixedTroveId = getPrefixedTroveId(props.collIndex, props.troveId);
const loanMode = storedState.loanModes[prefixedTroveId] ?? props.type;

const Card = loanMode === "leverage" ? PositionCardLeverage : PositionCardBorrow;
const Card = loanMode === "multiply" ? PositionCardLeverage : PositionCardBorrow;

return (
<Card
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/comps/Positions/Positions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function PositionsGroup({
positions.map((position, index) => (
match(position)
.returnType<[number, ReactNode]>()
.with({ type: P.union("borrow", "leverage") }, (p) => [
.with({ type: P.union("borrow", "multiply") }, (p) => [
index,
<PositionCardLoan key={index} {...p} />,
])
Expand All @@ -145,7 +145,7 @@ function PositionsGroup({
showNewPositionCard
? [
[0, <ActionCard key="0" type="borrow" />],
[1, <ActionCard key="1" type="leverage" />],
[1, <ActionCard key="1" type="multiply" />],
[2, <ActionCard key="2" type="earn" />],
[3, <ActionCard key="3" type="stake" />],
]
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/comps/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Menu } from "./Menu";
const menuItems: ComponentProps<typeof Menu>["menuItems"] = [
[content.menu.dashboard, "/", IconDashboard],
[content.menu.borrow, "/borrow", IconBorrow],
[content.menu.leverage, "/leverage", IconLeverage],
[content.menu.multiply, "/multiply", IconLeverage],
[content.menu.earn, "/earn", IconEarn],
[content.menu.stake, "/stake", IconStake],
];
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const MAX_COLLATERAL_DEPOSITS: Record<CollateralSymbol, dn.Dnum> = {
RETH: dn.from(100_000_000n, 18),
};

// LTV factor suggestions, as ratios of the leverage factor range
// LTV factor suggestions, as ratios of the multiply factor range
export const LEVERAGE_FACTOR_SUGGESTIONS = [
norm(1.5, 1.1, 11), // 1.5x leverage with a 1.1x => 11x range
norm(1.5, 1.1, 11), // 1.5x multiply with a 1.1x => 11x range
norm(2.5, 1.1, 11),
norm(5, 1.1, 11),
];
Expand Down
12 changes: 6 additions & 6 deletions frontend/app/src/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
menu: {
dashboard: "Dashboard",
borrow: "Borrow",
leverage: "Leverage",
multiply: "Multiply",
earn: "Earn",
stake: "Stake",
},
Expand Down Expand Up @@ -194,8 +194,8 @@ export default {
title: "Borrow BOLD",
description: "Set your own interest rate and borrow BOLD against ETH and staked ETH.",
},
leverage: {
title: "Leverage ETH",
multiply: {
title: "Multiply ETH",
description: "Set your own interest rate and increase your exposure to ETH and staked ETH.",
},
earn: {
Expand Down Expand Up @@ -256,11 +256,11 @@ export default {
},
},

// Leverage screen
// Multiply screen
leverageScreen: {
headline: (tokensIcons: N) => (
<>
Leverage your exposure to {tokensIcons}
Multiply your exposure to {tokensIcons}
</>
),
depositField: {
Expand All @@ -275,7 +275,7 @@ export default {
action: "Next: Summary",
infoTooltips: {
leverageLevel: [
"Leverage level",
"Multiply level",
<>
Choose the amplification of your exposure. Note that a higher level means higher liquidation risk. You are
responsible for your own assessment of what a suitable level is.
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/demo-mode/demo-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ACCOUNT_POSITIONS: Exclude<Position, PositionLoanUncommitted>[] = [
updatedAt: getTime(),
},
{
type: "leverage",
type: "multiply",
status: "active",
borrowed: dn.from(28_934.23, 18),
borrower: DEMO_ACCOUNT,
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/liquity-leverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function getLeverUpTroveParams(

const leverageRatio = BigInt(leverageFactor * 1000) * DECIMAL_PRECISION / 1000n;
if (leverageRatio <= currentLR) {
throw new Error(`Leverage ratio should increase: ${leverageRatio} <= ${currentLR}`);
throw new Error(`Multiply ratio should increase: ${leverageRatio} <= ${currentLR}`);
}

const currentCollAmount = troveData.entireColl;
Expand Down Expand Up @@ -117,7 +117,7 @@ export async function getLeverDownTroveParams(

const leverageRatio = BigInt(leverageFactor * 1000) * DECIMAL_PRECISION / 1000n;
if (leverageRatio >= currentLR) {
throw new Error(`Leverage ratio should decrease: ${leverageRatio} >= ${currentLR}`);
throw new Error(`Multiply ratio should decrease: ${leverageRatio} >= ${currentLR}`);
}

const currentCollAmount = troveData.entireColl;
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/screens/HomeScreen/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function BorrowingRow({
/>
</Link>
<Link
href={`/leverage/${symbol.toLowerCase()}`}
href={`/multiply/${symbol.toLowerCase()}`}
legacyBehavior
passHref
>
Expand All @@ -152,7 +152,7 @@ function BorrowingRow({
fontSize: 14,
})}
>
Leverage
Multiply
<TokenIcon symbol={symbol} size="mini" />
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/screens/LeverageScreen/LeverageScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function LeverageScreen() {
);

const newLoan: PositionLoanUncommitted = {
type: "leverage",
type: "multiply",
status: "active",
batchManager: interestRateDelegate,
borrowed: leverageField.debt ?? dn.from(0, 18),
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/screens/LoanScreen/LoanScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function LoanScreen() {
return {
loanModes: {
...loanModes,
[paramPrefixedId]: loanMode === "borrow" ? "leverage" : "borrow",
[paramPrefixedId]: loanMode === "borrow" ? "multiply" : "borrow",
},
};
});
Expand Down Expand Up @@ -195,7 +195,7 @@ export function LoanScreen() {
}}
/>
{action === "colldebt" && (
loanMode === "leverage"
loanMode === "multiply"
? <PanelUpdateLeveragePosition loan={loan.data} />
: <PanelUpdateBorrowPosition loan={loan.data} />
)}
Expand Down
28 changes: 14 additions & 14 deletions frontend/app/src/screens/LoanScreen/LoanScreenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import * as dn from "dnum";
import Image from "next/image";
import { match, P } from "ts-pattern";

type LoanMode = "borrow" | "leverage";
type LoanMode = "borrow" | "multiply";

export function LoanScreenCard({
collateral,
Expand Down Expand Up @@ -84,7 +84,7 @@ export function LoanScreenCard({
);

const nftUrl = useTroveNftUrl(loan?.collIndex ?? null, troveId);
const title = mode === "leverage" ? "Leverage loan" : "BOLD loan";
const title = mode === "multiply" ? "Multiply" : "BOLD loan";

const fullyRedeemed = loan && loan.status === "redeemed" && dn.eq(loan.borrowed, 0);

Expand Down Expand Up @@ -257,7 +257,7 @@ function LoanCardHeading({
color: inheritColor ? "inherit" : "var(--color-alt)",
}}
>
{mode === "leverage"
{mode === "multiply"
? <IconLeverage size={16} />
: <IconBorrow size={16} />}
</div>
Expand Down Expand Up @@ -397,7 +397,7 @@ function LoanCard({
troveId,
nftUrl,
}) => {
const title = mode === "leverage" ? "Leverage loan" : "BOLD loan";
const title = mode === "multiply" ? "Multiply" : "BOLD loan";
return (
<a.div
className={css({
Expand Down Expand Up @@ -507,14 +507,14 @@ function LoanCard({
color: "accent",
})}
>
{mode === "leverage"
{mode === "multiply"
? <IconBorrow size={16} />
: <IconLeverage size={16} />}
</div>
),
label: mode === "leverage"
label: mode === "multiply"
? "Convert to BOLD loan"
: "Convert to leverage loan",
: "Convert to Multiply position",
},
{
icon: (
Expand Down Expand Up @@ -577,7 +577,7 @@ function LoanCard({
selected={0}
onSelect={(index) => {
if (index === 0) {
onLeverageModeChange(mode === "leverage" ? "borrow" : "leverage");
onLeverageModeChange(mode === "multiply" ? "borrow" : "multiply");
}
if (index === 1) {
navigator.clipboard.writeText(window.location.href);
Expand Down Expand Up @@ -608,7 +608,7 @@ function LoanCard({
gap: 12,
})}
>
{mode === "leverage"
{mode === "multiply"
? (
<div
title={`${fmtnum(loan.deposit, "full")} ${collateral}`}
Expand All @@ -630,7 +630,7 @@ function LoanCard({
<div>
<Value
negative={loanDetails.status === "underwater" || loanDetails.status === "liquidatable"}
title={`Leverage factor: ${
title={`Multiply factor: ${
loanDetails.status === "underwater" || leverageFactor === null
? INFINITY
: `${roundToDecimal(leverageFactor, 3)}x`
Expand Down Expand Up @@ -668,7 +668,7 @@ function LoanCard({
color: "positionContentAlt",
})}
>
{mode === "leverage" ? "Total exposure" : "Total debt"}
{mode === "multiply" ? "Total exposure" : "Total debt"}
</div>
</div>
</div>
Expand All @@ -681,7 +681,7 @@ function LoanCard({
gap: 12,
})}
>
<GridItem label={mode === "leverage" ? "Net value" : "Collateral"}>
<GridItem label={mode === "multiply" ? "Net value" : "Collateral"}>
{fmtnum(loan.deposit)} {collateral.name}
</GridItem>
<GridItem label="Interest rate">
Expand All @@ -704,7 +704,7 @@ function LoanCard({
gap: 12,
})}
>
<GridItem label={mode === "leverage" ? "Net value" : "Collateral"}>N/A</GridItem>
<GridItem label={mode === "multiply" ? "Net value" : "Collateral"}>N/A</GridItem>
<GridItem label="Liq. price" title="Liquidation price">N/A</GridItem>
<GridItem label="Interest rate">N/A</GridItem>
<GridItem label="LTV" title="Loan-to-value ratio">N/A</GridItem>
Expand All @@ -730,7 +730,7 @@ function LoanCard({
gap: 12,
})}
>
{mode === "leverage"
{mode === "multiply"
? (
<GridItem label="Net value">
<Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export function PanelUpdateLeveragePosition({
),
},
{
start: <Field.FooterInfo label="Leverage" />,
start: <Field.FooterInfo label="Multiply" />,
end: (
<ValueUpdate
fontSize={14}
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/screens/TransactionsScreen/LoanCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ function LeveragedExposure({
>
<Value
negative={loanDetails.status === "underwater" || loanDetails.status === "liquidatable"}
title={`Leverage factor: ${
title={`Multiply factor: ${
loanDetails.status === "underwater" || loanDetails.leverageFactor === null
? INFINITY
: `${roundToDecimal(loanDetails.leverageFactor, 3)}x`
Expand Down Expand Up @@ -555,7 +555,7 @@ function LoadingCard({
onRetry: () => void;
txPreviewMode?: boolean;
}) {
const title = leverage ? "Leverage loan" : "BOLD loan";
const title = leverage ? "Multiply" : "BOLD loan";

const spring = useSpring({
to: match(loadingState)
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/services/StoredState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const StoredStateSchema = v.object({
vPrefixedTroveId(),
v.union([
v.literal("borrow"),
v.literal("leverage"),
v.literal("multiply"),
]),
),
});
Expand Down
Loading

0 comments on commit 0860975

Please sign in to comment.