Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@many-things/osmosis-router
Advanced tools
@many-things/osmosis-router
Minimal SDK for Osmosis Swap Estimation
yarn add @many-things/osmosis-router
# or use NPM
npm install @many-things/osmosis-router
USDC
(axlUSDC
) as tokenOutCurrency
)First, Define Currencies for your in/out tokens.
import { Currency } from '@keplr-wallet/types';
const tokenInCurrency: Currency = {
coinDenom: 'OSMO',
coinMinimalDenom: 'uosmo',
coinDecimals: 6,
};
const tokenOutCurrency: Currency = {
coinDenom: 'USDC',
coinMinimalDenom:
'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
coinDecimals: 6,
};
And just call estimateSwap
with the params.
Works like magic!
import { estimateSwap } from '@many-things/osmosis-router';
// 1 OSMO = 0.899660 USDC
const amount: string = (1 * 10 ** 6).toString();
estimateSwap(tokenInCurrency, tokenOutCurrency, amount); // CoinPretty (0.899660 USDC)
Note
estimateSwap
does the following:
- Update pools in Osmosis
- Get Routes (in -> out)
- Estimate swap using resolved route
The following is the current code for
estimateSwap
. You can use build your own custom implementation for efficiency, if you're estimating multiple times(e.g. using pools that are already fetched/cached).
import { type Pool } from '@many-things/osmosis-router';
import Axios, { AxiosInstance } from 'axios';
const defaultInstance = Axios.create({
baseURL: OSMOSIS_CHAIN_REST,
});
export const estimateSwap = async (
tokenInCurrency: Currency,
tokenOutCurrency: Currency,
amount: string,
pools?: Pool[],
instance: AxiosInstance = defaultInstance,
): Promise<CoinPretty> => {
const { getOsmosisPools, getOsmosisRoutes, getOsmosisSwapEstimation } =
await import('@many-things/osmosis-router');
if (!pools) {
pools = await getOsmosisPools({
instance,
}).catch((e) => {
console.log(e);
return [];
});
}
const routes = getOsmosisRoutes({
tokenInCurrency,
tokenOutCurrency,
amount,
pools,
});
const tokenOut = getOsmosisSwapEstimation({
tokenInCurrency,
tokenOutCurrency,
amount,
pools,
routes,
});
return tokenOut;
};
FAQs
Minimal SDK for Osmosis Swap Estimation
We found that @many-things/osmosis-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.