scans all known v4 channels (via getting them from ${cfg.validatorUrl}/channel/list, not via DB cause we may run v5 validators in a different setup) and gets the last balance tree map (by getting the latest NewState+ApproveState via /channel/last-approved), and for each record in the tree, subtracts outpaceV4.withdrawnPerUser(channelId, user), and finally sums all the remaining maps - that way we calculate all the un-withdrawn DAI for all users
deposits enough USDT from the validator's identity into the main v5 channel (configurable) to cover the entire un-withdrawn amount; should use 1 USDT = 1 DAI exchange rate
saves a SpenderAggregate in the DB that spends this deposited amount to distribute it to the users with un-withdrawn funds; should use 1 USDT = 1 DAI exchange rate
ensure it can only be ran once - mark the SpenderAggregate somehow (extra prop) so that we first check if it exists, and if so, we quit the script
Few additional notes:
yes, it will be possible to double spend by withdrawing on the new channel AND on the new old channels, if there are old channels that are not expired; we do not care about this, so we won't filter for expired channels only
Implement a script that:
${cfg.validatorUrl}/channel/list
, not via DB cause we may run v5 validators in a different setup) and gets the last balance tree map (by getting the latestNewState+ApproveState
via/channel/last-approved
), and for each record in the tree, subtractsoutpaceV4.withdrawnPerUser(channelId, user)
, and finally sums all the remaining maps - that way we calculate all the un-withdrawn DAI for all usersSpenderAggregate
in the DB that spends this deposited amount to distribute it to the users with un-withdrawn funds; should use 1 USDT = 1 DAI exchange rateSpenderAggregate
somehow (extra prop) so that we first check if it exists, and if so, we quit the scriptFew additional notes: