DegenBox
Constructor nonpayable
Constructor nonpayableParameters
wethToken_
address
address of WETH.
Functions
View Functions
DOMAIN_SEPARATOR
balanceOf
masterContractApproved
masterContractOf
nonces
owner
pendingOwner
pendingStrategy
strategy
strategyData
toAmount
toShare
totals
whitelistedMasterContracts
Write Functions
batch
batchFlashLoan
claimOwnership
deploy
deposit
flashLoan
harvest
permitToken
registerProtocol
setMasterContractApproval
setStrategy
setStrategyTargetPercentage
transfer
transferMultiple
transferOwnership
whitelistMasterContract
withdraw
DOMAIN_SEPARATOR | view
DOMAIN_SEPARATOR | viewParameters No parameters for this function. Return values
/
bytes32
balanceOf | view
balanceOf | viewmapping(IERC20 => mapping(address => uint256)) public balanceOfParameters
/
address
Token to check
/
address
The address which balance is checked
Return values
/
uint256
Shares of 'token' owned by 'address'
batch | payable
batch | payablefunction batch(bytes[] calldata calls, bool revertOnFail)
external payable
returns (bool[] memory successes, bytes[] memory results)Parameters
calls
bytes[]
An array of inputs for each call.
revertOnFail
bool
If True then reverts after a failed call and stops doing further calls.
Return values
successes
bool[]
An array indicating the success of a call, mapped one-to-one to calls.
results
bytes[]
An array with the returned data of each function call, mapped one-to-one to calls.
batchFlashLoan | nonpayable
batchFlashLoan | nonpayablefunction batchFlashLoan(
IBatchFlashBorrower borrower,
address[] calldata receivers,
IERC20[] calldata tokens,
uint256[] calldata amounts,
bytes calldata data
) public {Parameters
borrower
address
The address of the contract that implements and conforms to IBatchFlashBorrower and handles the flashloan.
receivers
address[]
The address of the contract that implements and conforms to IBatchFlashBorrower and handles the flashloan.
tokens
address[]
The addresses of the tokens.
amounts
uint256[]
amounts of the tokens for each receiver.
data
bytes
The calldata to pass to the borrower contract.
Return values
No return values for this function.
claimOwnership | nonpayable
claimOwnership | nonpayablefunction claimOwnership() publicNeeds to be called by pendingOwner to claim ownership.
deploy | payable
deploy | payablefunction deploy(
address masterContract,
bytes calldata data,
bool useCreate2
) public payable returns (address cloneAddress)Deploys a given master Contract as a clone.
Parameters
masterContract
address
The address of the contract to clone.
data
bytes
Additional abi encoded calldata that is passed to the new clone via IMasterContract.init.
useCreate2
bool
Creates the clone by using the CREATE2 opcode, in this case data will be used as salt.
Return values
cloneAddress
address
Address of the created clone contract.
deposit | payable
deposit | payablefunction deposit(
IERC20 token_,
address from,
address to,
uint256 amount,
uint256 share
) public payable allowed(from) returns (uint256 amountOut, uint256 shareOut)Parameters
token_
address
The ERC-20 token to deposit.
from
address
which account to pull the tokens from.
to
address
which account to push the tokens to.
amount
uint256
Token amount in native representation to deposit.
share
uint256
Token amount represented in shares to deposit. Takes precedence over amount.
Return values
amountOut
uint256
The amount deposited.
shareOut
uint256
The deposited amount represented in shares.
flashLoan | nonpayable
flashLoan | nonpayablefunction flashLoan(
IFlashBorrower borrower,
address receiver,
IERC20 token,
uint256 amount,
bytes calldata data
) publicParameters
borrower
address
The address of the contract that implements and conforms to IFlashBorrower and handles the flashloan.
receiver
address
Address of the token receiver.
token
address
The address of the token to receive.
amount
uint256
Amount of the tokens to receive.
data
bytes
The calldata to pass to the borrower contract.
Return values
No return values for this function.
harvest | nonpayable
harvest | nonpayablefunction harvest(
IERC20 token,
bool balance,
uint256 maxChangeAmount
) publicThe actual process of yield farming. Executes the strategy of token. Optionally does housekeeping if balance is true.
Parameters
token
address
The address of the token for which a strategy is deployed.
balance
bool
True if housekeeping should be done.
maxChangeAmount
uint256
The maximum amount for either pulling or pushing from/to the IStrategy contract.
Return values
No return values for this function.
masterContractApproved | view
masterContractApproved | viewmapping(address => mapping(address => bool)) public masterContractApproved;masterContract to user to approval state, returns True if the user has approved the masterContract.
Parameters
/
address
Address of the masterContract.
/
address
Address of the user.
Return values
/
bool
Returns True if the masterContract is approved by user.
masterContractOf | view
masterContractOf | viewmapping(address => address) public masterContractOf;Mapping from clone contracts to their masterContract.
Parameters
/
address
Address of the cloned contract.
Return values
/
address
Address of the masterContract clone contract is cloned from.
nonces | view
nonces | viewmapping(address => uint256) public nonces;User nonces for masterContract approvals.
Parameters
/
address
User address.
Return values
/
uint256
Nonce of the user.
owner | view
owner | viewOwner of the DegenBox contract. Can perform actions that onlyOwner() can perform, such as strategy updates.
Parameters
No parameters for this function.
Return values
/
address
Address of the Owner
pendingOwner | view
pendingOwner | viewWhen transferring ownership, the future owner is pending until they claims ownership.
Return values
/
address
Address of the pending owner.
pendingStrategy | view
pendingStrategy | viewStrategy change being submitted to a delay of 3 days, the setStrategy function is called twice, once to declare a strategy change, and another time after STRATEGY_DELAY (3 days). In between those calls, the new strategy is pendingStrategy.
Parameters
/
address
The address of the token that maps to a strategy to change.
Return values
/
address
The address of the contract that conforms to IStrategy.
permitToken | nonpayable
permitToken | nonpayablefunction permitToken(
IERC20 token,
address from,
address to,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) publicParameters
token
address
The ERC20 token that supports permit to call permit on.
from
address
The token owner's address
to
address
The token spender's address
amount
uint256
The amount to be approved.
deadline
uint256
Timestamp in the future until which permit can be called.
v
uint8
v of the ECDSA signature.
r
bytes32
r of the ECDSA signature.
s
bytes32
s of the ECDSA signature.
Return values No return values for this function.
registerProtocol | nonpayable
registerProtocol | nonpayableParameters No parameters for this function. Return values No return values for this function.
setMasterContractApproval | nonpayable
setMasterContractApproval | nonpayableParameters
user
address
masterContract
address
approved
bool
v
uint8
r
bytes32
s
bytes32
Return values No return values for this function.
setStrategy | nonpayable
setStrategy | nonpayablefunction setStrategy(IERC20 token, IStrategy newStrategy) public onlyOwnerSets the contract address of a new strategy that conforms to IStrategy for token. Must be called twice with the same arguments. A new strategy becomes pending first and can be activated once STRATEGY_DELAY is over. In the case of the Degenbox, STRATEGY_DELAY is 3 days.
Parameters
token
address
The address of the token that maps to a strategy to change.
newStrategy
address
The address of the contract that conforms to IStrategy.
Return values No return values for this function.
setStrategyTargetPercentage | nonpayable
setStrategyTargetPercentage | nonpayablefunction setStrategyTargetPercentage(
IERC20 token,
uint64 targetPercentage_
) public onlyOwner {Sets the target percentage of the strategy for token. It corresponds to the percentage of tokens deployed to the Strategy, vs kept in DegenBox.
Parameters
token
address
The address of the token that maps to a strategy to change.
targetPercentage_
uint64
The new target in percent. Must be lesser or equal to MAX_TARGET_PERCENTAGE.
Return values No return values for this function.
strategy | view
strategy | viewReturns the address of the Strategy mapped to the given ERC20 token.
Parameters
/
address
The address of the token that maps to a strategy
Return values
/
address
The address of the current strategy: a contract that conforms to IStrategy.
strategyData | view
strategyData | viewParameters
/
address
The address of the token that maps to a strategy
Return values
strategyStartDate
uint64
Timestamp of the strategy start date.
targetPercentage
uint64
Current targetPercentage (% of funds wanted in strategy) of the token
balance
uint128
Current balance held by strategy (before harvest)
toAmount | view
toAmount | viewfunction toAmount(
IERC20 token,
uint256 share,
bool roundUp
) external view returns (uint256 amount)Converts amounts of shares of a token into it's native representation.
Parameters
token
address
The ERC-20 token.
share
uint256
The amount of shares.
roundUp
bool
If the result should be rounded up.
Return values
amount
uint256
The share amount back into native representation.
toShare | view
toShare | viewfunction toShare(
IERC20 token,
uint256 amount,
bool roundUp
) external view returns (uint256 share)Converts amounts of a token in it's native representation into shares.
Parameters
token
address
The ERC-20 token.
amount
uint256
The token amount.
roundUp
bool
If the result share should be rounded up.
Return values
share
uint256
The token amount represented in shares.
totals | view
totals | viewmapping(IERC20 => Rebase) public totals;Keeps track of how many tokens are stored by DegenBox as well as how many shares are held by users.
Parameters
/
address
ERC20 Address which total we want.
Return values
elastic
uint128
How many tokens (in native representation) are deposited into DegenBox.
base
uint128
How many shares of tokens are held by users.
transfer | nonpayable
transfer | nonpayablefunction transfer(
IERC20 token,
address from,
address to,
uint256 share
) public allowed(from)Transfer shares from a user account to another one.
Parameters
token
address
The ERC20 token to transfer.
from
address
The account to transfer token from.
to
address
The account to transfer token to.
share
uint256
The amount of shares to transfer.
Return values No return values for this function.
transferMultiple | nonpayable
transferMultiple | nonpayablefunction transferMultiple(
IERC20 token,
address from,
address[] calldata tos,
uint256[] calldata shares
) public allowed(from) {Transfer shares from a user account to multiple other ones.
Parameters
token
address
The ERC20 token to transfer.
from
address
The account to transfer token from.
tos
address[]
The accounts to transfer token to.
shares
uint256[]
The amount of token in shares for each receiver in tos.
Return values No return values for this function.
transferOwnership | nonpayable
transferOwnership | nonpayablefunction transferOwnership(
address newOwner,
bool direct,
bool renounce
) public onlyOwnerTransfers ownership to newOwner. Either directly or claimable by the new pending owner. Can only be invoked by the current owner.
Parameters
newOwner
address
Address of the new owner.
direct
bool
True if newOwner should be set immediately. False if newOwner needs to use claimOwnership.
renounce
bool
Allows the newOwner to be address(0) if direct and renounce is True. Has no effect otherwise.
Return values No return values for this function.
whitelistMasterContract | nonpayable
whitelistMasterContract | nonpayablefunction whitelistMasterContract(
address masterContract,
bool approved
) public onlyOwnersoliEnables or disables a contract for approval without signed message.
Parameters
masterContract
address
masterContract which status is being changed.
approved
bool
New approval status.
Return values No return values for this function.
whitelistedMasterContracts | view
whitelistedMasterContracts | viewReturns True if a masterContract is whitelisted.
Parameters
/
address
Address of the masterContract.
Return values
/
bool
Whitelisting status.
withdraw | nonpayable
withdraw | nonpayablefunction withdraw(
IERC20 token_,
address from,
address to,
uint256 amount,
uint256 share
) public allowed(from) returns (uint256 amountOut, uint256 shareOut)Withdraws an amount of token from a user account.
Parameters
token_
address
The ERC-20 token to withdraw.
from
address
From which user to pull the tokens.
to
address
To which user to push the tokens.
amount
uint256
Amount of tokens. Either one of amount or share needs to be supplied.
share
uint256
Like above, but share takes precedence over amount.
Return values
amountOut
uint256
Amount of token withdrawn, in native representation.
shareOut
uint256
Shares of token withdrawn.
Events (for EVM logging)
LogDeploy
LogDeposit
LogFlashLoan
LogRegisterProtocol
LogSetMasterContractApproval
LogStrategyDivest
LogStrategyInvest
LogStrategyLoss
LogStrategyProfit
LogStrategyQueued
LogStrategySet
LogStrategyTargetPercentage
LogTransfer
LogWhiteListMasterContract
LogWithdraw
OwnershipTransferred
LogDeploy
LogDeployParameters
masterContract
address
true
data
bytes
false
cloneAddress
address
true
LogDeposit
LogDepositParameters
token
address
true
from
address
true
to
address
true
amount
uint256
false
share
uint256
false
LogFlashLoan
LogFlashLoanParameters
borrower
address
true
token
address
true
amount
uint256
false
feeAmount
uint256
false
receiver
address
true
LogRegisterProtocol
LogRegisterProtocolParameters
protocol
address
true
LogSetMasterContractApproval
LogSetMasterContractApprovalParameters
masterContract
address
true
user
address
true
approved
bool
false
LogStrategyDivest
LogStrategyDivestParameters
token
address
true
amount
uint256
false
LogStrategyInvest
LogStrategyInvestParameters
token
address
true
amount
uint256
false
LogStrategyLoss
LogStrategyLossParameters
token
address
true
amount
uint256
false
LogStrategyProfit
LogStrategyProfitParameters
token
address
true
amount
uint256
false
LogStrategyQueued
LogStrategyQueuedParameters
token
address
true
strategy
address
true
LogStrategySet
LogStrategySetParameters
token
address
true
strategy
address
true
LogStrategyTargetPercentage
LogStrategyTargetPercentageParameters
token
address
true
targetPercentage
uint256
false
LogTransfer
LogTransferParameters
token
address
true
from
address
true
to
address
true
share
uint256
false
LogWhiteListMasterContract
LogWhiteListMasterContractParameters
masterContract
address
true
approved
bool
false
LogWithdraw
LogWithdrawParameters
token
address
true
from
address
true
to
address
true
amount
uint256
false
share
uint256
false
OwnershipTransferred
OwnershipTransferredParameters
clopreviousOwner
address
true
newOwner
address
true
Last updated