Skip to main content
Reads the deposit supply cap and fee module information from the CommunityCodeDepositor (DCD) contract on-chain. Uses supplyCapInBase() and feeModule() to determine whether the account has a deposit cap and/or deposit fees configured.
Only available for accounts with both a communityCodeDepositorAddress and a depositFeeModuleAddress. Throws an APIError if either is missing.

Import

import { getDepositCap } from '@paxoslabs/amplify-sdk'

Usage

import { getDepositCap, getVaultsByConfig, YieldType } from '@paxoslabs/amplify-sdk'

const [vault] = await getVaultsByConfig({ yieldType: YieldType.CORE, chainId: 1 })

const cap = await getDepositCap({
  vaultName: vault.name,
  chainId: 1,
  assetAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
})

console.log(cap.hasDepositCap) // true if supply cap is set and not unlimited
console.log(cap.supplyCapInBase) // bigint — raw supply cap in base asset units
console.log(cap.hasFees) // true if deposit fee module is configured

Parameters

ParameterTypeRequiredDescription
vaultNamestringYesAccount name from getVaultsByConfig()
chainIdChainIdYesBlockchain network ID
assetAddressAddressYesAsset address for account lookup
interface GetDepositCapParams {
  vaultName: string
  chainId: ChainId
  assetAddress: Address
}

Return Type

interface DepositCapResult {
  /** Supply cap in base asset units (raw uint256 from DCD contract) */
  supplyCapInBase: bigint
  /** True when supplyCapInBase is neither 0 nor maxUint256 (unlimited) */
  hasDepositCap: boolean
  /** Deposit fee module contract address from the DCD */
  depositFeeModuleAddress: Address
  /** True if the fee module address is not the zero address */
  hasFees: boolean
}

Example: Supply Cap UI

import { getDepositCap, getCurrentSupply, getVaultsByConfig, YieldType } from '@paxoslabs/amplify-sdk'
import { formatUnits } from 'viem'

const [vault] = await getVaultsByConfig({ yieldType: YieldType.CORE, chainId: 1 })

const cap = await getDepositCap({
  vaultName: vault.name,
  chainId: 1,
  assetAddress: usdcAddress,
})

if (cap.hasDepositCap) {
  const supply = await getCurrentSupply({
    vaultName: vault.name,
    chainId: 1,
    assetAddress: usdcAddress,
  })

  const remaining = cap.supplyCapInBase - supply.totalValueInBase
  console.log(`Remaining capacity: ${formatUnits(remaining, 6)} base units`)
}

Error Handling

Error Message PatternDescriptionResolution
"Deposit cap not available for vault"Account has no DCD or fee moduleOnly accounts with fee modules support caps
"No vault found"No account matches parametersVerify vaultName, asset, chainId
"SDK not initialized"SDK not initializedCall initAmplifySDK() first