Withdraw Margin

Description

You could withdraw margins though this interfaces. But you should query withdrawable amount first here.

User Interface

TODO(Snapshots)

Function Description

Contract Address

MVault contract (referenced by General Info section)

Contract Name

MVault.sol

Function

function withdrawMargin(

uint256 baseAmount,

uint256 sldAmount

)

Function Selector

0x3bad4bbb

Invocation Type

Ethereum Transaction

Passing Parameters

uint256 baseAmount: base token amount you would like to withdraw, actual number multiplied by 1E(Token precision)

uint256 sldAmount: SLD token amount you would like to withdraw, actual number multiplied by 1E18

Return Value

None

Event Emitted

None

Event Signature

None

Transaction Sample(Kovan testnet)

ABI Description

    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "baseAmount",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "sldAmount",
          "type": "uint256"
        }
      ],
      "name": "withdrawMargin",
      "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 contract address
const CONTRACT_ADDRESS = "";
const ABI = [    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "baseAmount",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "sldAmount",
          "type": "uint256"
        }
      ],
      "name": "withdrawMargin",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }];

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

contract.methods.withdrawMargin(
    BigNumber(100).times(1e18).toString(10), // 100 base tokens
    BigNumber(200).times(1e18).toString(10), // 200 SLD tokens
).send({
    from: "CALLER_ADDRESS",
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});

HTTP Request Example

Withdraw Margin

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

Pay token margin for 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