Import the client
Call a swap
Vec<Vec<i128>>: one inner vector of step amounts per protocol the trade was
split across, in the same order as distribution.
You have to supply the distribution
This is the part that differs from calling the router. The aggregator does not decide how to split the trade, the caller does, by passingVec<DexDistribution>:
parts is a weight, not a percentage. Each entry receives
amount * parts / total_parts. A distribution may hold at most MAX_DISTRIBUTION_LENGTH
(15) entries. See Aggregator Operation for
the exact arithmetic.
Authorization
As with the router, the receiving address authorizes the swap. Your contract can only swap for a user inside an invocation that user authorized, or for itself.Read-only calls
get_adapters tells you which protocols are registered, and get_paused whether a given
one is currently closed to new swaps. Both are cheap, and checking get_paused before
including a protocol in a distribution avoids a failed swap.
Full interface on the
SoroswapAggregator page.