[ADD] Aggregator support
Aggregator is the ability for a user to utilise long tail ETH swap contracts such as Sushi Swap to convert to/from THORChain support L1 tokens such as BTC. For example
Inbound (e.g. Sushi supported ERC20 to BTC):
A user (typically a UI will do this) calls the Aggregator contract SwapIn()
function. This does the required logic of converting the user funds to ETH using Sushi (or alternative), then forwards the ETH onto THORChain Router which emits the Deposit
event. No changes are required by Bifrost/Thornode to support this.
Outbound (e.g. BTC to Sushi long tail asset):
A user deposits BTC to a THORChain ASGARD vault with memo such as TCS:ETH.0x123:0xabc
. THORChain internally swaps to L1 ETH, then to send the outbound, the Asgard/Yggdrasil uses the RouterV4 transferOutAndCall()
function which calls SwapOut()
on the Aggregator with the ETH. The Aggregator contract will then do the Sushi swap from ETH to 0x123
asset for the user 0xabc
specified in the memo.
Thornode/Bifrost consideration(s) for Aggregator(s):
- Outbound gas fees will be higher (maybe 150-200k? vs 40k gas for regular outbounds). Needs to be accounted for with fees, because TC is essentially paying for this extra Sushi swap as a convenience for the user.
- Bifrost should hardcode whitelist of aggregator contracts (for security - e.g. you don't want user input to be able to specify arbitrary contract addresses Asgard will call outbound into).
- Memo will need to support aggregator, e.g.
TCS:ETH.0xDestinationAsset:0xDestinationUserAddress
which specifically uses the 'TCS' Aggregator (hardcoded) for this memo. - inbound_addresses should return an array of supported Aggregator memo's, e.g.
"aggregators" : [
{
"memo" : "TCS",
"description" : "THORChain Aggregator (SushiSwap)",
"contract" : "0x12345abcde"
}
]
- Bifrost will need to read a new Event type
TransferOutAndCall(from, aggregatorContract, asset, amount, to, memo)
. Unfortunately can't just use the regularTransferOut()
event because an evil node could just send to their own aggregator contract and emit the event, leading to stealing from users. So the event logged needs to be for ALL the parameters, showing that is really what just happened. - Mimir to remove/pause Aggregator support. Comma separated list of recalled/paused aggregators? e.g.
"pauseAggregator":"TCS,ABC,XYZ"
??