How to use the @0x/asset-swapper.SwapQuoter.getSwapQuoterForProvidedOrders function in @0x/asset-swapper

To help you get started, we’ve selected a few @0x/asset-swapper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xProject / 0x-monorepo / packages / instant / src / util / asset_swapper_factory.ts View on Github external
getSwapQuoter: (supportedProvider: SupportedProvider, orderSource: OrderSource, network: Network): SwapQuoter => {
        const swapQuoterOpts: Partial = {
            chainId: network,
        };
        const swapQuoter = _.isString(orderSource)
            ? SwapQuoter.getSwapQuoterForStandardRelayerAPIUrl(supportedProvider, orderSource, swapQuoterOpts)
            : SwapQuoter.getSwapQuoterForProvidedOrders(supportedProvider, orderSource, swapQuoterOpts);
        return swapQuoter;
    },
    getSwapQuoteConsumer: (supportedProvider: SupportedProvider, network: Network): SwapQuoteConsumer => {
github 0xProject / 0x-monorepo / packages / instant / src / index.umd.ts View on Github external
assert.isHexString('takerAssetData', takerAssetData);
    assert.isValidOrderSource('orderSource', orderSource);
    assert.isNumber('chainId', chainId);

    let provider = supportedProvider;
    if (provider !== undefined) {
        provider = providerUtils.standardizeOrThrow(provider);
    }

    const bestProvider: ZeroExProvider = provider || providerFactory.getFallbackNoSigningProvider(chainId);

    const swapQuoterOptions = { chainId };

    const swapQuoter = _.isString(orderSource)
        ? SwapQuoter.getSwapQuoterForStandardRelayerAPIUrl(bestProvider, orderSource, swapQuoterOptions)
        : SwapQuoter.getSwapQuoterForProvidedOrders(bestProvider, orderSource, swapQuoterOptions);

    const wethAssetData = await swapQuoter.getEtherTokenAssetDataOrThrowAsync();
    const liquidity = await swapQuoter.getLiquidityForMakerTakerAssetDataPairAsync(wethAssetData, takerAssetData);
    return liquidity.makerAssetAvailableInBaseUnits.gt(new BigNumber(0));
};