@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
67 lines (66 loc) • 1.89 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
// src/routeAmount.ts
var routeAmount_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__exportAll({
all: () => all,
exact: () => exact
});
/**
* Spend an exact amount of the route's `fromToken`.
*
* @param amount - Amount in the token's smallest unit. `bigint` is serialised
* to a decimal string when the request is sent.
* @returns The `EXACT` member of the route amount union.
*
* @example
* ```ts
* const result = await sdk.route({
* chainId: 1,
* fromToken: NATIVE_ETH,
* toToken: WETH,
* amount: routeAmount.exact(10n ** 17n), // 0.1 ETH, wrapped
* signer: OWNER,
* });
* ```
*/
const exact = (amount) => ({
type: "EXACT",
amount
});
/**
* Spend the signer's entire `fromToken` balance, resolved on-chain at execution
* time.
*
* Not supported when `fromToken` is the chain's native sentinel — the server
* rejects it. A gas coin is sent via `msg.value`, so there is no on-chain
* balance to sweep; use {@link exact} for native inputs.
*
* @param simAmount - A realistic estimate of that balance, in the token's
* smallest unit. The server quotes and simulates against this value, so it
* shapes the returned quote and preconditions — but the amount actually moved
* is whatever the balance turns out to be.
* @returns The `ALL` member of the route amount union.
*
* @example
* ```ts
* const result = await sdk.route({
* chainId: 1,
* fromToken: USDC,
* toToken: A_ETH_USDC,
* amount: routeAmount.all(1_000_000n), // estimate: ~1 USDC on hand
* signer: OWNER,
* });
* ```
*/
const all = (simAmount) => ({
type: "ALL",
simAmount
});
exports.all = all;
exports.exact = exact;
Object.defineProperty(exports, "routeAmount_exports", {
enumerable: true,
get: function() {
return routeAmount_exports;
}
});
//# sourceMappingURL=routeAmount.cjs.map