bancor 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4f4f1ce7a6d3f6cf58091747194671a82e6b5308cfb792f38329b09f5632059
4
- data.tar.gz: efa191249b8a22d435e47754a00b71aa0c18daba5c6f2377781eef69452b46c0
3
+ metadata.gz: 2bfa4cb3e5cd8debc116acd391aa3fd653dd5067bba326ab756a0217b3d19930
4
+ data.tar.gz: c8713fe1b8f4ce702611d5f480acfbd0c96bf25badf7b35891b1a67fdaaa2e7e
5
5
  SHA512:
6
- metadata.gz: fbf0e032a266365c037ec1af5cd03b64f20e5bdb0db8d21d23fce0655e829dbc0b0c0277ec8358041590f3441a8c7f9b0058ca8ae37d27588e48e78fdda68312
7
- data.tar.gz: db09f303715542076e46633fb3b28bc4cd13372bd729206d367d081094ee88342b5a7ce89c9576c61892b249955bbb5b0160adf85874f7e529a45ecb58937991
6
+ metadata.gz: c90407a6b893d3497b5fde69fe9d856dfb816d5ebfb6e8aeaf19168cfed4e0536ffe46b62f68d38e0e348a66472d91646823aa8e0642c0a3ca2288903e7cb6fa
7
+ data.tar.gz: 754d2dc25b28db0acae690d675a7a6958dcb4db27b62732c554893e37d92f1a75e25e6c9866c28b7f0ca48d79f46eddb34718de4c12547d9db29aad400e4263f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bancor (0.1.1)
4
+ bancor (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,7 +2,7 @@ require "bancor/version"
2
2
 
3
3
  module Bancor
4
4
  class Protocol
5
- attr_reader :total_supply, :reserved_token, :price
5
+ attr_reader :total_supply, :reserved_token, :price, :transaction_price
6
6
 
7
7
  def initialize(eth:, rate:, crr:)
8
8
  @total_supply = eth * rate
@@ -24,5 +24,19 @@ module Bancor
24
24
  @total_supply = @total_supply - quantity
25
25
  @price = @reserved_token / (@total_supply * @crr)
26
26
  end
27
+
28
+ def pricing_to_buy(quantity)
29
+ @transaction_price = @reserved_token * ((((quantity / @total_supply) + 1) ** (1/@crr)) - 1)
30
+ @total_supply = @total_supply + quantity
31
+ @reserved_token = @reserved_token + @transaction_price
32
+ @price = @reserved_token / (@total_supply * @crr)
33
+ end
34
+
35
+ def pricing_to_sell(quantity)
36
+ @transaction_price = @reserved_token * (1 - ((1 - (quantity / @total_supply)) ** (1/@crr)))
37
+ @total_supply = @total_supply - quantity
38
+ @reserved_token = @reserved_token - @transaction_price
39
+ @price = @reserved_token / (@total_supply * @crr)
40
+ end
27
41
  end
28
42
  end
@@ -1,3 +1,3 @@
1
1
  module Bancor
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bancor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Kurotaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-15 00:00:00.000000000 Z
11
+ date: 2017-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler