Note Contract

NoteV2

Interface

contract NoteV2{
	mapping(uint256 => mapping(uint8 => mapping(uint256 => uint256)))
        public optionOrder;
    uint8[3] public cycleDay;
	   struct Fund {uint256 buyTime;uint256 investTime;uint256 endTime;uint256 balance;uint256 optionPercent;uint256[2] funds;uint256[2] position;uint256 totalFunds;uint256 profitPerShare;address manager;uint8 status;}
    Fund[] public fundList;
	mapping(address => mapping(uint256 => uint256)) public userBalance;
	mapping(address => bool) public manager;
    uint256[4] public rate;
	event Subscription(
        uint256 fundId,
        address user,
        uint256 amount,
        uint256 fee
    );
    event EarlyRedemption(uint256 fundId, address user, uint256 amount);
    event Redemption(uint256 fundId, address user, uint256 amount);
    event FixedInvestmentMint(
        uint256 fundId,
        uint256 payAmount,
        uint256 cToken
    );
    event FixedInvestmentRedeem(
        uint256 fundId,
        uint256 payAmount,
        uint256 cToken
    );
    event OptionOpen(uint256 fundId, uint256 orderNo);
    event OptionClose(
        uint256 fundId,
        uint256 orderNo,
        uint256 position,
        uint256 income
    );
    event OptionExercise(
        uint256 fundId,
        uint256 orderNo,
        uint256 position,
        uint256 income,
        bool isKnockout
    );
    event NewFund(uint256 fundId);
    event FundClosed(
        uint256 fundId,
        uint256 totalIncome,
        uint256[2] managerProfit
    );
    event FundCanceled(uint256 fundId);
    event SetManager(address manager, bool isManager);
}

Events

  • Subscription(uint256 fundId,address user,uint256 amount,uint256 fee)

User subscription

paramdescription

fundId

fundId

user

subscription user

amount

subscription amount

fee

fee

  • EarlyRedemption(uint256 fundId, address user, uint256 amount)

Redemption before expiration

paramdescription

fundId

fundId

user

redemption user

amount

redemption amount

  • Redemption(uint256 fundId, address user, uint256 amount)

Redemption on maturity

paramdescription

fundId

fundId

user

redemption user

amount

redemption amount

  • FixedInvestmentMint(uint256 fundId, uint256 payAmount, uint256 cToken)

Invest compound

paramdescription

fundId

fundId

payAmount

amount of invest

cToken

amount of ctoken

  • FixedInvestmentRedeem(uint256 fundId, uint256 payAmount, uint256 cToken)

Withdraw the amount of invest compound

paramdescription

fundId

fundId

payAmount

withdraw the amount of usdt

cToken

send cusdt data

  • OptionOpen(uint256 fundId,uint256 indexNo,uint8 poolId, uint256 orderNo)

Invest option

paramdescription

fundId

fundId

orderNo

orderNo

  • OptionExercise(uint256 fundId, uint256 orderNo,uint256 position,uint256 income, bool isKnockout)

Withdraw the amount of invest option

Invest option

paramdescription

fundId

fundId

orderNo

orderNo

position

position

income

withdraw the amount of usdt

isKnockout

is knockout

  • OptionClose(uint256 fundId,uint256 orderNo,uint256 position,uint256 income)

Option exercise

paramdescription

fundId

fundId

orderNo

orderNo

position

position

income

withdraw the amount of usdt

  • NewFund(uint256 fundId)

New fund

  • FundClosed( uint256 fundId, uint256 totalIncome, uint256[2] managerProfit)

Fund closed

paramdescription

fundId

fundId

totalIncome

total income

managerProfit[0]

performance fee

managerProfit[1]

manager profit

  • FundCanceled(uint256 fundId)

Fund canceled

  • SetManager(address manager, bool isManager)

Set manager rights

Methods(Read Contract)

1. User Balance

mapping(address => mapping(uint256 => uint256)) public userBalance

The amount of user invested

paramtypedescription

user

address

user address

fundId

uint256

fundId

returntypedescription

balance

uint256

balance

1.Pay Token

IERC20 public immutable payToken

View payment token

2. Option Order

mapping(uint256 => mapping(uint8 => mapping(uint256 => uint256))) public optionOrder

View fundId that map with option contract

paramtypedescription

indexNo

uint256

indexNo

pool_id

uint8

pool_id

order_no

uint256

order_no

returntypedescription

fundId

uint256

fundId

3. Cycle Day

uint8[3] public cycleDay

**Cycle day,unit/day **

paramtypedescription

index

uint8

index,option: 0,1,2

returntypedescription

day

uint256

days

4. Manager

mapping(address => bool) public manager

Whether is manager

paramtypedescription

address

address

query address

returntypedescription

isManager

bool

whether is manager

