@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
98 lines • 3.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchRatesMock = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const errors_1 = require("../../../../../errors");
const MIN_AMOUNT_FROM = new bignumber_js_1.default(0.0001);
const MAX_AMOUNT_FROM = new bignumber_js_1.default(1000);
const fetchRatesMock = (amountFrom, fromCurrencyID) => {
const bigNumberAmountFrom = (0, bignumber_js_1.default)(amountFrom);
if (bigNumberAmountFrom.lte(MIN_AMOUNT_FROM)) {
throw new errors_1.SwapExchangeRateAmountTooLow(undefined, {
minAmountFromFormatted: `${MIN_AMOUNT_FROM}`,
});
}
if (bigNumberAmountFrom.gte(MAX_AMOUNT_FROM)) {
throw new errors_1.SwapExchangeRateAmountTooHigh(undefined, {
maxAmountFromFormatted: `${MAX_AMOUNT_FROM}`,
});
}
if (fromCurrencyID === "bitcoin") {
return [
{
provider: "changelly",
providerType: "CEX",
rateId: "^WIpYZZFCdjPwLY7YLFnY*T5Q4@abI",
from: "ethereum",
to: "bitcoin",
amountFrom: "100",
amountTo: "0.059713921500",
rate: "0.000577819215",
payoutNetworkFees: "0.001932",
expirationTime: "1694082226000",
tradeMethod: "fixed",
status: "success",
},
{
provider: "changelly",
providerType: "CEX",
from: "ethereum",
to: "bitcoin",
amountFrom: "100",
amountTo: "0.05949154",
minAmountFrom: "21.61899",
maxAmountFrom: "2417804.095968",
payoutNetworkFees: "0.0019320000000000000000",
tradeMethod: "float",
status: "success",
},
];
}
return [
{
provider: "oneinch",
providerType: "DEX",
providerURL: "https://1inch.com/swap/#/1/unified/swap/usdt/eth&sourceTokenAmount=100",
from: "ethereum/erc20/usd_tether__erc20_",
to: "ethereum",
amountFrom: "100",
amountTo: "0.030863259880419774",
minAmountFrom: "0.0",
payoutNetworkFees: "0.00192528",
tradeMethod: "float",
status: "success",
},
{
provider: "changelly",
providerType: "CEX",
rateId: "^WIpYZZFCdjPwLY7YLFnY*T5Q4@abI",
from: "ethereum/erc20/usd_tether__erc20_",
to: "ethereum",
amountFrom: "100",
amountTo: "0.059713921500",
rate: "0.000577819215",
payoutNetworkFees: "0.001932",
expirationTime: "1694082226000",
tradeMethod: "fixed",
status: "success",
},
{
provider: "changelly",
providerType: "CEX",
from: "ethereum/erc20/usd_tether__erc20_",
to: "ethereum",
amountFrom: "100",
amountTo: "0.05949154",
minAmountFrom: "21.61899",
maxAmountFrom: "2417804.095968",
payoutNetworkFees: "0.0019320000000000000000",
tradeMethod: "float",
status: "success",
},
];
};
exports.fetchRatesMock = fetchRatesMock;
//# sourceMappingURL=fetchRates.mocks.js.map