New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@equilab/marginly-sdk

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equilab/marginly-sdk

SDK for the Marginly protocol

  • 1.0.2
  • npm
  • Socket score

Version published
Weekly downloads
19
decreased by-29.63%
Maintainers
2
Weekly downloads
 
Created
Source

Marginly SDK

SDK for the Marginly protocol

Usage

This SDK contains bindings for building Marginly contract calls and reproducing some inner math and calculations.

MarginlyPoolExecute

Contains an abstract class with methods to generate calls input for Marginly contracts.

import { BigNumber, parseUnits } from 'ethers';
import { convertPriceHumanToX96, MarginlyPoolExecute } from '@eq-lab/marginly-sdk';

const wethDecimals = BigNumber.from(18);
const usdcDecimals = BigNumber.from(6);

const depositBaseAmount = parseUnits('1', wethDecimals);
const longAmount = parseUnits('10', wethDecimals);
const limitPriceX96 = convertPriceHumanToX96(
    BigNumber.from(2000), 
    wethDecimals, 
    usdcDecimals
);

const { method, args, value } = MarginlyPoolExecute.depositBaseAndLong(
    depositBaseAmount, 
    longAmount, 
    limitPriceX96
);

MarginlyPoolPosition

This class is used to construct a Marginly position representation with real values from pools inner discounted ones. Moreover it contains methods for position characteristics calculations such as:

  • leverage
  • liquidation price
  • available withdraw amounts

MarginlyPoolMath

Contains low level math, used in contract calculations and other modules of sdk including:

  • FP96 math
  • discounted-to-real values conversions
  • X96 price conversions
  • low level position/pool parameters calculations (e.g. leverage, liquidation price)

Tests

Run tests

yarn test

FAQs

Package last updated on 28 Feb 2024

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