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

@interlay/xopts

v0.2.18

Published

Bitcoin-backed put options on Ethereum.

Downloads

105

Readme

XOPTS

About

In traditional finance, an option enables the owner to buy or sell an underlying asset at a specified conversion rate before an expiration date. XOPTS extends the native capabilities of Ethereum to track and execute PUT Options against BTC. Specifically, we enable sellers to lock DAI collateral in a contract to mint ERC-20 compatible option tokens that can be traded on Uniswap. Buyers can then insure an arbitrary amount of BTC relative to the contract's strike price and pay in an amount of DAI collateral as premium. Finally, options can be exercised once the buyer proves payment to the respective writers of that contract using an on-chain Bitcoin SPV client.

Protocol

  • A seller (writer) creates a BTC put option with a strike price (the value of BTC the seller is willing to insure in Dai), an expiry time (the validity of the option), and a premium (the fee paid to the seller for buying an option in Dai).
  • A seller writes an option contract previously created by locking a number of Dai into the option contract. This creates a number of option tokens with the specific expiry, premium and strike price that are now available for buyers to obtain. During this process the seller also attaches his BTC address to the option tokens. For example, if the strike price is 10,000 Dai for a BTC and the seller locks 1,000 Dai, he would have generated 1,000 option tokens.
  • The buyer then goes ahead and buys a number of option tokens at a specific expiry, premium, and strike price.
  • During the expiry time, the buyer can exercise the option. To achieve this, he must send a number of BTC to the seller. Then, he proves that he sent the required number of BTC to the option smart contract. In return, the option tokens are burned and the buyer obtains underlying Dai provided by the seller.
  • After the expiry time, the seller can reclaim any unused collateral.
  • At any time a buyer can exchange his option tokens on Uniswap in a (Dai/Options) trading pair.

System Overview

You can find more details on how XOpts works in our Guides (buy, sell, exercise, refund options).

Built with

Getting Started

Make sure you have node installed. Generally, we also recommend managing different version of node via version manager like NVM.

Clone this repository and enter into its root folder.

git clone [email protected]:interlay/xopts.git
cd xopts

Install the required node packages.

yarn install

Try it out

Compile the contracts and create the TypeChain interfaces.

yarn build

Start buidlerevm.

yarn buidler

In another terminal, deploy the contracts and create some test data. Execute this from the root folder of the project.

yarn deploy::test --network localhost

Note that you can deploy without specifying the network but this will not persist, hence we start an Ethereum node first.

Go to xopts.io and point your MetaMask wallet to localhost:8545. On your first setup, you might need to add one of the buidlerevm accounts to your MetaMask list of accounts by importing the private key. You can find the private keys of the buidlerevm accounts in the console output where you started buidler evm (with the yarn buidler command). It should look like this:

Development

After compiling the contracts as described above, run the tests.

yarn test

Docker

Tests for both smart contracts and frontend can be executed within Docker.

docker build . -t interlay/xopts
docker run -t interlay/xopts yarn test
docker run -t interlay/xopts yarn test-js

Docs

We build our docs using solidity-docgen and docsify.

yarn docs

Point your local browser to ./docs/index.html or use the docsify-cli tool to start a live reload development server.

yarn global add docsify-cli
docsify serve ./docs

Releasing

Prior to bumping the package.json version, first clean and rebuild the project.

yarn clean
yarn build
yarn tsc
yarn publish --access public

Bitcoin Testnet

In order to verify testnet transactions we need to swap out any mocked components.

  1. Launch a local instance of Ganache via yarn run ganache.
  2. Clone the btc-relay-sol repository.
  3. Deploy using the testnet configuration.
  4. On OptionPool deployment use the live relay address and ./lib/TxValidator.sol.

React UI

Clone the xopts-ui and in a separate terminal window.

git clone [email protected]:interlay/xopts-ui.git
yarn install
yarn start

You can interact with a locally deployed front-end on localhost:3000.

Deployments

Gas Costs

| Function | Gas | Details | |---------------------|---------|-----------------------------| | constructor | 4459604 | Deploy Option Factory | | createOption | 3099130 | Create Sell & Buy ERC-20 | | writeOption | 241516 | Deposit Collateral | | transfer | 119209 | Transfer Unsold Options | | insureOption | 221144 | Buy Options At Premium | | transfer | 117892 | Transfer Sold Options | | exerciseOption | 59380 | Prove BTC Payment |

Ethereum Ropsten Testnet

You can interact with Xopts on xopts.io or run a locally deployed front-end on localhost:3000.

Roadmap

  • [x] Put Options
  • [ ] Call Options

Contributing

If you would like to contribute, please file an issue on Github or reach out to us.

We are hiring!

License

(C) Copyright 2020 Interlay Ltd

XOPTS is licensed under the terms of the Apache License (Version 2.0). See LICENSE.

Contact

Website: Interlay.io

Twitter: @interlayHQ

Email: [email protected]