yield for a cause
This contract allows users to stake ERC20 tokens, which are deposited in Yearn Vaults and the yield generated is sent to one receiver. yDonate automatically detects the vault for the token staked by using the Yearn Registry
Source:
Live preview at:
The yDonate contract allows users to stake their tokens in Yearn Finance vaults and automatically donate the generated yield to a predefined receiver. This contract uses OpenZeppelin's ERC20.sol and interfaces with Yearn Finance's vaults and registry.
To deploy the yDonate contract, you need to provide the following parameters:
registryAddress
: The address of the Yearn Finance registry contract.receiver
: The address that will receive the donated yield.
The stake function allows users to stake their tokens in the corresponding Yearn Finance vault.
amount
: The number of tokens the user wants to stake.tokenAddress
: The address of the token that the user wants to stake.
The unstake function allows users to unstake their tokens and automatically donate the generated yield to the receiver.
tokenAddress
: The address of the staked token.
The donateYield function allows users to donate the generated yield without unstaking their tokens.
tokenAddress
: The address of the staked token.