
Product
Unify Your Security Stack with Socket Basics
A single platform for static analysis, secrets detection, container scanning, and CVE checksβbuilt on trusted open source tools, ready to run out of the box.
@morpho-org/blue-sdk
Advanced tools
Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).
Framework-agnostic package that defines Morpho-related entity classes:
MarketParams
: represents the immutable configuration of a market on MorphoMarket
: represents the state of a market on MorphoToken
: represents a ERC20 tokenUser
: represents a user of MorphoVaultConfig
: represents the configuration of a Morpho VaultVault
: represents the state of a Morpho VaultVaultUser
: represents the state of a user on a Morpho VaultVaultMarketAllocation
: represents the allocation (and configuration) of a Morpho Vault on a Morpho marketnpm install @morpho-org/blue-sdk
yarn add @morpho-org/blue-sdk
Leverage the MarketParams
class to manipulate a given market's immutable configuration:
import { MarketParams } from "@morpho-org/blue-sdk";
const config = new MarketParams({
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
lltv: 94_5000000000000000n, // 94.5%
});
config.liquidationIncentiveFactor; // e.g. 1_090000000000000000n (109%).
Leverage the Market
class to manipulate a specific market:
import { Market, MarketParams } from "@morpho-org/blue-sdk";
import { Time } from "@morpho-org/morpho-ts";
const market = new Market({
config: new MarketParams({
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
lltv: 94_5000000000000000n, // 94.5%
}),
totalSupplyAssets: 1000_000000000000000000n,
totalBorrowAssets: 920_000000000000000000n,
totalSupplyShares: 1000_000000000000000000000000n,
totalBorrowShares: 920_000000000000000000000000n,
lastUpdate: 1721000000n,
fee: 0n,
price: 1_100000000000000000000000000000000000n,
rateAtTarget: 94850992095n,
});
market.utilization; // e.g. 92_0000000000000000n (92%).
market.liquidity; // e.g. 80_000000000000000000n (in loan assets).
market.apyAtTarget; // e.g. 3_0000000000000000n (3%).
const accruedMarket = market.accrueInterest(Time.timestamp()); // Accrue interest to the latest's timestamp.
accruedMarket.toSupplyAssets(shares); // Convert supply shares to assets.
Leverage the Position
class to manipulate the position of a user on a given market:
import { Position } from "@morpho-org/blue-sdk";
import { Time } from "@morpho-org/morpho-ts";
const position = new AccrualPosition(
new Position({
user,
marketId: market.id,
supplyShares: 0n,
borrowShares: 20_000000000000000000000000n,
collateral: 27_000000000000000000n,
}),
market
);
position.borrowAssets; // e.g. 20_000000000000000000n (in loan assets).
position.isHealthy; // e.g. true.
position.maxBorrowableAssets; // e.g. 2100_000000000000000000n (in loan assets).
const accruedPosition = position.accrueInterest(Time.timestamp()); // Accrue interest to the latest's timestamp.
position.borrowAssets; // e.g. 20_400000000000000000n (in loan assets).
registerCustomAddresses
Extends the default address registry and unwrapped token mapping for known or custom chains. Useful for testing or adding support for new networks.
[!Note]
- Custom addresses should be registered statically, at the root level.
- Custom addresses can't be removed nor changed.
registerCustomAddresses(options?: {
addresses?: Record<number, ChainAddresses>; // Can be a subset of ChainAddresses if chain is known
unwrappedTokens?: Record<number, Record<Address, Address>>;
}): void
addresses
(optional)
A map of chainId β ChainAddresses
.
ChainAddresses
object with required addresses must be provided.unwrappedTokens
(optional)
A map of chainId β { wrapped β unwrapped }
.
addressesRegistry
, addresses
, and unwrappedTokensMapping
.Object.freeze()
to ensure immutability.registerCustomAddresses({
addresses: {
8453: { stEth: "0xabc..." }, // provide stEth address on base
31337: {
morpho: "0x123...",
bundler3: {
bundler3: "0x456...",
...
},
...
}, // registers a new local test chain
},
unwrappedTokens: {
31337: {
"0xWrapped": "0xUnwrapped" // e.g., WETH β ETH
}
}
});
FAQs
Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).
The npm package @morpho-org/blue-sdk receives a total of 5,515 weekly downloads. As such, @morpho-org/blue-sdk popularity was classified as popular.
We found that @morpho-org/blue-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checksβbuilt on trusted open source tools, ready to run out of the box.
Product
Socket is launching experimental protection for the Hugging Face ecosystem, scanning for malware and malicious payload injections inside model files to prevent silent AI supply chain attacks.
Research
/Security News
The Socket Threat Research Team uncovered a coordinated campaign that floods the Chrome Web Store with 131 rebranded clones of a WhatsApp Web automation extension to spam Brazilian users.