Skip to content

Commit

Permalink
chore(types): drop ambience from zoe tools types
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 2, 2024
1 parent a2c6d29 commit 9c8bc21
Show file tree
Hide file tree
Showing 40 changed files with 116 additions and 25 deletions.
2 changes: 2 additions & 0 deletions packages/agoric-cli/src/commands/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
} from '../lib/wallet.js';
import { bigintReplacer } from '../lib/format.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

// XXX support other decimal places
const COSMOS_UNIT = 1_000_000n;
const scaleDecimals = num => BigInt(num * Number(COSMOS_UNIT));
Expand Down
7 changes: 5 additions & 2 deletions packages/inter-protocol/src/auction/auctionBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import {
priceFrom,
} from './util.js';

/**
* @import {Baggage} from '@agoric/vat-data';
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

const { Fail } = assert;
const { makeEmpty } = AmountMath;

Expand Down Expand Up @@ -90,8 +95,6 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
);
};

/** @import {Baggage} from '@agoric/vat-data' */

/**
* @typedef {object} BookDataNotification
* @property {Ratio | null} startPrice identifies the priceAuthority and price
Expand Down
5 changes: 4 additions & 1 deletion packages/inter-protocol/src/auction/auctioneer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import { auctioneerParamTypes } from './params.js';
import { makeScheduler } from './scheduler.js';
import { AuctionState } from './util.js';

/** @import {Baggage} from '@agoric/vat-data' */
/**
* @import {Baggage} from '@agoric/vat-data';
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

const { Fail, quote: q } = assert;
const { add, multiply } = natSafeMath;
Expand Down
7 changes: 5 additions & 2 deletions packages/inter-protocol/src/auction/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
import { TimeMath, RelativeTimeRecordShape } from '@agoric/time';
import { M } from '@agoric/store';

/** @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js' */
/** @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js' */
/**
* @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
* @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

// TODO duplicated with zoe/src/TypeGuards.js
export const InvitationShape = M.remotable('Invitation');
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/auction/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
} from '@agoric/zoe/src/contractSupport/index.js';
import { Far } from '@endo/marshal';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

/**
* Constants for Auction State.
*
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/contractSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { AmountMath } from '@agoric/ertp';
import { M } from '@agoric/store';
import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport/index.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

const { Fail, quote: q } = assert;

export const amountPattern = harden({ brand: M.remotable(), value: M.any() });
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/price/fluxAggregatorKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { Far } from '@endo/marshal';
import { prepareOracleAdminKit } from './priceOracleKit.js';
import { prepareRoundsManagerKit } from './roundsManager.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

const trace = makeTracer('FlxAgg', true);

export const INVITATION_MAKERS_DESC = 'oracle invitation';
Expand Down
6 changes: 3 additions & 3 deletions packages/inter-protocol/src/price/roundsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';

const { add, subtract, multiply, floorDivide, ceilDivide, isGTE } = natSafeMath;

/** @import {OracleStatus} from './priceOracleKit.js' */
/**
* @import {Timestamp} from '@agoric/time'
* @import {TimerService} from '@agoric/time'
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
* @import {Timestamp, TimerService} from '@agoric/time'
* @import {OracleStatus} from './priceOracleKit.js'
*/

/** @type {string} */
Expand Down
1 change: 1 addition & 0 deletions packages/inter-protocol/src/vaultFactory/liquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const trace = makeTracer('LIQ');
/** @import {TimerWaker} from '@agoric/time' */
/** @import {CancelToken} from '@agoric/time' */
/** @import {RelativeTimeRecord} from '@agoric/time' */
/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

const makeCancelToken = makeCancelTokenMaker('liq');

Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/vaultFactory/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
import { priceFrom } from '../auction/util.js';
import { addSubtract } from '../contractSupport.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

/**
* Calculate the minimum collateralization given the liquidation margin and the
* "padding" from that liquidation threshold.
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/vaultFactory/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { provideDurableMapStore } from '@agoric/vat-data';
import { subtractRatios } from '@agoric/zoe/src/contractSupport/ratio.js';
import { amountPattern, ratioPattern } from '../contractSupport.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

export const CHARGING_PERIOD_KEY = 'ChargingPeriod';
export const RECORDING_PERIOD_KEY = 'RecordingPeriod';

Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/vaultFactory/proceeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
import { quoteAsRatio, subtractToEmpty } from '../contractSupport.js';
import { liquidationResults } from './liquidation.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

/**
* @typedef {{
* overage: Amount<'nat'>;
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/vaultFactory/storeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* API supports them.
*/

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

