Skip to content

feat: Yield+ domain model and pure utilities#5504

Draft
therealemjy wants to merge 1 commit intofeat/yield-plus-pr03-yieldplus-infrafrom
feat/yield-plus-pr04-domain-utils
Draft

feat: Yield+ domain model and pure utilities#5504
therealemjy wants to merge 1 commit intofeat/yield-plus-pr03-yieldplus-infrafrom
feat/yield-plus-pr04-domain-utils

Conversation

@therealemjy
Copy link
Copy Markdown
Member

Jira ticket(s)

VPD-634
VPD-632
VPD-629
VPD-640
VPD-633
VPD-638
VPD-637
VPD-643
VPD-635
VPD-639

Changes

  • add Yield+ domain types and mock models\n- add pure utilities for position formatting, leverage calculations, liquidation values, and chart candle conversion

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Apr 10, 2026 9:24am
dapp-testnet Ready Ready Preview Apr 10, 2026 9:24am
venus.io Ready Ready Preview Apr 10, 2026 9:24am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: 8fbae39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@venusprotocol/evm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@therealemjy therealemjy force-pushed the feat/yield-plus-pr03-yieldplus-infra branch from 164381d to 10e42f9 Compare April 10, 2026 08:39
@therealemjy therealemjy force-pushed the feat/yield-plus-pr04-domain-utils branch from 1c047df to ba51643 Compare April 10, 2026 08:39
@therealemjy therealemjy force-pushed the feat/yield-plus-pr03-yieldplus-infra branch from 10e42f9 to 0aae713 Compare April 10, 2026 09:07
@therealemjy therealemjy force-pushed the feat/yield-plus-pr04-domain-utils branch from ba51643 to 6eeb050 Compare April 10, 2026 09:08
@therealemjy therealemjy force-pushed the feat/yield-plus-pr03-yieldplus-infra branch 2 times, most recently from 570be16 to 9f54af2 Compare April 10, 2026 09:23
@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 76.49% 38862 / 50804
🔵 Statements 76.49% 38862 / 50804
🔵 Functions 59.01% 612 / 1037
🔵 Branches 71.19% 4449 / 6249
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/pages/YieldPlus/calculateMaxLeverageFactor/index.ts 91.66% 0% 100% 91.66% 1
apps/evm/src/pages/YieldPlus/formatLiquidationPriceTokensToReadableValue/index.tsx 0% 100% 100% 0% 3-20
apps/evm/src/types/index.ts 98.07% 88.88% 100% 98.07% 9
apps/evm/src/utilities/convertPercentageToBps/index.ts 66.66% 0% 100% 66.66% 1
apps/evm/src/utilities/formatToCandle/index.ts 100% 0% 100% 100%
apps/evm/src/utilities/formatToYieldPlusPosition/index.ts 98.95% 94.73% 100% 98.95% 1
Generated in workflow #13169 for commit 8fbae39 by the Vitest Coverage Report Action

@therealemjy
Copy link
Copy Markdown
Member Author

@greptile

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR introduces the Yield+ domain model (YieldPlusPosition type), mock data, and a suite of pure utilities: formatToYieldPlusPosition, calculateMaxLeverageFactor, formatLiquidationPriceTokensToReadableValue, formatToCandle, and convertPercentageToBps. All files follow the project's single-export-per-file structure and are well-covered by unit and snapshot tests. All findings are style/polish-level (P2).

Confidence Score: 5/5

Safe to merge — all findings are P2 style/polish suggestions with no blocking correctness issues on the changed path.

All four inline comments are P2: a precision concern in calculateMaxLeverageFactor (native float before BigNumber), a .tsx-vs-.ts extension mismatch, a naming convention question on price-ratio fields, and a missing .dp(0) on shortBalanceCents. None of these cause incorrect behavior in normal operating conditions, and the core logic for position formatting, leverage calculation, and APY computation is sound and well-tested.

No files require special attention before merge.

Important Files Changed

Filename Overview
apps/evm/src/utilities/formatToYieldPlusPosition/index.ts Core position formatter; logic is sound but shortBalanceCents lacks the .dp(0) rounding applied to the other cent values, risking fractional storage.
apps/evm/src/pages/YieldPlus/calculateMaxLeverageFactor/index.ts Leverage calculation computes the denominator in native JS float before passing to BigNumber, losing precision, and has no guard for denominator-zero edge case.
apps/evm/src/pages/YieldPlus/formatLiquidationPriceTokensToReadableValue/index.tsx Pure utility with no JSX; file extension should be .ts, not .tsx.
apps/evm/src/types/index.ts Adds YieldPlusPosition type; liquidationPriceTokens and entryPriceTokens use the Tokens suffix for price ratios rather than token quantities, conflicting with the project's naming convention.
apps/evm/src/utilities/convertPercentageToBps/index.ts Simple, correct utility; converts a percentage to BPS via BigNumber, then BigInt — no issues.
apps/evm/src/utilities/formatToCandle/index.ts Lightweight adapter from API candle shape to chart data shape; correct and well-tested.
apps/evm/src/mocks/models/yieldPlus.ts Mock data for YieldPlus positions; builds mock positions via the real formatToYieldPlusPosition, covering three different market configurations.
apps/evm/src/libs/translations/translations/en.json Adds yieldPlus.operationForm.invalidLiquidationPrice key in English; all other locales also updated.

Reviews (1): Last reviewed commit: "feat: yield+ domain model and pure utili..." | Re-trigger Greptile

Comment on lines +14 to +17
new BigNumber(
dsaTokenCollateralFactor /
(1 - longTokenCollateralFactor * (1 - proportionalCloseTolerancePercentage / 100)),
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Native floating-point arithmetic before BigNumber wrapping

The denominator is computed entirely in native JS floating-point before being passed to BigNumber. This discards BigNumber's precision guarantees — for deeply fractional inputs, the intermediate result can already be slightly off before rounding. Additionally, if longTokenCollateralFactor === 1 and proportionalCloseTolerancePercentage === 0, the denominator is exactly 0, giving Infinity (which propagates through .dp(2).toNumber() as Infinity). Callers would need to guard against this.

Prefer computing entirely in BigNumber:

Suggested change
new BigNumber(
dsaTokenCollateralFactor /
(1 - longTokenCollateralFactor * (1 - proportionalCloseTolerancePercentage / 100)),
)
const denominator = new BigNumber(1).minus(
new BigNumber(longTokenCollateralFactor).multipliedBy(
new BigNumber(1).minus(new BigNumber(proportionalCloseTolerancePercentage).dividedBy(100)),
),
);
if (denominator.isZero()) {
return Infinity;
}
return new BigNumber(dsaTokenCollateralFactor)
.dividedBy(denominator)
.dp(2, BigNumber.ROUND_DOWN)
.toNumber();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant