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

@moneyonchain/oracles

v1.5.1-beta.12

Published

Money On Chain Oracles and Beyond Oracle smart contracts

Downloads

40

Readme

MONEY ON CHAIN

Decentralized Oracle System

Overview

The objective of this system is to provide on-chain price for our tokens in a trust-less decentralized manner.

We describe the different components involved in this system and their interaction.

This repository contains the Smart Contracts' source code only and its related utilities and tests. The off-chain part of this system is available at money-on-chain/OMoC-Node.

Components

Smart Contracts: Which interfaces to register and approve Price Providers, start and close rounds, and publish price information on-chain by approved Price Providers.

Price Providers: Reference server implementation which will feed the contacts with price retrieved from exchange systems. It can determine the next price publisher, co-sign price publication messages, and call the smart contract interface to publish a new price. It is also responsible to keep the contract system running (schedules periodic tasks).

Supporters: A member willing to participate in the system only with its stake. By locking their funds for a period of time they can participate from the system earnings, fees and subsidy distribution.

WebDApp: An browser side application which interacts with the contracts and let you configure, monitor and operate the system.

Exchanges: External dependency to retrieve required prices from.

Project Structure

  • contracts: The source code of the Solidity contracts that support the system.
  • contracts/change: Contracts prepared to update system settings on chain.
  • contracts/libs: Some contracts with common functionality.
  • contracts/testing_mocks: Contracts used to mock up external contracts functionality.
  • test: Tests for this contract system.
  • scripts: Tools to monitor and interact with the system when running over RSK network.

Smart Contracts Design

Architecture

OracleManager: Allows any blockchain user to register an oracle in the system and subscribe it as a price-provider for different coin-pairs.

CoinPairPrice (one per coinpair): This contract keeps the price and is responsible to receive and validate price updates provided. Also tracks providers participation in order to provide rewards.

Supporters: Will track stake-period contributed by supporters and will provide a reward in compensation.

CoinPairRegister: A contract to set up which coin-pairs will the system accept.

Governance: Control changes and upgrades over the contracts

Smart-Contract Code structure

All the contracts are upgradeable so when they are deployed there are two instances one has the implementation code and one the storage. We must have the storage well organized so different upgrades can reuse the same storage without clashes. During upgrade the implementation code can be changed, but the storage doesn't change (the variables keep the same slots). So it is better to have the storage separated from the implementation even in the source code.

To do that we have all the storage in one base contract that is inherited by the implementation. All the reusable code is in libraries and doesn't use any storage (libraries are stateless).

Operation

Foundation will set up and deploy contracts and will provide theirs addresses for anyone willing to participate. When minimal participants join the contracts will be "started".

Kickoff

When a coinpair participants have reach a minimal number required to work, the 0-round will be manually started.

Rounds

The CoinPair contracts work on a round-basis. The top N price-provider which contribute more stake will be selected to work at the beginning of each round. Each round lasts one month, and it is expected for the selected providers to work to do their job the whole time of the round. The round will end and a new round will be started automatically. When the new round begins a new provider selection will be made. During the round, each time a provider publish a pair-price to the contract, it will be accounted one point. At the same time, the contract will be receiving reward tokens which will be distributed at the end of the round proportionally to the points collected by each provider.

Price publishing

The price publishing or posting is made by turns. The turns are selected proportionally to the stake of the participants and is determined by the previous publication-block's hash. Each hash determines a particular participants order for next publication.

When to publish a price is determined by the price change from previous publication. If the expected participant don't publish for a defined period of blocks, the following in the order defined will be allowed to publish. And this fallback scheme repeats allowing multiple providers to take fallback turn in case of being required.

To publish a price it is required the consensus from half plus one of the round-selected providers. To ask for consensus, providers connects off-chain. Willing to publish provider will create a "publish-message" including block number, price to publish, etc., and will deliver it to other providers who will validate its content and return their signature. When enough signatures is received, "publish-message" and signatures is sent to contract which will verify the agreement and set the price in accordance.

Supporters

Supporters do have a round-system too, but it is transparent for the users. Reward is collected all during a certain period, and after that it is assigned to current supporters according to their stake and will be all available for the user at the end of the following round. If the user decides to retire before it will receive a part proportional to how long it stayed in the system. Each participant registering a price-provider will automatically also be registered as supporter and will receive proportional support-rewards as any other supporter no matter if is selected as price-provider.