Maker
Overview
The Maker contract collects part of Astroport's pool fees (the factory's maker_fee). It swaps each fee token into a single base asset through the router, then splits the base asset across a list of legs. Each leg takes a share, may swap it along its own route, and then sends it to an address or deposits it into a contract.
Maker 2.x replaces 1.x's fixed splits (governance percent, second receiver, dev fund) and its bridges with legs and routes. A 1.7.0 Maker is migrated in place; see MigrateMsg.
Links
- Neutron Address: neutron1unc0549k2f0d7mjjyfm94fuz2x53wrx3px0pr55va27grdgmspcqgzfr8p (
astroport-maker2.0.0) - Terra Address: terra1ygcvxp9s054q8u2q4hvl52ke393zvgj0sllahlycm4mj8dm96zjsa45rzk (
astroport-maker2.0.0) - Contract Repo: https://github.com/astroport-fi/astroport-core/tree/main/contracts/tokenomics/maker
- contract.rs: https://github.com/astroport-fi/astroport-core/blob/main/contracts/tokenomics/maker/src/contract.rs
- msg.rs: https://github.com/astroport-fi/astroport-core/blob/main/contracts/tokenomics/maker/src/msg.rs
- Tests: https://github.com/astroport-fi/astroport-core/tree/main/contracts/tokenomics/maker/tests
How the Makers are configured
Both Makers swap through Router 2.0, use a max_spread of 25%, have no collect cooldown and an empty collectors list, so anyone can call collect. No fee token route starts at ASTRO and no leg sells ASTRO: neither Maker ever sells ASTRO. The owner is the protocol owner on each chain (the Assembly on Neutron, the satellite on Terra), run by the "Astroport - Contributors" DAO. Query config and routes for the exact live values.
Neutron: burn only
Fees are swapped into NTRN. A single leg swaps all of it into ASTRO and deposits it into the ASTRO burner, which burns it.
| Leg | Share | Route | Action |
|---|---|---|---|
| 1 | 100% | NTRN to ASTRO | deposit into the ASTRO burner with {"burn":{}} |
_34{_34 "base_asset": {_34 "native_token": {_34 "denom": "untrn"_34 }_34 },_34 "legs": [_34 {_34 "share": "1",_34 "route": [_34 {_34 "astro_swap": {_34 "offer_asset_info": {_34 "native_token": {_34 "denom": "untrn"_34 }_34 },_34 "ask_asset_info": {_34 "native_token": {_34 "denom": "factory/neutron1ffus553eet978k024lmssw0czsxwr97mggyv85lpcsdkft8v9ufsz3sa07/astro"_34 }_34 }_34 }_34 }_34 ],_34 "action": {_34 "deposit": {_34 "contract": "neutron1wl7akesary9ac3h5k3mjw3lj5e93pvpwlc8xjh05aug7zgl084gq8xhjxp",_34 "msg": "eyJidXJuIjp7fX0="_34 }_34 }_34 }_34 ]_34}
The seize config sends seized assets to the ASTRO burner, and ASTRO is the only seizable asset, so ASTRO that reaches the Maker (for example Incentives' incentivization fees) can be moved to the burner and burned.
Terra: USDC.inj base, three legs
Fees are swapped into USDC.inj (ibc/E8481AD838C31D4FC12A504B10F9B4E2F830F8818D2735C2FFC707579B5FA60B), then split:
| Leg | Share | Route | Action |
|---|---|---|---|
| 1 | 25% | USDC.inj to LUNA to ASTRO | send to the satellite, which IBC-transfers it to the Neutron ASTRO burner to be burned (transfer_astro on the satellite, callable by anyone) |
| 2 | 50% | none | send to the Terra "Astroport - Development Fund" DAO |
| 3 | 25% | none | deposit into yASTRO with {"deposit_rewards":{}}, streamed to yASTRO stakers over the following week |
_66{_66 "base_asset": {_66 "native_token": {_66 "denom": "ibc/E8481AD838C31D4FC12A504B10F9B4E2F830F8818D2735C2FFC707579B5FA60B"_66 }_66 },_66 "legs": [_66 {_66 "share": "0.25",_66 "route": [_66 {_66 "astro_swap": {_66 "offer_asset_info": {_66 "native_token": {_66 "denom": "ibc/E8481AD838C31D4FC12A504B10F9B4E2F830F8818D2735C2FFC707579B5FA60B"_66 }_66 },_66 "ask_asset_info": {_66 "native_token": {_66 "denom": "uluna"_66 }_66 }_66 }_66 },_66 {_66 "astro_swap": {_66 "offer_asset_info": {_66 "native_token": {_66 "denom": "uluna"_66 }_66 },_66 "ask_asset_info": {_66 "native_token": {_66 "denom": "ibc/8D8A7F7253615E5F76CB6252A1E1BD921D5EDB7BBAAF8913FB1C77FF125D9995"_66 }_66 }_66 }_66 }_66 ],_66 "action": {_66 "send": {_66 "recipient": "terra1k9j8rcyk87v5jvfla2m9wp200azegjz0eshl7n2pwv852a7ssceqsnn7pq"_66 }_66 }_66 },_66 {_66 "share": "0.5",_66 "route": [],_66 "action": {_66 "send": {_66 "recipient": "terra19gzq28ktdwsvkqzrr02u705a07hjwqmxse76552x7azxuwsej4nsm200yj"_66 }_66 }_66 },_66 {_66 "share": "0.25",_66 "route": [],_66 "action": {_66 "deposit": {_66 "contract": "terra1fe8uj96z7f4jfsnkrdxhchxdhdtx8alr9zjqze76hm2ga6tpxjjq5rdjw7",_66 "msg": "eyJkZXBvc2l0X3Jld2FyZHMiOnt9fQ=="_66 }_66 }_66 }_66 ]_66}
The seize config sends seized assets to the Terra Development Fund. The seizable assets are tokens that have no route to the base asset, including the legacy ASTRO CW20 and the xASTRO CW20.
Concepts
Base asset and routes
Every fee token needs a route: a list of router 2.x SwapOperations (astro_swap or pool_swap) that starts at the fee token and ends at the base asset. A route has between 1 and 5 hops, each hop must offer what the previous hop asked for, and no asset is visited twice. The base asset itself has no route; it's split across the legs as it is.
SwapOperation
A hop of a route, as defined by router 2.x. The Maker depends on the router crate for this type.
| Variants | Description |
|---|---|
AstroSwap | Swap in the factory's pool for this asset pair |
PoolSwap | Swap in a specific pool, given by address. The pool doesn't have to be registered in the factory |
Legs
A leg is one destination for part of the collected fees. There are 1 to 10 legs, every share is greater than zero and the shares add up to exactly 1. The last leg also gets what rounding leaves over.
| Params | Type | Description |
|---|---|---|
share | Decimal | The part of the base asset balance this leg gets |
route | Vec<SwapOperation> | Optional. If set, it starts at the base asset and the leg's share is swapped along it. It can end in any other asset, and doesn't visit the same asset twice |
action | LegAction | What happens to the leg's output: send { recipient } transfers it to recipient (if the leg has a route, the router pays recipient directly); deposit { contract, msg } executes contract with msg and the output attached, as native funds or as a CW20 send with msg as its hook. If the leg has a route, the Maker swaps first and deposits exactly what the swap produced. Neither target can be the Maker itself |
The example above burns half the fees and pays the other half to a DAO, with USDC as the base asset (eyJidXJuIjp7fX0= is {"burn":{}}, the ASTRO burner's execute message).
Price protection
Every swap goes through the router with a minimum_receive. The Maker prices the swap by simulating a probe of a thousandth of the amount along the same route. It scales that rate up to the full amount and takes off max_spread:
_1minimum_receive = amount * (probe_out / probe) * (1 - max_spread)
A swap whose price impact is more than max_spread fails its minimum and reverts the whole collect. To collect a large balance, use limit and collect it in parts. The base asset takes a limit too: it caps how much of it is split across the legs, so a balance too big for a leg's route can be split in parts as well.
The probe only sets the rate if it returns at least 1000 units, so that integer rounding stays under 0.1% of it. For smaller amounts the Maker tries larger probes (a hundredth, a tenth, then the whole amount); a probe that a pool refuses outright is skipped the same way, and only the whole amount failing to simulate fails the collect. What can't be priced even then is skipped, left for a later collect and reported with a skipped_dust attribute. A leg share that is too small to swap is also skipped and stays in the Maker for the next split.
The Maker measures a swap against the pool as it is at execution, so it can't tell that the pool was pushed off market just before. A collector that quotes the price elsewhere first can pass min_receive with each fee token: the swap then fails below that floor too, whatever the pool says.
max_spread is greater than zero and at most 50%. The default is 5%.
Who can collect
collectors is a list of addresses allowed to call collect. Empty, which is the default, means anyone can. The owner sets it at instantiate or migrate and changes it with update_config, where an empty list opens collect up again.
InstantiateMsg
Initializes the contract with the router, the base asset, the legs and the fee token routes.
| Params | Type | Description |
|---|---|---|
owner | String | Address allowed to change the configuration |
router | String | Router 2.x contract used for every swap |
base_asset | AssetInfo | Asset every fee token is swapped into before it's split across the legs |
max_spread | Option<Decimal> | Most price impact a swap may have. Defaults to 5% |
collect_cooldown | Option<u64> | If set, collect can be called at most once per this many seconds, between 30 and 600. Unset or 0 means no cooldown |
collectors | Vec<String> | Addresses allowed to call collect. Empty (the default) means anyone can |
legs | Vec<Leg> | Where the base asset goes |
routes | Vec<(AssetInfo, Vec<SwapOperation>)> | Optional. Routes from fee tokens to the base asset |
ExecuteMsg
collect
Swaps the listed fee tokens into the base asset along their routes, then splits the Maker's base asset balance across the legs. Anyone can call it unless collectors is set.
- Every listed token needs a route, even one with no balance.
- An empty list only splits the base asset the Maker already holds.
- The base asset can be listed, but it isn't swapped; its
limitcaps how much of it is split across the legs. - If a cooldown is set,
collectfails until the cooldown has passed since the last collect.
| Params | Type | Description |
|---|---|---|
assets | Vec<CollectAsset> | The fee tokens to swap, and optionally the base asset |
CollectAsset
A fee token to collect.
| Params | Type | Description |
|---|---|---|
info | AssetInfo | The token |
limit | Option<Uint128> | The most of it to swap in this call. Without it, the whole balance is swapped. For the base asset, the most of it to split across the legs |
min_receive | Option<Uint128> | The least base asset its swap must return, on top of the Maker's own price check. Ignored for the base asset and for amounts too small to price |
update_config
Owner only. Every field is optional. Legs are replaced as a whole and validated against the base asset, including a new one set in the same message. If the base asset changes, routes that end in the old one are refused at collect until they're replaced.
| Params | Type | Description |
|---|---|---|
router | Option<String> | Router 2.x contract used for every swap |
base_asset | Option<AssetInfo> | Asset every fee token is swapped into |
max_spread | Option<Decimal> | Most price impact a swap may have, at most 50% |
collect_cooldown | Option<u64> | Between 30 and 600 seconds. 0 removes the cooldown |
collectors | Option<Vec<String>> | Addresses allowed to call collect. An empty list lets anyone call it again |
legs | Option<Vec<Leg>> | Replaces the legs as a whole |
update_routes
Owner only. Adds or replaces routes, and removes the routes for the listed assets. A route must run from its asset to the base asset.
| Params | Type | Description |
|---|---|---|
add | Vec<(AssetInfo, Vec<SwapOperation>)> | Fee tokens and their routes to the base asset |
remove | Vec<AssetInfo> | Fee tokens whose routes are removed |
seize
Permissionless. Sends the listed assets to the seize receiver. Only assets in the seize config can be seized.
| Params | Type | Description |
|---|---|---|
assets | Vec<AssetWithLimit> | The assets to send to the seize receiver |
AssetWithLimit
An asset to seize, and optionally the most of it to send in this call.
| Params | Type | Description |
|---|---|---|
info | AssetInfo | The asset |
limit | Option<Uint128> | The most of it to send. Without it, the whole balance is sent |
update_seize_config
Owner only. Every field is optional. seizable_assets replaces the list as a whole, and an empty list clears it.
| Params | Type | Description |
|---|---|---|
receiver | Option<String> | Address that receives seized assets. Unchanged if not set |
seizable_assets | Option<Vec<AssetInfo>> | Assets that can be seized. Replaces the list as a whole; unchanged if not set, cleared by an empty list |
propose_new_owner
Creates a proposal to change contract ownership. The proposal validity period is set in the expires_in variable.
| Params | Type | Description |
|---|---|---|
owner | String | The newly proposed owner |
expires_in | u64 | The validity period of the proposal to change the owner |
drop_ownership_proposal
Removes the existing proposal to change contract ownership.
claim_ownership
Used by the proposed owner to claim contract ownership.
Internal messages
Only the Maker itself can call distribute, snapshot_leg and deposit_leg. collect uses them to split the base asset (at most limit of it) and to deposit a swapping leg's output.
QueryMsg
config
Returns the Maker's configuration.
Config
| Params | Type | Description |
|---|---|---|
owner | Addr | Address allowed to change the configuration |
router | Addr | Router 2.x contract used for every swap |
base_asset | AssetInfo | Asset every fee token is swapped into before it's split across the legs |
max_spread | Decimal | Most price impact a swap may have |
collect_cooldown | Option<u64> | If set, collect can be called at most once per this many seconds |
collectors | Vec<Addr> | Addresses allowed to call collect. Empty means anyone can |
legs | Vec<Leg> | Where the base asset goes |
routes
Returns every fee token route.
RouteResponse
Returned as a list, one entry per fee token.
| Params | Type | Description |
|---|---|---|
asset | AssetInfo | The fee token |
operations | Vec<SwapOperation> | Its route to the base asset |
balances
Returns the Maker's balances of the listed assets. Zero balances are left out.
| Params | Type | Description |
|---|---|---|
assets | Vec<AssetInfo> | The assets to look up |
BalancesResponse
| Params | Type | Description |
|---|---|---|
balances | Vec<Asset> | The non-zero balances |
query_seize_config
Returns the seize receiver and the seizable assets.
SeizeConfig
| Params | Type | Description |
|---|---|---|
receiver | Addr | Address that receives seized assets |
seizable_assets | Vec<AssetInfo> | Assets that can be seized |
MigrateMsg
Only a Maker at astroport-maker 1.7.0 can be migrated. The migration:
- keeps the owner, any pending ownership proposal, the seize config and the last collect time;
- keeps
max_spreadandcollect_cooldownunless the message sets them (collect_cooldown: 0removes it); - sets the router, base asset, collectors and legs from the message;
- removes the 1.x bridges and sets the routes from the message.
The old governance, second receiver and dev fund settings are dropped. Legs replace them. Fee tokens that aren't given a route stay in the Maker until the owner adds one with update_routes.
| Params | Type | Description |
|---|---|---|
router | String | Router 2.x contract used for every swap |
base_asset | AssetInfo | Asset every fee token is swapped into |
max_spread | Option<Decimal> | Keeps the old max spread if not set |
collect_cooldown | Option<u64> | Keeps the old cooldown if not set; 0 removes it |
collectors | Vec<String> | Addresses allowed to call collect. Empty (the default) means anyone can |
legs | Vec<Leg> | Where the base asset goes |
routes | Vec<(AssetInfo, Vec<SwapOperation>)> | Routes from fee tokens to the base asset |