#
Vault
This is the main contract of the Warlord protocol. It allows user to deposit WAR that will then be staked in the Warlord staking contract. It also handles the harvest and compound logic of the vault. Some admins functions are here to handle fees and pause the contract if needed. The Vault itself can change staker but not the underlying asset.
#
State Variables
#
_asset
Address of the definitive asset()
address private immutable _asset;
#
_NAME
Name of the vault
string private constant _NAME = "Tholgar Warlord Vault";
#
_SYMBOL
Symbol of the vault
string private constant _SYMBOL = "thWAR";
#
staker
Address of the stkWAR token
address public staker;
#
minter
Address of the WAR minter contract
address public minter;
#
swapper
Address of the swapper contract
address public swapper;
#
Functions
#
constructor
constructor(
address initialOwner,
address initialStaker,
address initialMinter,
address initialSwapper,
uint256 initialHarvestFee,
uint256 initialWithdrawalFee,
address initialFeeRecipient,
address initialFeeToken,
address initialOperator,
address definitiveAsset
)
Owned2Step(initialOwner)
AFees(initialHarvestFee, initialWithdrawalFee, initialFeeRecipient, initialFeeToken)
AOperator(initialOperator);
#
setStaker
update the staker contract to a new one
function setStaker(address newStaker) external onlyOwner;
Parameters
#
setSwapper
update the swapper contract to a new one
function setSwapper(address newSwapper) external onlyOwner;
Parameters
#
setMinter
update the minter contract to a new one
function setMinter(address newMinter) external onlyOwner;
Parameters
#
recoverERC20
Recover ERC2O tokens in the contract
Recover ERC2O tokens in the contract
function recoverERC20(address token) external onlyOwner returns (bool);
Parameters
Returns
#
pause
Pause the contract
function pause() external onlyOwner;
#
unpause
Unpause the contract
function unpause() external onlyOwner;
#
name
Returns the name of the token
function name() public view override returns (string memory);
#
symbol
Returns the symbol of the token
function symbol() public view override returns (string memory);
#
previewRedeem
previewRedeem returns the amount of assets that will be redeemed minus the withdrawal fees
function previewRedeem(uint256 shares) public view override returns (uint256 assets);
#
asset
asset is the definitive asset of the vault (WAR)
function asset() public view override returns (address);
#
totalAssets
totalAssets is the total number of stkWAR
function totalAssets() public view override returns (uint256);
#
deposit
function deposit(uint256 assets, address receiver) public override whenNotPaused returns (uint256 shares);
#
mint
function mint(uint256 shares, address receiver) public override whenNotPaused returns (uint256 assets);
#
withdraw
function withdraw(uint256 assets, address to, address owner) public override whenNotPaused returns (uint256 shares);
#
redeem
function redeem(uint256 shares, address to, address owner) public override whenNotPaused returns (uint256 assets);
#
_afterDeposit
stake assets after each deposit
function _afterDeposit(uint256 assets, uint256) internal override;
#
_beforeWithdraw
unstake assets before each withdraw to have enough WAR to transfer
function _beforeWithdraw(uint256 assets, uint256) internal override;
#
harvest
Harvest all rewards from staker
calldatas should swap from all reward tokens to feeToken
function harvest(address[] calldata tokensToHarvest, address[] calldata tokensToSwap, bytes[] calldata callDatas)
external
nonReentrant
onlyOperatorOrOwner;
Parameters
#
compound
Turn all rewards into more staked assets
function compound(address[] calldata tokensToSwap, bytes[] calldata callDatas, address[] calldata tokensToMint)
external
nonReentrant
onlyOperatorOrOwner;
Parameters
#
Events
#
StakerUpdated
Event emitted when a staker is updated
event StakerUpdated(address oldStaker, address newStaker);
#
MinterUpdated
Event emitted when a minter is updated
event MinterUpdated(address oldMinter, address newMinter);
#
SwapperUpdated
Event emitted when a swapper is updated
event SwapperUpdated(address oldSwapper, address newSwapper);
#
Harvested
Event emitted when reward have been harvested
event Harvested(uint256 amount);
#
Compounded
Event emitted when rewards are compounded into more stkWAR
event Compounded(uint256 amount);