@uniswap/v4-sdk
Version:
⚒️ An SDK for building applications on top of Uniswap V4
27 lines • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPathCurrency = exports.amountWithPathCurrency = void 0;
const sdk_core_1 = require("@uniswap/sdk-core");
function amountWithPathCurrency(amount, pool) {
return sdk_core_1.CurrencyAmount.fromFractionalAmount(getPathCurrency(amount.currency, pool), amount.numerator, amount.denominator);
}
exports.amountWithPathCurrency = amountWithPathCurrency;
function getPathCurrency(currency, pool) {
if (pool.involvesCurrency(currency)) {
return currency;
}
else if (pool.involvesCurrency(currency.wrapped)) {
return currency.wrapped;
}
else if (pool.currency0.wrapped.equals(currency)) {
return pool.currency0;
}
else if (pool.currency1.wrapped.equals(currency)) {
return pool.currency1;
}
else {
throw new Error(`Expected currency ${currency.symbol} to be either ${pool.currency0.symbol} or ${pool.currency1.symbol}`);
}
}
exports.getPathCurrency = getPathCurrency;
//# sourceMappingURL=pathCurrency.js.map