// XXX importing these that are declared to be used only for testing
// until @agoric/store supports composite keys
import { makeDecodePassable, makeEncodePassable } from '@endo/marshal';
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/vaultFactory/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
* @typedef {object} GetVaultParams
* @property {() => Ratio} getLiquidationMargin
* @property {() => Ratio} getMintFee
* @property {() => Promise<PriceQuote>} getCollateralQuote
* @property {() => Promise<import('@agoric/zoe/tools/types.js').PriceQuote>} getCollateralQuote
* @property {() => Ratio} getInterestRate - The annual interest rate on a debt
* position
* @property {() => RelativeTime} getChargingPeriod - The period (in seconds) at
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/src/vaultFactory/vaultFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { InvitationShape } from '../auction/params.js';
import { SHORTFALL_INVITATION_KEY, vaultDirectorParamTypes } from './params.js';
import { provideDirector } from './vaultDirector.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

const trace = makeTracer('VF', true);

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/inter-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ import { makePrioritizedVaults } from './prioritizedVaults.js';
import { Phase, prepareVault } from './vault.js';
import { calculateDistributionPlan } from './proceeds.js';

/**
* @import {Baggage} from '@agoric/vat-data';
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

const { details: X, Fail, quote: q } = assert;

const trace = makeTracer('VM');
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/test/vaultFactory/test-collatRatio.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport/index.js';
import { normalizedCollRatio } from '../../src/vaultFactory/storeUtils.js';
import { withAmountUtils } from '../supports.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

export const mockBrand = Far('brand');

const makeFakeQuote = (amountIn, amountOut) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/inter-protocol/test/vaultFactory/test-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
} from '../../src/vaultFactory/math.js';
import { withAmountUtils } from '../supports.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

const stable = withAmountUtils(makeIssuerKit('Stable'));

const aeth = withAmountUtils(makeIssuerKit('Aeth'));

//#region maxDebtForVaults
Expand Down
2 changes: 2 additions & 0 deletions packages/inter-protocol/test/vaultFactory/test-proceeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
import { calculateDistributionPlan } from '../../src/vaultFactory/proceeds.js';
import { withAmountUtils } from '../supports.js';

/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */

