Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0ad1ca5
first commit
AbigailTCameron Oct 31, 2021
49f2d03
include harvest
AbigailTCameron Nov 2, 2021
b5e47d5
current position
AbigailTCameron Nov 8, 2021
ddb1c13
current
AbigailTCameron Nov 8, 2021
bf1ce02
first draft
AbigailTCameron Nov 10, 2021
8ece63c
draft
AbigailTCameron Nov 10, 2021
87d4e90
pause-point
AbigailTCameron Nov 14, 2021
9333426
breakpoint
AbigailTCameron Nov 14, 2021
d36cad6
wonderland interface
AbigailTCameron Nov 14, 2021
3b8d31c
breakpoint
AbigailTCameron Nov 15, 2021
ac6048d
breakpoint
AbigailTCameron Nov 15, 2021
bc9121f
breakpoint
AbigailTCameron Nov 15, 2021
f2c6f8d
breakpoint
AbigailTCameron Nov 15, 2021
a1f1f52
breakpoint
AbigailTCameron Nov 16, 2021
fa90de5
pause
AbigailTCameron Nov 29, 2021
803280f
pause
AbigailTCameron Dec 8, 2021
61df5c9
pause
AbigailTCameron Dec 8, 2021
fce9d3c
wonderland testing
AbigailTCameron Dec 9, 2021
8a2eeb5
interface update
AbigailTCameron Dec 10, 2021
bd399bb
time-avax
AbigailTCameron Dec 10, 2021
90e23bf
time-avax
AbigailTCameron Dec 10, 2021
c83c3a3
time-avax-time
AbigailTCameron Dec 10, 2021
d8c75f6
wonderland base
AbigailTCameron Dec 10, 2021
188c580
time-farm
AbigailTCameron Dec 10, 2021
276c90a
time-mim
AbigailTCameron Dec 10, 2021
9ce46a0
time-mim
AbigailTCameron Dec 10, 2021
489fcbf
lp updated
AbigailTCameron Dec 10, 2021
bca6ba7
time-staking
AbigailTCameron Dec 10, 2021
3a80287
snowglobes
AbigailTCameron Dec 10, 2021
dccb291
wonderland base
AbigailTCameron Dec 10, 2021
084bef8
farm
AbigailTCameron Dec 10, 2021
1d81f18
price
AbigailTCameron Dec 10, 2021
82b52fb
running tests
AbigailTCameron Dec 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions contracts/interfaces/wonderland.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;


interface IDistributor {
function distribute() external returns ( bool );
}

interface IMemo {
function rebase( uint256 ohmProfit_, uint epoch_) external returns (uint256);

function circulatingSupply() external view returns (uint256);

function balanceOf(address who) external view returns (uint256);

function gonsForBalance( uint amount ) external view returns ( uint );

function balanceForGons( uint gons ) external view returns ( uint );

function index() external view returns ( uint );
}


interface IWarmup {
function retrieve( address staker_, uint amount_ ) external;
}


interface ITreasury {
function deposit( uint _amount, address _token, uint _profit ) external returns ( bool );
function valueOf( address _token, uint _amount ) external view returns ( uint value_ );
function mintRewards( address _recipient, uint _amount ) external;
}


enum PARAMETER { VESTING, PAYOUT, DEBT, MINPRICE }

interface ITimeBondDepository {
function initializeBondTerms(uint _controlVariable, uint _minimumPrice, uint _maxPayout, uint _maxDebt, uint _initialDebt, uint32 _vestingTerm) external;

function setBondTerms ( PARAMETER _parameter, uint _input ) external;

function setAdjustment ( bool _addition, uint _increment, uint _target, uint32 _buffer ) external;

function setStaking( address _staking, bool _helper ) external;

function deposit( uint _amount, uint _maxPrice, address _depositor) external payable returns ( uint );

function redeem( address _recipient, bool _stake ) external returns ( uint );

function stakeOrSend( address _recipient, bool _stake, uint _amount ) external returns ( uint );
}

