How to use the @0x/asset-swapper.SwapQuoterError.AssetUnavailable 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.ts View on Github external
? Web3Wrapper.toUnitAmount(error.amountAvailableToFill, asset.metaData.decimals)
                        : error.amountAvailableToFill;
                const roundedUnitAmountAvailableToFill = unitAmountAvailableToFill.decimalPlaces(
                    2,
                    BigNumber.ROUND_DOWN,
                );

                if (roundedUnitAmountAvailableToFill.isGreaterThan(BIG_NUMBER_ZERO)) {
                    return `There are only ${roundedUnitAmountAvailableToFill} ${assetName} available to buy`;
                }
            }

            return `Not enough ${assetName} available`;
        } else if (
            error.message === SwapQuoterError.StandardRelayerApiError ||
            error.message.startsWith(SwapQuoterError.AssetUnavailable)
        ) {
            const assetName = assetUtils.bestNameForAsset(asset, 'This asset');
            return `${assetName} is currently unavailable`;
        }

        return undefined;
    },
};