Skip to main content

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.

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.

LegShareRouteAction
1100%NTRN to ASTROdeposit 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:

LegShareRouteAction
125%USDC.inj to LUNA to ASTROsend to the satellite, which IBC-transfers it to the Neutron ASTRO burner to be burned (transfer_astro on the satellite, callable by anyone)
250%nonesend to the Terra "Astroport - Development Fund" DAO
325%nonedeposit 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.

router/msg.rs
Copy

_12
#[cw_serde]
_12
pub enum SwapOperation {
_12
AstroSwap {
_12
offer_asset_info: AssetInfo,
_12
ask_asset_info: AssetInfo,
_12
},
_12
PoolSwap {
_12
pool_addr: String,
_12
offer_asset_info: AssetInfo,
_12
ask_asset_info: AssetInfo,
_12
},
_12
}

VariantsDescription
AstroSwapSwap in the factory's pool for this asset pair
PoolSwapSwap 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.

json
msg.rs
Copy

_35
[
_35
{
_35
"share": "0.5",
_35
"route": [
_35
{
_35
"astro_swap": {
_35
"offer_asset_info": {
_35
"native_token": {
_35
"denom": "usdc"
_35
}
_35
},
_35
"ask_asset_info": {
_35
"native_token": {
_35
"denom": "astro"
_35
}
_35
}
_35
}
_35
}
_35
],
_35
"action": {
_35
"deposit": {
_35
"contract": "...",
_35
"msg": "eyJidXJuIjp7fX0="
_35
}
_35
}
_35
},
_35
{
_35
"share": "0.5",
_35
"action": {
_35
"send": {
_35
"recipient": "..."
_35
}
_35
}
_35
}
_35
]

ParamsTypeDescription
shareDecimalThe part of the base asset balance this leg gets
routeVec<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
actionLegActionWhat 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:


_1
minimum_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.

json
msg.rs
Copy

_48
{
_48
"owner": "...",
_48
"router": "...",
_48
"base_asset": {
_48
"native_token": {
_48
"denom": "..."
_48
}
_48
},
_48
"max_spread": "0.05",
_48
"collect_cooldown": 300,
_48
"collectors": ["..."],
_48
"legs": [
_48
{
_48
"share": "1",
_48
"route": [],
_48
"action": {
_48
"send": {
_48
"recipient": "..."
_48
}
_48
}
_48
}
_48
],
_48
"routes": [
_48
[
_48
{
_48
"native_token": {
_48
"denom": "..."
_48
}
_48
},
_48
[
_48
{
_48
"astro_swap": {
_48
"offer_asset_info": {
_48
"native_token": {
_48
"denom": "..."
_48
}
_48
},
_48
"ask_asset_info": {
_48
"native_token": {
_48
"denom": "..."
_48
}
_48
}
_48
}
_48
}
_48
]
_48
]
_48
]
_48
}

ParamsTypeDescription
ownerStringAddress allowed to change the configuration
routerStringRouter 2.x contract used for every swap
base_assetAssetInfoAsset every fee token is swapped into before it's split across the legs
max_spreadOption<Decimal>Most price impact a swap may have. Defaults to 5%
collect_cooldownOption<u64>If set, collect can be called at most once per this many seconds, between 30 and 600. Unset or 0 means no cooldown
collectorsVec<String>Addresses allowed to call collect. Empty (the default) means anyone can
legsVec<Leg>Where the base asset goes
routesVec<(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 limit caps how much of it is split across the legs.
  • If a cooldown is set, collect fails until the cooldown has passed since the last collect.
json
msg.rs
Copy

_22
{
_22
"collect": {
_22
"assets": [
_22
{
_22
"info": {
_22
"native_token": {
_22
"denom": "..."
_22
}
_22
},
_22
"limit": "1000000",
_22
"min_receive": "950000"
_22
},
_22
{
_22
"info": {
_22
"token": {
_22
"contract_addr": "..."
_22
}
_22
}
_22
}
_22
]
_22
}
_22
}

ParamsTypeDescription
assetsVec<CollectAsset>The fee tokens to swap, and optionally the base asset

CollectAsset​

A fee token to collect.

json
msg.rs
Copy

_9
{
_9
"info": {
_9
"native_token": {
_9
"denom": "..."
_9
}
_9
},
_9
"limit": "1000000",
_9
"min_receive": "950000"
_9
}

ParamsTypeDescription
infoAssetInfoThe token
limitOption<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_receiveOption<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.

json
msg.rs
Copy

_14
{
_14
"update_config": {
_14
"router": "...",
_14
"base_asset": {
_14
"native_token": {
_14
"denom": "..."
_14
}
_14
},
_14
"max_spread": "0.05",
_14
"collect_cooldown": 300,
_14
"collectors": [],
_14
"legs": []
_14
}
_14
}

ParamsTypeDescription
routerOption<String>Router 2.x contract used for every swap
base_assetOption<AssetInfo>Asset every fee token is swapped into
max_spreadOption<Decimal>Most price impact a swap may have, at most 50%
collect_cooldownOption<u64>Between 30 and 600 seconds. 0 removes the cooldown
collectorsOption<Vec<String>>Addresses allowed to call collect. An empty list lets anyone call it again
legsOption<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.

json
msg.rs
Copy

_36
{
_36
"update_routes": {
_36
"add": [
_36
[
_36
{
_36
"native_token": {
_36
"denom": "..."
_36
}
_36
},
_36
[
_36
{
_36
"astro_swap": {
_36
"offer_asset_info": {
_36
"native_token": {
_36
"denom": "..."
_36
}
_36
},
_36
"ask_asset_info": {
_36
"native_token": {
_36
"denom": "..."
_36
}
_36
}
_36
}
_36
}
_36
]
_36
]
_36
],
_36
"remove": [
_36
{
_36
"native_token": {
_36
"denom": "..."
_36
}
_36
}
_36
]
_36
}
_36
}

ParamsTypeDescription
addVec<(AssetInfo, Vec<SwapOperation>)>Fee tokens and their routes to the base asset
removeVec<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.

json
msg.rs
Copy

_14
{
_14
"seize": {
_14
"assets": [
_14
{
_14
"info": {
_14
"native_token": {
_14
"denom": "..."
_14
}
_14
},
_14
"limit": "1000000"
_14
}
_14
]
_14
}
_14
}

ParamsTypeDescription
assetsVec<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.

json
msg.rs
Copy

_8
{
_8
"info": {
_8
"native_token": {
_8
"denom": "..."
_8
}
_8
},
_8
"limit": "1000000"
_8
}

ParamsTypeDescription
infoAssetInfoThe asset
limitOption<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.

json
msg.rs
Copy

_12
{
_12
"update_seize_config": {
_12
"receiver": "...",
_12
"seizable_assets": [
_12
{
_12
"native_token": {
_12
"denom": "..."
_12
}
_12
}
_12
]
_12
}
_12
}

ParamsTypeDescription
receiverOption<String>Address that receives seized assets. Unchanged if not set
seizable_assetsOption<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.

json
msg.rs
Copy

_6
{
_6
"propose_new_owner": {
_6
"owner": "...",
_6
"expires_in": 1234567
_6
}
_6
}

ParamsTypeDescription
ownerStringThe newly proposed owner
expires_inu64The validity period of the proposal to change the owner

drop_ownership_proposal​

Removes the existing proposal to change contract ownership.

json
msg.rs
Copy

_3
{
_3
"drop_ownership_proposal": {}
_3
}

claim_ownership​

Used by the proposed owner to claim contract ownership.

json
msg.rs
Copy

_3
{
_3
"claim_ownership": {}
_3
}

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.

msg.rs
Copy

_27
#[cw_serde]
_27
pub enum ExecuteMsg {
_27
Collect { assets: Vec<CollectAsset> },
_27
Distribute { limit: Option<Uint128> },
_27
SnapshotLeg { leg: u32 },
_27
DepositLeg { leg: u32 },
_27
UpdateConfig {
_27
router: Option<String>,
_27
base_asset: Option<AssetInfo>,
_27
max_spread: Option<Decimal>,
_27
collect_cooldown: Option<u64>,
_27
collectors: Option<Vec<String>>,
_27
legs: Option<Vec<Leg>>,
_27
},
_27
UpdateRoutes {
_27
add: Vec<(AssetInfo, Vec<SwapOperation>)>,
_27
remove: Vec<AssetInfo>,
_27
},
_27
ProposeNewOwner { owner: String, expires_in: u64 },
_27
DropOwnershipProposal {},
_27
ClaimOwnership {},
_27
Seize { assets: Vec<AssetWithLimit> },
_27
UpdateSeizeConfig {
_27
receiver: Option<String>,
_27
seizable_assets: Option<Vec<AssetInfo>>,
_27
},
_27
}

QueryMsg​

config​

Returns the Maker's configuration.

json
msg.rs
Copy

_3
{
_3
"config": {}
_3
}

Config​

json
msg.rs
Copy

_23
{
_23
"owner": "...",
_23
"router": "...",
_23
"base_asset": {
_23
"native_token": {
_23
"denom": "..."
_23
}
_23
},
_23
"max_spread": "0.05",
_23
"collect_cooldown": 300,
_23
"collectors": [],
_23
"legs": [
_23
{
_23
"share": "1",
_23
"route": [],
_23
"action": {
_23
"send": {
_23
"recipient": "..."
_23
}
_23
}
_23
}
_23
]
_23
}

ParamsTypeDescription
ownerAddrAddress allowed to change the configuration
routerAddrRouter 2.x contract used for every swap
base_assetAssetInfoAsset every fee token is swapped into before it's split across the legs
max_spreadDecimalMost price impact a swap may have
collect_cooldownOption<u64>If set, collect can be called at most once per this many seconds
collectorsVec<Addr>Addresses allowed to call collect. Empty means anyone can
legsVec<Leg>Where the base asset goes

routes​

Returns every fee token route.

json
msg.rs
Copy

_3
{
_3
"routes": {}
_3
}

RouteResponse​

Returned as a list, one entry per fee token.

json
msg.rs
Copy

_25
[
_25
{
_25
"asset": {
_25
"native_token": {
_25
"denom": "..."
_25
}
_25
},
_25
"operations": [
_25
{
_25
"astro_swap": {
_25
"offer_asset_info": {
_25
"native_token": {
_25
"denom": "..."
_25
}
_25
},
_25
"ask_asset_info": {
_25
"native_token": {
_25
"denom": "..."
_25
}
_25
}
_25
}
_25
}
_25
]
_25
}
_25
]

ParamsTypeDescription
assetAssetInfoThe fee token
operationsVec<SwapOperation>Its route to the base asset

balances​

Returns the Maker's balances of the listed assets. Zero balances are left out.

json
msg.rs
Copy

_16
{
_16
"balances": {
_16
"assets": [
_16
{
_16
"native_token": {
_16
"denom": "..."
_16
}
_16
},
_16
{
_16
"token": {
_16
"contract_addr": "..."
_16
}
_16
}
_16
]
_16
}
_16
}

ParamsTypeDescription
assetsVec<AssetInfo>The assets to look up

BalancesResponse​

json
msg.rs
Copy

_12
{
_12
"balances": [
_12
{
_12
"info": {
_12
"native_token": {
_12
"denom": "..."
_12
}
_12
},
_12
"amount": "1000000"
_12
}
_12
]
_12
}

ParamsTypeDescription
balancesVec<Asset>The non-zero balances

query_seize_config​

Returns the seize receiver and the seizable assets.

json
msg.rs
Copy

_3
{
_3
"query_seize_config": {}
_3
}

SeizeConfig​

json
msg.rs
Copy

_10
{
_10
"receiver": "...",
_10
"seizable_assets": [
_10
{
_10
"native_token": {
_10
"denom": "..."
_10
}
_10
}
_10
]
_10
}

ParamsTypeDescription
receiverAddrAddress that receives seized assets
seizable_assetsVec<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_spread and collect_cooldown unless the message sets them (collect_cooldown: 0 removes 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.

json
msg.rs
Copy

_13
{
_13
"router": "...",
_13
"base_asset": {
_13
"native_token": {
_13
"denom": "..."
_13
}
_13
},
_13
"max_spread": null,
_13
"collect_cooldown": null,
_13
"collectors": [],
_13
"legs": [],
_13
"routes": []
_13
}

ParamsTypeDescription
routerStringRouter 2.x contract used for every swap
base_assetAssetInfoAsset every fee token is swapped into
max_spreadOption<Decimal>Keeps the old max spread if not set
collect_cooldownOption<u64>Keeps the old cooldown if not set; 0 removes it
collectorsVec<String>Addresses allowed to call collect. Empty (the default) means anyone can
legsVec<Leg>Where the base asset goes
routesVec<(AssetInfo, Vec<SwapOperation>)>Routes from fee tokens to the base asset