Skip to content

Commit c47b68b

Browse files
Merge pull request #221 from VeloraDEX/feat/bridge-price-shape
Feat/bridge price shape
2 parents 4700c80 + 8195608 commit c47b68b

File tree

12 files changed

+49
-19
lines changed

12 files changed

+49
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@velora-dex/sdk",
3-
"version": "9.3.0",
3+
"version": "9.3.1",
44
"main": "dist/index.js",
55
"module": "dist/sdk.esm.js",
66
"typings": "dist/index.d.ts",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ import {
174174
GetDeltaPriceFunctions,
175175
DeltaPrice,
176176
BridgePrice,
177+
AvailableBridge,
177178
DeltaPriceParams,
178179
} from './methods/delta/getDeltaPrice';
179180
import {
@@ -379,6 +380,7 @@ export type {
379380
BridgeStatus,
380381
Bridge,
381382
BridgeInfo,
383+
AvailableBridge,
382384
BridgeProtocolResponse,
383385
BuildDeltaOrderDataParams,
384386
BuildDeltaOrderFunctions,

src/methods/delta/getBridgeInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type GetBridgeInfo = (
3131
export type BridgeProtocolResponse = {
3232
protocol: string;
3333
displayName: string;
34+
icon: string;
3435
};
3536

3637
type BridgeProtocolsResponse = {

src/methods/delta/getDeltaPrice.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Prettify } from 'viem';
12
import { Bridge } from '../..';
23
import { API_URL, SwapSide } from '../../constants';
34
import { constructSearchString } from '../../helpers/misc';
@@ -105,14 +106,15 @@ type AvailableBridgePrice = Pick<
105106
| 'gasCost'
106107
| 'gasCostUSDBeforeFee'
107108
| 'gasCostBeforeFee'
109+
| 'receivedDestAmount'
110+
| 'receivedDestAmountBeforeFee'
111+
| 'receivedDestUSD'
112+
| 'receivedDestUSDBeforeFee'
108113
>;
109114

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+
>;
116118

117119
export type BridgePrice = Omit<DeltaPrice, 'bridge'> & {
118120
// destAmountAfterBridge: string; // became bridgeInfo.destAmountAfterBridge

src/methods/delta/helpers/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,7 @@ export type BridgePriceInfo = {
151151
destUSDAfterBridge: string;
152152
fees: BridgeQuoteFee[];
153153
estimatedTimeMs: number;
154+
fastest: boolean;
155+
bestReturn: boolean;
156+
recommended: boolean;
154157
};

src/methods/quote/getQuote.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export type QuoteParams<M extends TradeMode = TradeMode> = {
2929
userAddress?: string;
3030
/** @description Partner string */
3131
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;
3236
/** @description Preferred mode for the trade. In case of "all", Delta pricing is returned, with Market as a fallback */
3337
mode: M;
3438
};

src/methods/swap/adapters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type GetAdaptersFunctions = {
1515
};
1616

1717
type SearchStringParams = {
18-
network: number;
18+
chainId: number;
1919
version?: APIVersion;
2020
};
2121

@@ -30,7 +30,7 @@ export const constructGetAdapters = ({
3030
): Promise<AdaptersAsStrings> => {
3131
// always pass explicit type to make sure UrlSearchParams are correct
3232
const query = constructSearchString<SearchStringParams>({
33-
network: chainId,
33+
chainId,
3434
version,
3535
});
3636

src/methods/swap/rates.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ type RateQueryParams = {
4242
side?: 'SELL' | 'BUY';
4343

4444
/**
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`.
4646
*/
47-
network?: number;
47+
chainId?: number;
4848

4949
/**
5050
* @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 = ({
221221
const search = constructSearchString<Omit<RateQueryParams, 'route'>>({
222222
srcToken,
223223
destToken,
224-
network: chainId,
224+
chainId,
225225
version,
226226
...parsedOptions,
227227
});
@@ -253,7 +253,7 @@ export const constructGetRate = ({
253253
Omit<RateQueryParams, 'srcToken' | 'destToken'>
254254
>({
255255
route: _route, // route can be used in place of srcToken+destToken
256-
network: chainId,
256+
chainId,
257257
version,
258258
...parsedOptions,
259259
});

src/methods/swap/spender.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export const constructGetSpender = ({
3636
chainId,
3737
fetcher,
3838
}: ConstructFetchInput): GetSpenderFunctions => {
39-
const search = constructSearchString<{ network: number; version: string }>({
40-
network: chainId,
39+
const search = constructSearchString<{ chainId: number; version: string }>({
40+
chainId,
4141
version,
4242
});
4343

src/methods/swap/swapTx.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ type SwapQueryParams = {
4141
side: 'SELL' | 'BUY';
4242

4343
/**
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`.
4545
*/
46-
network?: number;
46+
chainId?: number;
4747

4848
/**
4949
* @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 =
179179

180180
type SwapRateOptions = Omit<
181181
SwapQueryParams,
182-
SwapTxInputFields | SwapTxInputListFields | 'network' | 'version'
182+
SwapTxInputFields | SwapTxInputListFields | 'chainId' | 'version'
183183
> & {
184184
/**
185185
* @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 = ({
244244
srcToken,
245245
destToken,
246246
route: _route,
247-
network: chainId,
247+
chainId,
248248
version,
249249
...parsedOptions,
250250
});

0 commit comments

Comments
 (0)