Links
Comment on page

Making a withdraw

For compatibility across tokens with various decimals, 2PI allows unifying all currency amounts to use the decimal representation. For example, a value of 10 in the amount field will utilize ten currency tokens.
twoPi.withdraw({vaultIdentifier, amount, unit})
This method withdraws the specified amount of stablecoins from 2PI vaults.
Note that the actual amount withdrawn will be smaller to the requested amount due to the withdraw fee (0.01%).

Method Parameters

Parameter
Type
Optionality
Description
vaultIdentifier
String
required
A string that represents the network/currency pair
amount
String
required
Amount to deposit
unit
String
optional
Flag to force the way values get represented.
options: wei | native Native: means it will handle amount values using decimal representation.
wei (default): the smallest denomination of a token. Based on the token decimals.

Example

JavaScript
const withdraw = await twoPi.withdraw ({
vaultIdentifier: 'mumbai_dai',
amount: '12',
unit: 'native',
});

Returns

The status of the operation plus a detailed list of the transactions that took part in the withdraw action.
{
status: 1,
transactionsReceipt: [
{ [10/76]
to: '0x3B353b1CBDDA3A3D648af9825Ee34d9CA816FD38',
from: '0x596B25b30898Ea5EAD475a5f4D672be9F5C5E143',
contractAddress: null,
transactionIndex: 1,
gasUsed: BigNumber { _hex: '0x17e421', _isBigNumber: true },
logsBloom: '0x0000000000000000008004000004004000800000010081002000040200000100004000000000000010000000008000000000801000081020
080001041024000901060000000004000000000804000084000a00000004000002010008800000400000040002000000000a101000002800000000408008022280
000010000000000000000000000080008400000200040000200000000180020000000000000e402200000101a00040000102000000000004000a00000000000000
000800000140100400020002004400010060020200000000000002001001011020404000600000100001000400000000100000000000000000020001000000a800
2004100000',
blockHash: '0x58524d9197df474057e20faaa13caf242ca0b62a385e0d7c2ccd00590f1f5e3c',
transactionHash: '0xbbfaf1ed1221b127eecf1bda09588eb00e6a865fd6fdd98e589ba36be85665c4',
logs: [
[Object], [Object], [Object], [Object], [Object],
[Object], [Object], [Object]
],
blockNumber: 22617729,
confirmations: 1,
cumulativeGasUsed: BigNumber { _hex: '0x183629', _isBigNumber: true },
effectiveGasPrice: BigNumber { _hex: '0x07aef40a00', _isBigNumber: true },
status: 1,
type: 0,
byzantium: true
}
]
}