@velora-dex/sdk 9.3.0 → 9.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velora-dex/sdk",
3
- "version": "9.3.0",
3
+ "version": "9.3.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/sdk.esm.js",
6
6
  "typings": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -174,6 +174,7 @@ import {
174
174
  GetDeltaPriceFunctions,
175
175
  DeltaPrice,
176
176
  BridgePrice,
177
+ AvailableBridge,
177
178
  DeltaPriceParams,
178
179
  } from './methods/delta/getDeltaPrice';
179
180
  import {
@@ -379,6 +380,7 @@ export type {
379
380
  BridgeStatus,
380
381
  Bridge,
381
382
  BridgeInfo,
383
+ AvailableBridge,
382
384
  BridgeProtocolResponse,
383
385
  BuildDeltaOrderDataParams,
384
386
  BuildDeltaOrderFunctions,
@@ -31,6 +31,7 @@ type GetBridgeInfo = (
31
31
  export type BridgeProtocolResponse = {
32
32
  protocol: string;
33
33
  displayName: string;
34
+ icon: string;
34
35
  };
35
36
 
36
37
  type BridgeProtocolsResponse = {
@@ -1,3 +1,4 @@
1
+ import { Prettify } from 'viem';
1
2
  import { Bridge } from '../..';
2
3
  import { API_URL, SwapSide } from '../../constants';
3
4
  import { constructSearchString } from '../../helpers/misc';
@@ -105,14 +106,15 @@ type AvailableBridgePrice = Pick<
105
106
  | 'gasCost'
106
107
  | 'gasCostUSDBeforeFee'
107
108
  | 'gasCostBeforeFee'
109
+ | 'receivedDestAmount'
110
+ | 'receivedDestAmountBeforeFee'
111
+ | 'receivedDestUSD'
112
+ | 'receivedDestUSDBeforeFee'
108
113
  >;
109
114
 
110
- type AvailableBridge = AvailableBridgePrice & {
111
- bridgeParams: {
112
- bridge: Bridge;
113
- bridgeInfo: BridgePriceInfo;
114
- }[];
115
- };
115
+ export type AvailableBridge = Prettify<
116
+ AvailableBridgePrice & Pick<BridgePrice, 'bridge' | 'bridgeInfo'>
117
+ >;
116
118
 
117
119
  export type BridgePrice = Omit<DeltaPrice, 'bridge'> & {
118
120
  // destAmountAfterBridge: string; // became bridgeInfo.destAmountAfterBridge
@@ -151,4 +151,7 @@ export type BridgePriceInfo = {
151
151
  destUSDAfterBridge: string;
152
152
  fees: BridgeQuoteFee[];
153
153
  estimatedTimeMs: number;
154
+ fastest: boolean;
155
+ bestReturn: boolean;
156
+ recommended: boolean;
154
157
  };
@@ -29,6 +29,10 @@ export type QuoteParams<M extends TradeMode = TradeMode> = {
29
29
  userAddress?: string;
30
30
  /** @description Partner string */
31
31
  partner?: string;
32
+ /** @description Maximum price impact (in percentage) acceptable for the trade */
33
+ maxImpact?: number;
34
+ /** @description Maximum price impact (in USD) acceptable for the trade */
35
+ maxUSDImpact?: number;
32
36
  /** @description Preferred mode for the trade. In case of "all", Delta pricing is returned, with Market as a fallback */
33
37
  mode: M;
34
38
  };
@@ -15,7 +15,7 @@ export type GetAdaptersFunctions = {
15
15
  };
16
16
 
17
17
  type SearchStringParams = {
18
- network: number;
18
+ chainId: number;
19
19
  version?: APIVersion;
20
20
  };
21
21
 
@@ -30,7 +30,7 @@ export const constructGetAdapters = ({
30
30
  ): Promise<AdaptersAsStrings> => {
31
31
  // always pass explicit type to make sure UrlSearchParams are correct
32
32
  const query = constructSearchString<SearchStringParams>({
33
- network: chainId,
33
+ chainId,
34
34
  version,
35
35
  });
36
36
 
@@ -42,9 +42,9 @@ type RateQueryParams = {
42
42
  side?: 'SELL' | 'BUY';
43
43
 
44
44
  /**
45
- * @description Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114). Default: `1`.
45
+ * @description Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Unichain - 130, Sonic - 146). Default: `1`.
46
46
  */
47
- network?: number;
47
+ chainId?: number;
48
48
 
49
49
  /**
50
50
  * @description If provided, **others** object is filled in the response with price quotes from other exchanges _(if available for comparison)_. Default: `false`.
@@ -221,7 +221,7 @@ export const constructGetRate = ({
221
221
  const search = constructSearchString<Omit<RateQueryParams, 'route'>>({
222
222
  srcToken,
223
223
  destToken,
224
- network: chainId,
224
+ chainId,
225
225
  version,
226
226
  ...parsedOptions,
227
227
  });
@@ -253,7 +253,7 @@ export const constructGetRate = ({
253
253
  Omit<RateQueryParams, 'srcToken' | 'destToken'>
254
254
  >({
255
255
  route: _route, // route can be used in place of srcToken+destToken
256
- network: chainId,
256
+ chainId,
257
257
  version,
258
258
  ...parsedOptions,
259
259
  });
@@ -36,8 +36,8 @@ export const constructGetSpender = ({
36
36
  chainId,
37
37
  fetcher,
38
38
  }: ConstructFetchInput): GetSpenderFunctions => {
39
- const search = constructSearchString<{ network: number; version: string }>({
40
- network: chainId,
39
+ const search = constructSearchString<{ chainId: number; version: string }>({
40
+ chainId,
41
41
  version,
42
42
  });
43
43
 
@@ -41,9 +41,9 @@ type SwapQueryParams = {
41
41
  side: 'SELL' | 'BUY';
42
42
 
43
43
  /**
44
- * @description Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114). Default: `1`.
44
+ * @description Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Unichain - 130, Sonic - 146). Default: `1`.
45
45
  */
46
- network?: number;
46
+ chainId?: number;
47
47
 
48
48
  /**
49
49
  * @description Comma Separated List of DEXs to include. **Supported DEXs:** Uniswap, Kyber, Bancor, AugustusRFQ, Oasis, Compound, Fulcrum, 0x, MakerDAO, Chai, Aave, Aave2, MultiPath, MegaPath, Curve, Curve3, Saddle, IronV2, BDai, idle, Weth, Beth, UniswapV2, Balancer, 0xRFQt, SushiSwap, LINKSWAP, Synthetix, DefiSwap, Swerve, CoFiX, Shell, DODOV1, DODOV2, OnChainPricing, PancakeSwap, PancakeSwapV2, ApeSwap, Wbnb, acryptos, streetswap, bakeryswap, julswap, vswap, vpegswap, beltfi, ellipsis, QuickSwap, COMETH, Wmatic, Nerve, Dfyn, UniswapV3, Smoothy, PantherSwap, OMM1, OneInchLP, CurveV2, mStable, WaultFinance, MDEX, ShibaSwap, CoinSwap, SakeSwap, JetSwap, Biswap, BProtocol eg: `UniswapV3,0x`.
@@ -179,7 +179,7 @@ type SwapTxInputListFields =
179
179
 
180
180
  type SwapRateOptions = Omit<
181
181
  SwapQueryParams,
182
- SwapTxInputFields | SwapTxInputListFields | 'network' | 'version'
182
+ SwapTxInputFields | SwapTxInputListFields | 'chainId' | 'version'
183
183
  > & {
184
184
  /**
185
185
  * @description List of DEXs to include. **Supported DEXs:** Uniswap, Kyber, Bancor, AugustusRFQ, Oasis, Compound, Fulcrum, 0x, MakerDAO, Chai, Aave, Aave2, MultiPath, MegaPath, Curve, Curve3, Saddle, IronV2, BDai, idle, Weth, Beth, UniswapV2, Balancer, 0xRFQt, SushiSwap, LINKSWAP, Synthetix, DefiSwap, Swerve, CoFiX, Shell, DODOV1, DODOV2, OnChainPricing, PancakeSwap, PancakeSwapV2, ApeSwap, Wbnb, acryptos, streetswap, bakeryswap, julswap, vswap, vpegswap, beltfi, ellipsis, QuickSwap, COMETH, Wmatic, Nerve, Dfyn, UniswapV3, Smoothy, PantherSwap, OMM1, OneInchLP, CurveV2, mStable, WaultFinance, MDEX, ShibaSwap, CoinSwap, SakeSwap, JetSwap, Biswap, BProtocol eg: `UniswapV3,0x`.
@@ -244,7 +244,7 @@ export const constructSwapTx = ({
244
244
  srcToken,
245
245
  destToken,
246
246
  route: _route,
247
- network: chainId,
247
+ chainId,
248
248
  version,
249
249
  ...parsedOptions,
250
250
  });