forked from buzz-language/buzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yield_farmer_bot.buzz
52 lines (44 loc) · 1.07 KB
/
yield_farmer_bot.buzz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import "solana/defi" as defi;
// Define lending pools
pool solend_usdc USDC {
apy = variable
collateral_factor = 0.8
}
pool mango_sol SOL {
apy = variable
collateral_factor = 0.7
}
// Define yield strategy
strategy yield_strategy {
rebalance {
// Move to highest yield pool
const best_pool = max_by(pools, p => p.apy);
if (best_pool.apy > current_pool.apy + 0.5%) {
withdraw_all(current_pool);
deposit_all(best_pool);
}
}
risk {
// Maintain healthy collateral ratio
foreach (pool in pools) {
if (pool.utilization > 0.9) {
reduce_position(pool, target: 0.8);
}
}
}
}
// Define yield farming bot
bot yield_bot {
pools = [solend_usdc, mango_sol]
strategy = yield_strategy
risk = 2%
interval = 1h
execute {
// Check yields and rebalance
strategy.rebalance();
// Manage risk
strategy.risk();
// Compound rewards
claim_and_reinvest();
}
}