Issue an MVault

Description

Issue a new MVault.

User Interface

TODO(Snapshots)

Function Description

Contract Address

MVault Factory contract (referenced by General Info section)

Contract Name

MVaultFactory.sol

Function

function createMVault(

address _token,

address _aggregator,

uint256 _strikePrice,

uint256 _APY,

uint256 _maxVolume,

uint256 _minDeposit,

uint256 _endTime

) public

Function Selector

0x40d601f8

Invocation Type

Ethereum Transaction

Passing Parameters

address _token: underlying asset address for MVault to be issued address _aggregator: trading pair address on DEX(ZERO ADDRESS for chainlink price feeder) uint256 _strikePrice: strike price for MVault, actual number multiplied by 1E18 uint256 _APY: APY for MVault, actual number multiplied by 1E18(1e18 means 100%) uint256 _maxVolume: Maximum volume for MVault, actual number multiplied by 1E(token precision) uint256 _minDeposit: Minimum deposit amount for user, actual number multiplied by 1E(token precision) uint256 _endTime: End Timestamp for current round MVault

Return Value

None

Event Emitted

event MVaultCreated(
    address vault,
    address publisher,
    address token,
    uint256 maxVolume,
    uint256 timestamp
);

Event Signature

0x2a4a5bd2ce3cffcb014f583ac33515c4e66b67e2d897ceb943c8b36509cf7c56

ABI Description

    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_token",
          "type": "address"
        },
        {
          "internalType": "address",
          "name": "_aggregator",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_strikePrice",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_APY",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_maxVolume",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_minDeposit",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_endTime",
          "type": "uint256"
        }
      ],
      "name": "createMVault",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }

Examples

Calling Examples

var Web3 = require('web3');
const BigNumber = require('bignumber.js');

// BSC Mainnet: https://bsc-dataseed.binance.org
// BSC Testnet: https://data-seed-prebsc-1-s1.binance.org:8545
const  web3 = new Web3("https://data-seed-prebsc-1-s1.binance.org:8545");

// Need MVault factory contract address
const CONTRACT_ADDRESS = "";
const ABI = [    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_token",
          "type": "address"
        },
        {
          "internalType": "address",
          "name": "_aggregator",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_strikePrice",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_APY",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_maxVolume",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_minDeposit",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_endTime",
          "type": "uint256"
        }
      ],
      "name": "createMVault",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }];

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.deposit(
    wbtc.address,
    ZERO_ADDRESS,
    BigNumber(60000).times(1e18).toString(10),
    BigNumber(10).times(1e18).toString(10),
    BigNumber(10).times(1e18).toString(10),
    BigNumber(0.001).times(1e18).toString(10),
    parseInt(Date.now() / 1000) + 60 * 60 * 24 * 7
  ).send({
    from: "CALLER_ADDRESS",
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});

HTTP Request Example

Send an MVault issuing Transaction

POST (BSC Mainnet) https://bsc-dataseed.binance.org/

Make a new MVault. More details on how to send a transaction via BSC RPC could be found here, https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction

Request Body

Name
Type
Description

jsonrpc*

string

"2.0"

method*

string

"eth_sendRawTransaction"

params*

array

the signed transaction data coerced into string array

id*

number

request sequence id, you could use timestamp as id

{
  "id":64,
  "jsonrpc": "2.0",
  "result": "0x146695866343024d1ad9854a72904d16abec8b1597e098619d2addbd44b14e4c"
}

Last updated