Vault 1.5 Developer Examples

Examples of what you can do with Vaults 1.5, in python

Copy the interface code from the previous page or from Github

Deposit in the vault

vault = IVault("ADDRESS")
## Get the token to approve
token = ERC20.at(vault.token()) 

## Approve the token for deposit
token.approve(vault, AMOUNT, {"from": a[0]})

## Deposit the amount
vault.deposit(AMOUNT, {"from": a[0]})

Invest from the Vault to the Strategy (earn)

Move funds from Vault to Strategy, making the funds productive

vault.earn({"from": a[0]})

Tend the Strategy

Reinvest accrued want to make it productive again

strategy = IStrategy("ADDRESS")
strategy.tend({"from": a[0]})

Harvest the Strategy

Reap the rewards of the strategy, increasing want, emitting tokens, tracking the profit and issuing performance fees

strategy = IStrategy("ADDRESS")
strategy.harvest({"from": a[0]})

Last updated

Was this helpful?