5. Fund List

  struct Fund {
        uint256 buyTime;
        uint256 investTime;
        uint256 endTime;
        uint256 balance;
        uint256 optionPercent;
        uint256[2] funds;
        uint256[2] position;
        uint256 totalFunds;
        uint256 profitPerShare; // muti by 1e18;
        address manager;
        uint8 status; //1 Fundraising;2 Investing;3 end;4 cancel;
    }
    Fund[] public fundList;

**Fund details **

paramtypedescription

fundId

uint256

fundId

returntypedescription

buyTime

uint256

buy time

investTime

uint256

the start time of fund closed

endTime

uint256

end time

balance

uint256

note balance

optionPercent

uint256

During manager invests, optionPercent =optionPercent/10000

totalfunds

uint256

The user's total investment amount, after the fund manager starts to invest, the value is not 0, after the closing period, the value has been determined

profitPerShare

uint256

After the end of the product, each user token can receive the amount, the value has been amplified by 1E18 times

manager

address

fund manager

status

uint8

Fund status,1 initial state, waiting to invest or investing,2 investing,3 closed, 4 cancelled

6. Get Fund

function getFund(uint256 _fundId) external view returns (uint256[2] memory funds, uint256[2] memory position)

Get fund investment situation

paramtypedescription

_fundId

uint256

_fundId

returntypedescription

funds[0]

uint256[2]

Amount of investible options

funds[1]

uint256[2]

Amount of investible compounds

position[0]

uint256[2]

Total option position

position[1]

uint256[2]

Amount of compound ctoken

7. Manager

mapping(address => bool) public manager

Whether is fund manager

paramtypedescription

address

address

query address

returntypedescription

isManager

bool

whether is manager

Methods(Write Contract)

1. Subscription

function subscription(uint256 _fundId, uint256 _amount) external

Invest fund

paramtypedescription

_fundId

uint256

_fundId

_amount

uint256

purchase amount

2. Partial Redemption

function partialRedemption(uint256 _fundId, uint256 _amount) external

Redemotion before closed

paramtypedescription

_noteId

uint256

_noteId

_amount

uint256

the amount of user withdraw

3. Redemption

function redemption(uint256 _fundId) external

**Redemption at expiration **

paramtypedescription

_fundId

uint256

_fundId

Fund manager operations

4. Add Fund

function addFund( uint256 _buyTime, uint256 _investTime, uint8 _cycleIndex, uint256 _optionPercent )

**Add fund product **

paramtypedescription

_buyTime

uint256

buy time

_investTime

uint256

beginning of closure

_cycleIndex

uint8

cycleDay[3] fund cycle,0:30days,1:60days,2:90days

_optionPercent

uint256

option percent

5.Cancel Note

function cancelFund(uint256 _fundId) external

**Cancel note **

paramtypedescription

_fundId

uint256

_fundId,close note products only before users start investing

6. Close Fund

function closeFund(uint256 _fundId) external

After the expiration, close the fund, and then user can be redeemed, at the same time the fund manager gains

7. Invest Option

function optionOpen( uint256 _fundId, uint256 _indexNo,uint8 _poolId, uint256 _position, bool _isCall, uint256 _price, uint256 _datetime, bytes calldata _signData ) external

Invest option

paramtypedescription

_fundId

uint256

fundId

_indexNo

uint256

indexNo

_poolId

uint256

poolId

_position

uint256

option position

_isCall

bool

buy direction,true is call,false is put

_price

uint256

buy price

_datetime

uint256

buy time

signData

bytes

buy price and time signature

8.Fixed Investment Mint

function fixedInvestmentMint(uint256 _fundId, uint256 _amount) external

Invest compound

paramtypedescription

_fundId

uint256

fundId

_amount

uint256

the amount of token

9. Fixed Investment Redeem

function fixedInvestmentRedeem(uint256 _fundId, uint256 _cTokenAmount)

**Withdraw compound **

paramtypedescription

_fundId

uint256

fundId

_amount

uint256

the amount of ctoken

10. Withdraw Option

function optionClose( uint256 _fundId, uint256 _orderNo, uint256 _position, uint256 _price, uint256 _datetime, bytes calldata _signData ) external

Withdraw option

paramtypedescription

_fundId

uint256

fundId

_orderNo

uint256

option contract id

_position

uint256

option number

_price

uint256

buy price

_datetime

uint256

buy time

signData

bytes

buy time and buy signature

11. Option Exercise

function optionExercise(uint256 _fundId,uint256 _indexNo, uint8 _poolId, uint256 _orderNo, bool _isKnockOut ) external

Option exercise at expiration

paramtypedescription

_noteId

uint256

noteId

_indexNo

uint256

indexNo

_poolId

uint256

poolId

_orderNo

uint256

option contract id

_isKnockout

uint256

whether is konckout

Last updated