Query Minimum Margin for new Quotation

Description

Query total Volume for certain MVault.

User Interface

TODO(Snapshots)

Function Description

Contract Address

MVault contract (referenced by General Info section)

Contract Name

MVault.sol

Function

function calMargins(

uint256 _maxVolume,

uint256 _APY,

uint256 _endTime ) public

Function Selector

0xb6624fb0

Invocation Type

Ethereum Call

Passing Parameters

uint256 _maxVolume: Maximum volume for MVault, actual number multiplied by 1E(token precision) uint256 _APY: APY for MVault, actual number multiplied by 1E18(1e18 means 100%) uint256 _endTime: End Timestamp for next round MVault

Return Value

uint256 baseMargin: token margin need to pay uint256 sldMargin: SLD token margin need to pay

ABI Description

    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_maxVolume",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_APY",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_endTime",
          "type": "uint256"
        }
      ],
      "name": "calMargins",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "baseMarginAmount",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "sldMarginAmount",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    }

Examples

Calling Examples

// This example is written by using Web3.js
// More details on Web3.js could be found here - https://web3js.readthedocs.io/

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 contract address
const CONTRACT_ADDRESS = "Replace with MVault contract address";
const ABI = [    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_maxVolume",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_APY",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "_endTime",
          "type": "uint256"
        }
      ],
      "name": "calMargins",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "baseMarginAmount",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "sldMarginAmount",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    }];

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

contract.methods.calMargins(
    BigNumber(60000).times(1e18).toString(10),
    BigNumber(0.1).times(1e18).toString(10),
    parseInt(Date.now() / 1000) + 60 * 60 * 24 * 7).call({
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});

HTTP Request Example

Query Margins

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

Make a contract call to get deposited funds details of Shield Protocol V1. More details on how to make a contract call request 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_call"

params

array

the signed transaction data coerced into string array, for instance,

id

number

request sequence id, you could use timestamp as id

{
    "jsonrpc": "2.0",
    "id": 1234,
    "result": "0x00000000000000000000000000000000000000000000006c6b935b8bbd40000000000000000000000000000000000000000000000000006c6b935b8bbd400000"
}

Request Body Example:

{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "from": "0x0000000000000000000000000000000000000000",
            "to": "0x85B18E8b86F998835099e6a021e2b1e8d5BcA9C7",
            "data": "0xb6624fb000000000000000000000000000000000000000000000152d02c7e14af6800000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000635736a0"
        },
        "latest"
    ],
    "id": 1234
}

CURL Example:

curl --location --request POST 'https://data-seed-prebsc-1-s1.binance.org:8545/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [
        {
            "from": "0x0000000000000000000000000000000000000000",
            "to": "0x85B18E8b86F998835099e6a021e2b1e8d5BcA9C7",
            "data": "0xb6624fb000000000000000000000000000000000000000000000152d02c7e14af6800000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000635736a0"
        },
        "latest"
    ],
    "id": 1234
}'

Last updated