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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bancor.rb +15 -1
- data/lib/bancor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bfa4cb3e5cd8debc116acd391aa3fd653dd5067bba326ab756a0217b3d19930
|
4
|
+
data.tar.gz: c8713fe1b8f4ce702611d5f480acfbd0c96bf25badf7b35891b1a67fdaaa2e7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c90407a6b893d3497b5fde69fe9d856dfb816d5ebfb6e8aeaf19168cfed4e0536ffe46b62f68d38e0e348a66472d91646823aa8e0642c0a3ca2288903e7cb6fa
|
7
|
+
data.tar.gz: 754d2dc25b28db0acae690d675a7a6958dcb4db27b62732c554893e37d92f1a75e25e6c9866c28b7f0ca48d79f46eddb34718de4c12547d9db29aad400e4263f
|
data/Gemfile.lock
CHANGED
data/lib/bancor.rb
CHANGED
@@ -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
|
data/lib/bancor/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|