| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.InvalidSlippageError = exports.InvalidExpectedOutputError = exports.basisPointScale = void 0; | ||
| exports.toAmount = toAmount; | ||
| exports.toAmountUp = toAmountUp; | ||
| exports.toVenueAmount = toVenueAmount; | ||
| exports.feeShares = feeShares; | ||
| exports.minimumOutput = minimumOutput; | ||
| const Errors = require("../core/Errors.js"); | ||
| exports.basisPointScale = 10_000; | ||
| function toAmount(anchor, venueShareAmount) { | ||
| return (venueShareAmount * anchor.shareSupply) / anchor.engineShares; | ||
| } | ||
| function toAmountUp(anchor, venueShareAmount) { | ||
| const { engineShares, shareSupply } = anchor; | ||
| return (venueShareAmount * shareSupply + engineShares - 1n) / engineShares; | ||
| } | ||
| function toVenueAmount(anchor, shareAmount) { | ||
| return (shareAmount * anchor.engineShares) / anchor.shareSupply; | ||
| } | ||
| function feeShares(options) { | ||
| const { activeAssets, shareSupply, totalFeeAssets } = options; | ||
| if (totalFeeAssets === 0n || totalFeeAssets >= activeAssets) | ||
| return 0n; | ||
| return (totalFeeAssets * shareSupply) / (activeAssets - totalFeeAssets); | ||
| } | ||
| function minimumOutput(expectedAmount, slippageBps) { | ||
| if (expectedAmount <= 0n) | ||
| throw new InvalidExpectedOutputError({ expectedAmount }); | ||
| if (!Number.isInteger(slippageBps) || | ||
| slippageBps < 0 || | ||
| slippageBps >= exports.basisPointScale) | ||
| throw new InvalidSlippageError({ slippageBps }); | ||
| const scale = BigInt(exports.basisPointScale); | ||
| const bounded = (expectedAmount * (scale - BigInt(slippageBps))) / scale; | ||
| return bounded === 0n ? 1n : bounded; | ||
| } | ||
| class InvalidExpectedOutputError extends Errors.BaseError { | ||
| constructor(options) { | ||
| super(`Expected output \`${options.expectedAmount}\` must be greater than zero.`); | ||
| Object.defineProperty(this, "name", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value: 'EarnShares.InvalidExpectedOutputError' | ||
| }); | ||
| } | ||
| } | ||
| exports.InvalidExpectedOutputError = InvalidExpectedOutputError; | ||
| class InvalidSlippageError extends Errors.BaseError { | ||
| constructor(options) { | ||
| super(`Slippage tolerance \`${options.slippageBps}\` is invalid.`, { | ||
| metaMessages: [ | ||
| `Slippage must be a whole number from 0 through ${exports.basisPointScale - 1} basis points.`, | ||
| ], | ||
| }); | ||
| Object.defineProperty(this, "name", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value: 'EarnShares.InvalidSlippageError' | ||
| }); | ||
| } | ||
| } | ||
| exports.InvalidSlippageError = InvalidSlippageError; | ||
| //# sourceMappingURL=EarnShares.js.map |
| {"version":3,"file":"EarnShares.js","sourceRoot":"","sources":["../../tempo/EarnShares.ts"],"names":[],"mappings":";;;AA0CA,4BAEC;AA0BD,gCAGC;AA0BD,sCAEC;AA6BD,8BAIC;AAmCD,sCAeC;AAxLD,4CAA2C;AAG9B,QAAA,eAAe,GAAG,MAAM,CAAA;AAuCrC,SAAgB,QAAQ,CAAC,MAAc,EAAE,gBAAwB;IAC/D,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,YAAY,CAAA;AACtE,CAAC;AA0BD,SAAgB,UAAU,CAAC,MAAc,EAAE,gBAAwB;IACjE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CAAA;IAC5C,OAAO,CAAC,gBAAgB,GAAG,WAAW,GAAG,YAAY,GAAG,EAAE,CAAC,GAAG,YAAY,CAAA;AAC5E,CAAC;AA0BD,SAAgB,aAAa,CAAC,MAAc,EAAE,WAAmB;IAC/D,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,WAAW,CAAA;AACjE,CAAC;AA6BD,SAAgB,SAAS,CAAC,OAA0B;IAClD,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAA;IAC7D,IAAI,cAAc,KAAK,EAAE,IAAI,cA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*/ | ||
| export const basisPointScale = 10_000; | ||
| /** | ||
| * Converts venue shares to a vault share amount at the anchor rate, rounding down. | ||
| * | ||
| * Mirrors `VaultAdapter.sharesToTokens`. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 4n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param venueShareAmount - Venue share amount, base units. | ||
| * @returns Vault share amount, rounded down. | ||
| */ | ||
| export function toAmount(anchor, venueShareAmount) { | ||
| return (venueShareAmount * anchor.shareSupply) / anchor.engineShares; | ||
| } | ||
| /** | ||
| * Converts venue shares to a vault share amount at the anchor rate, rounding up. | ||
| * | ||
| * Mirrors the adapter's ceiling conversion used by exact-asset exits. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmountUp( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 5n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param venueShareAmount - Venue share amount, base units. | ||
| * @returns Vault share amount, rounded up. | ||
| */ | ||
| export function toAmountUp(anchor, venueShareAmount) { | ||
| const { engineShares, shareSupply } = anchor; | ||
| return (venueShareAmount * shareSupply + engineShares - 1n) / engineShares; | ||
| } | ||
| /** | ||
| * Converts a vault share amount to venue shares at the anchor rate, rounding down. | ||
| * | ||
| * Mirrors `VaultAdapter.tokensToShares`. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const venueShareAmount = EarnShares.toVenueAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 10n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param shareAmount - Vault share amount, base units. | ||
| * @returns Venue share amount, rounded down. | ||
| */ | ||
| export function toVenueAmount(anchor, shareAmount) { | ||
| return (shareAmount * anchor.engineShares) / anchor.shareSupply; | ||
| } | ||
| /** | ||
| * Computes the dilution-correct vault shares minted for an asset-denominated fee. | ||
| * | ||
| * Mirrors `FeeMath`: | ||
| * `feeShares = floor(fee * shareSupply / (activeAssets - fee))`, zero when the | ||
| * fee is zero or not smaller than the active assets. Minting this amount to the | ||
| * fee ledger prices the fee at post-mint value per share. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shares = EarnShares.feeShares({ | ||
| * activeAssets: 1_100n, | ||
| * shareSupply: 1_000n, | ||
| * totalFeeAssets: 100n, | ||
| * }) | ||
| * // @log: 100n | ||
| * ``` | ||
| * | ||
| * @param options - Fee accrual inputs. | ||
| * @returns Vault shares to mint for the fee, rounded down. | ||
| */ | ||
| export function feeShares(options) { | ||
| const { activeAssets, shareSupply, totalFeeAssets } = options; | ||
| if (totalFeeAssets === 0n || totalFeeAssets >= activeAssets) | ||
| return 0n; | ||
| return (totalFeeAssets * shareSupply) / (activeAssets - totalFeeAssets); | ||
| } | ||
| /** | ||
| * Lowers an expected output by a basis-point slippage tolerance, flooring to `1n`. | ||
| * | ||
| * Suitable for lower bounds such as a deposit's minimum shares or a redeem's | ||
| * minimum assets; not for upper bounds such as an exact withdrawal's maximum | ||
| * shares. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const minimumShares = EarnShares.minimumOutput(1_000_000n, 50) | ||
| * // @log: 995_000n | ||
| * ``` | ||
| * | ||
| * @param expectedAmount - Expected output in base units. | ||
| * @param slippageBps - Allowed slippage in basis points from `0` through `9_999`. | ||
| * @returns The minimum accepted output, floored to `1n`. | ||
| * @throws `InvalidExpectedOutputError` when `expectedAmount` is not positive. | ||
| * @throws `InvalidSlippageError` when `slippageBps` is outside its valid range. | ||
| */ | ||
| export function minimumOutput(expectedAmount, slippageBps) { | ||
| if (expectedAmount <= 0n) | ||
| throw new InvalidExpectedOutputError({ expectedAmount }); | ||
| if (!Number.isInteger(slippageBps) || | ||
| slippageBps < 0 || | ||
| slippageBps >= basisPointScale) | ||
| throw new InvalidSlippageError({ slippageBps }); | ||
| const scale = BigInt(basisPointScale); | ||
| const bounded = (expectedAmount * (scale - BigInt(slippageBps))) / scale; | ||
| return bounded === 0n ? 1n : bounded; | ||
| } | ||
| /** | ||
| * Error thrown when an expected output is not positive. | ||
| */ | ||
| export class InvalidExpectedOutputError extends Errors.BaseError { | ||
| constructor(options) { | ||
| super(`Expected output \`${options.expectedAmount}\` must be greater than zero.`); | ||
| Object.defineProperty(this, "name", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value: 'EarnShares.InvalidExpectedOutputError' | ||
| }); | ||
| } | ||
| } | ||
| /** | ||
| * Error thrown when a slippage tolerance is not an integer from `0` through `9_999`. | ||
| */ | ||
| export class InvalidSlippageError extends Errors.BaseError { | ||
| constructor(options) { | ||
| super(`Slippage tolerance \`${options.slippageBps}\` is invalid.`, { | ||
| metaMessages: [ | ||
| `Slippage must be a whole number from 0 through ${basisPointScale - 1} basis points.`, | ||
| ], | ||
| }); | ||
| Object.defineProperty(this, "name", { | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true, | ||
| value: 'EarnShares.InvalidSlippageError' | ||
| }); | ||
| } | ||
| } | ||
| //# sourceMappingURL=EarnShares.js.map |
| {"version":3,"file":"EarnShares.js","sourceRoot":"","sources":["../../tempo/EarnShares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AAmBrC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,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D,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;IACrC,MAAM,OAAO,GAAG,CAAC,cAAc,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAA;IACxE,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;AACtC,CAAC;AASD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,MAAM,CAAC,SAAS;IAG9D,YAAY,OAA2C;QACrD,KAAK,CACH,qBAAqB,OAAO,CAAC,cAAc,+BAA+B,CAC3E,CAAA;QALe;;;;mBAAO,uCAAuC;WAAA;IAMhE,CAAC;CACF;AAQD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,SAAS;IAGxD,YAAY,OAAqC;QAC/C,KAAK,CAAC,wBAAwB,OAAO,CAAC,WAAW,gBAAgB,EAAE;YACjE,YAAY,EAAE;gBACZ,kDAAkD,eAAe,GAAG,CAAC,gBAAgB;aACtF;SACF,CAAC,CAAA;QAPc;;;;mBAAO,iCAAiC;WAAA;IAQ1D,CAAC;CACF"} |
| import * as Errors from '../core/Errors.js'; | ||
| /** Basis-point denominator used by slippage bounds. */ | ||
| export declare const basisPointScale = 10000; | ||
| /** | ||
| * Tempo Earn `VaultAdapter` conversion anchor. | ||
| * | ||
| * The adapter prices vault shares against venue shares through this pair: | ||
| * `engineShares` venue shares are worth `shareSupply` vault shares. It is initialised | ||
| * 1:1 and restated on `contribute` and `migrateEngine`. | ||
| * | ||
| * These conversions are raw and fee-blind; they ignore pending fee dilution | ||
| * and are unsuitable for user-facing value (use the adapter's `previewRedeem`). | ||
| */ | ||
| export type Anchor = { | ||
| /** Venue shares held by the engine at the anchor point. */ | ||
| engineShares: bigint; | ||
| /** Vault share supply at the anchor point. */ | ||
| shareSupply: bigint; | ||
| }; | ||
| /** | ||
| * Converts venue shares to a vault share amount at the anchor rate, rounding down. | ||
| * | ||
| * Mirrors `VaultAdapter.sharesToTokens`. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 4n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param venueShareAmount - Venue share amount, base units. | ||
| * @returns Vault share amount, rounded down. | ||
| */ | ||
| export declare function toAmount(anchor: Anchor, venueShareAmount: bigint): bigint; | ||
| export declare namespace toAmount { | ||
| type ErrorType = Errors.GlobalErrorType; | ||
| } | ||
| /** | ||
| * Converts venue shares to a vault share amount at the anchor rate, rounding up. | ||
| * | ||
| * Mirrors the adapter's ceiling conversion used by exact-asset exits. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmountUp( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 5n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param venueShareAmount - Venue share amount, base units. | ||
| * @returns Vault share amount, rounded up. | ||
| */ | ||
| export declare function toAmountUp(anchor: Anchor, venueShareAmount: bigint): bigint; | ||
| export declare namespace toAmountUp { | ||
| type ErrorType = Errors.GlobalErrorType; | ||
| } | ||
| /** | ||
| * Converts a vault share amount to venue shares at the anchor rate, rounding down. | ||
| * | ||
| * Mirrors `VaultAdapter.tokensToShares`. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const venueShareAmount = EarnShares.toVenueAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 10n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param shareAmount - Vault share amount, base units. | ||
| * @returns Venue share amount, rounded down. | ||
| */ | ||
| export declare function toVenueAmount(anchor: Anchor, shareAmount: bigint): bigint; | ||
| export declare namespace toVenueAmount { | ||
| type ErrorType = Errors.GlobalErrorType; | ||
| } | ||
| /** | ||
| * Computes the dilution-correct vault shares minted for an asset-denominated fee. | ||
| * | ||
| * Mirrors `FeeMath`: | ||
| * `feeShares = floor(fee * shareSupply / (activeAssets - fee))`, zero when the | ||
| * fee is zero or not smaller than the active assets. Minting this amount to the | ||
| * fee ledger prices the fee at post-mint value per share. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shares = EarnShares.feeShares({ | ||
| * activeAssets: 1_100n, | ||
| * shareSupply: 1_000n, | ||
| * totalFeeAssets: 100n, | ||
| * }) | ||
| * // @log: 100n | ||
| * ``` | ||
| * | ||
| * @param options - Fee accrual inputs. | ||
| * @returns Vault shares to mint for the fee, rounded down. | ||
| */ | ||
| export declare function feeShares(options: feeShares.Options): bigint; | ||
| export declare namespace feeShares { | ||
| type Options = { | ||
| /** Assets backing the active (non-queued) supply, base units. */ | ||
| activeAssets: bigint; | ||
| /** Active vault share supply, base units. */ | ||
| shareSupply: bigint; | ||
| /** Total fee liability in asset units. */ | ||
| totalFeeAssets: bigint; | ||
| }; | ||
| type ErrorType = Errors.GlobalErrorType; | ||
| } | ||
| /** | ||
| * Lowers an expected output by a basis-point slippage tolerance, flooring to `1n`. | ||
| * | ||
| * Suitable for lower bounds such as a deposit's minimum shares or a redeem's | ||
| * minimum assets; not for upper bounds such as an exact withdrawal's maximum | ||
| * shares. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const minimumShares = EarnShares.minimumOutput(1_000_000n, 50) | ||
| * // @log: 995_000n | ||
| * ``` | ||
| * | ||
| * @param expectedAmount - Expected output in base units. | ||
| * @param slippageBps - Allowed slippage in basis points from `0` through `9_999`. | ||
| * @returns The minimum accepted output, floored to `1n`. | ||
| * @throws `InvalidExpectedOutputError` when `expectedAmount` is not positive. | ||
| * @throws `InvalidSlippageError` when `slippageBps` is outside its valid range. | ||
| */ | ||
| export declare function minimumOutput(expectedAmount: bigint, slippageBps: number): bigint; | ||
| export declare namespace minimumOutput { | ||
| type ErrorType = InvalidExpectedOutputError | InvalidSlippageError | Errors.GlobalErrorType; | ||
| } | ||
| /** | ||
| * Error thrown when an expected output is not positive. | ||
| */ | ||
| export declare class InvalidExpectedOutputError extends Errors.BaseError { | ||
| readonly name = "EarnShares.InvalidExpectedOutputError"; | ||
| constructor(options: InvalidExpectedOutputError.Options); | ||
| } | ||
| export declare namespace InvalidExpectedOutputError { | ||
| type Options = { | ||
| expectedAmount: bigint; | ||
| }; | ||
| } | ||
| /** | ||
| * Error thrown when a slippage tolerance is not an integer from `0` through `9_999`. | ||
| */ | ||
| export declare class InvalidSlippageError extends Errors.BaseError { | ||
| readonly name = "EarnShares.InvalidSlippageError"; | ||
| constructor(options: InvalidSlippageError.Options); | ||
| } | ||
| export declare namespace InvalidSlippageError { | ||
| type Options = { | ||
| slippageBps: number; | ||
| }; | ||
| } | ||
| //# sourceMappingURL=EarnShares.d.ts.map |
| {"version":3,"file":"EarnShares.d.ts","sourceRoot":"","sources":["../../tempo/EarnShares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAE3C,uDAAuD;AACvD,eAAO,MAAM,eAAe,QAAS,CAAA;AAErC;;;;;;;;;GASG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,MAAM,CAA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pD,OAAO,EAAE,0BAA0B,CAAC,OAAO;CAKxD;AAED,MAAM,CAAC,OAAO,WAAW,0BAA0B,CAAC;IAClD,KAAY,OAAO,GAAG;QACpB,cAAc,EAAE,MAAM,CAAA;KACvB,CAAA;CACF;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,MAAM,CAAC,SAAS;IACxD,SAAkB,IAAI,qCAAoC;gBAE9C,OAAO,EAAE,oBAAoB,CAAC,OAAO;CAOlD;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB,CAAC;IAC5C,KAAY,OAAO,GAAG;QACpB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;CACF"} |
| import { EarnShares } from 'ox/tempo' | ||
| import { describe, expect, test } from 'vitest' | ||
| const anchor = { engineShares: 3n, shareSupply: 2n } as const | ||
| describe('toAmount', () => { | ||
| test('default', () => { | ||
| expect(EarnShares.toAmount(anchor, 7n)).toBe(4n) | ||
| }) | ||
| test('behavior: rounds down', () => { | ||
| expect(EarnShares.toAmount({ engineShares: 3n, shareSupply: 1n }, 2n)).toBe( | ||
| 0n, | ||
| ) | ||
| }) | ||
| }) | ||
| describe('toAmountUp', () => { | ||
| test('default', () => { | ||
| expect(EarnShares.toAmountUp(anchor, 7n)).toBe(5n) | ||
| }) | ||
| test('behavior: exact conversions do not round up', () => { | ||
| expect(EarnShares.toAmountUp(anchor, 3n)).toBe(2n) | ||
| }) | ||
| }) | ||
| describe('toVenueAmount', () => { | ||
| test('default', () => { | ||
| expect(EarnShares.toVenueAmount(anchor, 7n)).toBe(10n) | ||
| }) | ||
| test('behavior: identity at the initial 1:1 anchor', () => { | ||
| expect( | ||
| EarnShares.toVenueAmount({ engineShares: 1n, shareSupply: 1n }, 12_345n), | ||
| ).toBe(12_345n) | ||
| }) | ||
| }) | ||
| describe('feeShares', () => { | ||
| test('default', () => { | ||
| expect( | ||
| EarnShares.feeShares({ | ||
| activeAssets: 1_100n, | ||
| shareSupply: 1_000n, | ||
| totalFeeAssets: 100n, | ||
| }), | ||
| ).toBe(100n) | ||
| }) | ||
| test('behavior: zero fee mints nothing', () => { | ||
| expect( | ||
| EarnShares.feeShares({ | ||
| activeAssets: 1_100n, | ||
| shareSupply: 1_000n, | ||
| totalFeeAssets: 0n, | ||
| }), | ||
| ).toBe(0n) | ||
| }) | ||
| test('behavior: fee at or above active assets mints nothing', () => { | ||
| expect( | ||
| EarnShares.feeShares({ | ||
| activeAssets: 100n, | ||
| shareSupply: 1_000n, | ||
| totalFeeAssets: 100n, | ||
| }), | ||
| ).toBe(0n) | ||
| }) | ||
| test('behavior: rounds down', () => { | ||
| expect( | ||
| EarnShares.feeShares({ | ||
| activeAssets: 1_000n, | ||
| shareSupply: 999n, | ||
| totalFeeAssets: 100n, | ||
| }), | ||
| ).toBe(111n) | ||
| }) | ||
| }) | ||
| describe('minimumOutput', () => { | ||
| test('default', () => { | ||
| expect(EarnShares.minimumOutput(1_000_000n, 50)).toBe(995_000n) | ||
| }) | ||
| test('behavior: zero slippage returns the expected output', () => { | ||
| expect(EarnShares.minimumOutput(1_000_000n, 0)).toBe(1_000_000n) | ||
| }) | ||
| test('behavior: floors to 1n', () => { | ||
| expect(EarnShares.minimumOutput(1n, 9_999)).toBe(1n) | ||
| }) | ||
| test('error: non-positive expected output', () => { | ||
| expect(() => | ||
| EarnShares.minimumOutput(0n, 50), | ||
| ).toThrowErrorMatchingInlineSnapshot( | ||
| `[EarnShares.InvalidExpectedOutputError: Expected output \`0\` must be greater than zero.]`, | ||
| ) | ||
| }) | ||
| test('error: out-of-range slippage', () => { | ||
| expect(() => | ||
| EarnShares.minimumOutput(1_000_000n, 10_000), | ||
| ).toThrowErrorMatchingInlineSnapshot(` | ||
| [EarnShares.InvalidSlippageError: Slippage tolerance \`10000\` is invalid. | ||
| Slippage must be a whole number from 0 through 9999 basis points.] | ||
| `) | ||
| }) | ||
| test('error: non-integer slippage', () => { | ||
| expect(() => | ||
| EarnShares.minimumOutput(1_000_000n, 0.5), | ||
| ).toThrowErrorMatchingInlineSnapshot(` | ||
| [EarnShares.InvalidSlippageError: Slippage tolerance \`0.5\` is invalid. | ||
| Slippage must be a whole number from 0 through 9999 basis points.] | ||
| `) | ||
| }) | ||
| }) |
| import * as Errors from '../core/Errors.js' | ||
| /** Basis-point denominator used by slippage bounds. */ | ||
| export const basisPointScale = 10_000 | ||
| /** | ||
| * Tempo Earn `VaultAdapter` conversion anchor. | ||
| * | ||
| * The adapter prices vault shares against venue shares through this pair: | ||
| * `engineShares` venue shares are worth `shareSupply` vault shares. It is initialised | ||
| * 1:1 and restated on `contribute` and `migrateEngine`. | ||
| * | ||
| * These conversions are raw and fee-blind; they ignore pending fee dilution | ||
| * and are unsuitable for user-facing value (use the adapter's `previewRedeem`). | ||
| */ | ||
| export type Anchor = { | ||
| /** Venue shares held by the engine at the anchor point. */ | ||
| engineShares: bigint | ||
| /** Vault share supply at the anchor point. */ | ||
| shareSupply: bigint | ||
| } | ||
| /** | ||
| * Converts venue shares to a vault share amount at the anchor rate, rounding down. | ||
| * | ||
| * Mirrors `VaultAdapter.sharesToTokens`. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 4n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param venueShareAmount - Venue share amount, base units. | ||
| * @returns Vault share amount, rounded down. | ||
| */ | ||
| export function toAmount(anchor: Anchor, venueShareAmount: bigint): bigint { | ||
| return (venueShareAmount * anchor.shareSupply) / anchor.engineShares | ||
| } | ||
| export declare namespace toAmount { | ||
| type ErrorType = Errors.GlobalErrorType | ||
| } | ||
| /** | ||
| * Converts venue shares to a vault share amount at the anchor rate, rounding up. | ||
| * | ||
| * Mirrors the adapter's ceiling conversion used by exact-asset exits. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmountUp( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 5n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param venueShareAmount - Venue share amount, base units. | ||
| * @returns Vault share amount, rounded up. | ||
| */ | ||
| export function toAmountUp(anchor: Anchor, venueShareAmount: bigint): bigint { | ||
| const { engineShares, shareSupply } = anchor | ||
| return (venueShareAmount * shareSupply + engineShares - 1n) / engineShares | ||
| } | ||
| export declare namespace toAmountUp { | ||
| type ErrorType = Errors.GlobalErrorType | ||
| } | ||
| /** | ||
| * Converts a vault share amount to venue shares at the anchor rate, rounding down. | ||
| * | ||
| * Mirrors `VaultAdapter.tokensToShares`. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const venueShareAmount = EarnShares.toVenueAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 10n | ||
| * ``` | ||
| * | ||
| * @param anchor - The conversion anchor. | ||
| * @param shareAmount - Vault share amount, base units. | ||
| * @returns Venue share amount, rounded down. | ||
| */ | ||
| export function toVenueAmount(anchor: Anchor, shareAmount: bigint): bigint { | ||
| return (shareAmount * anchor.engineShares) / anchor.shareSupply | ||
| } | ||
| export declare namespace toVenueAmount { | ||
| type ErrorType = Errors.GlobalErrorType | ||
| } | ||
| /** | ||
| * Computes the dilution-correct vault shares minted for an asset-denominated fee. | ||
| * | ||
| * Mirrors `FeeMath`: | ||
| * `feeShares = floor(fee * shareSupply / (activeAssets - fee))`, zero when the | ||
| * fee is zero or not smaller than the active assets. Minting this amount to the | ||
| * fee ledger prices the fee at post-mint value per share. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shares = EarnShares.feeShares({ | ||
| * activeAssets: 1_100n, | ||
| * shareSupply: 1_000n, | ||
| * totalFeeAssets: 100n, | ||
| * }) | ||
| * // @log: 100n | ||
| * ``` | ||
| * | ||
| * @param options - Fee accrual inputs. | ||
| * @returns Vault shares to mint for the fee, rounded down. | ||
| */ | ||
| export function feeShares(options: feeShares.Options): bigint { | ||
| const { activeAssets, shareSupply, totalFeeAssets } = options | ||
| if (totalFeeAssets === 0n || totalFeeAssets >= activeAssets) return 0n | ||
| return (totalFeeAssets * shareSupply) / (activeAssets - totalFeeAssets) | ||
| } | ||
| export declare namespace feeShares { | ||
| export type Options = { | ||
| /** Assets backing the active (non-queued) supply, base units. */ | ||
| activeAssets: bigint | ||
| /** Active vault share supply, base units. */ | ||
| shareSupply: bigint | ||
| /** Total fee liability in asset units. */ | ||
| totalFeeAssets: bigint | ||
| } | ||
| export type ErrorType = Errors.GlobalErrorType | ||
| } | ||
| /** | ||
| * Lowers an expected output by a basis-point slippage tolerance, flooring to `1n`. | ||
| * | ||
| * Suitable for lower bounds such as a deposit's minimum shares or a redeem's | ||
| * minimum assets; not for upper bounds such as an exact withdrawal's maximum | ||
| * shares. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const minimumShares = EarnShares.minimumOutput(1_000_000n, 50) | ||
| * // @log: 995_000n | ||
| * ``` | ||
| * | ||
| * @param expectedAmount - Expected output in base units. | ||
| * @param slippageBps - Allowed slippage in basis points from `0` through `9_999`. | ||
| * @returns The minimum accepted output, floored to `1n`. | ||
| * @throws `InvalidExpectedOutputError` when `expectedAmount` is not positive. | ||
| * @throws `InvalidSlippageError` when `slippageBps` is outside its valid range. | ||
| */ | ||
| export function minimumOutput( | ||
| expectedAmount: bigint, | ||
| slippageBps: number, | ||
| ): bigint { | ||
| if (expectedAmount <= 0n) | ||
| throw new InvalidExpectedOutputError({ expectedAmount }) | ||
| if ( | ||
| !Number.isInteger(slippageBps) || | ||
| slippageBps < 0 || | ||
| slippageBps >= basisPointScale | ||
| ) | ||
| throw new InvalidSlippageError({ slippageBps }) | ||
| const scale = BigInt(basisPointScale) | ||
| const bounded = (expectedAmount * (scale - BigInt(slippageBps))) / scale | ||
| return bounded === 0n ? 1n : bounded | ||
| } | ||
| export declare namespace minimumOutput { | ||
| type ErrorType = | ||
| | InvalidExpectedOutputError | ||
| | InvalidSlippageError | ||
| | Errors.GlobalErrorType | ||
| } | ||
| /** | ||
| * Error thrown when an expected output is not positive. | ||
| */ | ||
| export class InvalidExpectedOutputError extends Errors.BaseError { | ||
| override readonly name = 'EarnShares.InvalidExpectedOutputError' | ||
| constructor(options: InvalidExpectedOutputError.Options) { | ||
| super( | ||
| `Expected output \`${options.expectedAmount}\` must be greater than zero.`, | ||
| ) | ||
| } | ||
| } | ||
| export declare namespace InvalidExpectedOutputError { | ||
| export type Options = { | ||
| expectedAmount: bigint | ||
| } | ||
| } | ||
| /** | ||
| * Error thrown when a slippage tolerance is not an integer from `0` through `9_999`. | ||
| */ | ||
| export class InvalidSlippageError extends Errors.BaseError { | ||
| override readonly name = 'EarnShares.InvalidSlippageError' | ||
| constructor(options: InvalidSlippageError.Options) { | ||
| super(`Slippage tolerance \`${options.slippageBps}\` is invalid.`, { | ||
| metaMessages: [ | ||
| `Slippage must be a whole number from 0 through ${basisPointScale - 1} basis points.`, | ||
| ], | ||
| }) | ||
| } | ||
| } | ||
| export declare namespace InvalidSlippageError { | ||
| export type Options = { | ||
| slippageBps: number | ||
| } | ||
| } |
| { | ||
| "type": "module", | ||
| "types": "../../_types/tempo/EarnShares.d.ts", | ||
| "main": "../../_cjs/tempo/EarnShares.js", | ||
| "module": "../../_esm/tempo/EarnShares.js" | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ZoneRpcAuthentication = exports.ZoneId = exports.VirtualMaster = exports.VirtualAddress = exports.TxEnvelopeTempo = exports.TransactionRequest = exports.TransactionReceipt = exports.Transaction = exports.TokenRole = exports.TokenId = exports.Tick = exports.TempoAddress = exports.SignatureEnvelope = exports.RpcSchemaTempo = exports.ReceivePolicyReceipt = exports.PoolId = exports.Period = exports.MultisigConfig = exports.KeyAuthorization = exports.Channel = exports.AuthorizationTempo = void 0; | ||
| exports.ZoneRpcAuthentication = exports.ZoneId = exports.VirtualMaster = exports.VirtualAddress = exports.TxEnvelopeTempo = exports.TransactionRequest = exports.TransactionReceipt = exports.Transaction = exports.TokenRole = exports.TokenId = exports.Tick = exports.TempoAddress = exports.SignatureEnvelope = exports.RpcSchemaTempo = exports.ReceivePolicyReceipt = exports.PoolId = exports.Period = exports.MultisigConfig = exports.KeyAuthorization = exports.EarnShares = exports.Channel = exports.AuthorizationTempo = void 0; | ||
| exports.AuthorizationTempo = require("./AuthorizationTempo.js"); | ||
| exports.Channel = require("./Channel.js"); | ||
| exports.EarnShares = require("./EarnShares.js"); | ||
| exports.KeyAuthorization = require("./KeyAuthorization.js"); | ||
@@ -7,0 +8,0 @@ exports.MultisigConfig = require("./MultisigConfig.js"); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;AA2B7D,0CAAuC;AAwCvC,4DAAyD;AA0BzD,wDAAqD;AA6BrD,wCAAqC;AAsBrC,wCAAqC;AAsBrC,oEAAiE;AAoBjE,wDAAqD;AAuBrD,8DAA2D;AAmB3D,oDAAiD;AAoBjD,oCAAiC;AAqBjC,0CAAuC;AAkBvC,8CAA2C;AAkD3C,kDAA+C;AAuB/C,gEAA6D;AAqB7D,gEAA6D;AA6B7D,0DAAuD;AA4BvD,wDAAqD;AAyBrD,sDAAmD;AAqBnD,wCAAqC;AAmCrC,sEAAmE"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;AA2B7D,0CAAuC;AAsBvC,gDAA6C;AAwC7C,4DAAyD;AA0BzD,wDAAqD;AA6BrD,wCAAqC;AAsBrC,wCAAqC;AAsBrC,oEAAiE;AAoBjE,wDAAqD;AAuBrD,8DAA2D;AAmB3D,oDAAiD;AAoBjD,oCAAiC;AAqBjC,0CAAuC;AAkBvC,8CAA2C;AAkD3C,kDAA+C;AAuB/C,gEAA6D;AAqB7D,gEAA6D;AA6B7D,0DAAuD;AA4BvD,wDAAqD;AAyBrD,sDAAmD;AAqBnD,wCAAqC;AAmCrC,sEAAmE"} |
+1
-1
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.version = void 0; | ||
| exports.version = '0.14.31'; | ||
| exports.version = '0.14.32'; | ||
| //# sourceMappingURL=version.js.map |
+22
-0
@@ -62,2 +62,24 @@ /** | ||
| /** | ||
| * Tempo Earn `VaultAdapter` share math: raw vault-share and venue-share conversions | ||
| * at the anchor rate, the dilution-correct fee-share formula, and the | ||
| * `minimumOutput` slippage floor. | ||
| * | ||
| * Conversions are fee-blind mirrors of the adapter's anchor arithmetic; use the | ||
| * adapter's `previewRedeem` for user-facing value. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 4n | ||
| * ``` | ||
| * | ||
| * @category Reference | ||
| */ | ||
| export * as EarnShares from './EarnShares.js'; | ||
| /** | ||
| * Tempo key authorization utilities for provisioning and signing access keys. | ||
@@ -64,0 +86,0 @@ * |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC;;;;;;;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H,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"} |
+1
-1
| /** @internal */ | ||
| export const version = '0.14.31'; | ||
| export const version = '0.14.32'; | ||
| //# sourceMappingURL=version.js.map |
@@ -64,2 +64,24 @@ /** @entrypointCategory Tempo */ | ||
| /** | ||
| * Tempo Earn `VaultAdapter` share math: raw vault-share and venue-share conversions | ||
| * at the anchor rate, the dilution-correct fee-share formula, and the | ||
| * `minimumOutput` slippage floor. | ||
| * | ||
| * Conversions are fee-blind mirrors of the adapter's anchor arithmetic; use the | ||
| * adapter's `previewRedeem` for user-facing value. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 4n | ||
| * ``` | ||
| * | ||
| * @category Reference | ||
| */ | ||
| export * as EarnShares from './EarnShares.js'; | ||
| /** | ||
| * Tempo key authorization utilities for provisioning and signing access keys. | ||
@@ -66,0 +88,0 @@ * |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,YAAY,EAAE,CAAA;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAA;AACjE;;;;;;;;;;;;;;;;;;GAkBG;A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GAgDG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"} |
| /** @internal */ | ||
| export declare const version = "0.14.31"; | ||
| export declare const version = "0.14.32"; | ||
| //# sourceMappingURL=version.d.ts.map |
+13
-0
| # ox | ||
| ## 0.14.32 | ||
| ### Patch Changes | ||
| - [#310](https://github.com/wevm/ox/pull/310) [`d882d95`](https://github.com/wevm/ox/commit/d882d95788b06669427ced3a44484a32221617c7) Thanks [@jxom](https://github.com/jxom)! - Added `EarnShares` to `ox/tempo`: raw EarnToken/venue-share conversions at the vault anchor rate, the dilution-correct fee-share formula, and a `minimumOutput` slippage floor. | ||
| ```ts | ||
| import { EarnShares } from "ox/tempo"; | ||
| const tokens = EarnShares.toTokens({ engineShares: 3n, supply: 2n }, 7n); | ||
| const minimumShares = EarnShares.minimumOutput(1_000_000n, 50n); | ||
| ``` | ||
| ## 0.14.31 | ||
@@ -4,0 +17,0 @@ |
+6
-1
| { | ||
| "name": "ox", | ||
| "description": "Ethereum Standard Library", | ||
| "version": "0.14.31", | ||
| "version": "0.14.32", | ||
| "main": "./_cjs/index.js", | ||
@@ -511,2 +511,7 @@ "module": "./_esm/index.js", | ||
| }, | ||
| "./tempo/EarnShares": { | ||
| "types": "./_types/tempo/EarnShares.d.ts", | ||
| "import": "./_esm/tempo/EarnShares.js", | ||
| "default": "./_cjs/tempo/EarnShares.js" | ||
| }, | ||
| "./tempo/KeyAuthorization.test-d": { | ||
@@ -513,0 +518,0 @@ "types": "./_types/tempo/KeyAuthorization.test-d.d.ts", |
+22
-0
@@ -66,2 +66,24 @@ /** @entrypointCategory Tempo */ | ||
| /** | ||
| * Tempo Earn `VaultAdapter` share math: raw vault-share and venue-share conversions | ||
| * at the anchor rate, the dilution-correct fee-share formula, and the | ||
| * `minimumOutput` slippage floor. | ||
| * | ||
| * Conversions are fee-blind mirrors of the adapter's anchor arithmetic; use the | ||
| * adapter's `previewRedeem` for user-facing value. | ||
| * | ||
| * @example | ||
| * ```ts twoslash | ||
| * import { EarnShares } from 'ox/tempo' | ||
| * | ||
| * const shareAmount = EarnShares.toAmount( | ||
| * { engineShares: 3n, shareSupply: 2n }, | ||
| * 7n, | ||
| * ) | ||
| * // @log: 4n | ||
| * ``` | ||
| * | ||
| * @category Reference | ||
| */ | ||
| export * as EarnShares from './EarnShares.js' | ||
| /** | ||
| * Tempo key authorization utilities for provisioning and signing access keys. | ||
@@ -68,0 +90,0 @@ * |
+1
-1
| /** @internal */ | ||
| export const version = '0.14.31' | ||
| export const version = '0.14.32' |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 4 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 4 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
7849371
0.41%1227
0.74%157736
0.5%