@agoric/inter-protocol 0.16.1 → 0.16.2-calypso-dev-84eb287.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +41 -36
- package/scripts/build-bundles.js +5 -21
- package/src/auction/auctionBook.d.ts +147 -0
- package/src/auction/auctionBook.d.ts.map +1 -0
- package/src/auction/auctionBook.js +135 -103
- package/src/auction/auctioneer.d.ts +69 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +63 -49
- package/src/auction/offerBook.d.ts +45 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +13 -12
- package/src/auction/params.d.ts +144 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +10 -9
- package/src/auction/scheduleMath.d.ts +5 -0
- package/src/auction/scheduleMath.d.ts.map +1 -0
- package/src/auction/scheduleMath.js +17 -15
- package/src/auction/scheduler.d.ts +49 -0
- package/src/auction/scheduler.d.ts.map +1 -0
- package/src/auction/scheduler.js +51 -43
- package/src/auction/sortedOffers.d.ts +8 -0
- package/src/auction/sortedOffers.d.ts.map +1 -0
- package/src/auction/sortedOffers.js +9 -7
- package/src/auction/util.d.ts +32 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +6 -4
- package/src/clientSupport.d.ts +167 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +154 -96
- package/src/collectFees.d.ts +2 -0
- package/src/collectFees.d.ts.map +1 -0
- package/src/contractSupport.d.ts +28 -0
- package/src/contractSupport.d.ts.map +1 -0
- package/src/contractSupport.js +14 -12
- package/src/econCommitteeCharter.d.ts +39 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +21 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +37 -33
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +1 -0
- package/src/interest-math.d.ts +3 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest.d.ts +28 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +21 -16
- package/src/price/README.md +13 -0
- package/src/price/fluxAggregatorContract.d.ts +70 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -0
- package/src/price/fluxAggregatorContract.js +62 -55
- package/src/price/fluxAggregatorKit.d.ts +103 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +50 -37
- package/src/price/priceOracleKit.d.ts +38 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +11 -13
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +79 -82
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.d.ts +69 -0
- package/src/proposals/add-auction.d.ts.map +1 -0
- package/src/proposals/add-auction.js +180 -0
- package/src/proposals/addAssetToVault.d.ts +160 -0
- package/src/proposals/addAssetToVault.d.ts.map +1 -0
- package/src/proposals/addAssetToVault.js +172 -38
- package/src/proposals/committee-proposal.d.ts +113 -0
- package/src/proposals/committee-proposal.d.ts.map +1 -0
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.d.ts +149 -0
- package/src/proposals/core-proposal.d.ts.map +1 -0
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/econ-behaviors.d.ts +539 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -0
- package/src/proposals/econ-behaviors.js +64 -45
- package/src/proposals/price-feed-proposal.d.ts +84 -0
- package/src/proposals/price-feed-proposal.d.ts.map +1 -0
- package/src/proposals/price-feed-proposal.js +108 -51
- package/src/proposals/startEconCommittee.d.ts +34 -0
- package/src/proposals/startEconCommittee.d.ts.map +1 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.d.ts +59 -0
- package/src/proposals/startPSM.d.ts.map +1 -0
- package/src/proposals/startPSM.js +38 -27
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.d.ts +35 -0
- package/src/proposals/upgrade-vaults.d.ts.map +1 -0
- package/src/proposals/upgrade-vaults.js +235 -0
- package/src/proposals/utils.d.ts +17 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +34 -7
- package/src/provisionPool.d.ts +167 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +122 -0
- package/src/provisionPoolKit.d.ts +367 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +522 -0
- package/src/psm/psm.d.ts +122 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +73 -69
- package/src/psm/types-ambient.d.ts +2 -0
- package/src/psm/types-ambient.d.ts.map +1 -0
- package/src/psm/types-ambient.js +3 -0
- package/src/reserve/assetReserve.d.ts +47 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +28 -19
- package/src/reserve/assetReserveKit.d.ts +74 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +18 -24
- package/src/reserve/params.d.ts +10 -0
- package/src/reserve/params.d.ts.map +1 -0
- package/src/tokens.d.ts +3 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +5 -0
- package/src/vaultFactory/burn.d.ts +2 -0
- package/src/vaultFactory/burn.d.ts.map +1 -0
- package/src/vaultFactory/burn.js +1 -1
- package/src/vaultFactory/liquidation.d.ts +23 -0
- package/src/vaultFactory/liquidation.d.ts.map +1 -0
- package/src/vaultFactory/liquidation.js +36 -22
- package/src/vaultFactory/math.d.ts +11 -0
- package/src/vaultFactory/math.d.ts.map +1 -0
- package/src/vaultFactory/math.js +10 -9
- package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +8 -11
- package/src/vaultFactory/params.d.ts +140 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +52 -24
- package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +4 -4
- package/src/vaultFactory/proceeds.d.ts +35 -0
- package/src/vaultFactory/proceeds.d.ts.map +1 -0
- package/src/vaultFactory/proceeds.js +26 -18
- package/src/vaultFactory/storeUtils.d.ts +25 -0
- package/src/vaultFactory/storeUtils.d.ts.map +1 -0
- package/src/vaultFactory/storeUtils.js +10 -12
- package/src/vaultFactory/types-ambient.d.ts +137 -0
- package/src/vaultFactory/types-ambient.d.ts.map +1 -0
- package/src/vaultFactory/{types.js → types-ambient.js} +42 -42
- package/src/vaultFactory/vault.d.ts +332 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +99 -93
- package/src/vaultFactory/vaultDirector.d.ts +340 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +63 -50
- package/src/vaultFactory/vaultFactory.d.ts +201 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +49 -32
- package/src/vaultFactory/vaultHolder.d.ts +126 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +10 -14
- package/src/vaultFactory/vaultKit.d.ts +32 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +5 -4
- package/src/vaultFactory/vaultManager.d.ts +674 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +249 -151
- package/CHANGELOG.md +0 -1033
- package/bundles/bundle-auctioneer-js-meta.json +0 -722
- package/bundles/bundle-auctioneer.js +0 -1
- package/bundles/bundle-econCommitteeCharter-js-meta.json +0 -514
- package/bundles/bundle-econCommitteeCharter.js +0 -1
- package/bundles/bundle-feeDistributor-js-meta.json +0 -458
- package/bundles/bundle-feeDistributor.js +0 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +0 -674
- package/bundles/bundle-fluxAggregatorKit.js +0 -1
- package/bundles/bundle-psm-js-meta.json +0 -666
- package/bundles/bundle-psm.js +0 -1
- package/bundles/bundle-reserve-js-meta.json +0 -662
- package/bundles/bundle-reserve.js +0 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +0 -542
- package/bundles/bundle-scaledPriceAuthority.js +0 -1
- package/bundles/bundle-vaultFactory-js-meta.json +0 -790
- package/bundles/bundle-vaultFactory.js +0 -1
- package/exported.js +0 -2
- package/scripts/add-collateral-core.js +0 -112
- package/scripts/deploy-contracts.js +0 -100
- package/scripts/init-core.js +0 -198
- package/scripts/invite-committee-core.js +0 -42
- package/scripts/manual-price-feed.js +0 -117
- package/scripts/price-feed-core.js +0 -104
- package/scripts/start-local-chain.sh +0 -84
- package/src/psm/types.js +0 -3
- package/src/typeGuards.js +0 -13
- package/src/vaultFactory/type-imports.js +0 -4
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function prepareScaledBidBook(baggage: Baggage): (bidScalingPattern: globalThis.Pattern, collateralBrand: globalThis.Brand) => import("@endo/exo").Guarded<{
|
|
2
|
+
/**
|
|
3
|
+
* @param {ZCFSeat} seat
|
|
4
|
+
* @param {Ratio} bidScaling
|
|
5
|
+
* @param {Amount<'nat'>} wanted
|
|
6
|
+
* @param {boolean} exitAfterBuy
|
|
7
|
+
*/
|
|
8
|
+
add(seat: ZCFSeat, bidScaling: Ratio, wanted: Amount<"nat">, exitAfterBuy: boolean): string;
|
|
9
|
+
/** @param {Ratio} bidScaling */
|
|
10
|
+
offersAbove(bidScaling: Ratio): [string, BidderRecord][];
|
|
11
|
+
hasOrders(): boolean;
|
|
12
|
+
delete(key: any): void;
|
|
13
|
+
updateReceived(key: any, sold: any): void;
|
|
14
|
+
exitAllSeats(): void;
|
|
15
|
+
}>;
|
|
16
|
+
export function preparePriceBook(baggage: Baggage): (priceRatioPattern: globalThis.Pattern, collateralBrand: globalThis.Brand) => import("@endo/exo").Guarded<{
|
|
17
|
+
/**
|
|
18
|
+
* @param {ZCFSeat} seat
|
|
19
|
+
* @param {Ratio} price
|
|
20
|
+
* @param {Amount<'nat'>} wanted
|
|
21
|
+
* @param {boolean} exitAfterBuy
|
|
22
|
+
*/
|
|
23
|
+
add(seat: ZCFSeat, price: Ratio, wanted: Amount<"nat">, exitAfterBuy: boolean): string;
|
|
24
|
+
offersAbove(price: any): [string, BidderRecord][];
|
|
25
|
+
hasOrders(): boolean;
|
|
26
|
+
delete(key: any): void;
|
|
27
|
+
updateReceived(key: any, sold: any): void;
|
|
28
|
+
exitAllSeats(): void;
|
|
29
|
+
}>;
|
|
30
|
+
export type BidderRecord = {
|
|
31
|
+
seat: ZCFSeat;
|
|
32
|
+
wanted: Amount<"nat">;
|
|
33
|
+
seqNum: NatValue;
|
|
34
|
+
received: Amount<"nat">;
|
|
35
|
+
} & {
|
|
36
|
+
exitAfterBuy: boolean;
|
|
37
|
+
} & ({
|
|
38
|
+
bidScaling: Pattern;
|
|
39
|
+
price: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
bidScaling: undefined;
|
|
42
|
+
price: Ratio;
|
|
43
|
+
});
|
|
44
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
45
|
+
//# sourceMappingURL=offerBook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerBook.d.ts","sourceRoot":"","sources":["offerBook.js"],"names":[],"mappings":"AAkDO,8CAFI,OAAO,wFA2Ke,WAC5B;IA1JC;;;;;OAKG;cAJQ,OAAO,cACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;IAsBlB,gCAAgC;4BAApB,KAAK;;;;;GAqCpB;AAcI,0CAFI,OAAO,wFA8Ee,WAC5B;IA7DC;;;;;OAKG;cAJQ,OAAO,SACP,KAAK,UACL,MAAM,CAAC,KAAK,CAAC,gBACb,OAAO;;;;;;GA0DrB;2BAnMU;IACZ,IAAQ,EAAE,OAAO,CAAC;IAClB,MAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAU,EAAE,QAAQ,CAAC;IACrB,QAAY,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CACzB,GAAG;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,GAAG,CAC1B;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACzC;IAAE,UAAU,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAC1C;6BApBqB,kBAAkB"}
|
package/src/auction/offerBook.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
toScaledRateOfferKey,
|
|
13
13
|
} from './sortedOffers.js';
|
|
14
14
|
|
|
15
|
-
/** @
|
|
15
|
+
/** @import {Baggage} from '@agoric/vat-data' */
|
|
16
16
|
|
|
17
17
|
// multiple offers might be provided at the same time (since the time
|
|
18
18
|
// granularity is limited to blocks), so we increment a sequenceNumber with each
|
|
@@ -25,12 +25,14 @@ const nextSequenceNumber = () => {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @typedef {{
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* } &
|
|
33
|
-
* }
|
|
28
|
+
* seat: ZCFSeat;
|
|
29
|
+
* wanted: Amount<'nat'>;
|
|
30
|
+
* seqNum: NatValue;
|
|
31
|
+
* received: Amount<'nat'>;
|
|
32
|
+
* } & { exitAfterBuy: boolean } & (
|
|
33
|
+
* | { bidScaling: Pattern; price: undefined }
|
|
34
|
+
* | { bidScaling: undefined; price: Ratio }
|
|
35
|
+
* )} BidderRecord
|
|
34
36
|
*/
|
|
35
37
|
|
|
36
38
|
const ScaledBidBookStateShape = harden({
|
|
@@ -41,7 +43,8 @@ const ScaledBidBookStateShape = harden({
|
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* Prices in this book are expressed as percentage of the full oracle price
|
|
44
|
-
* snapshot taken when the auction started. .4 is 60% off. 1.1 is 10% above
|
|
46
|
+
* snapshot taken when the auction started. .4 is 60% off. 1.1 is 10% above
|
|
47
|
+
* par.
|
|
45
48
|
*
|
|
46
49
|
* @param {Baggage} baggage
|
|
47
50
|
*/
|
|
@@ -51,7 +54,6 @@ export const prepareScaledBidBook = baggage =>
|
|
|
51
54
|
'scaledBidBook',
|
|
52
55
|
undefined,
|
|
53
56
|
/**
|
|
54
|
-
*
|
|
55
57
|
* @param {Pattern} bidScalingPattern
|
|
56
58
|
* @param {Brand} collateralBrand
|
|
57
59
|
*/
|
|
@@ -134,8 +136,8 @@ const PriceBookStateShape = harden({
|
|
|
134
136
|
});
|
|
135
137
|
|
|
136
138
|
/**
|
|
137
|
-
* Prices in this book are actual prices expressed in terms of bid amount
|
|
138
|
-
*
|
|
139
|
+
* Prices in this book are actual prices expressed in terms of bid amount and
|
|
140
|
+
* collateral amount.
|
|
139
141
|
*
|
|
140
142
|
* @param {Baggage} baggage
|
|
141
143
|
*/
|
|
@@ -145,7 +147,6 @@ export const preparePriceBook = baggage =>
|
|
|
145
147
|
'priceBook',
|
|
146
148
|
undefined,
|
|
147
149
|
/**
|
|
148
|
-
*
|
|
149
150
|
* @param {Pattern} priceRatioPattern
|
|
150
151
|
* @param {Brand} collateralBrand
|
|
151
152
|
*/
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
|
|
3
|
+
* @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
|
|
4
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
5
|
+
*/
|
|
6
|
+
export const InvitationShape: import("@endo/patterns").Matcher;
|
|
7
|
+
/**
|
|
8
|
+
* In seconds, how often to start an auction. The auction will start at
|
|
9
|
+
* AUCTION_START_DELAY seconds after a multiple of START_FREQUENCY, with the
|
|
10
|
+
* price at STARTING_RATE_BP. Every CLOCK_STEP, the price will be reduced by
|
|
11
|
+
* DISCOUNT_STEP_BP, as long as the rate is at or above LOWEST_RATE_BP, or until
|
|
12
|
+
* START_FREQUENCY has elapsed.
|
|
13
|
+
*/
|
|
14
|
+
export const START_FREQUENCY: "StartFrequency";
|
|
15
|
+
/** in seconds, how often to reduce the price */
|
|
16
|
+
export const CLOCK_STEP: "ClockStep";
|
|
17
|
+
/** discount or markup for starting price in basis points. 9999 = 1bp discount */
|
|
18
|
+
export const STARTING_RATE_BP: "StartingRate";
|
|
19
|
+
/** A limit below which the price will not be discounted. */
|
|
20
|
+
export const LOWEST_RATE_BP: "LowestRate";
|
|
21
|
+
/** amount to reduce prices each time step in bp, as % of the start price */
|
|
22
|
+
export const DISCOUNT_STEP_BP: "DiscountStep";
|
|
23
|
+
/**
|
|
24
|
+
* VaultManagers liquidate vaults at a frequency configured by START_FREQUENCY.
|
|
25
|
+
* Auctions start this long after the hour to give vaults time to finish.
|
|
26
|
+
*/
|
|
27
|
+
export const AUCTION_START_DELAY: "AuctionStartDelay";
|
|
28
|
+
export const PRICE_LOCK_PERIOD: "PriceLockPeriod";
|
|
29
|
+
export const auctioneerParamPattern: import("@endo/patterns").Matcher;
|
|
30
|
+
export namespace auctioneerParamTypes {
|
|
31
|
+
let Electorate: "invitation";
|
|
32
|
+
let StartFrequency: "relativeTime";
|
|
33
|
+
let ClockStep: "relativeTime";
|
|
34
|
+
let StartingRate: "nat";
|
|
35
|
+
let LowestRate: "nat";
|
|
36
|
+
let DiscountStep: "nat";
|
|
37
|
+
let AuctionStartDelay: "relativeTime";
|
|
38
|
+
let PriceLockPeriod: "relativeTime";
|
|
39
|
+
}
|
|
40
|
+
export function makeAuctioneerParams({ ElectorateInvitationAmount, StartFrequency, ClockStep, LowestRate, StartingRate, DiscountStep, AuctionStartDelay, PriceLockPeriod, TimerBrand, }: AuctionParams): {
|
|
41
|
+
Electorate: {
|
|
42
|
+
type: "invitation";
|
|
43
|
+
value: import("@agoric/ertp/src/types").SetAmount<import("@endo/patterns").Key>;
|
|
44
|
+
};
|
|
45
|
+
StartFrequency: {
|
|
46
|
+
type: "relativeTime";
|
|
47
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
48
|
+
};
|
|
49
|
+
ClockStep: {
|
|
50
|
+
type: "relativeTime";
|
|
51
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
52
|
+
};
|
|
53
|
+
AuctionStartDelay: {
|
|
54
|
+
type: "relativeTime";
|
|
55
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
56
|
+
};
|
|
57
|
+
PriceLockPeriod: {
|
|
58
|
+
type: "relativeTime";
|
|
59
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
60
|
+
};
|
|
61
|
+
StartingRate: {
|
|
62
|
+
type: "nat";
|
|
63
|
+
value: bigint;
|
|
64
|
+
};
|
|
65
|
+
LowestRate: {
|
|
66
|
+
type: "nat";
|
|
67
|
+
value: bigint;
|
|
68
|
+
};
|
|
69
|
+
DiscountStep: {
|
|
70
|
+
type: "nat";
|
|
71
|
+
value: bigint;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export function makeAuctioneerParamManager(publisherKit: import("@agoric/notifier").StoredPublisherKit<GovernanceSubscriptionState>, zcf: ZCF, initial: AuctionParams): import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
75
|
+
Electorate: "invitation";
|
|
76
|
+
StartFrequency: "relativeTime";
|
|
77
|
+
ClockStep: "relativeTime";
|
|
78
|
+
StartingRate: "nat";
|
|
79
|
+
LowestRate: "nat";
|
|
80
|
+
DiscountStep: "nat";
|
|
81
|
+
AuctionStartDelay: "relativeTime";
|
|
82
|
+
PriceLockPeriod: "relativeTime";
|
|
83
|
+
}>;
|
|
84
|
+
export function makeGovernedTerms({ storageNode: _storageNode, marshaller: _marshaller }: {
|
|
85
|
+
storageNode: ERef<StorageNode>;
|
|
86
|
+
marshaller: ERef<Marshaller>;
|
|
87
|
+
}, timer: ERef<import("@agoric/time").TimerService>, priceAuthority: ERef<PriceAuthority>, reservePublicFacet: ERef<AssetReservePublicFacet>, params: AuctionParams): {
|
|
88
|
+
priceAuthority: globalThis.ERef<PriceAuthority>;
|
|
89
|
+
reservePublicFacet: globalThis.ERef<globalThis.GovernedPublicFacet<import("@endo/exo").Guarded<{
|
|
90
|
+
makeAddCollateralInvitation(): Promise<Invitation<string, never>>;
|
|
91
|
+
getPublicTopics(): {
|
|
92
|
+
metrics: import("@agoric/zoe/src/contractSupport").PublicTopic<import("../reserve/assetReserveKit").MetricsNotification>;
|
|
93
|
+
};
|
|
94
|
+
}>>>;
|
|
95
|
+
timerService: globalThis.ERef<import("@agoric/time").TimerService>;
|
|
96
|
+
governedParams: {
|
|
97
|
+
Electorate: {
|
|
98
|
+
type: "invitation";
|
|
99
|
+
value: import("@agoric/ertp/src/types").SetAmount<import("@endo/patterns").Key>;
|
|
100
|
+
};
|
|
101
|
+
StartFrequency: {
|
|
102
|
+
type: "relativeTime";
|
|
103
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
104
|
+
};
|
|
105
|
+
ClockStep: {
|
|
106
|
+
type: "relativeTime";
|
|
107
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
108
|
+
};
|
|
109
|
+
AuctionStartDelay: {
|
|
110
|
+
type: "relativeTime";
|
|
111
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
112
|
+
};
|
|
113
|
+
PriceLockPeriod: {
|
|
114
|
+
type: "relativeTime";
|
|
115
|
+
value: import("@agoric/time").RelativeTimeRecord;
|
|
116
|
+
};
|
|
117
|
+
StartingRate: {
|
|
118
|
+
type: "nat";
|
|
119
|
+
value: bigint;
|
|
120
|
+
};
|
|
121
|
+
LowestRate: {
|
|
122
|
+
type: "nat";
|
|
123
|
+
value: bigint;
|
|
124
|
+
};
|
|
125
|
+
DiscountStep: {
|
|
126
|
+
type: "nat";
|
|
127
|
+
value: bigint;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export type AuctionParams = {
|
|
132
|
+
ElectorateInvitationAmount: Amount<"set">;
|
|
133
|
+
StartFrequency: RelativeTime;
|
|
134
|
+
ClockStep: RelativeTime;
|
|
135
|
+
StartingRate: bigint;
|
|
136
|
+
LowestRate: bigint;
|
|
137
|
+
DiscountStep: bigint;
|
|
138
|
+
AuctionStartDelay: RelativeTime;
|
|
139
|
+
PriceLockPeriod: RelativeTime;
|
|
140
|
+
TimerBrand: import("@agoric/time").TimerBrand;
|
|
141
|
+
};
|
|
142
|
+
export type AuctionParamManager = ReturnType<typeof makeAuctioneerParamManager>;
|
|
143
|
+
import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
|
|
144
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAQA;;;;GAIG;AAGH,+DAAyD;AAEzD;;;;;;GAMG;AACH,+CAAgD;AAChD,gDAAgD;AAChD,qCAAsC;AACtC,iFAAiF;AACjF,8CAA+C;AAC/C,4DAA4D;AAC5D,0CAA2C;AAC3C,4EAA4E;AAC5E,8CAA+C;AAC/C;;;GAGG;AACH,sDAAuD;AAIvD,kDAAmD;AAEnD,sEASG;;;;;;;;;;;AA2BI,yLADK,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCxB;AAQM,yDAJI,OAAO,kBAAkB,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,OAC1E,GAAG,WACH,aAAa;;;;;;;;;GA0BvB;AAUM,0FANI;IAAE,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;CAAE,SAChE,IAAI,CAAC,OAAO,cAAc,EAAE,YAAY,CAAC,kBACzC,IAAI,CAAC,cAAc,CAAC,sBACpB,IAAI,CAAC,uBAAuB,CAAC,UAC7B,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBvB;;gCAxGa,MAAM,CAAC,KAAK,CAAC;oBACb,YAAY;eACZ,YAAY;kBACZ,MAAM;gBACN,MAAM;kBACN,MAAM;uBACN,YAAY;qBACZ,YAAY;gBACZ,OAAO,cAAc,EAAE,UAAU;;kCAmGjC,UAAU,CAAC,OAAO,0BAA0B,CAAC;oCAnKkC,4BAA4B"}
|
package/src/auction/params.js
CHANGED
|
@@ -6,14 +6,17 @@ import {
|
|
|
6
6
|
import { TimeMath, RelativeTimeRecordShape } from '@agoric/time';
|
|
7
7
|
import { M } from '@agoric/store';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @import {AsyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
|
|
11
|
+
* @import {SyncSpecTuple} from '@agoric/governance/src/contractGovernance/typedParamManager.js';
|
|
12
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
13
|
+
*/
|
|
11
14
|
|
|
12
15
|
// TODO duplicated with zoe/src/TypeGuards.js
|
|
13
16
|
export const InvitationShape = M.remotable('Invitation');
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
|
-
* In seconds, how often to start an auction.
|
|
19
|
+
* In seconds, how often to start an auction. The auction will start at
|
|
17
20
|
* AUCTION_START_DELAY seconds after a multiple of START_FREQUENCY, with the
|
|
18
21
|
* price at STARTING_RATE_BP. Every CLOCK_STEP, the price will be reduced by
|
|
19
22
|
* DISCOUNT_STEP_BP, as long as the rate is at or above LOWEST_RATE_BP, or until
|
|
@@ -70,12 +73,10 @@ export const auctioneerParamTypes = harden({
|
|
|
70
73
|
* @property {bigint} DiscountStep
|
|
71
74
|
* @property {RelativeTime} AuctionStartDelay
|
|
72
75
|
* @property {RelativeTime} PriceLockPeriod
|
|
73
|
-
* @property {import('@agoric/time
|
|
76
|
+
* @property {import('@agoric/time').TimerBrand} TimerBrand
|
|
74
77
|
*/
|
|
75
78
|
|
|
76
|
-
/**
|
|
77
|
-
* @param {AuctionParams} initial
|
|
78
|
-
*/
|
|
79
|
+
/** @param {AuctionParams} initial */
|
|
79
80
|
export const makeAuctioneerParams = ({
|
|
80
81
|
ElectorateInvitationAmount,
|
|
81
82
|
StartFrequency,
|
|
@@ -148,8 +149,8 @@ export const makeAuctioneerParamManager = (publisherKit, zcf, initial) => {
|
|
|
148
149
|
harden(makeAuctioneerParamManager);
|
|
149
150
|
|
|
150
151
|
/**
|
|
151
|
-
* @param {{storageNode: ERef<StorageNode
|
|
152
|
-
* @param {ERef<
|
|
152
|
+
* @param {{ storageNode: ERef<StorageNode>; marshaller: ERef<Marshaller> }} caps
|
|
153
|
+
* @param {ERef<import('@agoric/time').TimerService>} timer
|
|
153
154
|
* @param {ERef<PriceAuthority>} priceAuthority
|
|
154
155
|
* @param {ERef<AssetReservePublicFacet>} reservePublicFacet
|
|
155
156
|
* @param {AuctionParams} params
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function computeRoundTiming(params: Awaited<import("./params.js").AuctionParamManager>, baseTime: TimestampRecord): import("./scheduler.js").Schedule;
|
|
2
|
+
export function nextDescendingStepTime(liveSchedule: import("./scheduler.js").Schedule | null, nextSchedule: import("./scheduler.js").Schedule | null, now: Timestamp): Timestamp | null;
|
|
3
|
+
export function timeVsSchedule(time: Timestamp, schedule: import("./scheduler.js").Schedule): "before" | "during" | "endExactly" | "after";
|
|
4
|
+
import type { TimestampRecord } from '@agoric/time';
|
|
5
|
+
//# sourceMappingURL=scheduleMath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduleMath.d.ts","sourceRoot":"","sources":["scheduleMath.js"],"names":[],"mappings":"AA0CO,2CAJI,OAAO,CAAC,OAAO,aAAa,EAAE,mBAAmB,CAAC,YAClD,eAAe,GACb,OAAO,gBAAgB,EAAE,QAAQ,CAqE7C;AAcM,qDALI,OAAO,gBAAgB,EAAE,QAAQ,GAAG,IAAI,gBACxC,OAAO,gBAAgB,EAAE,QAAQ,GAAG,IAAI,OACxC,SAAS,GACP,SAAS,GAAG,IAAI,CAuB5B;AAQM,qCAJI,SAAS,YACT,OAAO,gBAAgB,EAAE,QAAQ,GAC/B,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAiBxD;qCAjKkC,cAAc"}
|
|
@@ -4,6 +4,8 @@ import { TimeMath } from '@agoric/time';
|
|
|
4
4
|
import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
5
|
import { assertAllDefined, makeTracer } from '@agoric/internal';
|
|
6
6
|
|
|
7
|
+
/** @import {TimestampRecord} from '@agoric/time'; */
|
|
8
|
+
|
|
7
9
|
const { subtract, multiply, floorDivide } = natSafeMath;
|
|
8
10
|
const { Fail } = assert;
|
|
9
11
|
|
|
@@ -18,23 +20,24 @@ const subtract1 = relTime =>
|
|
|
18
20
|
/**
|
|
19
21
|
* The length of the auction has to be inferred from the governed params.
|
|
20
22
|
*
|
|
21
|
-
* 1. The auction starts by offering collateral at a `StartingRate` (e.g., 105%)
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* 1. The auction starts by offering collateral at a `StartingRate` (e.g., 105%) of
|
|
24
|
+
* the market price at auction start, and continues until it reaches (or
|
|
25
|
+
* would exceed on its next step) LowestRate (e.g., 65%)
|
|
24
26
|
* 2. The offer price changes every `ClockStep` seconds
|
|
25
|
-
* 3. The offer price changes by `DiscountStep` amount (e.g., 5%) each step So
|
|
26
|
-
*
|
|
27
|
-
*
|
|
27
|
+
* 3. The offer price changes by `DiscountStep` amount (e.g., 5%) each step So it
|
|
28
|
+
* must run however many `ClockSteps` are required to get from `StartingRate`
|
|
29
|
+
* to `LowestRate` changing by `DiscountStep` each time.
|
|
28
30
|
*
|
|
29
|
-
* Therefore, the duration is `(StartingRate - LowestRate) / DiscountStep *
|
|
31
|
+
* Therefore, the duration is `(StartingRate - LowestRate) / DiscountStep *
|
|
32
|
+
* ClockStep`.
|
|
30
33
|
*
|
|
31
|
-
* Note that this is what's
|
|
34
|
+
* Note that this is what's _scheduled_. More than one auction can be running
|
|
32
35
|
* simultaneously, and some conditions can cause some of the auctions to stop
|
|
33
36
|
* selling early (e.g. reaching their target debt to raise or selling all of
|
|
34
37
|
* their collateral).
|
|
35
38
|
*
|
|
36
39
|
* @param {Awaited<import('./params.js').AuctionParamManager>} params
|
|
37
|
-
* @param {
|
|
40
|
+
* @param {TimestampRecord} baseTime
|
|
38
41
|
* @returns {import('./scheduler.js').Schedule}
|
|
39
42
|
*/
|
|
40
43
|
export const computeRoundTiming = (params, baseTime) => {
|
|
@@ -82,7 +85,7 @@ export const computeRoundTiming = (params, baseTime) => {
|
|
|
82
85
|
// computed start is `startDelay + baseTime + freq - (baseTime mod freq)`.
|
|
83
86
|
// That is, if there are hourly starts, we add an hour to the time, and
|
|
84
87
|
// subtract baseTime mod freq. Then we add the delay.
|
|
85
|
-
/** @type {
|
|
88
|
+
/** @type {TimestampRecord} */
|
|
86
89
|
const startTime = TimeMath.addAbsRel(
|
|
87
90
|
TimeMath.addAbsRel(
|
|
88
91
|
baseTime,
|
|
@@ -108,10 +111,10 @@ export const computeRoundTiming = (params, baseTime) => {
|
|
|
108
111
|
harden(computeRoundTiming);
|
|
109
112
|
|
|
110
113
|
/**
|
|
111
|
-
* Calculate when the next descending step will start. If we're between
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* the
|
|
114
|
+
* Calculate when the next descending step will start. If we're between auctions
|
|
115
|
+
* (i.e. liveSchedule is undefined), or the last step of the current auction has
|
|
116
|
+
* started, then it'll be nextSchedule.startTime. Otherwise, it's the start of
|
|
117
|
+
* the step following the current step.
|
|
115
118
|
*
|
|
116
119
|
* @param {import('./scheduler.js').Schedule | null} liveSchedule
|
|
117
120
|
* @param {import('./scheduler.js').Schedule | null} nextSchedule
|
|
@@ -143,7 +146,6 @@ export const nextDescendingStepTime = (liveSchedule, nextSchedule, now) => {
|
|
|
143
146
|
harden(nextDescendingStepTime);
|
|
144
147
|
|
|
145
148
|
/**
|
|
146
|
-
*
|
|
147
149
|
* @param {Timestamp} time
|
|
148
150
|
* @param {import('./scheduler.js').Schedule} schedule
|
|
149
151
|
* @returns {'before' | 'during' | 'endExactly' | 'after'}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function makeScheduler(auctionDriver: AuctionDriver, timer: import("@agoric/time").TimerService, params: Awaited<import("./params.js").AuctionParamManager>, timerBrand: import("@agoric/time").TimerBrand, scheduleRecorder: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<ScheduleNotification>, paramUpdateSubscription: StoredSubscription<GovernanceSubscriptionState>): Promise<{
|
|
2
|
+
getSchedule: () => {
|
|
3
|
+
liveAuctionSchedule: Schedule | null;
|
|
4
|
+
nextAuctionSchedule: Schedule | null;
|
|
5
|
+
};
|
|
6
|
+
getAuctionState: () => "active" | "waiting";
|
|
7
|
+
} & import("@endo/marshal").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
8
|
+
getSchedule: () => {
|
|
9
|
+
liveAuctionSchedule: Schedule | null;
|
|
10
|
+
nextAuctionSchedule: Schedule | null;
|
|
11
|
+
};
|
|
12
|
+
getAuctionState: () => "active" | "waiting";
|
|
13
|
+
}>>;
|
|
14
|
+
export type AuctionDriver = {
|
|
15
|
+
reducePriceAndTrade: () => void;
|
|
16
|
+
finalize: () => void;
|
|
17
|
+
startRound: () => void;
|
|
18
|
+
capturePrices: () => void;
|
|
19
|
+
};
|
|
20
|
+
export type ScheduleNotification = {
|
|
21
|
+
/**
|
|
22
|
+
* start time of current auction if
|
|
23
|
+
* auction is active
|
|
24
|
+
*/
|
|
25
|
+
activeStartTime: Timestamp | null;
|
|
26
|
+
/**
|
|
27
|
+
* start time of next auction
|
|
28
|
+
*/
|
|
29
|
+
nextStartTime: Timestamp | null;
|
|
30
|
+
/**
|
|
31
|
+
* when the next descending
|
|
32
|
+
* step will take place
|
|
33
|
+
*/
|
|
34
|
+
nextDescendingStepTime: Timestamp | null;
|
|
35
|
+
};
|
|
36
|
+
export type Schedule = {
|
|
37
|
+
startTime: import("@agoric/time").TimestampRecord;
|
|
38
|
+
endTime: import("@agoric/time").TimestampRecord;
|
|
39
|
+
steps: NatValue;
|
|
40
|
+
endRate: NatValue;
|
|
41
|
+
startDelay: RelativeTime;
|
|
42
|
+
clockStep: RelativeTime;
|
|
43
|
+
lockTime?: Timestamp | undefined;
|
|
44
|
+
};
|
|
45
|
+
export type FullSchedule = {
|
|
46
|
+
nextAuctionSchedule: Schedule | null;
|
|
47
|
+
liveAuctionSchedule: Schedule | null;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["scheduler.js"],"names":[],"mappings":"AA+EO,6CAPI,aAAa,SACb,OAAO,cAAc,EAAE,YAAY,UACnC,OAAO,CAAC,OAAO,aAAa,EAAE,mBAAmB,CAAC,cAClD,OAAO,cAAc,EAAE,UAAU,oBACjC,OAAO,6CAA6C,EAAE,QAAQ,CAAC,oBAAoB,CAAC,2BACpF,kBAAkB,CAAC,2BAA2B,CAAC;;;;;;;;;;;;IA2RzD;;yBA5Ta,MAAM,IAAI;cACV,MAAM,IAAI;gBACV,MAAM,IAAI;mBACV,MAAM,IAAI;;;;;;;qBAKV,SAAS,GAAG,IAAI;;;;mBAEhB,SAAS,GAAG,IAAI;;;;;4BAChB,SAAS,GAAG,IAAI;;;eAqThB,OAAO,cAAc,EAAE,eAAe;aACtC,OAAO,cAAc,EAAE,eAAe;WACtC,QAAQ;aACR,QAAQ;gBACR,YAAY;eACZ,YAAY;;;;yBAMZ,QAAQ,GAAG,IAAI;yBACf,QAAQ,GAAG,IAAI"}
|
package/src/auction/scheduler.js
CHANGED
|
@@ -20,21 +20,22 @@ const MAX_LATE_TICK = 300n;
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @file The scheduler is presumed to be quiescent between auction rounds. Each
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Auction round consists of a sequence of steps with decreasing prices. There
|
|
24
|
+
* should always be a next schedule, but between rounds, liveSchedule is
|
|
25
|
+
* null.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* changed.
|
|
27
|
+
* The lock period that the liquidators use might start before the previous
|
|
28
|
+
* round has finished, so we need to schedule the next round each time an
|
|
29
|
+
* auction starts. This means if the scheduling parameters change, it'll be a
|
|
30
|
+
* full cycle before we switch. Otherwise, the vaults wouldn't know when to
|
|
31
|
+
* start their lock period. If the lock period for the next auction hasn't
|
|
32
|
+
* started when each aucion ends, we recalculate it, in case the parameters
|
|
33
|
+
* have changed.
|
|
33
34
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* If the clock skips forward (because of a chain halt, for instance), the
|
|
36
|
+
* scheduler will try to cleanly and quickly finish any round already in
|
|
37
|
+
* progress. It would take additional work on the manual timer to test this
|
|
38
|
+
* thoroughly.
|
|
38
39
|
*/
|
|
39
40
|
|
|
40
41
|
const makeCancelToken = makeCancelTokenMaker('scheduler');
|
|
@@ -49,12 +50,11 @@ const makeCancelToken = makeCancelTokenMaker('scheduler');
|
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* @typedef {object} ScheduleNotification
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* auction if auction is active
|
|
53
|
+
* @property {Timestamp | null} activeStartTime start time of current auction if
|
|
54
|
+
* auction is active
|
|
55
55
|
* @property {Timestamp | null} nextStartTime start time of next auction
|
|
56
|
-
* @property {Timestamp | null} nextDescendingStepTime when the next descending
|
|
57
|
-
*
|
|
56
|
+
* @property {Timestamp | null} nextDescendingStepTime when the next descending
|
|
57
|
+
* step will take place
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
60
|
const safelyComputeRoundTiming = (params, baseTime) => {
|
|
@@ -71,9 +71,9 @@ const nominalStartTime = nextSchedule =>
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @param {AuctionDriver} auctionDriver
|
|
74
|
-
* @param {import('@agoric/time
|
|
74
|
+
* @param {import('@agoric/time').TimerService} timer
|
|
75
75
|
* @param {Awaited<import('./params.js').AuctionParamManager>} params
|
|
76
|
-
* @param {import('@agoric/time
|
|
76
|
+
* @param {import('@agoric/time').TimerBrand} timerBrand
|
|
77
77
|
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<ScheduleNotification>} scheduleRecorder
|
|
78
78
|
* @param {StoredSubscription<GovernanceSubscriptionState>} paramUpdateSubscription
|
|
79
79
|
*/
|
|
@@ -92,7 +92,7 @@ export const makeScheduler = async (
|
|
|
92
92
|
*/
|
|
93
93
|
let liveSchedule = null;
|
|
94
94
|
|
|
95
|
-
/** @returns {Promise<{ now: Timestamp
|
|
95
|
+
/** @returns {Promise<{ now: Timestamp; nextSchedule: Schedule | null }>} */
|
|
96
96
|
const initializeNextSchedule = async () => {
|
|
97
97
|
return E.when(
|
|
98
98
|
// XXX manualTimer returns a bigint, not a timeRecord.
|
|
@@ -114,7 +114,7 @@ export const makeScheduler = async (
|
|
|
114
114
|
|
|
115
115
|
const stepCancelToken = makeCancelToken();
|
|
116
116
|
|
|
117
|
-
/** @type {typeof AuctionState[keyof typeof AuctionState]} */
|
|
117
|
+
/** @type {(typeof AuctionState)[keyof typeof AuctionState]} */
|
|
118
118
|
let auctionState = AuctionState.WAITING;
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -149,18 +149,7 @@ export const makeScheduler = async (
|
|
|
149
149
|
auctionState = AuctionState.WAITING;
|
|
150
150
|
auctionDriver.finalize();
|
|
151
151
|
|
|
152
|
-
if (nextSchedule) {
|
|
153
|
-
// only recalculate the next schedule at this point if the lock time has
|
|
154
|
-
// not been reached.
|
|
155
|
-
const nextLock = nextSchedule.lockTime;
|
|
156
|
-
if (nextLock && TimeMath.compareAbs(now, nextLock) < 0) {
|
|
157
|
-
const afterNow = TimeMath.addAbsRel(
|
|
158
|
-
now,
|
|
159
|
-
TimeMath.coerceRelativeTimeRecord(1n, timerBrand),
|
|
160
|
-
);
|
|
161
|
-
nextSchedule = safelyComputeRoundTiming(params, afterNow);
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
152
|
+
if (!nextSchedule) {
|
|
164
153
|
console.error(
|
|
165
154
|
'🛠️ finishAuctionRound without scheduling the next; repair with new auctioneer params',
|
|
166
155
|
);
|
|
@@ -233,9 +222,13 @@ export const makeScheduler = async (
|
|
|
233
222
|
liveSchedule.clockStep,
|
|
234
223
|
Far('PriceStepWaker', {
|
|
235
224
|
wake(time) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
225
|
+
try {
|
|
226
|
+
setTimeMonotonically(time);
|
|
227
|
+
trace('wake step', now);
|
|
228
|
+
clockTick(liveSchedule);
|
|
229
|
+
} catch (e) {
|
|
230
|
+
console.error(`⚠️ Auction threw ${e}. Caught in PriceStepWaker.`);
|
|
231
|
+
}
|
|
239
232
|
},
|
|
240
233
|
}),
|
|
241
234
|
stepCancelToken,
|
|
@@ -249,10 +242,14 @@ export const makeScheduler = async (
|
|
|
249
242
|
start,
|
|
250
243
|
Far('SchedulerWaker', {
|
|
251
244
|
wake(time) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
245
|
+
try {
|
|
246
|
+
setTimeMonotonically(time);
|
|
247
|
+
auctionDriver.capturePrices();
|
|
248
|
+
// eslint-disable-next-line no-use-before-define
|
|
249
|
+
return startAuction();
|
|
250
|
+
} catch (e) {
|
|
251
|
+
console.error(`⚠️ Auction threw ${e}. Caught in SchedulerWaker.`);
|
|
252
|
+
}
|
|
256
253
|
},
|
|
257
254
|
}),
|
|
258
255
|
);
|
|
@@ -333,7 +330,18 @@ export const makeScheduler = async (
|
|
|
333
330
|
// NB: may be fired with the initial params as well
|
|
334
331
|
async updateState(_newState) {
|
|
335
332
|
trace('received param update', _newState);
|
|
333
|
+
await null;
|
|
334
|
+
|
|
335
|
+
let fixableSchedule;
|
|
336
336
|
if (!nextSchedule) {
|
|
337
|
+
fixableSchedule = true;
|
|
338
|
+
} else {
|
|
339
|
+
now = await E(timer).getCurrentTimestamp();
|
|
340
|
+
fixableSchedule =
|
|
341
|
+
TimeMath.compareAbs(nextSchedule.startTime, now) < 0;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (fixableSchedule) {
|
|
337
345
|
trace('repairing nextSchedule and restarting');
|
|
338
346
|
({ nextSchedule } = await initializeNextSchedule());
|
|
339
347
|
startSchedulingFromScratch();
|
|
@@ -354,8 +362,8 @@ export const makeScheduler = async (
|
|
|
354
362
|
|
|
355
363
|
/**
|
|
356
364
|
* @typedef {object} Schedule
|
|
357
|
-
* @property {import('@agoric/time
|
|
358
|
-
* @property {import('@agoric/time
|
|
365
|
+
* @property {import('@agoric/time').TimestampRecord} startTime
|
|
366
|
+
* @property {import('@agoric/time').TimestampRecord} endTime
|
|
359
367
|
* @property {NatValue} steps
|
|
360
368
|
* @property {NatValue} endRate
|
|
361
369
|
* @property {RelativeTime} startDelay
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function toPartialOfferKey(offerPrice: Ratio): string;
|
|
2
|
+
export function toPriceOfferKey(offerPrice: Ratio, sequenceNumber: bigint): string;
|
|
3
|
+
export function fromPriceOfferKey(key: string, numBrand: Brand<"nat">, denomBrand: Brand<"nat">, useDecimals: number): [normalizedPrice: Ratio, sequenceNumber: bigint];
|
|
4
|
+
/** @type {(rate: Ratio) => string} */
|
|
5
|
+
export const toBidScalingComparator: (rate: Ratio) => string;
|
|
6
|
+
export function toScaledRateOfferKey(rate: Ratio, sequenceNumber: bigint): string;
|
|
7
|
+
export function fromScaledRateOfferKey(key: string, brand: Brand, useDecimals: number): [normalizedPrice: Ratio, sequenceNumber: bigint];
|
|
8
|
+
//# sourceMappingURL=sortedOffers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortedOffers.d.ts","sourceRoot":"","sources":["sortedOffers.js"],"names":[],"mappings":"AA8BO,8CAFI,KAAK,UAMf;AAUM,4CALI,KAAK,kBACL,MAAM,GACJ,MAAM,CAWlB;AAqCM,uCANI,MAAM,YACN,KAAK,CAAC,KAAK,CAAC,cACZ,KAAK,CAAC,KAAK,CAAC,eACZ,MAAM,GACJ,CAAC,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAS5D;AAED,sCAAsC;AACtC,qCADW,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAKhC;AAUK,2CALI,KAAK,kBACL,MAAM,GACJ,MAAM,CAWlB;AAUM,4CALI,MAAM,SACN,KAAK,eACL,MAAM,GACJ,CAAC,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,CAQ5D"}
|