withdraw method

Future<TransactionBlock> withdraw(
  1. String poolId,
  2. int quantity,
  3. AssetType assetType, [
  4. String? recipientAddress,
])

Construct transaction block for withdrawing the assetType (base or quote) of the amount of quantity asset from a pool poolId to recipientAddress.

If omitted recipientAddress, this.currentAddress will be used. The function will throw if the recipientAddress === DUMMY_ADDRESS

Implementation

/// of [quantity] asset from a pool [poolId] to [recipientAddress].
  ///
/// If omitted [recipientAddress], `this.currentAddress` will be used. The function
/// will throw if the `recipientAddress === DUMMY_ADDRESS`
Future<TransactionBlock> withdraw(
	String poolId,
	int quantity,
	AssetType assetType,
	[String? recipientAddress]
) async {
    recipientAddress ??= currentAddress;
	final txb = TransactionBlock();
	final functionName = assetType == AssetType.base ? 'withdraw_base' : 'withdraw_quote';
    final typeArgs = await getPoolTypeArgs(poolId);
	final withdraw = txb.moveCall(
		"$PACKAGE_ID::$MODULE_CLOB::$functionName",
		typeArguments: typeArgs,
		arguments: [txb.object(poolId), txb.pureInt(quantity), txb.object(_checkAccountCap())],
	);
	txb.transferObjects([withdraw], txb.pureAddress(_checkAddress(recipientAddress)));
	return txb;
}