npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@storm-trade/sdk

v0.7.9

Published

Storm Trade protocol SDK

Downloads

233

Readme

NOTE: smart contract interaction diagrams can be found at /misc/pics

Storm Trade TON contracts

Welcome to the Storm Trade repository! This repository contains the smart contract code for the first perpetual futures decentralized exchange (DEX) protocol on the TON blockchain. Storm Trade allows users to trade futures contracts with no expiration date, providing a unique trading experience compared to traditional futures exchanges. The platform's aim is to provide a secure, transparent, and efficient trading environment for its users.

This repository contains the smart contract code for Storm Trade written in FunС programming language, as well as the tests and scripts written in Typescript.

Architecture overview

Hackaton protocol smart contracts system consists of three key components:

  • Position manager. Sharded smart contract. It contains the latest long and/or short position and orders for a specific trader. It provides its data every time a request is sent to the vAMM contract, which implies a change in trader position data. Afrer every provide_position request contract locks it data, waiting for vAMM's response to prevent double spending or data inconsistency caused by asynchronous TON architecture. Contract unlocks it's state after unlock_position or update_position vAMM's messages.
  • vAMM. Handles all the exchange operations with corresponding handler, position data and oracle price

vAMM main handlers:

  • increase_position: This function allows users to open a new position or increase their opened position in a perpetual futures contract by buying more of the underlying asset. Takes amount, direction, leverage, min_base_asset_amount, previous position_ref and last oracle price_ref.

  • add_margin: This function allows users to add more collateral to their open position in order to increase their margin and reduce the risk of liquidation. This function allows users to open a new position or increase their opened position in a perpetual futures contract by buying more of the underlying asset. Takes amount, previous position_ref and last oracle price_ref.

  • close_position: This function allows users to close their open position in a perpetual futures contract by selling the underlying asset. Takes _size, _minQuoteAssetAmount, flag _addToMargin, previous position_ref and last oracle price_ref.

  • remove_margin: This function allows users to withdraw excess collateral from their open position. Takes _amount, previous position_ref and last oracle price_ref.

  • pay_funding: This function allows users to pay the funding rate for holding a perpetual futures position. Perpetual futures contracts typically have a funding rate that is paid periodically to ensure that the price of the futures contract stays in line with the underlying asset. Takes last oracle price_ref.

  • liquidate: : This function allows the exchange to automatically liquidate a user's open position if it becomes under-collateralized. Can be called by anyone. Takes to_liquidate_address, previous position_ref and the last oracle price_ref.

Layout

This project was bootstraped using Blueprint 💙

  • contracts - contains the source code of all the smart contracts of the project and their dependencies.
  • wrappers - contains the wrapper classes (implementing Contract from ton-core) for the contracts, including any [de]serialization primitives and compilation functions.
  • tests - tests for the contracts.
  • scripts - contains scripts used by the project, mainly the deployment scripts.

How to use

  • Clone this repo
  • Run yarn install

Testing

Run tests:

yarn test

Tests are writen with @ton-community/sandbox.

License

MIT