@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
44 lines (37 loc) • 1.71 kB
text/typescript
// AUTO-GENERATED from manifest.json — do not edit by hand.
// Regenerate with: yarn generate:composer-sdk
import type { TypedGuard } from '../types.js';
import type {
BandGuardConfig,
CoreNumericInvariantGuardConfig,
MinAmountGuardConfig,
SlippageGuardConfig,
} from './config.generated.js';
/** Assert that output amounts are within a slippage tolerance in basis points */
export const slippage = <P extends string>(
config: Omit<SlippageGuardConfig, 'port'> & { port: P },
): TypedGuard<P> => ({
kind: 'slippage',
...config,
});
/** Assert a numeric (uint256) handle output of the target op satisfies a comparison against a constant threshold. Emits one IR1 binary invariant; reverts the run on violation. */
export const coreNumericInvariant = <P extends string>(
config: Omit<CoreNumericInvariantGuardConfig, 'port'> & { port: P },
): TypedGuard<P> => ({
kind: 'core.numericInvariant',
...config,
});
/** Assert that an output stays within a tolerance in basis points of its simulated value, in both directions */
export const band = <P extends string>(
config: Omit<BandGuardConfig, 'port'> & { port: P },
): TypedGuard<P> => ({
kind: 'band',
...config,
});
/** Require a resource output to carry at least `amount`. Emits one on-chain assertGreaterThanEqual. The compile fails with validation_error and a shortfall when the minimum the flow guarantees at the port is below `amount`, and with a simulation revert when the port has no guaranteed minimum and its simulated amount is below `amount`. */
export const minAmount = <P extends string>(
config: Omit<MinAmountGuardConfig, 'port'> & { port: P },
): TypedGuard<P> => ({
kind: 'minAmount',
...config,
});