Module 0x1::TreasuryScripts
use 0x1::Account;
use 0x1::Offer;
use 0x1::Token;
use 0x1::Treasury;
use 0x1::TreasuryWithdrawDaoProposal;
Function withdraw_and_split_lt_withdraw_cap
public entry fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(signer: signer, for_address: address, amount: u128, lock_period: u64)
Implementation
public entry fun withdraw_and_split_lt_withdraw_cap<TokenT: store>(
signer: signer,
for_address: address,
amount: u128,
lock_period: u64,
) {
// 1. take cap: LinearWithdrawCapability<TokenT>
let cap = Treasury::remove_linear_withdraw_capability<TokenT>(&signer);
// 2. withdraw token and split
let (tokens, new_cap) = Treasury::split_linear_withdraw_cap(&mut cap, amount);
// 3. deposit
Account::deposit_to_self(&signer, tokens);
// 4. put or destroy key
if (Treasury::is_empty_linear_withdraw_capability(&cap)) {
Treasury::destroy_linear_withdraw_capability(cap);
} else {
Treasury::add_linear_withdraw_capability(&signer, cap);
};
// 5. offer
Offer::create(&signer, new_cap, for_address, lock_period);
}
Specification
pragma verify = false;
Function withdraw_token_with_linear_withdraw_capability
public entry fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(signer: signer)
Implementation
public entry fun withdraw_token_with_linear_withdraw_capability<TokenT: store>(
signer: signer,
) {
// 1. take cap
let cap = Treasury::remove_linear_withdraw_capability<TokenT>(&signer);
// 2. withdraw token
let tokens = Treasury::withdraw_with_linear_capability(&mut cap);
// 3. deposit
Account::deposit_to_self(&signer, tokens);
// 4. put or destroy key
if (Treasury::is_empty_linear_withdraw_capability(&cap)) {
Treasury::destroy_linear_withdraw_capability(cap);
} else {
Treasury::add_linear_withdraw_capability(&signer, cap);
};
}
Specification
pragma verify = false;
Function propose_withdraw
public entry fun propose_withdraw<TokenT: copy, drop, store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64)
Implementation
public entry fun propose_withdraw<TokenT: copy + drop + store>(signer: signer, receiver: address, amount: u128, period: u64, exec_delay: u64){
TreasuryWithdrawDaoProposal::propose_withdraw<TokenT>(&signer, receiver, amount, period, exec_delay)
}
Specification
pragma verify = false;
Function execute_withdraw_proposal
public entry fun execute_withdraw_proposal<TokenT: copy, drop, store>(signer: signer, proposer_address: address, proposal_id: u64)
Implementation
public entry fun execute_withdraw_proposal<TokenT:copy + drop + store>(signer: signer, proposer_address: address,
proposal_id: u64,){
TreasuryWithdrawDaoProposal::execute_withdraw_proposal<TokenT>(&signer, proposer_address, proposal_id);
}
Specification
pragma verify = false;