# Castle finance
---
### Yearn for DAOs
- DAOs need to manage their treasuries and pay for expenses
- overwhelmingly governance tokens
- move a part of it to stables
- earn yield on that stables
---
### How? Vaults
- risk managed
- only smart contract risk
- diversification(?)
- high yield vaults - (only stables)
- solend/jet/port
---
### How?
- DAOs can submit/withdraw their money at any time
- Permissioned updates of weights by castle.finance team
---
### Weight submission
- E[R] = R - EL
- R - Return from interest rate curve of money market
- EL - Expected loss
- https://github.com/castle-finance/optimizer_math/blob/master/optimizer_math.ipynb
- can rebalance every 60 seconds (!)
---
### More on rebalancing
```rust=
/// Calculate and store optimal allocations to downstream lending markets
pub fn handler(ctx: Context<Rebalance>, proposed_weights_arg: StrategyWeightsArg) -> ProgramResult {
```
```rust=
pub struct StrategyWeightsArg {
solend: u16,
port: u16,
jet: u16,
}
```
---
### Fees
- No reference in the docs, so code
```rust=
pub struct VaultConfig {
/// Basis points of the accrued interest that gets sent to the fee_receiver
pub fee_carry_bps: u32,
/// Basis points of the AUM that gets sent to the fee_receiver
pub fee_mgmt_bps: u32,
```
---
### Fees (contd)
```shell=
$ ANCHOR_WALLET=~/keypairs/foo.json ts-node test/client.test.ts
Initialized client
{
...
feeCarryBps: 0,
feeMgmtBps: 0,
referralFeePct: 0,
allocationCapPct: 60,
...
strategyType: { maxYield: {} },
padding: [ 0, 0, 0 ]
}
```
---
### Wen token?
- no token as of now
---
### Huge focus on integration with DAOs
- https://realms.today/realms (solana specific, create a DAO in 4 clicks)
- voting (quorums)
- multisigs
- Protocols can add their custom actions (Iphone widgets) to DAOs created by realms
---
### Things we can learn
- A client sdk to interact with vaults (not sure how relevant on Ethereum)
- Seamless DAO integration
- Relatively nice/professional UI
---
### Comments
- We should focus more on "using offchain intelligence" part in our pitches
- Bespoke/customized optimization functions for each DAO is our strength
- The problem of decentralized weight updates is extremely difficult!
---
# End
---
{"metaMigratedAt":"2023-06-17T02:57:49.198Z","metaMigratedFrom":"YAML","title":"Castle finance","breaks":true,"contributors":"[{\"id\":\"4f552fb1-9945-4de4-97bf-04dd414ff08b\",\"add\":5110,\"del\":2599}]"}