#
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 admions 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
#
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;
#
MAX_BPS
Max BPS value (100%)
uint256 public constant MAX_BPS = 10_000;
#
harvestFee
fee to be applied when harvesting rewards
uint256 public harvestFee;
#
feeRecipient
address to receive the harvest fee
address public feeRecipient;
#
feeToken
token to be used to pay the harvest fee
address public feeToken;
#
operator
operator caller address to allow access only to web3 function
address public operator;
#
Functions
#
constructor
constructor(
address initialOwner,
address initialStaker,
address initialMinter,
address initialSwapper,
uint256 initialHarvestFee,
address initialFeeRecipient,
address initialFeeToken,
address initialOperator,
address definitiveAsset
)
Owned2Step(initialOwner)
ERC4626(ERC20(definitiveAsset), "Tholgar Warlord Token", "tWAR")
AFees(initialHarvestFee, initialFeeRecipient, initialFeeToken)
AOperator(initialOperator);
#
setStaker
update the staker contract to a new one
function setStaker(address newStaker) external onlyOwner;
Parameters
#
setOperator
function setOperator(address newOperator) external onlyOwner;
#
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
#
setHarvestFee
function setHarvestFee(uint256 newHarvestFee) external virtual onlyOwner;
#
setFeeRecipient
function setFeeRecipient(address newFeeRecipient) external virtual onlyOwner;
#
setFeeToken
function setFeeToken(address newFeeToken) external virtual onlyOwner;
#
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;
#
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 receiver, address owner)
public
override
whenNotPaused
returns (uint256 shares);
#
redeem
function redeem(uint256 shares, address receiver, 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);
#
HarvestFeeUpdated
Event emitted when harvestFee is updated
event HarvestFeeUpdated(uint256 oldHarvestFee, uint256 newHarvestFee);
#
FeeRecipientUpdated
Event emitted when feeRecipient is updated
event FeeRecipientUpdated(address oldFeeRecipient, address newFeeRecipient);
#
FeeTokenUpdated
Event emitted when feeToken is updated
event FeeTokenUpdated(address oldFeeToken, address newFeeToken);
#
OperatorUpdated
Event emitted when a output tokens and/or ratios are updated
event OperatorUpdated(address oldOperator, address newOperator);