Next available sub-account
GET/v1/data/lending/next-account
Discover the next available sub-account or position ID for a given lender and owner.
Different protocols handle sub-accounts differently:
- Euler V2 (
accountType: SELECT): Sub-accounts are derived by XORing the owner's last address byte with an index (0-255). The integrator selects anaccountIdfrom the range. Any unused value automatically creates a new sub-account. - Dolomite (
accountType: SELECT): Margin sub-accounts are arbitraryuint256account numbers (accountIdRangeis0to2^256-1). Account0is the default cross-margin account;activeAccountIdslists funded accounts andnextAccountIdis the lowest unused integer. Any unused number automatically creates a new sub-account. - Init Capital (
accountType: AUTOGEN): Position IDs are NFT hashes generated on-chain. To create a new position, omit theposId/accountIdparameter entirely. ThenextAccountIdfield is a preview of the ID that will be generated. - Other lenders (Aave, Morpho, Compound, etc.): Do not support sub-accounts — returns a 400 error.
Integration Guide
accountType | To create new account | To use existing account |
|---|---|---|
SELECT | Pass accountId=<unused value> from accountIdRange | Pass accountId=<existing value> |
AUTOGEN | Omit accountId / posId parameter | Pass posId=<existing ID> |
Plain-text reference — GET /v1/data/lending/next-account
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
chainId | query | string | yes | Chain ID. See the ChainId schema for the full set of supported chains. |
lender | query | string | yes | Lender identifier. See the LenderId schema for the full set of accepted values. |
account | query | string | yes | Owner wallet address. |
Response 200
| Field | Type | Description |
|---|---|---|
success | True | |
data | object | |
data.accountType | SELECT, AUTOGEN | SELECT — integrator picks an ID from the range (Euler V2). AUTOGEN — ID is generated on-chain; omit the param to create (Init Capital). |
data.nextAccountId | string | For SELECT: lowest unused account ID. For AUTOGEN: preview of the on-chain generated ID. |
data.activeAccountIds | string[] | Currently active account IDs for this owner. May be empty for AUTOGEN protocols. |
data.accountIdRange | string[] | Inclusive [min, max] range of valid account IDs. |
data.createHint | string | Human-readable instructions for integrators on how to create a new sub-account. |
actions | null |
Example response
{
"success": true,
"data": {
"accountType": "SELECT",
"nextAccountId": "1",
"activeAccountIds": [
"0",
"3",
"7"
],
"accountIdRange": [
"0",
"255"
],
"createHint": "string"
}
}
Request
Responses
- 200
- 400
- 429
- 500
- 502
Next account information
Validation error
Rate limited. Unauthenticated callers share a per-IP budget; send an x-api-key header to lift it. Retry with exponential backoff.
Unexpected server error. Safe to retry with backoff.
An upstream data source or protocol origin failed (error.code is ORIGIN_FAILED). error.details carries the per-origin status. This is also what a missing or malformed required parameter currently returns, rather than a 400.