Technical Principles
Contract Overview

Smart contract

DeFund protocol is an intelligent contract system composed of many libraries, which together complete the functions implemented by the protocol.

Core contracts mainly provide core implementation functions for the protocol. They define the generation and operation logic of the Fund.

Extension contracts are mainly contracts that connect to third party contracts, currently Uniswap's PathFinder, PriceOracle and PositionViewer.

The data processing contract is mainly used to capture the Fund's data.

Library contracts are mainly used by third party libraries, such as OpenZeppelin, Uniswap.

Core contract

The core contract of DeFund Protocol mainly consists of the following parts:

  • FundAccount
  • FundProxy
  • FundManager

FundAccount

A FundAccount is a contract for a single fund that holds all of the fund's assets.

FundProxy

FundProxy is a contract that operates fund contracts. GP and LP mainly operate funds in this contract.

Modulefunction
ProxyConfig.solManage official maintainable and updated configuration items
FundData.solKeep the core data of the fund
NavCalculator.solHandle the calculation of the net value of the fund
CallExecutor.solHandles calls to fund contracts

FundManager

FundManager is a management contract used to create fund accounts and perform operations such as authorization and transaction security verification.

Modulefunction
ManagerConfig.solManage official maintainable and updated configuration Settings
FundFactory.solHandle fund creation and other processes
ProtocolAdapter.solPerforms security checks on user-initiated transactions
RoleFundViewer.solRecord the association between the user and the fund according to the role
PositionHolder.solRecord the liquidity pool created by the fund
CalldataDecoder.solResolution fund transaction
AssetPriority.solManage the redemption priority of assets within the fund

Extension contract

Extension contracts are mainly used to connect to third party contracts, currently Uniswap's PathFinder and PriceOracle.

FundViewer

The contract is mainly used for data processing, mainly for queries to obtain fund data.

PathFinder

PathFinder is Uniswap V3's Pathfinder contract that finds the best path based on the borrower's asset value and the borrower's asset value.

PriceOracle

PriceOracle is Uniswap's price prognosticator contract that uses Uniswap's price prognosticator to forecast borrowing prices and evaluate the asset value of the borrower's loan account.

Library

Library contracts are mainly used for third-party libraries, such as OpenZeppelin, Uniswap.