Skip to content

Commit

Permalink
fix: demurrage constructor args
Browse files Browse the repository at this point in the history
  • Loading branch information
kamikazechaser committed Nov 5, 2024
1 parent c4e2b76 commit 8ebae0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 25 additions & 7 deletions internal/container/publish.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package container

import (
"errors"
"fmt"
"math/big"
"strings"
Expand Down Expand Up @@ -264,19 +265,31 @@ func (c *Container) erc20Demurrage() *cli.Command {
return nil
},
},
&cli.Uint64Flag{
Name: "demurrage-level",
Aliases: []string{"decay-level"},
Usage: "Level of decay per minute",
Value: 20000,
&cli.Int64Flag{
Name: "demurrage-rate",
Aliases: []string{"expiry-rate"},
Usage: "This is the rate at which the voucher will expire per redistribution period",
Value: 2,
Required: false,
Action: func(ctx *cli.Context, x int64) error {
if x < 1 {
return errors.New("rate should be atleast 1 percent")
}
return nil
},
},
&cli.Uint64Flag{
&cli.Int64Flag{
Name: "redistribution-period",
Aliases: []string{"period-minutes"},
Usage: "Number of minutes between each time the demurraged value can be withdrawn to the Sink Account",
Value: 43200,
Required: false,
Action: func(ctx *cli.Context, x int64) error {
if x < 10080 {
return errors.New("redistribution period should be atleast 1 week equivalent in minutes")
}
return nil
},
},
&cli.StringFlag{
Name: "sink-address",
Expand All @@ -286,11 +299,16 @@ func (c *Container) erc20Demurrage() *cli.Command {
},
},
Action: func(cCtx *cli.Context) error {
base := new(big.Int).Sub(big.NewInt(100), big.NewInt(cCtx.Int64("demurrage-rate")))
exponent := new(big.Int).SetInt64(1)
exponent = exponent.Div(exponent, big.NewInt(cCtx.Int64("redistribution-period")))
result := new(big.Int).Exp(base, exponent, nil)

contract := contract.NewERC20Demurrage(contract.ERC20DemurrageConstructorArgs{
Name: cCtx.String("name"),
Symbol: strings.ToUpper(cCtx.String("symbol")),
Decimals: uint8(cCtx.Uint("decimals")),
DecayLevel: big.NewInt(int64(cCtx.Uint64("demurrage-level"))),
DecayLevel: result,
PeriodMinutes: big.NewInt(int64(cCtx.Uint64("redistribution-period"))),
DefaultSinkAddress: ethutils.HexToAddress(cCtx.String("sink-address")),
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/erc20demurrage/erc20demurrage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
solidityVersion = "0.8.25+commit.b61c2a91"
evmFork = "istanbul"

gasLimit = 6_000_000
gasLimit = 7_500_000
)

var (
Expand Down

0 comments on commit 8ebae0c

Please sign in to comment.