-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketch use of converter inside LockstakeEngine
- Loading branch information
Showing
3 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
pragma solidity ^0.8.16; | ||
|
||
interface GemLike { | ||
function burn(address, uint256) external; | ||
function mint(address, uint256) external; | ||
} | ||
|
||
contract MkrNgtMock { | ||
GemLike public immutable mkr; | ||
GemLike public immutable ngt; | ||
uint256 public immutable rate; | ||
|
||
constructor(address mkr_, address ngt_, uint256 rate_) { | ||
mkr = GemLike(mkr_); | ||
ngt = GemLike(ngt_); | ||
rate = rate_; | ||
} | ||
|
||
function mkrToNgt(address usr, uint256 mkrAmt) external { | ||
mkr.burn(msg.sender, mkrAmt); | ||
uint256 ngtAmt = mkrAmt * rate; | ||
ngt.mint(usr, ngtAmt); | ||
} | ||
|
||
function ngtToMkr(address usr, uint256 ngtAmt) external { | ||
ngt.burn(msg.sender, ngtAmt); | ||
uint256 mkrAmt = ngtAmt / rate; | ||
mkr.mint(usr, mkrAmt); | ||
} | ||
} |