DAO Treasury
A Treasury for DAOs. It can receive and send sui::coin::Coin.
Structs
DaoTreasury
struct DaoTreasury<phantom DaoWitness: drop> has key, store {
    id: UID,
    coins: Bag,
    dao: ID,
}- coins - Stores the treasury coins 
- dao- The - sui::object::IDof the DAO.
DaoTreasury
struct FlashLoan<phantom DaoWitness, phantom CoinType> {
    amount: u64,
    fee: u64,
    type: TypeName
}- amounts: The amount being borrowed 
- fee- The fee amount to be repaid. 
- type: The std::type_name::TypeName of the CoinType to repay the loan. 
Interface
dao
Returns the sui::object::ID of the Dao that owns the treasury.
public fun dao<DaoWitness: drop>(treasury: &DaoTreasury<DaoWitness>): ID - @param treasury: A DaoTreasury. 
- @return ID 
balance
Returns the amount of Coin in the treasury.
public fun balance<DaoWitness: drop, CoinType>(treasury: &DaoTreasury<DaoWitness>): u64- @param treasury: A DaoTreasury. 
- @return u64 
donate
Adds token to the treasury.
public fun donate<DaoWitness: drop, CoinType>(treasury: &mut DaoTreasury<DaoWitness>, token: Coin<CoinType>, ctx: &mut TxContext)- @param treasury A DaoTreasury. 
- @param token It will be donated to the - treasury.
transfer
Withdraws a coin from the treasury.
public fun transfer<DaoWitness: drop, CoinType, TransferCoin>(
    treasury: &mut DaoTreasury<DaoWitness>,
    _: &DaoAdmin<DaoWitness>,
    value: u64,
    ctx: &mut TxContext
): Coin<CoinType>- @param treasury: A DaoTreasury. 
- @param _ : Immutable reference to the DaoAdmin. 
- @param value : The amount to withdraw. 
- @return Coin 
transfer_linear_vesting_wallet
Withdraws a LinearWallet from the treasury.
public fun transfer_linear_vesting_wallet<DaoWitness: drop, CoinType, TransferCoin>(
    treasury: &mut DaoTreasury<DaoWitness>,
    _: &DaoAdmin<DaoWitness>,
    c: &Clock,
    value: u64,
    start: u64,
    duration: u64,
    ctx: &mut TxContext    
): LinearWallet<CoinType>- @param treasury: A DaoTreasury. 
- @param _ : Immutable reference to the DaoAdmin. 
- @param c: The - sui::clock::Clock
- @param value : The amount to withdraw. 
- @param start : The amount to withdraw. 
- @param duration : The duration of the vesting schedule. 
- @return LinearWallet. 
flash_loan
Requests a Flash Loan from the treasury.
public fun flash_loan<DaoWitness: drop, CoinType>(
    treasury: &mut DaoTreasury<DaoWitness>, 
    value: u64, 
    ctx: &mut TxContext
): (Coin<CoinType>, FlashLoan<DaoWitness, CoinType>)- @param treasury: A DaoTreasury. 
- @param value : The amount of the loan. 
- @return Coin<CoinType>. The coin that is being borrowed. 
- @return FlashLoan<DaoWitness, CoinType>. Hot potato to ensure that the coin is returned within the same transaction block. 
fee
Returns the service fee amount that must be paid.
public fun fee<DaoWitness: drop, CoinType>(flash_loan: &FlashLoan<DaoWitness, CoinType>): u64- @param flash_loan: A FlashLoan hot potato. 
- @return u64. 
amount
Returns the amount of the loan without the fees.
public fun amount<DaoWitness: drop, CoinType>(flash_loan: &FlashLoan<DaoWitness, CoinType>): u64- @param flash_loan: A FlashLoan hot potato. 
- @return u64. 
repay_flash_loan
Repays the flash_loan to the treasury.
public fun repay_flash_loan<DaoWitness: drop, CoinType>(
    treasury: &mut DaoTreasury<DaoWitness>, 
    flash_loan: FlashLoan<DaoWitness, CoinType>,
    token: Coin<CoinType>
)- @param treasury: A DaoTreasury. 
- @param flash_loan: A FlashLoan hot potato. 
- @param token: The borrowed coin + fee. 
Aborts
- token.valueis smaller than the initial loan amount + fee amount.
Last updated
Was this helpful?
