Wrapper EnhancementsGlobalsTreasury

# Class: Treasury

Interact with the deployed Kosu Treasury contract.

Instances of the Treasury class provide methods to interact with deployed Kosu Treasury contracts for functionality such as deposits/withdrawals and allowance management.

If instantiated outside the Kosu class, the web3Wrapper provided to the constructor must include the Treasury's ABI (from the compiled Solidity source).

# Hierarchy

  • Treasury

# Index

# Constructors

# Properties

# Methods

# Constructors

# constructor

+ new Treasury(options: KosuOptions, kosuToken?: KosuToken): Treasury

Defined in Treasury.ts:45

Creates a new Treasury instance.

Parameters:

Name Type Description
options KosuOptions Initialization options (see KosuOptions).
kosuToken? KosuToken Configured/instantiated KosuToken instance.

Returns: Treasury

# Properties

# address

address: string

Defined in Treasury.ts:40

They deployed Treasury's address for the detected networkID.


# coinbase

coinbase: string

Defined in Treasury.ts:45

The user's coinbase address (if available via supplied provider).


# contract

contract: TreasuryContract

Defined in Treasury.ts:35

A lower-level, auto-generated contract wrapper for the Treasury contract, generated from solidity source code.


# kosuToken

kosuToken: KosuToken

Defined in Treasury.ts:29

An instance of the KosuToken class to communicate with the KOSU ERC-20 token.


# web3Wrapper

web3Wrapper: Web3Wrapper

Defined in Treasury.ts:24

The web3Wrapper instance with the contract's ABI loaded.

# Methods

# approveTreasury

approveTreasury(value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in Treasury.ts:238

Approve the treasury to transfer KOSU on behalf of the user's coinbase account.

example

// approve the treasury for 1,000,000 KOSU

const value = new BigNumber(web3 - utils.toWei("1000000"));
const receipt = await treasury.approveTreasury(value);

Parameters:

Name Type Description
value BigNumber | string | number The amount of KOSU (in wei) to approve the treasury for.

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The decoded transaction receipt, after the TX has been mined.


# authorizeProxy

authorizeProxy(_proxy: string): Promise‹TransactionReceiptWithDecodedLogs›

Defined in Treasury.ts:135

Authorize an address to vote in proxy

Parameters:

Name Type Description
_proxy string The address to be added as a proxy

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The decoded transaction receipt, after the TX is mined in a block.


# currentBalance

currentBalance(address: string): Promise‹BigNumber›

Defined in Treasury.ts:200

Read the available (current) treasury balance for a provided address.

example

// view current balance of address

const address = "0x91c987bf62D25945dB517BDAa840A6c661374402";
const balanceWei = await treasury.currentBalance(address);

// convert to ether from wei
const balance = web3 - utils.fromWei(balanceWei);

Parameters:

Name Type Description
address string The Ethereum address to check current balance of.

Returns: Promise‹BigNumber›

The user's current treasury balance (in wei).


# deauthorizeProxy

deauthorizeProxy(_proxy: string): Promise‹TransactionReceiptWithDecodedLogs›

Defined in Treasury.ts:146

Remove an address's authorization to vote in proxy

Parameters:

Name Type Description
_proxy string The address to be removed as a proxy

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The decoded transaction receipt, after the TX is mined in a block.


# deposit

deposit(value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in Treasury.ts:94

Deposit tokens in the treasury, from the detected coinbase account.

example

// deposit 10 KOSU

const value = new BigNumber(web3 - utils.toWei("10"));
const receipt = await treasury.deposit(value);

Parameters:

Name Type Description
value BigNumber | string | number The uint value of tokens to deposit in wei.

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The decoded transaction receipt, after the TX has been included in a block.


# getContract

getContract(): Promise‹TreasuryContract›

Defined in Treasury.ts:64

Asynchronously initializes the contract instance, or returns it from cache.

Returns: Promise‹TreasuryContract›

The lower-level contract wrapper instance.


# isProxyFor

isProxyFor(_account: string, _proxy: string): Promise‹boolean›

Defined in Treasury.ts:158

Checks if an address is a valid proxy for another address

Parameters:

Name Type Description
_account string The balance holder
_proxy string The possible voting proxy

Returns: Promise‹boolean›

The boolean status of proxy voting permission


# pay

pay(value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in Treasury.ts:249

Sends ether to the contract to bond and deposit tokens.

Parameters:

Name Type Description
value BigNumber | string | number Amount of wei to deposit

Returns: Promise‹TransactionReceiptWithDecodedLogs›

Logs from the transaction block.


# systemBalance

systemBalance(address: string): Promise‹BigNumber›

Defined in Treasury.ts:179

Read the total system balance of KOSU for a provided address string.

example

// view system balance of address

const address = "0x91c987bf62D25945dB517BDAa840A6c661374402";
const balanceWei = await treasury.systemBalance(address);

// convert to ether from wei
const balance = web3 - utils.fromWei(balanceWei);

Parameters:

Name Type Description
address string The Ethereum address to check system balance for.

Returns: Promise‹BigNumber›

The user's total KOSU system balance, in wei.


# treasuryAllowance

treasuryAllowance(): Promise‹BigNumber›

Defined in Treasury.ts:219

View the current treasury allowance for the detected coinbase account.

example

// view current allowance for the treasury

const allowanceWei = await treasury.treasuryAllowance();

// convert to ether from wei
const allowance = web3 - utils.fromWei(allowanceWei);

Returns: Promise‹BigNumber›

The current KOSU approval for the Treasury for the current user, in wei.


# withdraw

withdraw(value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in Treasury.ts:124

Withdraw tokens from treasury to the detected coinbase account.

example

// withdraw 10 KOSU

const value = new BigNumber(web3 - utils.toWei("10"));
const receipt = await treasury.withdraw(value);

Parameters:

Name Type Description
value BigNumber | string | number The uint value of tokens to withdraw in wei.

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The decoded transaction receipt, after the TX is mined in a block.