Skip to content

Commit c5c7f76

Browse files
feat: support off-chain APYs
1 parent 6f7caac commit c5c7f76

File tree

7 files changed

+73
-12
lines changed
  • apps/evm/src
    • clients/api/queries/useGetPools/getPools
      • formatOutput/formatDistributions/formatRewardDistribution
      • getApiPools
    • components/Apy/BoostTooltip
    • libs/translations/translations
    • pages/Market/OperationForm/AssetInfo
    • types
    • utilities/getCombinedDistributionApys

7 files changed

+73
-12
lines changed

apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/formatDistributions/formatRewardDistribution/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type BigNumber from 'bignumber.js';
33
import type {
44
IntrinsicApyDistribution,
55
MerklDistribution,
6+
OffChainApyDistribution,
67
RewardDistributorDistribution,
78
Token,
89
TokenDistribution,
@@ -23,7 +24,9 @@ interface IntrinsicApyRewardDetails {
2324
description: string;
2425
}
2526

26-
type FormatDistributionInput<TType extends 'venus' | 'merkl' | 'intrinsic'> = {
27+
type ApiRewardType = 'venus' | 'merkl' | 'intrinsic' | 'off-chain';
28+
29+
type FormatDistributionInput<TType extends ApiRewardType> = {
2730
rewardType: TType;
2831
isActive: boolean;
2932
marketAddress: Address;
@@ -34,7 +37,7 @@ type FormatDistributionInput<TType extends 'venus' | 'merkl' | 'intrinsic'> = {
3437
rewardDetails: TType extends 'merkl' ? MerklRewardDetails : IntrinsicApyRewardDetails | null;
3538
};
3639

37-
const formatRewardDistribution = <TType extends 'venus' | 'merkl' | 'intrinsic'>({
40+
const formatRewardDistribution = <TType extends ApiRewardType>({
3841
marketAddress,
3942
isActive,
4043
rewardType,
@@ -86,6 +89,16 @@ const formatRewardDistribution = <TType extends 'venus' | 'merkl' | 'intrinsic'>
8689
return distribution;
8790
}
8891

92+
if (rewardType === 'off-chain') {
93+
const distribution: OffChainApyDistribution = {
94+
...baseProps,
95+
type: 'off-chain',
96+
isActive,
97+
};
98+
99+
return distribution;
100+
}
101+
89102
const distribution: RewardDistributorDistribution = {
90103
...baseProps,
91104
isActive,

apps/evm/src/clients/api/queries/useGetPools/getPools/getApiPools/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ interface ApiIntrinsicApyReward extends ApiReward {
4040
};
4141
}
4242

43+
type ApiOffChainApyReward = Omit<ApiIntrinsicApyReward, 'type'> & {
44+
rewardType: 'intrinsic';
45+
};
46+
4347
export type PointsProgram = 'ethena' | 'etherfi' | 'kelp' | 'solv' | 'aster';
4448

4549
export interface ApiPointsDistribution {
@@ -54,7 +58,11 @@ export interface ApiPointsDistribution {
5458
logoUrl?: string;
5559
}
5660

57-
export type ApiRewardDistributor = ApiVenusReward | ApiMerklReward | ApiIntrinsicApyReward;
61+
export type ApiRewardDistributor =
62+
| ApiVenusReward
63+
| ApiMerklReward
64+
| ApiIntrinsicApyReward
65+
| ApiOffChainApyReward;
5866

5967
export interface ApiMarketEModeSettings {
6068
marketAddress: Address;

apps/evm/src/components/Apy/BoostTooltip/index.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ export const BoostTooltip: React.FC<BoostTooltipProps> = ({
3636
{
3737
name:
3838
type === 'supply'
39-
? t('apy.boost.tooltip.baseSupplyApyLabel')
40-
: t('apy.boost.tooltip.baseBorrowApyLabel'),
39+
? t('apy.boost.tooltip.supplyApy.name')
40+
: t('apy.boost.tooltip.borrowApy.name'),
4141
value: formatPercentageToReadableValue(baseApyPercentage),
4242
logoSrc: token.iconSrc,
43+
description:
44+
type === 'supply'
45+
? t('apy.boost.tooltip.supplyApy.description')
46+
: t('apy.boost.tooltip.borrowApy.description'),
4347
},
4448
];
4549

@@ -94,6 +98,17 @@ export const BoostTooltip: React.FC<BoostTooltipProps> = ({
9498

9599
return listItems.push(distribution);
96100
}
101+
102+
if (d.type === 'off-chain') {
103+
const distribution: DistributionProps = {
104+
name: t('apy.boost.tooltip.offChainApy.name'),
105+
description: t('apy.boost.tooltip.offChainApy.description'),
106+
value: formatPercentageToReadableValue(d.apyPercentage),
107+
logoSrc: d.token.iconSrc,
108+
};
109+
110+
return listItems.push(distribution);
111+
}
97112
}, []);
98113

99114
// Add Prime distribution

apps/evm/src/libs/translations/translations/en.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,31 @@
177177
"boost": {
178178
"iconAlt": "Boosted market icon",
179179
"tooltip": {
180-
"baseBorrowApyLabel": "Borrow APY",
181-
"baseSupplyApyLabel": "Supply APY",
180+
"borrowApy": {
181+
"description": "The accruing interest when borrowing this asset from the Venus Protocol.",
182+
"name": "Borrow APY"
183+
},
182184
"defaultMerklRewardName": "Merkl rewards",
183185
"externalRewardDescription": "Rewards from this external program can be claimed through their <AppLink>official app</AppLink>. The Venus protocol does not guarantee them and accepts no liability.",
184186
"intrinsicApy": {
185-
"description": "Yield generated by the supplied asset, independent of lending yield from Venus. Commonly from staking or other external rewards.",
187+
"description": "The native yield from the underlying asset itself — for example, staking rewards. This yield originates from external sources and is not guaranteed by Venus Protocol.",
186188
"name": "Intrinsic APY"
187189
},
190+
"offChainApy": {
191+
"description": "Additional yield from off-chain activities, such as airdrop or promotional campaigns, managed by third parties. This yield is not guaranteed by Venus Protocol.",
192+
"name": "Off-chain APY"
193+
},
188194
"pointDistribution": {
189195
"learnMore": "Learn more"
190196
},
191197
"primeDistribution": {
192198
"description": "Venus Prime rewards dedicated users with boosted rewards. The Venus protocol does not guarantee these rewards and accepts no liability.",
193199
"name": "Prime APY"
194200
},
201+
"supplyApy": {
202+
"description": "The total yield earned by supplying your asset to Venus Protocol.",
203+
"name": "Supply APY"
204+
},
195205
"xvsDistribution": {
196206
"description": "Distribution rewards are initiated and implemented by the decentralized Venus community. The Venus protocol does not guarantee them and accepts no liability.",
197207
"name": "XVS distribution"
@@ -239,11 +249,13 @@
239249
},
240250
"assetInfo": {
241251
"borrowApy": "Borrow APY",
242-
"intrinsicApy": "Intrinsic APY ({{tokenSymbol}})",
243252
"distributionApy": "Distribution APY ({{tokenSymbol}})",
244253
"distributionTooltip": "Distribution rewards are initiated and implemented by the decentralized Venus community. The Venus protocol does not guarantee them and accepts no liability.",
245-
"intrinsicApyTooltip": "APY earned directly from the asset itself (e.g. staking or external rewards), separate from Venus lending yield. The Venus protocol does not guarantee them and accepts no liability.",
246254
"externalDistributionApy": "{{description}} APY ({{tokenSymbol}})",
255+
"intrinsicApy": "Intrinsic APY ({{tokenSymbol}})",
256+
"intrinsicApyTooltip": "APY earned directly from the asset itself (e.g. staking or external rewards), separate from Venus lending yield. The Venus protocol does not guarantee them and accepts no liability.",
257+
"offChainApy": "Off-chain APY ({{tokenSymbol}})",
258+
"offChainApyTooltip": "Additional yield from off-chain activities, such as airdrop or promotional campaigns, managed by third parties. The Venus protocol does not guarantee them and accepts no liability.",
247259
"primeApy": "Prime APY ({{tokenSymbol}})",
248260
"supplyApy": "Supply APY",
249261
"totalApy": {

apps/evm/src/pages/Market/OperationForm/AssetInfo/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ export const AssetInfo: React.FC<AssetInfoProps> = ({
123123
if (distribution.type === 'intrinsic') {
124124
label = t('assetInfo.intrinsicApy', { tokenSymbol: distribution.token.symbol });
125125
}
126+
if (distribution.type === 'off-chain') {
127+
label = t('assetInfo.offChainApy', { tokenSymbol: distribution.token.symbol });
128+
}
126129
const children =
127130
distribution.type === 'prime' ? (
128131
<ValueUpdate
@@ -146,6 +149,9 @@ export const AssetInfo: React.FC<AssetInfoProps> = ({
146149
if (distribution.type === 'intrinsic') {
147150
tooltip = t('assetInfo.intrinsicApyTooltip');
148151
}
152+
if (distribution.type === 'off-chain') {
153+
tooltip = t('assetInfo.offChainApyTooltip');
154+
}
149155

150156
const row: LabeledInlineContentProps = {
151157
label,

apps/evm/src/types/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Token as PSToken } from '@pancakeswap/sdk';
22
import type { ChainId, Token, VToken } from '@venusprotocol/chains';
3+
import type { Omit } from '@wagmi/core/internal';
34
import type BigNumber from 'bignumber.js';
45
import type { Address, ByteArray, Hex } from 'viem';
56

@@ -97,12 +98,17 @@ export interface IntrinsicApyDistribution {
9798
};
9899
}
99100

101+
export type OffChainApyDistribution = Omit<IntrinsicApyDistribution, 'type' | 'rewardDetails'> & {
102+
type: 'off-chain';
103+
};
104+
100105
export type TokenDistribution =
101106
| RewardDistributorDistribution
102107
| PrimeDistribution
103108
| PrimeSimulationDistribution
104109
| MerklDistribution
105-
| IntrinsicApyDistribution;
110+
| IntrinsicApyDistribution
111+
| OffChainApyDistribution;
106112

107113
export interface PointDistribution {
108114
title: string;

apps/evm/src/utilities/getCombinedDistributionApys/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const aggregatePercentages = ({ distributions }: AggregatePercentagesInput) =>
1616
if (
1717
distribution.type === 'venus' ||
1818
distribution.type === 'merkl' ||
19-
distribution.type === 'intrinsic'
19+
distribution.type === 'intrinsic' ||
20+
distribution.type === 'off-chain'
2021
) {
2122
return {
2223
...acc,

0 commit comments

Comments
 (0)