Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jup-ag/crema-sdk

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jup-ag/crema-sdk

the front sdk for crema swap

  • 2.0.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
386
decreased by-3.98%
Maintainers
4
Weekly downloads
 
Created
Source

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} $

FAQs

Package last updated on 06 Jun 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc