Skip to content

Commit

Permalink
Add support of watermark in init method
Browse files Browse the repository at this point in the history
  • Loading branch information
donhardman committed Jul 11, 2021
1 parent de77d41 commit 518e67c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ composer require muvon/bitclout-creator-coin
```php
use Muvon\Bitclout\CreatorCoin;
$Coin = CreatorCoin::create(0); // pass reward basis points
$Coin->init(1000, 1000); // locked and supply in nanos
// Watermark is optional
$Coin->init(1000, 1000, 0); // locked, supply and watermark in nanos
```

### Emulate buys
Expand Down
6 changes: 4 additions & 2 deletions src/CreatorCoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ public static function create(int $reward): static {
* Locked amount in nanos
* @param int $supply
* Total supply in $creator coins in nanos
* @param int $watermark
* Optional watermark in case we use same strategy
* @return static
*/
public function init(int $locked, int $supply): static {
public function init(int $locked, int $supply, int $watermark = 0): static {
if ($this->supply > 0) {
throw new Exception('Creator coin was inited already');
}
$this->locked = $locked;
$this->supply = $supply;
$this->watermark = $supply;
$this->watermark = max($supply, $watermark);
$this->recalculateRate();
return $this;
}
Expand Down

0 comments on commit 518e67c

Please sign in to comment.