Skip to content

Instantly share code, notes, and snippets.

@nmushegian
Created March 27, 2022 13:42
Show Gist options
  • Save nmushegian/1bbf3780c90b8c290137143ae1b5cd64 to your computer and use it in GitHub Desktop.
Save nmushegian/1bbf3780c90b8c290137143ae1b5cd64 to your computer and use it in GitHub Desktop.
contract Vault {
Gem public top;
Gem public bot;
constructor(address _top, address _bot) {
top = _top; bot = _bot;
}
function cost(uint amt) external returns (uint);
function exit(uint amt) external returns (uint);
function join(uint amt) external returns (uint out) {
// #VARIANT burn and mint
out = cost(amt);
top.burn(msg.sender, amt);
bot.mint(msg.sender, out);
return out;
// #VARIANT hold and mint
out = cost(amt);
top.pull(msg.sender, amt);
bot.mint(msg.sender, out);
return out;
// etc
}
}
contract VaultWrap {
GemFab public gf;
mapping(address=>bool) public built;
constructor (GemFab _gf) {
gf = _gf;
}
function wrap(address bot, string name, string symbol) returns (Vault) {
require(gf.built(bot), 'ERR_FAKE_GEM');
address top = gf.build(name, symbol);
address vault = new Vault(top, bot);
built[vault] = true;
return vault;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment