# Moonwell SDK
## Example
This is an example page.
## Hello world
This is me.
With some Tailwind CSS
import InstallCommandTabs from '../../components/InstallCommandTabs.mdx'
## Getting Started \[Integrate Moonwell SDK with just a few lines of code]
### Overview
Moonwell SDK is a TypeScript library that provides a simple and intuitive way to interact with Moonwell's lending protocol. It offers a comprehensive set of tools for querying market data across multiple networks including Base and Optimism.
Key features:
* 🔌 Easy network configuration
* 📊 Real-time market data access
* 📱 Multi-network support
### Installation
### Quick Start
#### 1. Set up your Networks & RPC urls
```ts twoslash
import { createMoonwellClient } from '@moonwell-fi/moonwell-sdk';
const moonwellClient = createMoonwellClient({ // [!code focus]
networks: { // [!code focus]
base: { // [!code focus]
rpcUrls: ["https://base.llamarpc.com"], // [!code focus]
}, // [!code focus]
optimism: { // [!code focus]
rpcUrls: ["https://optimism.llamarpc.com"], // [!code focus]
}, // [!code focus]
}, // [!code focus]
}); // [!code focus]
```
:::info
In a production app, it is highly recommended to pass through your authenticated RPC provider URL (Alchemy, Infura, Ankr, etc). If no URL is provided, moonwell-sdk will default to a public RPC provider.
:::
#### 2. Consume Actions
Now that you have a Client set up, you can now interact with Base and consume [Actions](/docs/actions/core/getMarkets)!
```ts twoslash
// [!include ~/snippets/moonClient.ts]
const markets = await moonwellClient.getMarkets(); // [!code focus]
```
### Live Example
import InstallCommandTabs from '../../components/InstallCommandTabs.mdx'
## Installation
Install Moonwell SDK via your package manager.
### Package Manager
Install the required packages.
## Types \[Glossary of Types in moonwell-sdk]
### `Market`
Represents a lending/borrowing market in the Moonwell protocol, containing information such as interest rates, total supply, total borrow, and other market-specific metrics.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/market.ts)
### `UserBalance`
Contains information about a user's token balances, including wallet balance, allowance, and other token-specific balance information.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/userBalance.ts)
### `UserPosition`
Represents a user's position in a specific market, including their supplied and borrowed amounts, collateral status, and other position-specific details.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/userPosition.ts)
### `UserReward`
Contains information about rewards earned by a user from various protocol activities, including reward rates and accrued amounts.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/userReward.ts)
### `Proposal`
Represents a governance proposal in the Moonwell protocol, including proposal details, voting status, and execution information.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/proposal.ts)
### `SnapshotProposal`
Contains information about off-chain governance proposals created through Snapshot, including proposal content and voting parameters.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/snapshotProposal.ts)
### `Delegate`
Represents delegation information, including delegator and delegate addresses and voting power.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/delegate.ts)
### `Discussion`
Contains information about governance-related discussions, including discussion content, participants, and metadata.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/discussion.ts)
### `Amount`
A utility class for handling token amounts with precision, providing methods for mathematical operations and conversions between different decimal representations.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/common/amount.ts)
### `StakingInfo`
Contains global staking information for the protocol, including total staked amounts, reward rates, and other staking parameters.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/staking.ts)
### `StakingSnapshot`
Represents a point-in-time snapshot of staking metrics, useful for historical analysis and tracking changes over time.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/staking.ts)
### `UserStakingInfo`
Contains information about a specific user's staking position, including staked amounts, unclaimed rewards, and other user-specific staking details.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/staking.ts)
### `VoteReceipt`
Records information about a user's vote on a governance proposal, including voting power used and voting direction.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/voteReceipt.ts)
### `UserVotingPowers`
Contains information about a user's voting power across different governance mechanisms, including delegated and received voting power.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/userVotingPowers.ts)
### `CirculatingSupplySnapshot`
Represents a point-in-time snapshot of token circulating supply metrics, useful for tracking token distribution and supply changes.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/circulatingSupply.ts)
### `MarketSnapshot`
Contains a point-in-time snapshot of market metrics, including interest rates, total supply, total borrow, and other market parameters.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/market.ts)
### `MorphoMarket`
Represents a market in the Morpho protocol integration, containing market-specific parameters and states for optimized lending.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/morphoMarket.ts)
### `MorphoMarketUserPosition`
Contains information about a user's position in a Morpho market, including supplied and borrowed amounts through the Morpho protocol.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/morphoUserPosition.ts)
### `MorphoUserReward`
Represents rewards earned by a user through participation in Morpho markets, including reward rates and accrued amounts.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/morphoUserReward.ts)
### `MorphoVault`
Contains information about a Morpho vault, including vault parameters, total deposits, and other vault-specific metrics.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/morphoVault.ts)
### `MorphoVaultSnapshot`
Represents a point-in-time snapshot of Morpho vault metrics, useful for tracking vault performance and changes over time.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/morphoVault.ts)
### `MorphoVaultUserPosition`
Contains information about a user's position in a Morpho vault, including deposited amounts and other position-specific details.
[See Type](https://github.com/moonwell-fi/moonwell-sdk/blob/main/src/types/morphoUserPosition.ts)
import NetworkMorphoMarketParameterInfo from "../../../../components/NetworkMorphoMarketParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoMarket
Retrieves detailed information about a specific Morpho market, including its current state, parameters, and optionally its reward configurations. The market can be queried either using chainId and marketId combination, or using network and market name.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const market = await moonwellClient.getMorphoMarket({ // [!code focus:4]
chainId: 8453,
marketId: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoMarket | undefined
```
* **Type:** [`MorphoMarket`](/docs/glossary/types#morphomarket)
### Parameters
#### includeRewards (optional)
* **Type:** `boolean`
Whether to include rewards in the response.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const market = await moonwellClient.getMorphoMarket({
chainId: 8453,
marketId: "0x0000000000000000000000000000000000000000",
includeRewards: true, // [!code focus]
});
```
#### chainId
* **Type:** `number`
The chain ID to get the market for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const market = await moonwellClient.getMorphoMarket({
chainId: 8453, // [!code focus]
marketId: "0x0000000000000000000000000000000000000000",
});
```
#### marketId
* **Type:** `Address`
The unique ID of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const market = await moonwellClient.getMorphoMarket({
chainId: 8453,
marketId: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the market for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const market = await moonwellClient.getMorphoMarket({
network: "base", // [!code focus]
market: "USDC-ETH",
});
```
#### market
* **Type:** `string`
The market to get.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const market = await moonwellClient.getMorphoMarket({
network: "base",
market: "USDC-ETH", // [!code focus]
});
```
import NetworkMorphoMarketParameterInfo from "../../../../components/NetworkMorphoMarketParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoMarketUserPosition
Retrieves detailed information about a user's position in a specific Morpho market, including their supplied and borrowed amounts, rewards, and other position-specific metrics.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const marketUserPosition = await moonwellClient.getMorphoMarketUserPosition({ // [!code focus:5]
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
marketId: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoMarketUserPosition | undefined
```
* **Type:** [`MorphoMarketUserPosition`](/docs/glossary/types#morphomarketuserposition)
### Parameters
#### userAddress
* **Type:** `Address`
The user address to get the market user position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const marketUserPosition = await moonwellClient.getMorphoMarketUserPosition({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
chainId: 8453,
marketId: "0x0000000000000000000000000000000000000000",
});
```
#### chainId
* **Type:** `number`
The chain ID to get the market user position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const marketUserPosition = await moonwellClient.getMorphoMarketUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
marketId: "0x0000000000000000000000000000000000000000",
});
```
#### marketId
* **Type:** `Address`
The unique ID of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const marketUserPosition = await moonwellClient.getMorphoMarketUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
marketId: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the market user position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const marketUserPosition = await moonwellClient.getMorphoMarketUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
market: "USDC-ETH",
});
```
#### market
* **Type:** `string`
The market to get the user position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const marketUserPosition = await moonwellClient.getMorphoMarketUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base",
market: "USDC-ETH", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoMarketUserPositions
Retrieves all active positions for a specific user across Morpho markets, including their supplied and borrowed assets, along with corresponding balances and other position-specific details.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const marketUserPositions = await moonwellClient.getMorphoMarketUserPositions({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoMarketUserPosition[]
```
* **Type:** [`MorphoMarketUserPosition[]`](/docs/glossary/types#morphomarketuserposition)
### Parameters
#### userAddress
* **Type:** `Address`
The user address to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const marketUserPositions = await moonwellClient.getMorphoMarketUserPositions({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const marketUserPositions = await moonwellClient.getMorphoMarketUserPositions({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const marketUserPositions = await moonwellClient.getMorphoMarketUserPositions({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoMarkets
Retrieves a comprehensive list of all Morpho lending and borrowing markets supported by Moonwell, including their current states, interest rates, and market-specific parameters. Each market contains detailed information about the underlying asset, total supply, total borrow, and current market conditions.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const markets = await moonwellClient.getMorphoMarkets(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoMarket[]
```
* **Type:** [`MorphoMarket[]`](/docs/glossary/types#morphomarket)
:::info[Nullable Fields]
The `collateralAssets` and `collateralAssetsUsd` fields may be `null` when the Morpho API returns no data for a market. This can occur for markets with no collateral deposited or during API data synchronization delays.
When consuming these fields, check for `null` to distinguish between "data unavailable" and "zero collateral":
```ts
if (market.collateralAssets === null) {
// Data not available from API
} else if (market.collateralAssets.value === 0) {
// Market has zero collateral
}
```
:::
### Parameters
#### includeRewards (optional)
* **Type:** `boolean`
Whether to include rewards in the response.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const markets = await moonwellClient.getMorphoMarkets({
includeRewards: true // [!code focus]
})
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the markets for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const markets = await moonwellClient.getMorphoMarkets({
chainId: 8453 // [!code focus]
})
```
#### network (optional)
* **Type:** `string`
The network to get the markets for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const markets = await moonwellClient.getMorphoMarkets({
network: "base", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoUserBalances
Retrieves all token balances for a specific user across Moonwell isolated markets.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const balances = await moonwellClient.getMorphoUserBalances({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserBalance[]
```
* **Type:** [`UserBalance[]`](/docs/glossary/types#morphouserbalance)
### Parameters
#### userAddress
* **Type:** `Address`
The user address to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const balances = await moonwellClient.getMorphoUserBalances({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const balances = await moonwellClient.getMorphoUserBalances({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const balances = await moonwellClient.getMorphoUserBalances({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoUserRewards
Retrieves all rewards earned and amounts for a specific user across Moonwell isolated markets.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const userRewards = await moonwellClient.getMorphoUserRewards({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
{/* :::details[Example]
::: */}
```
MorphoUserReward[]
```
* **Type:** [`MorphoUserReward[]`](/docs/glossary/types#morphouserreward)
### Parameters
#### userAddress
* **Type:** `Address`
The user address to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const userRewards = await moonwellClient.getMorphoUserRewards({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const userRewards = await moonwellClient.getMorphoUserRewards({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the market user positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const userRewards = await moonwellClient.getMorphoUserRewards({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
});
```
import NetworkMorphoVaultParameterInfo from "../../../../components/NetworkMorphoVaultParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoVault
Returns detailed information about a specific Moonwell Morpho Vault, including its current state, configuration, and optionally its reward data.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const vault = await moonwellClient.getMorphoVault({ // [!code focus:4]
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoVault | undefined
```
* **Type:** [`MorphoVault`](/docs/glossary/types#morphovault)
### Parameters
#### includeRewards
* **Type:** `boolean`
Whether to include rewards in the response.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vault = await moonwellClient.getMorphoVault({
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000",
includeRewards: true, // [!code focus]
});
```
#### chainId
* **Type:** `number`
The chain ID to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vault = await moonwellClient.getMorphoVault({
chainId: 8453, // [!code focus]
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
#### vaultAddress
* **Type:** `Address`
The address of the vault to get.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vault = await moonwellClient.getMorphoVault({
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vault = await moonwellClient.getMorphoVault({
network: "base", // [!code focus]
vault: "mwETH",
});
```
#### vault
* **Type:** `string`
The key of the vault to get.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vault = await moonwellClient.getMorphoVault({
network: "base",
vault: "mwETH", // [!code focus]
});
```
import NetworkMorphoVaultParameterInfo from "../../../../components/NetworkMorphoVaultParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoVaultSnapshots
Returns historical snapshots of a Moonwell Morpho Vault's state, including metrics like total supply and total borrow at different points in time.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const vaultSnapshots = await moonwellClient.getMorphoVaultSnapshots({ // [!code focus:4]
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoVaultSnapshot[]
```
* **Type:** [`MorphoVaultSnapshot[]`](/docs/glossary/types#morphovaultsnapshot)
### Parameters
#### chainId
* **Type:** `number`
The chain ID to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultSnapshots = await moonwellClient.getMorphoVaultSnapshots({
chainId: 8453, // [!code focus]
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
#### vaultAddress
* **Type:** `Address`
The address of the vault to get.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultSnapshots = await moonwellClient.getMorphoVaultSnapshots({
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vaultSnapshots = await moonwellClient.getMorphoVaultSnapshots({
network: "base", // [!code focus]
vault: "mwETH",
});
```
#### vault
* **Type:** `string`
The key of the vault to get.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vaultSnapshots = await moonwellClient.getMorphoVaultSnapshots({
network: "base",
vault: "mwETH", // [!code focus]
});
```
import NetworkMorphoVaultParameterInfo from "../../../../components/NetworkMorphoVaultParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoVaultUserPosition
Retrieves detailed information about a user's position in a specific Moonwell Morpho Vault, including their deposited assets, earned rewards, and other position-specific metrics.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const vaultUserPosition = await moonwellClient.getMorphoVaultUserPosition({ // [!code focus:5]
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoVaultUserPosition | undefined
```
* **Type:** [`MorphoVaultUserPosition`](/docs/glossary/types#morphovaultuserposition)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user to get the position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultUserPosition = await moonwellClient.getMorphoVaultUserPosition({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
#### chainId
* **Type:** `number`
The chain ID to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultUserPosition = await moonwellClient.getMorphoVaultUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
vaultAddress: "0x0000000000000000000000000000000000000000",
});
```
#### vaultAddress
* **Type:** `Address`
The address of the vault to get the user position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultUserPosition = await moonwellClient.getMorphoVaultUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
vaultAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vaultUserPosition = await moonwellClient.getMorphoVaultUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
vault: "mwETH",
});
```
#### vault
* **Type:** `string`
The key of the vault to get the user position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vaultUserPosition = await moonwellClient.getMorphoVaultUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base",
vault: "mwETH", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoVaultUserPositions
Retrieves all active Moonwell Morpho Vault positions for a specific user address. This function returns detailed information about a user's deposits, including the amount deposited, current value, and any accrued rewards across all Moonwell Morpho Vaults they participate in.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const vaultUserPositions = await moonwellClient.getMorphoVaultUserPositions({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
}); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoVaultUserPosition[]
```
* **Type:** [`MorphoVaultUserPosition[]`](/docs/glossary/types#morphovaultuserposition)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user to get the positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultUserPositions = await moonwellClient.getMorphoVaultUserPositions({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaultUserPositions = await moonwellClient.getMorphoVaultUserPositions({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the vault for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vaultUserPositions = await moonwellClient.getMorphoVaultUserPositions({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMorphoVaults
Retrieves a list of all Moonwell Morpho Vaults with their current state, including supply and borrow rates, total deposits, total borrows, and other key metrics.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const vaults = await moonwellClient.getMorphoVaults(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MorphoVault[]
```
* **Type:** [`MorphoVault[]`](/docs/glossary/types#morphovault)
### Parameters
#### includeRewards (optional)
* **Type:** `boolean`
Whether to include rewards in the response.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaults = await moonwellClient.getMorphoVaults({
includeRewards: true // [!code focus]
})
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the markets for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const vaults = await moonwellClient.getMorphoVaults({
chainId: 8453 // [!code focus]
})
```
#### network (optional)
* **Type:** `string`
The network to get the markets for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const vaults = await moonwellClient.getMorphoVaults({
network: "base", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getCirculatingSupplySnapshots
Returns WELL circulating supply snapshots.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const snapshots = await moonwellClient.getCirculatingSupplySnapshots(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
CirculatingSupplySnapshot[]
```
* **Type:** [`CirculatingSupplySnapshot[]`](/docs/glossary/types#circulatingsupplysnapshot)
### Parameters
#### chainId (optional)
* **Type:** `number`
The chain ID to get the circulating supply snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const snapshots = await moonwellClient.getCirculatingSupplySnapshots({
chainId: 1284, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the circulating supply snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const snapshots = await moonwellClient.getCirculatingSupplySnapshots({
network: "moonbeam", // [!code focus]
});
```
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getDelegates
Returns a list of all protocol delegates. Delegates are accounts that have been given voting power by other token holders to participate in governance decision.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const delegates = await moonwellClient.getDelegates(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
Delegate[]
```
* **Type:** [`Delegate[]`](/docs/glossary/types#delegate)
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getDiscussions
Returns all governance discussions across the Moonwell protocol. This function allows you to fetch the complete list of active and past governance discussions, including proposals, their descriptions, and related metadata.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const discussions = await moonwellClient.getDiscussions(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
Discussion[]
```
* **Type:** [`Discussion[]`](/docs/glossary/types#discussion)
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getGovernanceTokenInfo
Returns information about the specified governance token, including its total supply.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const info = await moonwellClient.getGovernanceTokenInfo({ // [!code focus:3]
governanceToken: "WELL",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
{ totalSupply: Amount } | undefined
```
* **Type:** [`Amount`](/docs/glossary/types#amount)
### Parameters
#### governanceToken
* **Type:** `"WELL" | "WELL_TESTNET" | "MOVR"`
The governance token to get the info for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const info = await moonwellClient.getGovernanceTokenInfo({
governanceToken: "WELL", // [!code focus]
});
```
import NetworkParameterInfo from '../../../../components/NetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getProposal
Retrieves detailed information about a specific governance proposal from the Moonwell protocol. This function allows you to fetch proposal data such as the proposal's current state, voting results, description, and associated actions by providing the proposal's ID and network information.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const proposal = await moonwellClient.getProposal({ // [!code focus:4]
proposalId: 1,
chainId: 1284,
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
Proposal | undefined
```
* **Type:** [`Proposal`](/docs/glossary/types#proposal)
### Parameters
#### proposalId
* **Type:** `number`
The ID of the proposal.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposal = await moonwellClient.getProposal({
proposalId: 1, // [!code focus]
chainId: 1284,
});
```
#### chainId
* **Type:** `number`
The chain ID to get the proposal for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposal = await moonwellClient.getProposal({
proposalId: 1,
chainId: 1284, // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the proposal for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const proposal = await moonwellClient.getProposal({
proposalId: 1,
network: "moonbeam", // [!code focus]
});
```
import OptionalNetworkParameterInfo from '../../../../components/OptionalNetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getProposals
Returns all governance proposals from the Moonwell protocol. This includes both active and historical proposals, allowing you to view the complete governance history. Each proposal contains details such as the proposal title, description, voting status, vote counts, and execution status.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const proposals = await moonwellClient.getProposals(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
Proposal[]
```
* **Type:** [`Proposal[]`](/docs/glossary/types#proposal)
### Parameters
#### chainId (optional)
* **Type:** `number`
The chain ID to get the proposals for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposals = await moonwellClient.getProposals({
chainId: 1284 // [!code focus]
})
```
#### network (optional)
* **Type:** `string`
The network to get the proposals for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const proposals = await moonwellClient.getProposals({
network: "moonbeam" // [!code focus]
})
```
import NetworkParameterInfo from "../../../../components/NetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getSnapshotProposal
Retrieves detailed information about a specific governance proposal from Moonwell Offchain Governance on [Snapshot](https://snapshot.org/). This function allows you to fetch proposal data such as the proposal title, description, voting options, current voting results, and other metadata using the proposal's unique identifier.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const proposal = await moonwellClient.getSnapshotProposal({ // [!code focus:4]
proposalId: '0x0000000000000000000000000000000000000000',
chainId: 1284,
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
SnapshotProposal | undefined
```
* **Type:** [`SnapshotProposal`](/docs/glossary/types#snapshotproposal)
### Parameters
#### proposalId
* **Type:** `string`
The ID of the proposal.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposal = await moonwellClient.getSnapshotProposal({
proposalId: '0x0000000000000000000000000000000000000000', // [!code focus]
chainId: 1284,
});
```
#### chainId
* **Type:** `number`
The chain ID to get the proposal for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposal = await moonwellClient.getSnapshotProposal({
proposalId: '0x0000000000000000000000000000000000000000',
chainId: 1284, // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the proposal for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const proposal = await moonwellClient.getSnapshotProposal({
proposalId: '0x0000000000000000000000000000000000000000',
network: "moonbeam", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getSnapshotProposals
Returns all governance proposals from Moonwell Offchain Governance on [Snapshot](https://snapshot.org/) including both active and completed proposals. This function allows you to query proposals across different networks and includes details such as proposal titles, descriptions, voting periods, choices, and current voting results. You can filter proposals by chain ID or network and paginate through results.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const proposals = await moonwellClient.getSnapshotProposals(); // [!code focus]
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
{ proposals: SnapshotProposal[], total: number, active: number }
```
* **Type:** [`SnapshotProposal[]`](/docs/glossary/types#snapshotproposal)
### Parameters
#### pagination (optional)
* **Type:** `{ size?: number; page?: number }`
The pagination options.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposals = await moonwellClient.getSnapshotProposals({
pagination: { size: 10, page: 1 }, // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the proposals for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const proposals = await moonwellClient.getSnapshotProposals({
chainId: 1284, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the proposals for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const proposals = await moonwellClient.getSnapshotProposals({
network: "moonbeam", // [!code focus]
});
```
import NetworkParameterInfo from "../../../../components/NetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getStakingInfo
Returns detailed information about the current staking state in the Moonwell protocol, including rewards data and protocol parameters. This function is useful for retrieving information about WELL token staking, such as total staked amounts and current reward rates.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const info = await moonwellClient.getStakingInfo({ // [!code focus:3]
chainId: 1284,
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
StakingInfo[]
```
* **Type:** [`StakingInfo[]`](/docs/glossary/types#stakinginfo)
### Parameters
#### chainId
* **Type:** `number`
The chain ID to get the staking info for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const info = await moonwellClient.getStakingInfo({
chainId: 1284, // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the staking info for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const info = await moonwellClient.getStakingInfo({
network: "moonbeam", // [!code focus]
});
```
import NetworkParameterInfo from "../../../../components/NetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getStakingSnapshots
Retrieves historical snapshots of staking positions across the protocol. These snapshots capture the state of all staking positions at specific points in time, including information such as:
* Total staked amounts
* Individual staker positions
* Staking rewards data
* Timestamp of each snapshot
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const snapshots = await moonwellClient.getStakingSnapshots({ // [!code focus:3]
chainId: 1284,
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
StakingSnapshot[]
```
* **Type:** [`StakingSnapshot[]`](/docs/glossary/types#stakingsnapshot)
### Parameters
#### chainId
* **Type:** `number`
The chain ID to get the staking snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const snapshots = await moonwellClient.getStakingSnapshots({
chainId: 1284, // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the staking snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const snapshots = await moonwellClient.getStakingSnapshots({
network: "moonbeam", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserStakingInfo
Retrieves detailed staking information for a specific user address across Moonwell's protocol. This includes data about the user's staked positions, rewards, and other staking-related metrics. The function can be used to query information on different networks within the Moonwell ecosystem.
The returned information includes:
* Active staking positions
* Staking rewards
* Historical staking data
* Associated token amounts and values
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const info = await moonwellClient.getUserStakingInfo({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserStakingInfo[]
```
* **Type:** [`UserStakingInfo[]`](/docs/glossary/types#userstakinginfo)
### Parameters
#### userAddress
* **Type:** `Address`
The user address to get the staking info for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const info = await moonwellClient.getUserStakingInfo({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the user staking info for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const info = await moonwellClient.getUserStakingInfo({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 1284, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to get the user staking info for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const info = await moonwellClient.getUserStakingInfo({
userAddress: "0x0000000000000000000000000000000000000000",
network: "moonbeam", // [!code focus]
});
```
import NetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserVoteReceipt
Retrieves the voting details for a specific user's vote on a governance proposal. This includes information such as:
* Whether the user has voted
* The support status of their vote (for/abstain/against)
* The voting power they used
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const receipt = await moonwellClient.getUserVoteReceipt({ // [!code focus:5]
proposalId: 1,
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 1284,
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
VoteReceipt[]
```
* **Type:** [`VoteReceipt[]`](/docs/glossary/types#votereceipt)
### Parameters
#### proposalId
* **Type:** `number`
The proposal ID to get the vote receipt for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const receipt = await moonwellClient.getUserVoteReceipt({
proposalId: 1, // [!code focus]
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 1284,
});
```
#### userAddress
* **Type:** `Address`
The user address to get the vote receipt for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const receipt = await moonwellClient.getUserVoteReceipt({
proposalId: 1,
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
chainId: 1284,
});
```
#### chainId
* **Type:** `number`
The chain ID to get the vote receipt for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const receipt = await moonwellClient.getUserVoteReceipt({
proposalId: 1,
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 1284, // [!code focus]
});
```
#### network
The network to get the vote receipt for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const receipt = await moonwellClient.getUserVoteReceipt({
proposalId: 1,
userAddress: "0x0000000000000000000000000000000000000000",
network: "moonbeam", // [!code focus]
});
```
import OptionalNetworkParameterInfo from "../../../../components/OptionalNetworkParameterInfo.mdx";
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserVotingPowers
Retrieves the voting power information for a specific user's governance tokens. The function returns details about a user's current voting capabilities, including their direct token-based voting power, any voting power delegated to them by other users, and their own delegation status.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const powers = await moonwellClient.getUserVotingPowers({ // [!code focus:4]
governanceToken: "WELL",
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserVotingPowers[]
```
* **Type:** [`UserVotingPowers[]`](/docs/glossary/types#uservotingpowers)
### Parameters
#### governanceToken
* **Type:** `"WELL" | "WELL_TESTNET" | "MOVR"`
The governance token to get the user voting powers for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const powers = await moonwellClient.getUserVotingPowers({
governanceToken: "WELL", // [!code focus]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
#### userAddress
* **Type:** `Address`
The user address to get the voting powers for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const powers = await moonwellClient.getUserVotingPowers({
governanceToken: "WELL",
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the user voting powers for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const powers = await moonwellClient.getUserVotingPowers({
governanceToken: "WELL",
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 1284, // [!code focus]
});
```
#### network (optional)
The network to get the user voting powers for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { moonbeam } from "@moonwell-fi/moonwell-sdk/environments";
const powers = await moonwellClient.getUserVotingPowers({
governanceToken: "WELL",
userAddress: "0x0000000000000000000000000000000000000000",
network: "moonbeam", // [!code focus]
});
```
import NetworkMarketInfo from '../../../../components/NetworkMarketParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMarket
Retrieves detailed information about a specific Moonwell lending market.
This function allows you to query market data using either:
* Chain ID and market address
* Network name and market identifier
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const market = await moonwellClient.getMarket({ // [!code focus:4]
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
Market | undefined
```
* **Type:** [`Market`](/docs/glossary/types#market)
### Parameters
#### chainId
* **Type:** `number`
The chain ID where the market is located.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const market = await moonwellClient.getMarket({
chainId: 8453, // [!code focus]
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
#### marketAddress
* **Type:** `Address`
The address of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const market = await moonwellClient.getMarket({
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457", // [!code focus]
});
```
#### network
* **Type:** `string`
The network where the market is located.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const market = await moonwellClient.getMarket({
network: "base", // [!code focus]
market: "MOONWELL_ETH",
});
```
#### market
* **Type:** `string`
The name of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const market = await moonwellClient.getMarket({
network: "base",
market: "MOONWELL_ETH", // [!code focus]
});
```
import NetworkParameterInfo from '../../../../components/NetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMarketSnapshots
Returns market snapshots for either core or isolated markets on a specified network.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const marketSnapshots = await moonwellClient.getMarketSnapshots({ // [!code focus:5]
type: "core",
marketId: "0x0000000000000000000000000000000000000000",
chainId: 8453,
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
MarketSnapshot[]
```
* **Type:** [`MarketSnapshot[]`](/docs/glossary/types#marketsnapshot)
### Parameters
#### type
* **Type:** `"core" | "isolated"`
* **Required:** Yes
Specifies which type of market to query:
* `"core"` - Moonwell Core lending markets
* `"isolated"` - Morpho Markets with isolated risk parameters
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const coreSnapshots = await moonwellClient.getMarketSnapshots({
type: "core", // [!code focus]
marketId: "0x0000000000000000000000000000000000000000",
chainId: 8453,
});
```
#### marketId
* **Type:** `Address`
The market ID to get the snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const coreSnapshots = await moonwellClient.getMarketSnapshots({
type: "core",
marketId: "0x0000000000000000000000000000000000000000", // [!code focus]
chainId: 8453,
});
```
#### chainId
* **Type:** `number`
The chain ID to get the snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const coreSnapshots = await moonwellClient.getMarketSnapshots({
type: "core",
marketId: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network
* **Type:** `string`
The network to get the snapshots for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const coreSnapshots = await moonwellClient.getMarketSnapshots({
type: "core",
marketId: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
});
```
import OptionalNetworkParameterInfo from '../../../../components/OptionalNetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getMarkets
Retrieves a list of all markets available on Moonwell.
Each market contains detailed information about the asset, including supply and borrow rates, total liquidity, collateral factor, and other key metrics.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const allMarkets = await moonwellClient.getMarkets(); // [!code focus]
// Get markets for a specific chain with liquid staking rewards
const marketsWithRewards = await moonwellClient.getMarkets({
chainId: 8453,
includeLiquidStakingRewards: true
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
Returns an array of Market objects containing detailed information about each available market.
:::details[Example]
:::
```
Market[]
```
* **Type:** [`Market[]`](/docs/glossary/types#market)
* **Description:** An array of market objects, each containing:
* Asset information (symbol, name, decimals)
* Current market rates (supply APY, borrow APY)
* Market size (total supply, total borrow)
* Risk parameters (collateral factor, liquidation threshold)
* Protocol fees and reserves
### Parameters
#### includeLiquidStakingRewards (optional)
* **Type:** `boolean`
* **Default:** `false`
* **Description:** When set to `true`, includes additional information about liquid staking rewards available for each market.
Whether to include liquid staking rewards in the response.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const markets = await moonwellClient.getMarkets({
includeLiquidStakingRewards: true // [!code focus]
})
```
#### chainId (optional)
* **Type:** `number`
The chain ID to filter the markets by.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const markets = await moonwellClient.getMarkets({
chainId: 8453 // [!code focus]
})
```
#### network (optional)
* **Type:** `string`
The network to filter the markets by.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const markets = await moonwellClient.getMarkets({
network: "base" // [!code focus]
})
```
import OptionalNetworkParameterInfo from '../../../../components/OptionalNetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserBalances
Returns all token balances for a specific user across Moonwell core and isolated markets.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const balances = await moonwellClient.getUserBalances({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserBalance[]
```
* **Type:** [`UserBalance[]`](/docs/glossary/types#user-balance)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const balances = await moonwellClient.getUserBalances({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the balances for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const balances = await moonwellClient.getUserBalances({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to filter the markets by.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const balances = await moonwellClient.getUserBalances({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base" // [!code focus]
})
```
import NetworkMarketParameterInfo from '../../../../components/NetworkMarketParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserPosition
Returns a user's lending and borrowing position in a specific Moonwell market, including their supplied assets, borrowed amounts, and account health information.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const position = await moonwellClient.getUserPosition({ // [!code focus:5]
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserPosition | undefined
```
* **Type:** [`UserPosition`](/docs/glossary/types#userposition)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const position = await moonwellClient.getUserPosition({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
#### chainId
* **Type:** `number`
The chain ID to get the position for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const position = await moonwellClient.getUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
#### marketAddress
* **Type:** `Address`
The address of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const position = await moonwellClient.getUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457", // [!code focus]
});
```
#### network
* **Type:** `string`
The network where the market is located.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const position = await moonwellClient.getUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
market: "MOONWELL_ETH",
});
```
#### market
* **Type:** `string`
The name of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const position = await moonwellClient.getUserPosition({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base",
market: "MOONWELL_ETH", // [!code focus]
});
```
import OptionalNetworkParameterInfo from '../../../../components/OptionalNetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserPositions
Returns all user positions across Moonwell core and isolated markets.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const positions = await moonwellClient.getUserPositions({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserPosition[]
```
* **Type:** [`UserPosition[]`](/docs/glossary/types#userposition)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const positions = await moonwellClient.getUserPositions({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the positions for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const positions = await moonwellClient.getUserPositions({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to filter the markets by.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const positions = await moonwellClient.getUserPositions({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base" // [!code focus]
})
```
import NetworkMarketParameterInfo from '../../../../components/NetworkMarketParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserReward
Returns a user's reward for a specific market.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const reward = await moonwellClient.getUserReward({ // [!code focus:5]
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserReward | undefined
```
* **Type:** [`UserReward`](/docs/glossary/types#userreward)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const reward = await moonwellClient.getUserReward({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
#### chainId
* **Type:** `number`
The chain ID to get the reward for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const reward = await moonwellClient.getUserReward({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457",
});
```
#### marketAddress
* **Type:** `Address`
The address of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const reward = await moonwellClient.getUserReward({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453,
marketAddress: "0x628ff693426583D9a7FB391E54366292F509D457", // [!code focus]
});
```
#### network
* **Type:** `string`
The network where the market is located.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const reward = await moonwellClient.getUserReward({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base", // [!code focus]
market: "MOONWELL_ETH",
});
```
#### market
* **Type:** `string`
The name of the market.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const reward = await moonwellClient.getUserReward({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base",
market: "MOONWELL_ETH", // [!code focus]
});
```
import OptionalNetworkParameterInfo from '../../../../components/OptionalNetworkParameterInfo.mdx';
import { LiveExample } from '../../../../components/LiveExample';
import { moonwellClient } from '../../../../snippets/moonClient';
## getUserRewards
Returns all user rewards across Moonwell core and isolated markets.
### Usage
:::code-group
```ts twoslash [example.ts]
import { moonwellClient } from './client'
const rewards = await moonwellClient.getUserRewards({ // [!code focus:3]
userAddress: "0x0000000000000000000000000000000000000000",
});
```
```ts twoslash [client.ts] filename="client.ts"
// [!include ~/snippets/moonClient.ts]
```
:::
### Returns
:::details[Example]
:::
```
UserReward[]
```
* **Type:** [`UserReward[]`](/docs/glossary/types#userreward)
### Parameters
#### userAddress
* **Type:** `Address`
The address of the user.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const rewards = await moonwellClient.getUserRewards({
userAddress: "0x0000000000000000000000000000000000000000", // [!code focus]
});
```
#### chainId (optional)
* **Type:** `number`
The chain ID to get the rewards for.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
const rewards = await moonwellClient.getUserRewards({
userAddress: "0x0000000000000000000000000000000000000000",
chainId: 8453, // [!code focus]
});
```
#### network (optional)
* **Type:** `string`
The network to filter the markets by.
```ts twoslash
// [!include ~/snippets/moonClient.ts]
// ---cut---
import { base } from "@moonwell-fi/moonwell-sdk/environments";
const rewards = await moonwellClient.getUserRewards({
userAddress: "0x0000000000000000000000000000000000000000",
network: "base" // [!code focus]
})
```