open-index/open-npm huggingface dataset:
npm package: @jup-ag/plugin
Description: Jupiter Plugin is an open-sourced, lite version of Jupiter that provides end-to-end swap flow by linking it in your HTML.
Latest version: 1.0.14

# Jupiter Plugin

Jupiter Plugin is an open-sourced, lite version of Jupiter that provides end-to-end swap flow by linking it in your HTML.

Visit our Demo / Playground over at https://plugin.jup.ag

With several templates to get you started, and auto generated code snippets.

## Local Development

If you are running the project locally, you will need to set `NEXT_PUBLIC_IS_PLUGIN_DEV=true` in your `.env` file.
npm package: @jup-ag/react-hook
Description: The react hook to connect integrate Jupiter.
Author: zhengyutay
Latest version: 6.2.0

# @jup-ag/react-hook

The react hook to connect integrate Jupiter.

# Installation

Yarn
```
yarn add @jup-ag/react-hook
```

NPM
```
npm install @jup-ag/react-hook
```

## Usage
At your App shell:
```tsx
import { JupiterProvider } from '@jup-ag/react-hook';
import { Connection } from '@solana/web3.js';

const connection = new Connection('https://rpc.ankr.com/solana');

const App = ({ children }) => {
  const wallet = useWallet() // user wallet
  return (
    <JupiterProivder connection={connection} cluster="mainnet-beta" userPublicKey={wallet.publicKey}>
      {children}
    </JupiterProvider>
  )
}
```

```tsx
import { useJupiter } from '@jup-ag/raect-hook';

const SwapForm = () => {
  const jupiter = useJupiter({
    amount, // integer amount in term of input mint
    inputMint,
    outputMint,
    slippageBps,
    debounceTime, // debounce time before refresh
  })

  const {
    allTokenMints, // all the token mints that is possible to be input
    routeMap, // routeMap, same as the one in @jup-ag/core
    exchange, // exchange 
    refresh, // function to refresh rates
    lastRefreshTimestamp: lastRefreshTimestamp.current, // timestamp when the data was last returned
    loading, // loading states
    routes, // all the routes from inputMint to outputMint
    error,
  } = jupiter
}
```

## Example repo
https://github.com/ZhengYuTay/create-dapp-solana-nextjs
npm package: @jup-ag/swap-sdk
Description: the front sdk for crema swap
Latest version: 2.0.5

## Install:

```
npm i @cremafinance/crema-sdk
```

## Build:

```
npm run build
```

## Instructions:

```
import { TokenSwap } from '@cremafinance/crema-sdk'
const swap = await new TokenSwap(conn, swapProgramId, swapKey, null).load()
const amountOut: any = await swap.preSwapA(amountIn) // a->b
const amountOut: any = await swap.preSwapB(amountIn) // b->a
```

## Parameters Description：

```
amountIn: Decimal (using decimal.js repo)
```


## Liquidity Calculation Formula

Assuming the current price is $P_{c}$，the price range that users add liquidity in is $[P_{a},P_{b}]$

$
\LARGE
L = \begin {cases}
    ¦   {Δx} \over {1 \over {\sqrt{P_{a}}}} -  {1 \over {\sqrt{P_{b}}}} &, \text P_{c} < P_{a} \\    \
    ¦   {Δy} \over {\sqrt{P_{b}} - \sqrt{P_{a}}} &, \text P_{c} > P_{b}\\
    ¦   {{Δx} \over {1 \over {\sqrt{P_{c}}}} -  {1 \over {\sqrt{P_{b}}}}} = {{Δy} \over {\sqrt{P_{c}} - \sqrt{P_{a}}}} &, \text P_{c} \in [P_{a},P_{b}]  \\    \
    \end {cases}
$