const debt = withAmountUtils(makeIssuerKit('IST'));
const coll = withAmountUtils(makeIssuerKit('aEth'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ import {
setupElectorateReserveAndAuction,
} from './vaultFactoryUtils.js';

/** @import {VaultFactoryContract as VFC} from '../../src/vaultFactory/vaultFactory.js' */
/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
* @import {VaultFactoryContract as VFC} from '../../src/vaultFactory/vaultFactory.js'
*/

/**
* @typedef {Record<string, any> & {
Expand Down
5 changes: 5 additions & 0 deletions packages/vats/src/priceAuthorityRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { E } from '@endo/far';
import { Far } from '@endo/marshal';
import { PriceAuthorityI } from '@agoric/zoe/src/contractSupport/priceAuthority.js';

/**
* @import {Baggage} from '@agoric/vat-data';
* @import {MutableQuote, PriceAuthority, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

const { Fail } = assert;

/**
Expand Down
1 change: 0 additions & 1 deletion packages/zoe/exported.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import './src/zoeService/types-ambient.js';
import './src/contractSupport/types-ambient.js';
import './src/contracts/exported.js';
import './src/types-ambient.js';
import './tools/types-ambient.js';
import '@agoric/notifier/exported.js';
import '@agoric/ertp/exported.js';
import '@agoric/store/exported.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/zoe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"scripts": {
"build": "yarn build:bundles",
"build:bundles": "node scripts/build-bundles.js",
"prepack": "echo \"export {}; \" | cat - tools/types-ambient.js > tools/types.js && tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*' tools/types.js",
"prepack": "tsc --build tsconfig.build.json",
"postpack": "git clean -f '*.d.ts*'",
"test": "ava --verbose",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:unit": "ava 'test/unitTests/**/test-*.js' -T 1m --verbose",
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contractSupport/priceAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { makeTracer } from '@agoric/internal';
import { TimestampShape } from '@agoric/time';
import { M } from '@agoric/store';

/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery, PriceQuoteCreate, PriceAuthorityKit, PriceQuoteTrigger, MutableQuote,} from '@agoric/zoe/tools/types.js';
*/

const { quote: q, Fail } = assert;

const trace = makeTracer('PA', false);
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contractSupport/priceAuthorityInitial.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { AmountMath } from '@agoric/ertp';
import { multiplyBy } from './ratio.js';
import { mintQuote } from './priceAuthorityTransform.js';

/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

/**
* Override `makeQuoteNotifier`, `quoteGiven` to provide an initial price
* in case one is not yet available from the source.
Expand Down
5 changes: 4 additions & 1 deletion packages/zoe/src/contractSupport/priceAuthorityTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { Fail, assert } from '@agoric/assert';
import { AmountMath } from '@agoric/ertp';
import { makeNotifier } from '@agoric/notifier';

/** @import {EOnly} from '@endo/eventual-send' */
/**
* @import {EOnly} from '@endo/eventual-send';
* @import {MutableQuote, PriceAuthority, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

/**
* @param {Brand<'set'>} quoteBrand
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contractSupport/priceQuote.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { AmountMath } from '@agoric/ertp';
import { Nat } from '@endo/nat';
import { E } from '@endo/eventual-send';

/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

const { Fail } = assert;

// PriceAuthorities return quotes as a pair of an amount and a payment, both
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contracts/callSpread/fundedCallSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
import { makePayoffHandler } from './payoffHandler.js';
import { Position } from './position.js';

/**
* @import {PriceAuthority} from '@agoric/zoe/tools/types.js';
*/

/**
* This contract implements a fully collateralized call spread. This is a
* combination of a call option bought at one strike price and a second call
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contracts/callSpread/pricedCallSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
import { makePayoffHandler } from './payoffHandler.js';
import { Position } from './position.js';

/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

const { Fail } = assert;

const PERCENT_BASE = 100n;
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contracts/loan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
} from '../../contractSupport/index.js';
import { makeLendInvitation } from './lend.js';

/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

/**
* Add collateral of a particular brand and get a loan of another
* brand. Collateral (also known as margin) must be greater than the
Expand Down
10 changes: 5 additions & 5 deletions packages/zoe/src/contracts/loan/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @property {AutoswapInstance} autoswapInstance
*
* @property {PriceAuthority} priceAuthority
* @property {import('../../../tools/types.js').PriceAuthority} priceAuthority
*
* Used for getting the current value of collateral and setting
* liquidation triggers.
Expand Down Expand Up @@ -66,7 +66,7 @@
*
* A function to get the current debt
*
* @property {PromiseRecord<PriceQuote>} liquidationPromiseKit
* @property {PromiseRecord<import('../../../tools/types.js').PriceQuote>} liquidationPromiseKit
*
* PromiseKit that includes a promise that resolves to a PriceQuote
* when liquidation is triggered
Expand All @@ -80,7 +80,7 @@
* The ZCFSeat holding the collateral in escrow after the borrower
* escrows it
*
* @property {PromiseRecord<PriceQuote>} liquidationPromiseKit
* @property {PromiseRecord<import('../../../tools/types.js').PriceQuote>} liquidationPromiseKit
*
* PromiseKit that includes a promise that resolves to a PriceQuote
* when liquidation is triggered
Expand Down Expand Up @@ -179,7 +179,7 @@
* @property {PromiseRecord<any>} liquidationPromiseKit
* @property {bigint} [mmr]
* @property {Handle<'Instance'>} autoswapInstance
* @property {PriceAuthority} priceAuthority
* @property {import('../../../tools/types.js').PriceAuthority} priceAuthority
* @property {PeriodNotifier} periodNotifier
* @property {bigint} interestRate
* @property {import('@agoric/time').RelativeTime} interestPeriod
Expand All @@ -198,7 +198,7 @@
*
* Make an invitation to add collateral to protect against liquidation
*
* @property {() => Promise<PriceQuote>} getLiquidationPromise
* @property {() => Promise<import('../../../tools/types.js').PriceQuote>} getLiquidationPromise
*
* Get a promise for a priceQuote that will resolve if liquidation
* occurs. The priceQuote is for the value of the collateral that
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contracts/priceAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
import { notForProductionUse } from '@agoric/internal/src/magic-cookie-test-only.js';

import '../../tools/types-ambient.js';
import {
calculateMedian,
makeOnewayPriceAuthorityKit,
Expand All @@ -33,6 +32,7 @@ import {

/**
* @import {LegacyMap} from '@agoric/store'
* @import {PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/
/** @typedef {bigint | number | string} ParsableNumber */
/**
Expand Down
4 changes: 4 additions & 0 deletions packages/zoe/src/contracts/scaledPriceAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { makeInitialTransform } from '../contractSupport/priceAuthorityInitial.j
import { makePriceAuthorityTransform } from '../contractSupport/priceAuthorityTransform.js';
import { provideQuoteMint } from '../contractSupport/priceAuthorityQuoteMint.js';

/**
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
*/

/**
* @typedef {object} ScaledPriceAuthorityOpts
* @property {ERef<PriceAuthority>} sourcePriceAuthority
Expand Down
Loading

0 comments on commit 9c8bc21

Please sign in to comment.