Package Exports
- @mimicry/sdk
- @mimicry/sdk/dist/index.js
- @mimicry/sdk/dist/sdk.esm.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mimicry/sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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.
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 infoObject = await remilio.getInfo();
// 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 startThis builds to /dist and runs the project in watch mode so any edits you save inside src causes a rebuild to /dist.
- Use
yarn buildto do a one-off build. - Use
yarn analyizeto fix linting issues, run tests, and check distribution size. - Use
yarn publishto publish to NPM.
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 querying a player's position history with pagination and filtering
- Add support for 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 querying player earning statistics
- Add support for running strategy backtests