An open API service indexing awesome lists of open source software.

https://github.com/kurotaky/bancor

Implement the logic of Bancor protocol.
https://github.com/kurotaky/bancor

bancor bancor-protocol cryptocurrency

Last synced: 7 months ago
JSON representation

Implement the logic of Bancor protocol.

Awesome Lists containing this project

README

          

# Bancor
[![Gem](https://img.shields.io/gem/v/bancor.svg?style=flat-square)](https://rubygems.org/gems/bancor)
[![Build Status](https://travis-ci.org/kurotaky/bancor.svg?branch=master)](https://travis-ci.org/kurotaky/bancor)

Implement the logic of Bancor protocol.

* [Bancor Protocol: Continuous Liquidity for Cryptographic Tokens through their Smart Contracts](https://storage.googleapis.com/website-bancor/2018/04/01ba8253-bancor_protocol_whitepaper_en.pdf)
* [Bancor Protocol: Continuous Liquidity and Asynchronous Price Discovery for Tokens through their Smart Contracts; aka “Smart Tokens](https://bravenewcoin.com/assets/Whitepapers/Bancor-Protocol-Whitepaper-en.pdf)

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'bancor'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install bancor

## Usage
### issue/destroy by reserve token
```ruby
irb(main):008:0> bp = Bancor::Protocol.new(eth: 300000, rate: 1, crr: 0.2)
=> #

irb(main):009:0> bp.issue_by_reserve_token 300
=> 299.40179372385245

irb(main):010:0> bp
=> #

irb(main):011:0> bp.issue_by_reserve_token 700
=> 693.9974382206417

irb(main):012:0> bp
=> #

irb(main):013:0> bp.destroy_by_reserve_token 1302
=> 1307.966524590907

irb(main):014:0> bp
=> #

irb(main):015:0> bp.issue_by_reserve_token 100
=> 100.34530853232869

irb(main):016:0> bp
=> #
```

### issue/destroy by smart token
```ruby
irb(main):015:0> bp = Bancor::Protocol.new(eth: 300000, rate: 1, crr: 0.2)
=> #

irb(main):016:0> bp.issue_by_smart_token 50
=> 0.0

irb(main):017:0> bp
=> #

irb(main):018:0> bp.issue_by_smart_token 100
=> 0.0

irb(main):019:0> bp
=> #

irb(main):020:0> bp.destroy_by_smart_token 100
=> 0.0

irb(main):021:0> bp
=> #

irb(main):022:0> bp.destroy_by_smart_token 50
=> 0.0

irb(main):023:0> bp
=> #
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kurotaky/bancor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the Bancor project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kurotaky/bancor/blob/master/CODE_OF_CONDUCT.md).