-
Notifications
You must be signed in to change notification settings - Fork 74
Description
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: booleanThis 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: 50This will generate the correct TypeScript definition:
dynamicSlippage?: { maxBps: number };Files to Update
- Primary:
swagger.yaml- Update the OpenAPI specification - Secondary: Regenerate TypeScript definitions using the OpenAPI tools configured in
openapitools.json
Steps to Reproduce
- Install
@jup-ag/[email protected] - Try to use
dynamicSlippageas an object:
const swapObj = await jupiterQuoteApi.swapPost({
swapRequest: {
quoteResponse: quote,
userPublicKey: publicKey.toBase58(),
dynamicSlippage: {
maxBps: 50,
},
// ... other properties
},
});- 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.