Link

DeFund Smart Contract Under Development

The DeFund smart contract controls:

  • Minting & Burning
  • Asset balancing
  • Asset distribution
  • Chainlink oracle price feeds.

Public contract functions


GetOwner()

Limit: None
Function: Returns the Owner wallet.
Example: GetOwner()

GetToken()

Limit: None
Function: Returns the Defund Share Token address.
Example: GetToken()

GetAggregator(address token_contract)

Limit: None
Function: Returns the Chainlink aggregator address for the specified ERC-20 asset.
Example: GetAggregator(0x0000000000000000000000000000000000000000)

GetSource(uint index)

Limit: None
Function: Returns the specified ERC-20 asset address.
Example: GetSource(0)

GetSourcesCount()

Limit: None
Function: Returns the number of held ERC-20 assets.
Example: GetSourcesCount()

ContainsSource(address token_contract)

Limit: None
Function: Returns true if DeFund contains the specified ERC-20 asset.
Example: ContainsSource(0x0000000000000000000000000000000000000000)

GetFees(address token_contract)

Limit: None
Function: Returns the amount of fees collected for the specified ERC-20 asset.
          Use 0x0000000000000000000000000000000000000000 to retrieve ETH fees.
Example: GetFees(0x0000000000000000000000000000000000000000)

GetHoldings(address token_contract)

Limit: None
Function: Returns the current amount of the specified ERC-20 asset held by the contract.
Example: GetHoldings(0x0000000000000000000000000000000000000000)

GetTotalValue()

Limit: None
Function: Returns the total ETH valuation of assets held by the contract.
          This uses Chainlink's aggregators.
Example: GetTotalValue()

GetHeldValue(address token_contract)

Limit: None
Function: Returns the ETH valuation of the assets specified that DeFund currently holds.
Example: GetHeldValue(0x0000000000000000000000000000000000000000)

GetAccountValue(address owner)

Limit: None
Function: Returns the ETH valuation represented by the amount of DFT held by the specified wallet. 
Example: GetAccountValue(0x0000000000000000000000000000000000000000)

SetOwner(address account)

Limit: Creator only
Function: Changes the creator wallet.
Example: SetOwner(0x0000000000000000000000000000000000000000)

SetToken(address account)

Limit: Creator only
Function: Changes the Defund Share Token contract address.
Example: SetToken(0x0000000000000000000000000000000000000000)

UpdateAggregator(address token_contract, address aggregator_contract)

Limit: Creator only
Function: Adds or updates the chainlink aggregator with the associated ERC-20 asset.
Example: UpdateAggregator(0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000)

DeleteAggregator(address token_contract)

Limit: Creator only
Function: Removes the chainlink aggregator associated with the specified ERC-20 asset.
Example: DeleteAggregator(0x0000000000000000000000000000000000000000)

AddSource(address token_contract)

Limit: Creator only
Function: Adds the specified ERC-20 asset to the list of underlying assets in the fund.
          This function will automatically rebalance existing assets.
Example: AddSource(0x0000000000000000000000000000000000000000)

RemoveSource(address token_contract)

Limit: Creator only
Function: Removes the specified ERC-20 asset from the list of underlying assets in the fund.
          This function will immediately sell the assets held & rebalance existing assets. 
Example: RemoveSource(0x0000000000000000000000000000000000000000)

function PayFees(address payable account_holder, address token_contract, uint256 amount)

Limit: Creator only
Function: Sends the amount specified in fees, to the target account holder.
          Send 0x0 for the token contract to spend ETH fees.
Example: PayFees(0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000,10000000000000000)

WithdrawTokens(uint256 tokenAmount)

Limit: None
Function: Withdraws the equivalent amount of tokens based on the input DFT amount.
          You must first approve the token amount for the defund contract to access.
Example: WithdrawTokens(10000000000000000)

WithdrawETH(uint256 tokenAmount)

Limit: None
Function: Sells the equivalent amount of token based on input DFT amount & withdraws the resulting ETH.
          You must first approve the token amount for the defund contract to access.
Example: WithdrawETH(10000000000000000)

Deposit()

Limit: None
Function: Uses the deposited ETH to purchase an evenly distributed amount of underlying assets.
          This process mints DFT into the depositor's account.
Example: Deposit() (or simply send a transaction to the contract address)

A basic interface for DeFund exists. This is used by the Defund Oracle contract.

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

interface IDefund {
    function GetTotalValue() external view returns (uint256);
    function GetHoldings(address token_contract) external view returns(uint256);
    function GetHeldValue(address token_contract) external view returns(uint256);
    function GetAccountValue(address owner) external view returns(uint256);
    function GetAggregator(address token_contract) external view returns(address);
    function GetSourcesCount() external view returns(uint);
    function GetSource(uint index) external view returns(address);
}