interface ITimeStaking {
function rebase() external;
function unstake( uint _amount, bool _trigger) external;
}

interface IStaking {
function stake( uint _amount, address _recipient ) external returns ( bool );
function claim( address _recipient ) external;
}

interface IStakingHelper {
function stake( uint _amount, address _recipient ) external;
}
7 changes: 7 additions & 0 deletions contracts/lib/safe-math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ library SafeMath {
return c;
}

function add32(uint32 a, uint32 b) internal pure returns (uint32) {
uint32 c = a + b;
require(c >= a, "SafeMath: addition overflow");

return c;
}

/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
Expand Down
131 changes: 131 additions & 0 deletions contracts/snowglobes/traderJoe/snowglobe-joe-avax-craft.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// https://github.com/iearn-finance/vaults/blob/master/contracts/vaults/yVault.sol

pragma solidity ^0.6.7;

import "../../interfaces/controller.sol";

import "../../lib/erc20.sol";
import "../../lib/safe-math.sol";

contract SnowGlobeJoeAvaxCraft is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;

IERC20 public token;

uint256 public min = 9500;
uint256 public constant max = 10000;

address public governance;
address public timelock;
address public controller;

constructor(address _token, address _governance, address _timelock, address _controller)
public
ERC20(
string(abi.encodePacked("freezing ", ERC20(_token).name())),
string(abi.encodePacked("s", ERC20(_token).symbol()))
)
{
_setupDecimals(ERC20(_token).decimals());
token = IERC20(_token);
governance = _governance;
timelock = _timelock;
controller = _controller;
}

function balance() public view returns (uint256) {
return
token.balanceOf(address(this)).add(
IController(controller).balanceOf(address(token))
);
}

function setMin(uint256 _min) external {
require(msg.sender == governance, "!governance");
require(_min <= max, "numerator cannot be greater than denominator");
min = _min;
}

function setGovernance(address _governance) public {
require(msg.sender == governance, "!governance");
governance = _governance;
}

function setTimelock(address _timelock) public {
require(msg.sender == timelock, "!timelock");
timelock = _timelock;
}

function setController(address _controller) public {
require(msg.sender == timelock, "!timelock");
controller = _controller;
}

// Custom logic in here for how much the globes allows to be borrowed
// Sets minimum required on-hand to keep small withdrawals cheap
function available() public view returns (uint256) {
return token.balanceOf(address(this)).mul(min).div(max);
}

function earn() public {
uint256 _bal = available();
token.safeTransfer(controller, _bal);
IController(controller).earn(address(token), _bal);
}

function depositAll() external {
deposit(token.balanceOf(msg.sender));
}

function deposit(uint256 _amount) public {
uint256 _pool = balance();
uint256 _before = token.balanceOf(address(this));
token.safeTransferFrom(msg.sender, address(this), _amount);
uint256 _after = token.balanceOf(address(this));
_amount = _after.sub(_before); // Additional check for deflationary tokens
uint256 shares = 0;
if (totalSupply() == 0) {
shares = _amount;
} else {
shares = (_amount.mul(totalSupply())).div(_pool);
}
_mint(msg.sender, shares);
}

function withdrawAll() external {
withdraw(balanceOf(msg.sender));
}

// Used to swap any borrowed reserve over the debt limit to liquidate to 'token'
function harvest(address reserve, uint256 amount) external {
require(msg.sender == controller, "!controller");
require(reserve != address(token), "token");
IERC20(reserve).safeTransfer(controller, amount);
}

// No rebalance implementation for lower fees and faster swaps
function withdraw(uint256 _shares) public {
uint256 r = (balance().mul(_shares)).div(totalSupply());
_burn(msg.sender, _shares);

// Check balance
uint256 b = token.balanceOf(address(this));
if (b < r) {
uint256 _withdraw = r.sub(b);
IController(controller).withdraw(address(token), _withdraw);
uint256 _after = token.balanceOf(address(this));
uint256 _diff = _after.sub(b);
if (_diff < _withdraw) {
r = b.add(_diff);
}
}

token.safeTransfer(msg.sender, r);
}

