@uniswap/v4-sdk
Version:
⚒️ An SDK for building applications on top of Uniswap V4
22 lines • 830 B
JavaScript
import { CurrencyAmount } from '@uniswap/sdk-core';
export function amountWithPathCurrency(amount, pool) {
return CurrencyAmount.fromFractionalAmount(getPathCurrency(amount.currency, pool), amount.numerator, amount.denominator);
}
export 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}`);
}
}
//# sourceMappingURL=pathCurrency.js.map