Skip to main content

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 an accountId from the range. Any unused value automatically creates a new sub-account.
  • Dolomite (accountType: SELECT): Margin sub-accounts are arbitrary uint256 account numbers (accountIdRange is 0 to 2^256-1). Account 0 is the default cross-margin account; activeAccountIds lists funded accounts and nextAccountId is 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 the posId/accountId parameter entirely. The nextAccountId field 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

accountTypeTo create new accountTo use existing account
SELECTPass accountId=<unused value> from accountIdRangePass accountId=<existing value>
AUTOGENOmit accountId / posId parameterPass posId=<existing ID>
Plain-text reference — GET /v1/data/lending/next-account

Parameters

ParameterInTypeRequiredDescription
chainIdquerystringyesChain ID. See the ChainId schema for the full set of supported chains.
lenderquerystringyesLender identifier. See the LenderId schema for the full set of accepted values.
accountquerystringyesOwner wallet address.

Response 200

FieldTypeDescription
successTrue
dataobject
data.accountTypeSELECT, AUTOGENSELECT — integrator picks an ID from the range (Euler V2). AUTOGEN — ID is generated on-chain; omit the param to create (Init Capital).
data.nextAccountIdstringFor SELECT: lowest unused account ID. For AUTOGEN: preview of the on-chain generated ID.
data.activeAccountIdsstring[]Currently active account IDs for this owner. May be empty for AUTOGEN protocols.
data.accountIdRangestring[]Inclusive [min, max] range of valid account IDs.
data.createHintstringHuman-readable instructions for integrators on how to create a new sub-account.
actionsnull

Example response

{
"success": true,
"data": {
"accountType": "SELECT",
"nextAccountId": "1",
"activeAccountIds": [
"0",
"3",
"7"
],
"accountIdRange": [
"0",
"255"
],
"createHint": "string"
}
}

Request

Responses

Next account information