@agoric/zoe
Version:
Zoe: the Smart Contract Framework for Offer Enforcement
47 lines • 2.49 kB
TypeScript
/**
* @import {OfferHandler, ZCF} from '@agoric/zoe';
*/
/**
* Autoswap is a rewrite of Uniswap. Please see the documentation for
* more https://agoric.com/documentation/zoe/guide/contracts/autoswap.html
*
* When the contract is instantiated, the two tokens (Central and Secondary) are
* specified in the issuerKeywordRecord. There is no behavioral difference
* between the two when trading; the names were chosen for consistency with our
* constant product AMM. When trading, use the keywords In and Out to specify
* the amount to be paid in, and the amount to be received.
*
* When adding or removing liquidity, the amounts deposited must be in
* proportion to the current balances in the pool. The amount of the Central
* asset is used as the basis. The Secondary assets must be added in proportion.
* If less Secondary is provided than required, we refuse the offer. If more is
* provided than is required, we return the excess.
*
* Before trading can take place, it is necessary to add liquidity using
* makeAddLiquidityInvitation(). Separate invitations are available for adding
* and removing liquidity, and for doing swaps. Other API operations support
* price checks and checking the size of the liquidity pool.
*
* The swap operation requires either the input amount or the output amount to
* be specified. makeSwapInInvitation treats the give amount as definitive,
* while makeSwapOutInvitation honors the want amount. With swapIn, a want
* amount can be specified, and if the offer can't be satisfied, the offer will
* be refunded. Similarly with swapOut, the want amount will be satisfied if
* possible. If more is provided as the give amount than necessary, the excess
* will be refunded. If not enough is provided, the offer will be refunded.
*
* The publicFacet can make new invitations (makeSwapInInvitation,
* makeSwapOutInvitation, makeAddLiquidityInvitation, and
* makeRemoveLiquidityInvitation), tell how much would be paid for a given input
* (getInputPrice), or how much would be earned by depositing a specified amount
* (getOutputPrice). In addition, there are requests for the LiquidityIssuer
* (getLiquidityIssuer), the current outstanding liquidity (getLiquiditySupply),
* and the current balances in the pool (getPoolAllocation).
*
* @param {ZCF} zcf
*/
export function start(zcf: ZCF): Promise<{
publicFacet: AutoswapPublicFacet;
}>;
import type { ZCF } from '@agoric/zoe';
//# sourceMappingURL=autoswap.d.ts.map