Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Adding a page to a manually-listed sidebar (`docsSidebar`, `operatorSidebar`, `s

Moving, renaming, or deleting any file under `docs/`, `operator/`, or `staker/` requires an entry in `redirects.ts`. This is enforced twice: the husky `pre-commit` hook runs `yarn checkRedirects`, and `.github/workflows/check-redirects.yml` pipes a rename-aware `git diff` into `yarn checkRedirects --stdin`.

`scripts/checkRedirects/` also rejects duplicate `from` values and verifies that any `#anchor` in a `to` target actually exists as a heading in the destination file. URL derivation (`util/contentRoots.ts`): strip the extension, lowercase, drop a trailing `/index`, and map `docs/` → ``, `operator/` → `/operator`, `staker/` → `/staker`.
`scripts/checkRedirects/` also rejects duplicate `from` values and verifies that any `#anchor` in a `to` target actually exists as a heading in the destination file. URL derivation: a page with an explicit `slug` in its frontmatter (all synced SDK pages) uses that slug verbatim — `util/slugs.ts` reads the old frontmatter back out of git for deleted/renamed files, and a move that keeps the slug needs no redirect. Otherwise (`util/contentRoots.ts`) strip the extension, drop a trailing `/index`, and map `docs/` → ``, `operator/` → `/operator`, `staker/` → `/staker`; casing is preserved.

## MDX conventions

Expand Down
39 changes: 0 additions & 39 deletions docs/sdk/API/01-vault/getMaxWithdraw.md

This file was deleted.

71 changes: 71 additions & 0 deletions docs/sdk/API/01-vault/getPositionData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
id: getPositionData
slug: /sdk/api/vault/requests/getpositiondata
description: Use the StakeWise SDK getPositionData method to fetch the data needed to calculate a user's allocator and staker positions.
---

#### Description:

Fetches the user's position in a vault: stake, minted and boosted osToken, wallet osToken balance and the APY parameters. Pass the result as `data` to `calculateAllocatorPosition` or `calculateStakerPosition`.

#### Arguments:

| Name | Type | Required | Description |
|--------------|----------|----------|--------------------------|
| userAddress | `string` | **Yes** | The address of the user |
| vaultAddress | `string` | **Yes** | The address of the vault |

#### Returns:

```ts
type Output = {
vault: {
apyData: {
vaultApy: number
borrowApy: number
osTokenApy: number
feePercent: number
ltvPercent: bigint
osTokenRate: bigint
osTokenMintApy: number
allocatorMaxBoostApy: number
leverageMaxMintLtvPercent: bigint
leverageMaxBorrowLtvPercent: bigint
}
isCollateralized: boolean
isOsTokenEnabled: boolean
} | null
stakedAssets: bigint
exitingAssets: bigint
mintedShares: bigint
walletShares: bigint
boostedShares: bigint
boostedAssets: bigint
leverageReward: bigint
}
```

| Name | Description |
|----------------|--------------------------------------------------------------------------|
| vault | Vault, osToken and Aave APY parameters, `null` if the vault is not found |
| stakedAssets | Assets staked by the user in the vault |
| exitingAssets | Assets of the user in the exit queue |
| mintedShares | osToken shares minted by the user |
| walletShares | osToken shares in the user's wallet |
| boostedShares | osToken shares in the user's boost position, including exiting |
| boostedAssets | Assets in the user's boost position, including exiting |
| leverageReward | Annual reward of the existing boost position in assets |

#### Example:

```ts
const data = await sdk.vault.getPositionData({
userAddress: '0x...',
vaultAddress: '0x...',
})

const { apy, totalAssets } = sdk.vault.helpers.calculateAllocatorPosition({
data,
boostedSharesDelta: parseEther('1'),
})
```
3 changes: 3 additions & 0 deletions docs/sdk/API/01-vault/getVault.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Output = {
tokenSymbol: string | null
displayName: string | null
description: string | null
isStateUpdateRequired: boolean
lastFeeUpdateTimestamp: string
osTokenConfig: {
ltvPercent: string
Expand Down Expand Up @@ -91,13 +92,15 @@ type Output = {
| `tokenName` | ERC20 token name |
| `tokenSymbol` | ERC20 token symbol |
| `displayName` | Name of vault |
| `isStateUpdateRequired` | Indicates whether the vault state is out of sync with the latest rewards nonce |
| `pendingMetaSubVault` | The address of the meta vault that is pending to join as a sub vault |
| `ejectingSubVault` | The address of the sub vault currently being ejected (for meta vaults) |
| `canHarvest` | Defines whether the vault can harvest new rewards |
| `allocatorMaxBoostApy` | The average max boost APY earned in this vault by the allocator |
| `description` | Description of vault |
| `whitelist` | List of authorized users for deposits |
| `blocklist` | List of blocked users for deposits |
| `lastUpdateStateTimestamp` | The timestamp of the last vault state update. Will be null if the state has never been updated |
| `performance` | Vault performance indicator (percent) |
| `lastFeeUpdateTimestamp` | The timestamp of the last fee update |
| `lastFeePercent` | The vault last fee percent |
Expand Down
43 changes: 43 additions & 0 deletions docs/sdk/API/01-vault/helpers/calculateAllocatorPosition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
id: calculateAllocatorPosition
slug: /sdk/api/vault/helpers/calculateallocatorposition
description: Use the StakeWise SDK calculateAllocatorPosition helper to calculate a user's vault APY and total staked assets after staking, minting, burning or boosting.
---

#### Description:

Calculates the user's APY and total staked assets in a vault from the result of `getPositionData` and optional deltas. Zero deltas return the current position.

A negative `boostedSharesDelta` is ignored: unboosted shares stay in the position while they are exiting.

#### Arguments:

| Name | Type | Required | Description |
|--------------------|----------------|----------|--------------------------------------------------------------------|
| data | `PositionData` | **Yes** | Result of `getPositionData` |
| stakedAssetsDelta | `bigint` | No | Change in staked assets (e.g. `+assets` to stake, `-assets` to unstake). Defaults to `0n` |
| mintedSharesDelta | `bigint` | No | Change in minted osToken shares (`+shares` to mint, `-shares` to burn). Defaults to `0n` |
| boostedSharesDelta | `bigint` | No | Change in boosted osToken shares (`+shares` to boost). Defaults to `0n` |

#### Returns:

```ts
type Output = {
apy: number
totalAssets: bigint
}
```

#### Example:

```ts
const data = await sdk.vault.getPositionData({
userAddress: '0x...',
vaultAddress: '0x...',
})

const { apy, totalAssets } = sdk.vault.helpers.calculateAllocatorPosition({
data,
stakedAssetsDelta: parseEther('1'),
})
```
41 changes: 41 additions & 0 deletions docs/sdk/API/01-vault/helpers/calculateStakerPosition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
id: calculateStakerPosition
slug: /sdk/api/vault/helpers/calculatestakerposition
description: Use the StakeWise SDK calculateStakerPosition helper to calculate a user's net staker APY and total assets after staking, minting, burning or boosting.
---

#### Description:

Calculates the staker's net APY and total assets across the wallet, mint and boost from the result of `getPositionData` and optional deltas. Synchronous, no requests. Zero deltas return the current position. For a single vault use `calculateAllocatorPosition`.

#### Arguments:

| Name | Type | Required | Description |
|--------------------|----------------|----------|---------------------------------------------------|
| data | `PositionData` | **Yes** | Result of `getPositionData` |
| stakedAssetsDelta | `bigint` | No | Change in staked assets. Defaults to `0n` |
| mintedSharesDelta | `bigint` | No | Change in minted osToken shares. Defaults to `0n` |
| boostedSharesDelta | `bigint` | No | Change in boosted osToken shares. Defaults to `0n` |

#### Returns:

```ts
type Output = {
apy: number
totalAssets: bigint
}
```

#### Example:

```ts
const data = await sdk.vault.getPositionData({
userAddress: '0x...',
vaultAddress: '0x...',
})

const { apy, totalAssets } = sdk.vault.helpers.calculateStakerPosition({
data,
stakedAssetsDelta: parseEther('1'),
})
```
31 changes: 31 additions & 0 deletions docs/sdk/API/03-osToken/01-transactions/claimRedeemerExitQueue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: claimRedeemerExitQueue
slug: /sdk/api/osToken/transactions/claimredeemerexitqueue
description: Use the StakeWise SDK claimRedeemerExitQueue method to withdraw exited assets from the OsTokenRedeemer exit queue for a specific user.
---

#### Description:

Withdraws exited assets from the OsTokenRedeemer queue.

#### Arguments:

| Name | Type | Required | Description |
|-------------|----------|----------|----------------------------------------------------------------|
| userAddress | `string` | **Yes** | The user address |
| positions | `Array` | **Yes** | Claimable positions (`positionTicket` + `exitQueueIndex`) |

#### Returns:

Transaction hash.

#### Example:

```ts
const { positions } = await sdk.osToken.getRedeemerExitQueuePositions({ userAddress: '0x...' })

await sdk.osToken.claimRedeemerExitQueue({
userAddress: '0x...',
positions,
})
```
37 changes: 37 additions & 0 deletions docs/sdk/API/03-osToken/01-transactions/redeemerWithdraw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: redeemerWithdraw
slug: /sdk/api/osToken/transactions/redeemerwithdraw
description: Use the StakeWise SDK osToken redeemerWithdraw method to redeem osToken through the OsTokenRedeemer exit queue.
---

#### Description:

Enters the OsTokenRedeemer exit queue with your osToken shares. The osToken must be approved to the OsTokenRedeemer contract (or use a permit) before calling. Returns a transaction hash; the position ticket is emitted in the `ExitQueueEntered` event.

#### Arguments:

| Name | Type | Required | Description |
|--------------|----------|----------|---------------------------|
| shares | `bigint` | **Yes** | osToken shares to redeem |
| userAddress | `string` | **Yes** | The user address |

#### Example:

```ts
const params = {
shares: 0n,
userAddress: '0x...',
}

// Send transaction
const hash = await sdk.osToken.redeemerWithdraw(params)

// Wait for the transaction to be confirmed and indexed
await sdk.provider.waitForTransaction(hash)
await sdk.utils.waitForSubgraph({ hash })

// When you sign transactions on the backend (for custodians)
const { data, to } = await sdk.osToken.redeemerWithdraw.encode(params)
// Get an approximate gas per transaction
const gas = await sdk.osToken.redeemerWithdraw.estimateGas(params)
```
37 changes: 0 additions & 37 deletions docs/sdk/API/03-osToken/getMaxMint.md

This file was deleted.

55 changes: 0 additions & 55 deletions docs/sdk/API/03-osToken/getPosition.md

This file was deleted.

Loading
Loading