@@ -2,7 +2,6 @@ package currencycreator
22
33import (
44 "fmt"
5- "math"
65 "testing"
76
87 "github.com/stretchr/testify/require"
@@ -15,9 +14,9 @@ func TestEstimateCurrentPrice(t *testing.T) {
1514
1615func TestEstimatValueExchange (t * testing.T ) {
1716 quarks := EstimateValueExchange (& EstimateValueExchangeArgs {
18- ValueInQuarks : 5000000 , // $5
19- CurrentSupplyInQuarks : 7232649000000000 , // 723,264.9 tokens
20- ValueMintDecimals : 6 ,
17+ ValueInQuarks : 10000000 , // $10
18+ CurrentValueInQuarks : 1000000000 , // $1000
19+ ValueMintDecimals : 6 ,
2120 })
2221
2322 fmt .Printf ("%d quarks\n " , quarks )
@@ -63,19 +62,19 @@ func TestEstimates_CsvTable(t *testing.T) {
6362 startValue := uint64 (10000 ) // $0.01
6463 endValue := uint64 (1000000000000000 ) // $1T
6564
66- fmt .Println ("value locked,payment value,payment quarks,sell value" )
65+ fmt .Println ("value locked,total circulating supply,new circulating supply, payment value,payment quarks,sell value" )
6766 for valueLocked := startValue ; valueLocked <= endValue ; valueLocked *= 10 {
68- circulatingSupply , _ := EstimateBuy (& EstimateBuyArgs {
67+ totalCirculatingSupply , _ := EstimateBuy (& EstimateBuyArgs {
6968 BuyAmountInQuarks : valueLocked ,
7069 CurrentSupplyInQuarks : 0 ,
7170 ValueMintDecimals : 6 ,
7271 })
7372
7473 for paymentValue := startValue ; paymentValue <= valueLocked ; paymentValue *= 10 {
7574 paymenQuarks := EstimateValueExchange (& EstimateValueExchangeArgs {
76- ValueInQuarks : paymentValue ,
77- CurrentSupplyInQuarks : circulatingSupply ,
78- ValueMintDecimals : 6 ,
75+ ValueInQuarks : paymentValue ,
76+ CurrentValueInQuarks : valueLocked ,
77+ ValueMintDecimals : 6 ,
7978 })
8079
8180 sellValue , _ := EstimateSell (& EstimateSellArgs {
@@ -84,9 +83,18 @@ func TestEstimates_CsvTable(t *testing.T) {
8483 ValueMintDecimals : 6 ,
8584 })
8685
87- require .True (t , math .Abs (float64 (paymentValue )- float64 (sellValue )) <= 1 )
86+ diff := int64 (paymentValue ) - int64 (sellValue )
87+ require .True (t , diff >= - 1 && diff <= 1 )
88+
89+ newCirculatingSupply , _ := EstimateBuy (& EstimateBuyArgs {
90+ BuyAmountInQuarks : valueLocked - paymentValue ,
91+ CurrentSupplyInQuarks : 0 ,
92+ ValueMintDecimals : 6 ,
93+ })
94+ diff = int64 (totalCirculatingSupply ) - int64 (newCirculatingSupply ) - int64 (paymenQuarks )
95+ require .True (t , diff >= - 1 && diff <= 1 )
8896
89- fmt .Printf ("%d,%d,%d,%d\n " , valueLocked , paymentValue , paymenQuarks , sellValue )
97+ fmt .Printf ("%d,%d,%d,%d,%d,%d \n " , valueLocked , totalCirculatingSupply , newCirculatingSupply , paymentValue , paymenQuarks , sellValue )
9098 }
9199 }
92100}
0 commit comments