Skip to content

Fix dynamicSlippage Type Definition in swagger.yaml - Should Accept Object with maxBps #78

@KoenRijpstra

Description

@KoenRijpstra

The dynamicSlippage parameter in swagger.yaml is currently defined as boolean, but according to the Jupiter API documentation, it should accept an object with a maxBps property for configurable dynamic slippage.

Current Problem

In swagger.yaml, the SwapRequest schema defines:

dynamicSlippage:
  type: boolean

This generates TypeScript definitions like:

dynamicSlippage?: boolean;

However, developers trying to use the documented object format get TypeScript errors:

// This should work according to docs but causes TS error
dynamicSlippage: {
  maxBps: 50, // Maximum slippage in basis points
}
// Error: Type '{ maxBps: number; }' is not assignable to type 'boolean | undefined'

Expected Behavior

The API should accept an object with maxBps property for configurable dynamic slippage with maximum cap.

Proposed Fix

Update the swagger.yaml file to define dynamicSlippage as:

dynamicSlippage:
  type: object
  properties:
    maxBps:
      type: integer
      description: Maximum slippage in basis points
      example: 50

This will generate the correct TypeScript definition:

dynamicSlippage?: { maxBps: number };

Files to Update

  1. Primary: swagger.yaml - Update the OpenAPI specification
  2. Secondary: Regenerate TypeScript definitions using the OpenAPI tools configured in openapitools.json

Steps to Reproduce

  1. Install @jup-ag/[email protected]
  2. Try to use dynamicSlippage as an object:
const swapObj = await jupiterQuoteApi.swapPost({
  swapRequest: {
    quoteResponse: quote,
    userPublicKey: publicKey.toBase58(),
    dynamicSlippage: {
      maxBps: 50,
    },
    // ... other properties
  },
});
  1. Observe TypeScript error

Current Workaround

Developers must use unsafe type assertions:

dynamicSlippage: {
  maxBps: 50,
} as any,

Environment

  • Package: @jup-ag/[email protected]
  • TypeScript: Latest
  • Issue affects all TypeScript users of the package

Impact

This affects all TypeScript developers using the @jup-ag/api package who want to implement configurable dynamic slippage as documented in the official API documentation. The current type definitions force developers to abandon TypeScript safety or avoid using this feature entirely.

Additional Context

The Jupiter API documentation clearly shows examples using the object format with maxBps, but the generated TypeScript definitions don't match the actual API capabilities. This creates confusion and forces developers to use workarounds that bypass TypeScript's type safety.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions