Skip to main content
Use these enums and constants from @dzapio/sdk to avoid typos and ensure correct values in API calls.

Services

Use with getAllowance, approve, and sign when specifying the DZap service:
import { Services } from "@dzapio/sdk";

Services.trade;  // "trade" - swaps and bridges
Services.dca;    // "dca"  - DCA operations
Services.zap;    // "zap"  - Zap operations
There is no Services.swap; use Services.trade for swap/bridge.

TxnStatus

Returned on transaction and approval results. Use for status checks:
import { TxnStatus } from "@dzapio/sdk";

TxnStatus.mining;
TxnStatus.success;
TxnStatus.rejected;
TxnStatus.error;
TxnStatus.reverted;
TxnStatus.pendingWalletConfirmation;
TxnStatus.partialSuccess;
TxnStatus.waitingForExecution;
Example: if (result.status === TxnStatus.success) { ... }

ApprovalModes

Use with getAllowance and approve (parameter name is mode, not permitType):
import { ApprovalModes } from "@dzapio/sdk";

ApprovalModes.Default;                      // Standard ERC20 approval
ApprovalModes.PermitSingle;
ApprovalModes.PermitWitnessTransferFrom;
ApprovalModes.PermitBatchWitnessTransferFrom;
ApprovalModes.AutoPermit;                   // Recommended: auto-select best

PermitTypes

Use with sign() for permit signatures (parameter name is permitType):
import { PermitTypes } from "@dzapio/sdk";

PermitTypes.PermitSingle;
PermitTypes.PermitWitnessTransferFrom;
PermitTypes.PermitBatchWitnessTransferFrom;
PermitTypes.EIP2612Permit;
PermitTypes.AutoPermit;

contractErrorActions (trade failure actions)

When a trade fails, the response may include action with one of:
// From SDK types (contractErrorActions)
"TRY_ANOTHER_ROUTE";   // Retry with bestReturnSource
"INCREASE_SLIPPAGE";   // User should increase slippage
"INCREASE_ALLOWANCE";  // Allowance issue
Handle TRY_ANOTHER_ROUTE by rebuilding the trade request with protocol: bestReturnSource and calling trade() again.

Native token address

Skip approval for the native token (e.g. ETH). Use this address for comparisons:
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
Filter it out before calling getAllowance or approve:
const NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const tokensForApproval = tokens.filter(
  (t) => t.address.toLowerCase() !== NATIVE.toLowerCase()
);

Next steps