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
1
const withdraw = await twoPi.withdraw ({
2
vaultIdentifier: 'mumbai_dai',
3
amount: '12',
4
unit: 'native',
5
});
Copied!

Returns

The status of the operation plus a detailed list of the transactions that took part in the withdraw action.
1
{
2
status: 1,
3
transactionsReceipt: [
4
{ [10/76]
5
to: '0x3B353b1CBDDA3A3D648af9825Ee34d9CA816FD38',
6
from: '0x596B25b30898Ea5EAD475a5f4D672be9F5C5E143',
7
contractAddress: null,
8
transactionIndex: 1,
9
gasUsed: BigNumber { _hex: '0x17e421', _isBigNumber: true },
10
logsBloom: '0x0000000000000000008004000004004000800000010081002000040200000100004000000000000010000000008000000000801000081020
11
080001041024000901060000000004000000000804000084000a00000004000002010008800000400000040002000000000a101000002800000000408008022280
12
000010000000000000000000000080008400000200040000200000000180020000000000000e402200000101a00040000102000000000004000a00000000000000
13
000800000140100400020002004400010060020200000000000002001001011020404000600000100001000400000000100000000000000000020001000000a800
14
2004100000',
15
blockHash: '0x58524d9197df474057e20faaa13caf242ca0b62a385e0d7c2ccd00590f1f5e3c',
16
transactionHash: '0xbbfaf1ed1221b127eecf1bda09588eb00e6a865fd6fdd98e589ba36be85665c4',
17
logs: [
18
[Object], [Object], [Object], [Object], [Object],
19
[Object], [Object], [Object]
20
],
21
blockNumber: 22617729,
22
confirmations: 1,
23
cumulativeGasUsed: BigNumber { _hex: '0x183629', _isBigNumber: true },
24
effectiveGasPrice: BigNumber { _hex: '0x07aef40a00', _isBigNumber: true },
25
status: 1,
26
type: 0,
27
byzantium: true
28
}
29
]
30
}
Copied!