@@ -17,6 +17,18 @@ export function generateWithdrawTxs(contracts, batchLimits, amount, to) {
17 return [...csrTxs, ...lsrTxs];
17 return [...csrTxs, ...lsrTxs];
21+ * Recurse over batchLimits to generate a valid number of withdraw txs.
22+ * amount may exceed the number of withdraw txs available in the consolidated SR contract.
24+ * @param {object} contracts - The azimuth contracts object
25+ * @param {array} batchLimits - An array of the maximum withdraw limit for each batch
26+ * @param {amount} amount - The number of txs to be generated
27+ * @param {string} to - The addresss to withdraw to
28+ * @return {array} An array with the number of transactions missing as the head
29+ * (i.e. requested amount exceeded available), and the generated transactions
30+ * as the rest of the list
20function generateConditionalWithdrawTxs(
32function generateConditionalWithdrawTxs(
21 contracts,
33 contracts,
22 batchLimits,
34 batchLimits,
@@ -24,11 +36,11 @@ function generateConditionalWithdrawTxs(
25 offset = 0
37 offset = 0
27− // Successfully withdraw all requesed
39+ // Successfully withdrawn all requested, none missing
28 if (amount <= 0) {
40 if (amount <= 0) {
29 return [0];
41 return [0];
31− // Return missing amount in car
43+ // Return missing amount in head of list
32 if (batchLimits.length === 0) {
44 if (batchLimits.length === 0) {
33 return [amount];
45 return [amount];