function getRatio() public view returns (uint256) {
return balance().mul(1e18).div(totalSupply());
}
}
136 changes: 136 additions & 0 deletions contracts/snowglobes/wonderland/snowglobe-time-avax-time.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// https://github.com/iearn-finance/vaults/blob/master/contracts/vaults/yVault.sol

pragma solidity ^0.6.7;

import "../../interfaces/controller.sol";

import "../../lib/erc20.sol";
import "../../lib/safe-math.sol";

contract SnowGlobeTimeAvaxTime is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;

IERC20 public token;

uint256 public min = 9500;
uint256 public constant max = 10000;

address public governance;
address public timelock;
address public controller;

constructor(
address _token,
address _governance,
address _timelock,
address _controller
)
public
ERC20(
string(abi.encodePacked("freezing ", ERC20(_token).name())),
string(abi.encodePacked("s", ERC20(_token).symbol()))
)
{
_setupDecimals(ERC20(_token).decimals());
token = IERC20(_token);
governance = _governance;
timelock = _timelock;
controller = _controller;
}

function balance() public view returns (uint256) {
return
token.balanceOf(address(this)).add(
IController(controller).balanceOf(address(token))
);
}

function setMin(uint256 _min) external {
require(msg.sender == governance, "!governance");
require(_min <= max, "numerator cannot be greater than denominator");
min = _min;
}

function setGovernance(address _governance) public {
require(msg.sender == governance, "!governance");
governance = _governance;
}

function setTimelock(address _timelock) public {
require(msg.sender == timelock, "!timelock");
timelock = _timelock;
}

function setController(address _controller) public {
require(msg.sender == timelock, "!timelock");
controller = _controller;
}

// Custom logic in here for how much the globes allows to be borrowed
// Sets minimum required on-hand to keep small withdrawals cheap
function available() public view returns (uint256) {
return token.balanceOf(address(this)).mul(min).div(max);
}

function earn() public {
uint256 _bal = available();
token.safeTransfer(controller, _bal);
IController(controller).earn(address(token), _bal);
}

function depositAll() external {
deposit(token.balanceOf(msg.sender));
}

function deposit(uint256 _amount) public {
uint256 _pool = balance();
uint256 _before = token.balanceOf(address(this));
token.safeTransferFrom(msg.sender, address(this), _amount);
uint256 _after = token.balanceOf(address(this));
_amount = _after.sub(_before); // Additional check for deflationary tokens
uint256 shares = 0;
if (totalSupply() == 0) {
shares = _amount;
} else {
shares = (_amount.mul(totalSupply())).div(_pool);
}
_mint(msg.sender, shares);
}

function withdrawAll() external {
withdraw(balanceOf(msg.sender));
}

// Used to swap any borrowed reserve over the debt limit to liquidate to 'token'
function harvest(address reserve, uint256 amount) external {
require(msg.sender == controller, "!controller");
require(reserve != address(token), "token");
IERC20(reserve).safeTransfer(controller, amount);
}

// No rebalance implementation for lower fees and faster swaps
function withdraw(uint256 _shares) public {
uint256 r = (balance().mul(_shares)).div(totalSupply());
_burn(msg.sender, _shares);

// Check balance
uint256 b = token.balanceOf(address(this));
if (b < r) {
uint256 _withdraw = r.sub(b);
IController(controller).withdraw(address(token), _withdraw);
uint256 _after = token.balanceOf(address(this));
uint256 _diff = _after.sub(b);
if (_diff < _withdraw) {
r = b.add(_diff);
}
}

token.safeTransfer(msg.sender, r);
}

function getRatio() public view returns (uint256) {
return balance().mul(1e18).div(totalSupply());
}
}
Loading