Skip to content

Commit 596afc5

Browse files
authored
Merge branch 'main' into feature/dvxsdk-65-add-sdk-stable-support
2 parents 2a300de + 41e9c96 commit 596afc5

File tree

93 files changed

+6432
-1955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+6432
-1955
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MAINNET_RPC_URL=
2+
BASE_RPC_URL=

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"esbenp.prettier-vscode",
4+
"JuanBlanco.solidity",
45
"biomejs.biome"
56
]
67
}

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
"[markdown]": {
88
"editor.defaultFormatter": "esbenp.prettier-vscode"
99
},
10+
"[solidity]": {
11+
"editor.defaultFormatter": "JuanBlanco.solidity"
12+
},
1013
"[typescript]": {
1114
"editor.defaultFormatter": "biomejs.biome"
12-
}
15+
},
16+
"solidity.formatter": "forge"
1317
}

docs/adding-new-chain.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ Add your chain's contract addresses to the `_addressesRegistry` mapping:
6161
},
6262
```
6363

64+
Remember to register the USDC address if it supports ERC-2612 permit version 2, otherwise the signature will default to permit version 1 (if `hasSimplePermit` is set to true).
65+
Also make sure to add the Permit2 contract (if available) to enable transactional flows using Permit2, otherwise the approval will default to the classic erc20 approval.
66+
6467
### 4. Add Deployment Blocks
6568

6669
**File:** `packages/blue-sdk/src/addresses.ts`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"lint-staged": "^15.4.3",
4343
"semver": "^7.7.1",
4444
"typescript": "^5.7.2",
45-
"viem": "^2.23.0",
45+
"viem": "^2.33.3",
4646
"vitest": "^3.0.5"
4747
},
4848
"lint-staged": {

packages/blue-api-sdk/src/cache.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ export const typePolicies = {
979979
fields: {
980980
shares: { read: readMaybeBigInt },
981981
assets: { read: readMaybeBigInt },
982+
pnl: { read: readMaybeBigInt },
982983
},
983984
},
984985
VaultV2Sentinel: {

packages/blue-api-sdk/src/types.ts

Lines changed: 165 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export type Market = {
435435
riskAnalysis: Array<RiskAnalysis>;
436436
/** Current state */
437437
state: Maybe<MarketState>;
438-
/** Vaults with the market in supply queue */
438+
/** Whitelisted vaults having the market enabled with a non-zero cap. */
439439
supplyingVaults: Array<Vault>;
440440
targetBorrowUtilization: Scalars["BigInt"]["output"];
441441
targetWithdrawUtilization: Scalars["BigInt"]["output"];
@@ -2031,6 +2031,12 @@ export type PaginatedVaultV2Factories = {
20312031
pageInfo: Maybe<PageInfo>;
20322032
};
20332033

2034+
export type PaginatedVaultV2HistoricalCaps = {
2035+
__typename?: "PaginatedVaultV2HistoricalCaps";
2036+
items: Maybe<Array<VaultV2HistoricalCaps>>;
2037+
pageInfo: Maybe<PageInfo>;
2038+
};
2039+
20342040
export type PaginatedVaultV2Positions = {
20352041
__typename?: "PaginatedVaultV2Positions";
20362042
items: Maybe<Array<VaultV2Position>>;
@@ -2778,23 +2784,24 @@ export type User = {
27782784
tag: Maybe<Scalars["String"]["output"]>;
27792785
transactions: Array<Transaction>;
27802786
vaultPositions: Array<VaultPosition>;
2781-
/** @deprecated WIP */
27822787
vaultV2Positions: Array<VaultV2Position>;
27832788
};
27842789

27852790
/** User state history */
27862791
export type UserHistory = {
27872792
__typename?: "UserHistory";
27882793
/** Total borrow assets of all the user's market positions, in USD. */
2789-
marketsBorrowAssetsUsd: Maybe<Array<FloatDataPoint>>;
2794+
marketsBorrowAssetsUsd: Array<FloatDataPoint>;
27902795
/** Total collateral of all the user's market positions, in USD. */
2791-
marketsCollateralUsd: Maybe<Array<FloatDataPoint>>;
2796+
marketsCollateralUsd: Array<FloatDataPoint>;
27922797
/** Total margin of all the user's market positions, in USD. */
2793-
marketsMarginUsd: Maybe<Array<FloatDataPoint>>;
2798+
marketsMarginUsd: Array<FloatDataPoint>;
27942799
/** Total supply assets of all the user's market positions, in USD. */
2795-
marketsSupplyAssetsUsd: Maybe<Array<FloatDataPoint>>;
2800+
marketsSupplyAssetsUsd: Array<FloatDataPoint>;
2801+
/** Total value of all the user's VaultV2 positions, in USD. */
2802+
vaultV2sAssetsUsd: Array<FloatDataPoint>;
27962803
/** Total value of all the user's vault positions, in USD. */
2797-
vaultsAssetsUsd: Maybe<Array<FloatDataPoint>>;
2804+
vaultsAssetsUsd: Array<FloatDataPoint>;
27982805
};
27992806

28002807
/** User state history */
@@ -2817,6 +2824,11 @@ export type UserHistoryMarketsSupplyAssetsUsdArgs = {
28172824
options?: InputMaybe<TimeseriesOptions>;
28182825
};
28192826

2827+
/** User state history */
2828+
export type UserHistoryVaultV2sAssetsUsdArgs = {
2829+
options?: InputMaybe<TimeseriesOptions>;
2830+
};
2831+
28202832
/** User state history */
28212833
export type UserHistoryVaultsAssetsUsdArgs = {
28222834
options?: InputMaybe<TimeseriesOptions>;
@@ -2853,6 +2865,12 @@ export type UserState = {
28532865
marketsSupplyPnlUsd: Maybe<Scalars["Float"]["output"]>;
28542866
/** Return Over Equity of the supply side of all the user's market positions, taking into account prices variation. */
28552867
marketsSupplyRoeUsd: Maybe<Scalars["Float"]["output"]>;
2868+
/** Total value of all the user's VaultV2 positions, in USD. */
2869+
vaultV2sAssetsUsd: Maybe<Scalars["Float"]["output"]>;
2870+
/** Profit (from the underlying asset's price variation) & Loss (from bad debt socialization) of all the user's VaultV2 positions, in USD. */
2871+
vaultV2sPnlUsd: Maybe<Scalars["Float"]["output"]>;
2872+
/** Return Over Equity of all the user's VaultV2 positions, taking into account prices variation. */
2873+
vaultV2sRoeUsd: Maybe<Scalars["Float"]["output"]>;
28562874
/** Total value of all the user's vault positions, in USD. */
28572875
vaultsAssetsUsd: Maybe<Scalars["Float"]["output"]>;
28582876
/** Profit (from the underlying asset's price variation) & Loss (from bad debt socialization) of all the user's vault positions, in USD. */
@@ -3471,9 +3489,9 @@ export type VaultPositionHistory = {
34713489
assets: Maybe<Array<BigIntDataPoint>>;
34723490
/** Value of the position since its inception, in USD. */
34733491
assetsUsd: Maybe<Array<FloatDataPoint>>;
3474-
/** Profit (from the underlying asset's price variation) & Loss (from bad debt socialization) of the position since its inception, in underlying assets. */
3492+
/** Profit & Loss of the position (due to the interest) of the position since its inception, in underlying assets. */
34753493
pnl: Maybe<Array<BigIntDataPoint>>;
3476-
/** Profit (from the underlying asset's price variation) & Loss (from bad debt socialization) of the position since its inception, in USD for display purposes. */
3494+
/** Profit & Loss of the position (due to the asset's price variation and interest) since its inception, in USD. */
34773495
pnlUsd: Maybe<Array<FloatDataPoint>>;
34783496
/** Return Over Equity of the position since its inception. */
34793497
roe: Maybe<Array<FloatDataPoint>>;
@@ -3532,7 +3550,7 @@ export type VaultPositionState = {
35323550
id: Scalars["ID"]["output"];
35333551
/** Profit & Loss of the position (due to the interest) since its inception, in loan assets. */
35343552
pnl: Maybe<Scalars["BigInt"]["output"]>;
3535-
/** Profit & Loss of the position's supply side (due to the asset's price variation and interest) since its inception, in USD. */
3553+
/** Profit & Loss of the position (due to the asset's price variation and interest) since its inception, in USD. */
35363554
pnlUsd: Maybe<Scalars["Float"]["output"]>;
35373555
/** Return Over Equity of the position since its inception. */
35383556
roe: Maybe<Scalars["Float"]["output"]>;
@@ -3742,9 +3760,9 @@ export type VaultV2 = {
37423760
address: Scalars["Address"]["output"];
37433761
allocators: Array<VaultV2Allocator>;
37443762
asset: Asset;
3745-
/** 6hr average apy of the vault. At the moment, this is not the realized apy but the compounded weighted average apr of all adapters (capped by max rate) */
3763+
/** Realized average APY of the vault, calculated from share price evolution over a predefined lookback period. Uses normalized timestamps (rounded to hour/day/week boundaries) for optimal caching and performance. Available periods: 1h, 6h (default), 1d, 7d, 30d, 90d, 1y, or 'inception' for all-time APY. */
37463764
avgApy: Maybe<Scalars["Float"]["output"]>;
3747-
/** 6hr average apy of the vault. At the moment, this is not the realized apy but the compounded weighted average apr of all adapters (capped by max rate), minus vault V2 fees, plus the instantaneous rewards distributed to vault users */
3765+
/** Realized average net APY of the vault (after fees, with rewards), calculated from share price evolution over a predefined lookback period. Uses normalized timestamps (rounded to hour/day/week boundaries) for optimal caching and performance. Available periods: 1h, 6h (default), 1d, 7d, 30d, 90d, 1y, or 'inception' for all-time net APY. */
37483766
avgNetApy: Maybe<Scalars["Float"]["output"]>;
37493767
caps: PaginatedVaultV2Caps;
37503768
chain: Chain;
@@ -3760,9 +3778,9 @@ export type VaultV2 = {
37603778
*/
37613779
historicalState: VaultV2History;
37623780
id: Scalars["ID"]["output"];
3763-
/** The assets deposited to the vault that are not generating interests. */
3781+
/** The assets deposited to the vault that are not generating interest. */
37643782
idleAssets: Scalars["BigInt"]["output"];
3765-
/** The USD value of assets deposited to the vault that are not generating interests. */
3783+
/** The USD value of assets deposited to the vault that are not generating interest. */
37663784
idleAssetsUsd: Maybe<Scalars["Float"]["output"]>;
37673785
/** The liquidity available from the liquidity adapter + idle assets. */
37683786
liquidity: Scalars["BigInt"]["output"];
@@ -3772,6 +3790,8 @@ export type VaultV2 = {
37723790
/** Annual management fee rate (unitless fraction, e.g., 0.025 for 2.5%) */
37733791
managementFee: Scalars["Float"]["output"];
37743792
managementFeeRecipient: Scalars["Address"]["output"];
3793+
/** Max APY */
3794+
maxApy: Scalars["BigInt"]["output"];
37753795
/** Max rate per second */
37763796
maxRate: Scalars["BigInt"]["output"];
37773797
metadata: Maybe<VaultV2Metadata>;
@@ -3801,6 +3821,14 @@ export type VaultV2AdaptersArgs = {
38013821
skip?: InputMaybe<Scalars["Int"]["input"]>;
38023822
};
38033823

3824+
export type VaultV2AvgApyArgs = {
3825+
lookback?: InputMaybe<VaultV2LookbackPeriod>;
3826+
};
3827+
3828+
export type VaultV2AvgNetApyArgs = {
3829+
lookback?: InputMaybe<VaultV2LookbackPeriod>;
3830+
};
3831+
38043832
export type VaultV2CapsArgs = {
38053833
first?: InputMaybe<Scalars["Int"]["input"]>;
38063834
skip?: InputMaybe<Scalars["Int"]["input"]>;
@@ -3899,13 +3927,36 @@ export type VaultV2Factory = {
38993927
id: Scalars["ID"]["output"];
39003928
};
39013929

3930+
/** Vault V2 historical allocation data per cap */
3931+
export type VaultV2HistoricalCaps = {
3932+
__typename?: "VaultV2HistoricalCaps";
3933+
/** Absolute cap limit for this cap, in vault asset units */
3934+
absoluteCap: Array<BigIntDataPoint>;
3935+
/** Allocated assets in this cap, in vault asset units */
3936+
allocation: Array<BigIntDataPoint>;
3937+
/** Allocated assets in USD for display purpose */
3938+
allocationUsd: Array<FloatDataPoint>;
3939+
/** The cap this allocation refers to */
3940+
cap: Maybe<VaultV2Caps>;
3941+
/** Relative allocation (allocation / totalAssets) */
3942+
relativeAllocation: Array<FloatDataPoint>;
3943+
/** Relative cap limit for this cap, in vault asset units */
3944+
relativeCap: Array<BigIntDataPoint>;
3945+
};
3946+
39023947
/** Vault V2 history */
39033948
export type VaultV2History = {
39043949
__typename?: "VaultV2History";
39053950
/** Average APY computed from share price evolution over a lookback period (1-24 hours). Returns annualized compound rate. */
39063951
avgApy: Array<FloatDataPoint>;
39073952
/** Average Net APY computed from share price evolution over a lookback period (1-24 hours). Returns annualized compound rate. Includes rewards and deductedfees. */
39083953
avgNetApy: Array<FloatDataPoint>;
3954+
/** Historical allocation data grouped by caps. Returns allocation timeseries for requested caps within the requested timerange. */
3955+
caps: PaginatedVaultV2HistoricalCaps;
3956+
/** The assets deposited to the vault that are not generating interest. */
3957+
idleAssets: Array<BigIntDataPoint>;
3958+
/** Idle assets in USD for display purpose. */
3959+
idleAssetsUsd: Array<FloatDataPoint>;
39093960
/** Real assets in the vault (excluding virtual accrual). */
39103961
realAssets: Array<BigIntDataPoint>;
39113962
/** Real assets in USD for display purpose. */
@@ -3932,6 +3983,22 @@ export type VaultV2HistoryAvgNetApyArgs = {
39323983
options?: InputMaybe<TimeseriesOptions>;
39333984
};
39343985

3986+
/** Vault V2 history */
3987+
export type VaultV2HistoryCapsArgs = {
3988+
capType_in?: InputMaybe<Array<VaultV2CapType>>;
3989+
options?: InputMaybe<TimeseriesOptions>;
3990+
};
3991+
3992+
/** Vault V2 history */
3993+
export type VaultV2HistoryIdleAssetsArgs = {
3994+
options?: InputMaybe<TimeseriesOptions>;
3995+
};
3996+
3997+
/** Vault V2 history */
3998+
export type VaultV2HistoryIdleAssetsUsdArgs = {
3999+
options?: InputMaybe<TimeseriesOptions>;
4000+
};
4001+
39354002
/** Vault V2 history */
39364003
export type VaultV2HistoryRealAssetsArgs = {
39374004
options?: InputMaybe<TimeseriesOptions>;
@@ -3962,6 +4029,26 @@ export type VaultV2HistoryTotalSupplyArgs = {
39624029
options?: InputMaybe<TimeseriesOptions>;
39634030
};
39644031

4032+
/** Predefined lookback periods for vault APY calculations. Using these periods ensures better query performance through timestamp normalization and caching. */
4033+
export enum VaultV2LookbackPeriod {
4034+
/** Since vault inception (all-time) */
4035+
Inception = "INCEPTION",
4036+
/** 90 days (~3 months) lookback period */
4037+
NinetyDays = "NINETY_DAYS",
4038+
/** 1 day (24 hours) lookback period */
4039+
OneDay = "ONE_DAY",
4040+
/** 1 hour lookback period */
4041+
OneHour = "ONE_HOUR",
4042+
/** 1 year (365 days) lookback period */
4043+
OneYear = "ONE_YEAR",
4044+
/** 7 days (1 week) lookback period */
4045+
SevenDays = "SEVEN_DAYS",
4046+
/** 6 hours lookback period (default) */
4047+
SixHours = "SIX_HOURS",
4048+
/** 30 days (~1 month) lookback period */
4049+
ThirtyDays = "THIRTY_DAYS",
4050+
}
4051+
39654052
/** Vault V2 metadata */
39664053
export type VaultV2Metadata = {
39674054
__typename?: "VaultV2Metadata";
@@ -3981,13 +4068,77 @@ export type VaultV2Position = {
39814068
/** Value of vault shares held, in USD. */
39824069
assetsUsd: Maybe<Scalars["Float"]["output"]>;
39834070
chain: Chain;
4071+
/** Timeseries history for each of this position's stats. */
4072+
history: VaultV2PositionHistory;
39844073
id: Scalars["ID"]["output"];
4074+
/** Profit & Loss of the position (due to the interest) since its inception, in loan assets. */
4075+
pnl: Maybe<Scalars["BigInt"]["output"]>;
4076+
/** Profit & Loss of the position (due to the asset's price variation and interest) since its inception, in USD. */
4077+
pnlUsd: Maybe<Scalars["Float"]["output"]>;
4078+
/** Return Over Equity of the position since its inception. */
4079+
roe: Maybe<Scalars["Float"]["output"]>;
4080+
/** Return Over Equity of the position since its inception, taking into account the underlying asset's price variation. */
4081+
roeUsd: Maybe<Scalars["Float"]["output"]>;
39854082
/** Amount of vault shares */
39864083
shares: Scalars["BigInt"]["output"];
39874084
user: User;
39884085
vault: VaultV2;
39894086
};
39904087

4088+
/** Vault V2 position history */
4089+
export type VaultV2PositionHistory = {
4090+
__typename?: "VaultV2PositionHistory";
4091+
/** Value of the position since its inception, in underlying assets. */
4092+
assets: Maybe<Array<BigIntDataPoint>>;
4093+
/** Value of the position since its inception, in USD. */
4094+
assetsUsd: Maybe<Array<FloatDataPoint>>;
4095+
/** Profit & Loss of the position (due to the interest) of the position since its inception, in underlying assets. */
4096+
pnl: Maybe<Array<BigIntDataPoint>>;
4097+
/** Profit & Loss of the position (due to the asset's price variation and interest) since its inception, in USD. */
4098+
pnlUsd: Maybe<Array<FloatDataPoint>>;
4099+
/** Return Over Equity of the position since its inception. */
4100+
roe: Maybe<Array<FloatDataPoint>>;
4101+
/** Return Over Equity of the position since its inception, taking into account the underlying asset's price variation. */
4102+
roeUsd: Maybe<Array<FloatDataPoint>>;
4103+
/** Value of the position since its inception, in vault shares. */
4104+
shares: Maybe<Array<BigIntDataPoint>>;
4105+
};
4106+
4107+
/** Vault V2 position history */
4108+
export type VaultV2PositionHistoryAssetsArgs = {
4109+
options?: InputMaybe<TimeseriesOptions>;
4110+
};
4111+
4112+
/** Vault V2 position history */
4113+
export type VaultV2PositionHistoryAssetsUsdArgs = {
4114+
options?: InputMaybe<TimeseriesOptions>;
4115+
};
4116+
4117+
/** Vault V2 position history */
4118+
export type VaultV2PositionHistoryPnlArgs = {
4119+
options?: InputMaybe<TimeseriesOptions>;
4120+
};
4121+
4122+
/** Vault V2 position history */
4123+
export type VaultV2PositionHistoryPnlUsdArgs = {
4124+
options?: InputMaybe<TimeseriesOptions>;
4125+
};
4126+
4127+
/** Vault V2 position history */
4128+
export type VaultV2PositionHistoryRoeArgs = {
4129+
options?: InputMaybe<TimeseriesOptions>;
4130+
};
4131+
4132+
/** Vault V2 position history */
4133+
export type VaultV2PositionHistoryRoeUsdArgs = {
4134+
options?: InputMaybe<TimeseriesOptions>;
4135+
};
4136+
4137+
/** Vault V2 position history */
4138+
export type VaultV2PositionHistorySharesArgs = {
4139+
options?: InputMaybe<TimeseriesOptions>;
4140+
};
4141+
39914142
/** Vault V2 sentinel */
39924143
export type VaultV2Sentinel = {
39934144
__typename?: "VaultV2Sentinel";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
// Copyright (c) 2025 Morpho Association
3+
pragma solidity >=0.5.0;
4+
5+
interface IERC2612 {
6+
function permit(address owner, address spender, uint256 shares, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
7+
external;
8+
function nonces(address owner) external view returns (uint256);
9+
function DOMAIN_SEPARATOR() external view returns (bytes32);
10+
}

0 commit comments

Comments
 (0)