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

@mimicry/sdk

v1.1.0

Published

A node SDK designed to simplify interaction with the Mimicry Protocol smart contracts.

Downloads

42

Readme

This NPM library provides convenient access to smart contracts used by the Mimicry Protocol.

The intended audience is professional traders and market makers who wish to programmatically manage positions, and application developers who wish to integrate Mimicry Markets into their apps.

Installation

Run yarn add @mimicry/mimicry-sdk@latest to install the SDK.

Setup

The SDK allows developers to instantiate an instance in a few lines of code. For example:

import { Mimicry, ChainId, Direction } from "@mimicry/mimicry-sdk";
import { ethers } from "ethers";
import 'dotenv/config';

const privateKey = process.env.PRIVATE_KEY;
const providerUrl = process.env.PROVIDER_URL;
const provider = new ethers.JsonRpcProvider(providerUrl);
const signer = new ethers.Wallet(privateKey, provider);
const mimicry = new Mimicry(signer, ChainId.MUMBAI);

Usage

The SDK provides a number of methods to interact with the Mimicry Protocol. See ./example/ for a full example.

Here is a summary of the methods available:

Currencies - link to Currency class

// Get all supported currencies
const currencies = await mimicry.getCurrencies();

// Get a specific currency by address
const mockUsdc = await mimicry.getCurrency('0x123'); 

// Get currency name, symbol, address, decimals
const infoObject = await mockUsdc.getInfo(); 

// Approve spending of a currency; 
// note this is done automatically when opening a position
const tx = await mockUsdc.approveSpending('0x456', 10.50); 

Markets - link to Market class

// Get all known markets
const markets = await mimicry.getMarkets();

// Get one market
const remilio = await mimicry.getMarket('0x123');

// Get market name, address, description, image, metric, reference value, and skew of deposited capital
const marketInfo = await remilio.getInfo();

// Get market price history
const priceHistory = await remilio.getTicks();

// Open a position
const tx = await remilio.openPosition(Direction.SHORT, mockUsdc, 13.75);

// Close a specific position
const tx = await remilio.closePosition(15);

// Commit a value transfer in a market based on the current skew
const tx = await remilio.commitValueTransfer();

// Get the value of a specific position
const positionValue = await remilio.getPositionValue(28);

For Contributors

To run TSDX, use:

yarn start

This builds to /dist and runs the project in watch mode so any edits you save inside src causes a rebuild to /dist.

  • Use yarn build to do a one-off build.
  • Use yarn analyize to fix linting issues, run tests, and check distribution size.
  • Use yarn publish to publish to NPM. Note there is a weird quirk where you need to commit and sync the package.json version number at the start of the process, before entering the NPM 2FA code. Otherwise, the version number will be out of sync with the published package.

Roadmap

  • [ ] Add support for returning the token id and url when opening a position
  • [ ] Add support for querying a market's price history as candles with pagination and filtering
  • [ ] Add support for subgraph querying a player's position history with pagination and filtering
  • [ ] Add support for subgraph querying a market's position history with pagination and filtering
  • [ ] Add support for adding new markets
  • [ ] Add support for editing market name, description, or image
  • [ ] Add support for querying markets more efficiently
  • [ ] Add support for subgraph querying player earning statistics