Instance of the position of a specific user on a specific market
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 = newAccrualPosition(
newPosition({
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).
Addresses customization
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.
✅ Use Cases
Injecting additional or missing contract addresses on known chains.
Providing a full set of addresses for an unknown (custom) chain.
Registering mappings of wrapped → unwrapped tokens per chain (e.g., WETH → ETH).
Function Signature
registerCustomAddresses(options?: {
addresses?: Record<number, ChainAddresses>; // Can be a subset of ChainAddresses if chain is known
unwrappedTokens?: Record<number, Record<Address, Address>>;
}): void
Parameters
addresses(optional)
A map of chainId → ChainAddresses.
For known chains, partial overrides are allowed (e.g., add a missing adapter).
For unknown chains, a complete ChainAddresses object with required addresses must be provided.
Throws an error if you attempt to override an existing address.
unwrappedTokens(optional)
A map of chainId → { wrapped → unwrapped }.
Throws an error if you attempt to override an existing mapping.
Behavior
Merges user-provided addresses and unwrapped tokens into the internal registries.
Uses a deep merge with custom logic to prevent overwriting existing values.
Updates internal constants: addressesRegistry, addresses, and unwrappedTokensMapping.
Applies Object.freeze() to ensure immutability.
Example
registerCustomAddresses({
addresses: {
8453: { stEth: "0xabc..." }, // provide stEth address on base31337: {
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 4,087 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.
Package last updated on 12 Aug 2025
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.
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.