8. Withdraw DAI from Private Pool

Description

Withdraw DAI from private liquidity pool.

TBD: Narratives & Rules of withdrawal

User Interface

Function Description

Item

Description

Contract Address

Private pool contract (referenced by Smart Contract Overview section)

Contract Name

SLDDAIPools2.sol

Function

function withdraw(uint256 amount)

Function Selector

0x2e1a7d4d

Invocation Type

Ethereum Transaction

Passing Parameters

Amount of DAIs to withdraw; actual number multiplied by 1E18

Return Value

None

Event Emitted

event Withdraw(address indexed account, uint256 amount);

Event Signature

0x884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364

Transaction Sample(BSC testnet)

ABI Description

{
	"inputs": [{
		"internalType": "uint256",
		"name": "mintAmount",
		"type": "uint256"
	}],
	"name": "provide",
	"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");

const CONTRACT_ADDRESS = "Replace with Private Pool Contract Address";
const ABI = [{
	"inputs": [{
		"internalType": "uint256",
		"name": "amount",
		"type": "uint256"
	}],
	"name": "deposit",
	"outputs": [],
	"stateMutability": "nonpayable",
	"type": "function"
}];

// Deposit 10 DAI to private pool.
const DEPOSIT_AMOUNT = 10e18;

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

contract.methods.provide(new BigNumber(DEPOSIT_AMOUNT).toString()).send({
    from: "CALLER_ADDRESS",
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});

HTTP Request Example

Send a Deposit Transaction

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

Make a deposit transaction to Shield Protocol V1 on BSC network. 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

NameTypeDescription

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