Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@velora-dex/sdk",
"version": "9.3.4",
"version": "9.3.5-dev.1",
"main": "dist/index.js",
"module": "dist/sdk.esm.js",
"typings": "dist/index.d.ts",
Expand Down
6 changes: 5 additions & 1 deletion src/methods/delta/getDeltaPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export type DeltaPriceParams = {
destChainId?: number;
/** @description SELL or BUY, default is SELL */
side?: SwapSideUnion;
/** @description In %. It's a way to bypass the API price impact check (default = 15%) */
maxImpact?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add maxUSDImpact. It's present in other price endpoints

maxUSDImpact?: number;

includeAgents?: string[];
excludeAgents?: string[];
Expand All @@ -42,6 +45,7 @@ export type DeltaPriceParams = {

/** @description Allow swap on destChain after bridge. Default is true. */
allowBridgeAndSwap?: boolean;
degenMode?: boolean;
};

type DeltaPriceQueryOptions = Omit<
Expand Down Expand Up @@ -195,7 +199,7 @@ export const constructGetDeltaPrice = ({
excludeBridges: excludeBridgesString,
});

const fetchURL = `${pricesUrl}/${search}` as const;
const fetchURL = `${pricesUrl}${search}` as const;

const data = await fetcher<DeltaPriceResponse>({
url: fetchURL,
Expand Down
2 changes: 2 additions & 0 deletions src/methods/delta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type SubmitDeltaOrderParams = BuildDeltaOrderDataParams & {
partiallyFillable?: boolean;
/** @description Referrer address */
referrerAddress?: string;
degenMode?: boolean;
} & Pick<DeltaOrderToPost, 'type' | 'includeAgents' | 'excludeAgents'>;

type SubmitDeltaOrder = (
Expand Down Expand Up @@ -91,6 +92,7 @@ export const constructSubmitDeltaOrder = (
type: orderParams.type,
includeAgents: orderParams.includeAgents,
excludeAgents: orderParams.excludeAgents,
degenMode: orderParams.degenMode,
});

return response;
Expand Down
15 changes: 12 additions & 3 deletions src/methods/delta/postDeltaOrder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { API_URL } from '../../constants';
import { constructSearchString } from '../../helpers/misc';
import type { ConstructFetchInput, RequestParameters } from '../../types';
import { DeltaAuctionOrder, DeltaAuction } from './helpers/types';

Expand All @@ -21,7 +22,9 @@ export type DeltaOrderToPost = {
excludeAgents?: string[];
};

export type PostDeltaOrderParams = Omit<DeltaOrderToPost, 'chainId'>;
export type PostDeltaOrderParams = Omit<DeltaOrderToPost, 'chainId'> & {
degenMode?: boolean;
};

export type DeltaOrderApiResponse = Omit<DeltaAuction, 'transactions'> & {
orderVersion: string; // "2.0.0"
Expand All @@ -45,11 +48,17 @@ export const constructPostDeltaOrder = ({
}: ConstructFetchInput): PostDeltaOrderFunctions => {
const postOrderUrl = `${apiURL}/delta/orders` as const;

const postDeltaOrder: PostDeltaOrder = (postData, requestParams) => {
const postDeltaOrder: PostDeltaOrder = (_postData, requestParams) => {
const { degenMode, ...postData } = _postData;
const deltaOrderToPost: DeltaOrderToPost = { ...postData, chainId };

const search = constructSearchString<{ degenMode?: boolean }>({
degenMode,
});
const fetchURL = `${postOrderUrl}/${search}` as const;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing slash changes POST URL for all orders

High Severity

The URL template `${postOrderUrl}/${search}` introduces a spurious / between the path and the query string. When degenMode is not provided (the common case), constructSearchString returns "", so the URL becomes …/delta/orders/ instead of the previous …/delta/orders. When degenMode is provided, it becomes …/delta/orders/?degenMode=true instead of …/delta/orders?degenMode=true. This is a regression for every postDeltaOrder call. The existing test expects the URL without a trailing slash. The sibling getDeltaOrders uses ${baseUrl}${search} (no extra /) for the same endpoint.

Fix in Cursor Fix in Web

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes we do /search, sometimes without /. We should decide on one way


return fetcher<DeltaOrderApiResponse>({
url: postOrderUrl,
url: fetchURL,
method: 'POST',
data: deltaOrderToPost,
requestParams,
Expand Down
2 changes: 2 additions & 0 deletions src/methods/swap/rates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ type RateQueryParams = {
* @description Exclude all RFQs from pricing, e.g.: AugustusRFQ, Hashflow. Default: false
*/
excludeRFQ?: boolean;
degenMode?: boolean;
};

// more details in the docs https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair#query-parameters
Expand Down Expand Up @@ -169,6 +170,7 @@ export type RateOptions = {
srcTokenDexTransferFee?: string;
/** @description Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers. */
destTokenDexTransferFee?: string;
degenMode?: boolean;
};

type CommonGetRateInput = {
Expand Down
1 change: 1 addition & 0 deletions src/methods/swap/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export type BuildOptionsBase = {
ignoreAllowance?: boolean;
/** @description Allows the API to return the contract parameters only. */
onlyParams?: boolean;
degenMode?: boolean;
};

export type BuildOptionsWithGasPrice = BuildOptionsBase & Partial<WithGasPrice>;
Expand Down
Loading