@agoric/inter-protocol 0.16.2-upgrade-14-dev-0169c7e.0 → 0.16.2-upgrade-16-dev-8879538.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/package.json +41 -34
- package/scripts/build-bundles.js +5 -21
- package/src/auction/auctionBook.d.ts +84 -0
- package/src/auction/auctionBook.d.ts.map +1 -0
- package/src/auction/auctionBook.js +135 -103
- package/src/auction/auctioneer.d.ts +83 -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 +149 -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 +97 -40
- 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 +238 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +77 -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 +181 -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 +1169 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -0
- package/src/proposals/econ-behaviors.js +66 -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 +202 -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 +770 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +463 -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 +163 -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 +360 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +8 -11
- package/src/vaultFactory/params.d.ts +145 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +52 -24
- package/src/vaultFactory/prioritizedVaults.d.ts +992 -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 +234 -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 +402 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +99 -93
- package/src/vaultFactory/vaultDirector.d.ts +388 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +61 -50
- package/src/vaultFactory/vaultFactory.d.ts +277 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +49 -32
- package/src/vaultFactory/vaultHolder.d.ts +270 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +10 -14
- package/src/vaultFactory/vaultKit.d.ts +102 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +5 -4
- package/src/vaultFactory/vaultManager.d.ts +819 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +248 -151
- package/CHANGELOG.md +0 -1066
- package/exported.js +0 -2
- package/scripts/add-collateral-core.js +0 -113
- package/scripts/deploy-contracts.js +0 -100
- package/scripts/init-core.js +0 -200
- 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
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.2-upgrade-
|
|
3
|
+
"version": "0.16.2-upgrade-16-dev-8879538.0+8879538",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": "^18.12 || ^20.9"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "yarn build:bundles",
|
|
12
12
|
"build:bundles": "node ./scripts/build-bundles.js",
|
|
13
|
+
"prepack": "tsc --build tsconfig.build.json",
|
|
14
|
+
"postpack": "git clean -f '*.d.ts*'",
|
|
13
15
|
"test": "ava",
|
|
14
16
|
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
|
|
15
17
|
"test:xs": "exit 0",
|
|
16
18
|
"lint-fix": "yarn lint:eslint --fix",
|
|
17
19
|
"lint": "run-s --continue-on-error lint:*",
|
|
18
20
|
"lint:eslint": "eslint .",
|
|
19
|
-
"lint:types": "tsc
|
|
21
|
+
"lint:types": "tsc"
|
|
20
22
|
},
|
|
21
23
|
"repository": {
|
|
22
24
|
"type": "git",
|
|
@@ -29,53 +31,58 @@
|
|
|
29
31
|
},
|
|
30
32
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "0.6.1-upgrade-
|
|
33
|
-
"@agoric/ertp": "0.16.3-upgrade-
|
|
34
|
-
"@agoric/governance": "0.10.4-upgrade-
|
|
35
|
-
"@agoric/internal": "0.
|
|
36
|
-
"@agoric/notifier": "0.6.3-upgrade-
|
|
37
|
-
"@agoric/store": "0.9.3-upgrade-
|
|
38
|
-
"@agoric/time": "0.3.3-upgrade-
|
|
39
|
-
"@agoric/vat-data": "0.5.3-upgrade-
|
|
40
|
-
"@agoric/vats": "0.15.2-upgrade-
|
|
41
|
-
"@agoric/zoe": "0.26.3-upgrade-
|
|
42
|
-
"@endo/captp": "
|
|
43
|
-
"@endo/eventual-send": "
|
|
44
|
-
"@endo/far": "
|
|
45
|
-
"@endo/marshal": "
|
|
46
|
-
"@endo/nat": "
|
|
47
|
-
"
|
|
34
|
+
"@agoric/assert": "0.6.1-upgrade-16-dev-8879538.0+8879538",
|
|
35
|
+
"@agoric/ertp": "0.16.3-upgrade-16-dev-8879538.0+8879538",
|
|
36
|
+
"@agoric/governance": "0.10.4-upgrade-16-dev-8879538.0+8879538",
|
|
37
|
+
"@agoric/internal": "0.3.3-upgrade-16-dev-8879538.0+8879538",
|
|
38
|
+
"@agoric/notifier": "0.6.3-upgrade-16-dev-8879538.0+8879538",
|
|
39
|
+
"@agoric/store": "0.9.3-upgrade-16-dev-8879538.0+8879538",
|
|
40
|
+
"@agoric/time": "0.3.3-upgrade-16-dev-8879538.0+8879538",
|
|
41
|
+
"@agoric/vat-data": "0.5.3-upgrade-16-dev-8879538.0+8879538",
|
|
42
|
+
"@agoric/vats": "0.15.2-upgrade-16-dev-8879538.0+8879538",
|
|
43
|
+
"@agoric/zoe": "0.26.3-upgrade-16-dev-8879538.0+8879538",
|
|
44
|
+
"@endo/captp": "^4.2.0",
|
|
45
|
+
"@endo/eventual-send": "^1.2.2",
|
|
46
|
+
"@endo/far": "^1.1.2",
|
|
47
|
+
"@endo/marshal": "^1.5.0",
|
|
48
|
+
"@endo/nat": "^5.0.7",
|
|
49
|
+
"@endo/promise-kit": "^1.1.2",
|
|
50
|
+
"jessie.js": "^0.3.4"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
|
-
"@agoric/
|
|
51
|
-
"@agoric/
|
|
52
|
-
"@agoric/swingset-
|
|
53
|
-
"@agoric/
|
|
54
|
-
"@endo/bundle-source": "2.
|
|
55
|
-
"@endo/init": "
|
|
56
|
-
"@endo/promise-kit": "
|
|
57
|
-
"@fast-check/ava": "^1.1.
|
|
58
|
-
"ava": "^5.
|
|
59
|
-
"c8": "^
|
|
53
|
+
"@agoric/smart-wallet": "0.5.4-upgrade-16-dev-8879538.0+8879538",
|
|
54
|
+
"@agoric/swingset-liveslots": "0.10.3-upgrade-16-dev-8879538.0+8879538",
|
|
55
|
+
"@agoric/swingset-vat": "0.32.3-upgrade-16-dev-8879538.0+8879538",
|
|
56
|
+
"@agoric/zone": "0.2.3-upgrade-16-dev-8879538.0+8879538",
|
|
57
|
+
"@endo/bundle-source": "^3.2.3",
|
|
58
|
+
"@endo/init": "^1.1.2",
|
|
59
|
+
"@endo/promise-kit": "^1.1.2",
|
|
60
|
+
"@fast-check/ava": "^1.1.5",
|
|
61
|
+
"ava": "^5.3.0",
|
|
62
|
+
"c8": "^9.1.0",
|
|
60
63
|
"deep-object-diff": "^1.1.9",
|
|
61
64
|
"import-meta-resolve": "^2.2.1"
|
|
62
65
|
},
|
|
63
66
|
"files": [
|
|
64
|
-
"scripts
|
|
67
|
+
"scripts",
|
|
65
68
|
"src/",
|
|
66
|
-
"exported.js",
|
|
67
69
|
"NEWS.md"
|
|
68
70
|
],
|
|
69
71
|
"ava": {
|
|
70
72
|
"files": [
|
|
71
|
-
"test
|
|
73
|
+
"test/**/*.test.*"
|
|
74
|
+
],
|
|
75
|
+
"require": [
|
|
76
|
+
"@endo/init/debug.js"
|
|
72
77
|
],
|
|
73
|
-
"concurrency": 2,
|
|
74
78
|
"workerThreads": false,
|
|
75
79
|
"timeout": "10m"
|
|
76
80
|
},
|
|
77
81
|
"publishConfig": {
|
|
78
82
|
"access": "public"
|
|
79
83
|
},
|
|
80
|
-
"
|
|
84
|
+
"typeCoverage": {
|
|
85
|
+
"atLeast": 95.87
|
|
86
|
+
},
|
|
87
|
+
"gitHead": "8879538cd1d125a08346f02dd5701d0d70c90bb8"
|
|
81
88
|
}
|
package/scripts/build-bundles.js
CHANGED
|
@@ -1,36 +1,20 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import '@endo/init';
|
|
3
|
-
import {
|
|
4
|
-
createBundles,
|
|
5
|
-
extractProposalBundles,
|
|
6
|
-
} from '@agoric/internal/src/node/createBundles.js';
|
|
7
|
-
import url from 'url';
|
|
8
|
-
import process from 'process';
|
|
9
|
-
|
|
10
|
-
import { defaultProposalBuilder } from './init-core.js';
|
|
11
|
-
import { defaultProposalBuilder as collateralProposalBuilder } from './add-collateral-core.js';
|
|
12
3
|
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { createBundles } from '@agoric/internal/src/node/createBundles.js';
|
|
5
|
+
import url from 'url';
|
|
15
6
|
|
|
16
7
|
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
17
|
-
await extractProposalBundles(
|
|
18
|
-
[
|
|
19
|
-
['.', defaultProposalBuilder],
|
|
20
|
-
['.', collateralProposalBuilder],
|
|
21
|
-
],
|
|
22
|
-
dirname,
|
|
23
|
-
);
|
|
24
8
|
|
|
25
9
|
await createBundles(
|
|
26
10
|
[
|
|
27
|
-
['
|
|
11
|
+
['@agoric/inter-protocol/src/psm/psm.js', '../bundles/bundle-psm.js'],
|
|
28
12
|
[
|
|
29
|
-
'
|
|
13
|
+
'@agoric/inter-protocol/src/econCommitteeCharter.js',
|
|
30
14
|
'../bundles/bundle-econCommitteeCharter.js',
|
|
31
15
|
],
|
|
32
16
|
[
|
|
33
|
-
'
|
|
17
|
+
'@agoric/inter-protocol/src/price/fluxAggregatorContract.js',
|
|
34
18
|
'../bundles/bundle-fluxAggregatorKit.js',
|
|
35
19
|
],
|
|
36
20
|
],
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export function makeOfferSpecShape(bidBrand: Brand<"nat">, collateralBrand: Brand<"nat">): import("@endo/patterns").Matcher;
|
|
2
|
+
export function prepareAuctionBook(baggage: Baggage, zcf: ZCF, makeRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorderKit): (bidBrand: globalThis.Brand<"nat">, collateralBrand: globalThis.Brand<"nat">, pAuthority: PriceAuthority, node: globalThis.StorageNode) => import("@endo/exo").Guarded<{
|
|
3
|
+
/**
|
|
4
|
+
* @param {Amount<'nat'>} assetAmount
|
|
5
|
+
* @param {ZCFSeat} sourceSeat
|
|
6
|
+
* @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
|
|
7
|
+
* would like to raise. The auction is requested to not sell more
|
|
8
|
+
* collateral than required to raise that much. The auctioneer might
|
|
9
|
+
* sell more if there is more than one supplier of collateral, and
|
|
10
|
+
* they request inconsistent limits.
|
|
11
|
+
*/
|
|
12
|
+
addAssets(assetAmount: Amount<"nat">, sourceSeat: ZCFSeat, proceedsGoal?: import("@agoric/ertp/src/types.js").NatAmount | undefined): void;
|
|
13
|
+
/** @type {(reduction: Ratio) => void} */
|
|
14
|
+
settleAtNewRate(reduction: Ratio): void;
|
|
15
|
+
getCurrentPrice(): Ratio | null;
|
|
16
|
+
hasOrders(): boolean;
|
|
17
|
+
captureOraclePriceForRound(): void;
|
|
18
|
+
setStartingRate(rate: any): void;
|
|
19
|
+
/**
|
|
20
|
+
* @param {OfferSpec} offerSpec
|
|
21
|
+
* @param {ZCFSeat} seat
|
|
22
|
+
* @param {boolean} trySettle
|
|
23
|
+
*/
|
|
24
|
+
addOffer(offerSpec: OfferSpec, seat: ZCFSeat, trySettle: boolean): void;
|
|
25
|
+
getSeats(): {
|
|
26
|
+
collateralSeat: ZCFSeat;
|
|
27
|
+
bidHoldingSeat: ZCFSeat;
|
|
28
|
+
};
|
|
29
|
+
exitAllSeats(): void;
|
|
30
|
+
endAuction(): void;
|
|
31
|
+
getDataUpdates(): globalThis.Subscriber<BookDataNotification>;
|
|
32
|
+
getPublicTopics(): {
|
|
33
|
+
bookData: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<BookDataNotification>;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
export type OfferSpec = {
|
|
37
|
+
maxBuy: Amount<"nat">;
|
|
38
|
+
} & {
|
|
39
|
+
exitAfterBuy?: boolean;
|
|
40
|
+
} & ({
|
|
41
|
+
offerPrice: Ratio;
|
|
42
|
+
} | {
|
|
43
|
+
offerBidScaling: Ratio;
|
|
44
|
+
});
|
|
45
|
+
export type BookDataNotification = {
|
|
46
|
+
/**
|
|
47
|
+
* identifies the priceAuthority and price
|
|
48
|
+
*/
|
|
49
|
+
startPrice: Ratio | null;
|
|
50
|
+
/**
|
|
51
|
+
* the price at the current auction
|
|
52
|
+
* tier
|
|
53
|
+
*/
|
|
54
|
+
currentPriceLevel: Ratio | null;
|
|
55
|
+
/**
|
|
56
|
+
* The proceeds the sellers
|
|
57
|
+
* were targeting to raise
|
|
58
|
+
*/
|
|
59
|
+
startProceedsGoal: Amount<"nat"> | null;
|
|
60
|
+
/**
|
|
61
|
+
* The remainder of the
|
|
62
|
+
* proceeds the sellers were targeting to raise
|
|
63
|
+
*/
|
|
64
|
+
remainingProceedsGoal: Amount<"nat"> | null;
|
|
65
|
+
/**
|
|
66
|
+
* The proceeds raised so
|
|
67
|
+
* far in the auction
|
|
68
|
+
*/
|
|
69
|
+
proceedsRaised: Amount<"nat"> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* How much collateral was available
|
|
72
|
+
* for sale at the start. (If more is deposited later, it'll be added in.)
|
|
73
|
+
*/
|
|
74
|
+
startCollateral: Amount<"nat">;
|
|
75
|
+
/**
|
|
76
|
+
* The amount of collateral
|
|
77
|
+
* remaining
|
|
78
|
+
*/
|
|
79
|
+
collateralAvailable: Amount<"nat"> | null;
|
|
80
|
+
};
|
|
81
|
+
export type AuctionBook = ReturnType<ReturnType<typeof prepareAuctionBook>>;
|
|
82
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
83
|
+
import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
|
|
84
|
+
//# sourceMappingURL=auctionBook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionBook.d.ts","sourceRoot":"","sources":["auctionBook.js"],"names":[],"mappings":"AA8EO,6CAHI,KAAK,CAAC,KAAK,CAAC,mBACZ,KAAK,CAAC,KAAK,CAAC,oCAiBtB;AAwBM,0DAHI,GAAG,mBACH,OAAO,6CAA6C,EAAE,eAAe;IA6YxE;;;;;;;;OAQG;2BAPQ,MAAM,CAAC,KAAK,CAAC,cACb,OAAO;IA6ElB,yCAAyC;+BAAlB,KAAK,GAAK,IAAI;;;;;IA4GrC;;;;OAIG;wBAHQ,SAAS,QACT,OAAO,aACP,OAAO;;;;;;;;;;;GAyFzB;wBA1tBY;IACZ,MAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CACvB,GAAG;IACN,YAAgB,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,CACE;IACR,UAAoB,EAAE,KAAK,CAAC;CACnB,GACD;IACR,eAAyB,EAAE,KAAK,CAAC;CACxB,CACJ;;;;;gBAyBQ,KAAK,GAAG,IAAI;;;;;uBACZ,KAAK,GAAG,IAAI;;;;;uBAEZ,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;;;;2BAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;;;;oBAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS;;;;;qBAEzB,MAAM,CAAC,KAAK,CAAC;;;;;yBAEb,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI;;0BA8qBpB,UAAU,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;6BA5vBrC,kBAAkB;oCACiD,4BAA4B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/// <reference types="@agoric/internal/exported" />
|
|
2
|
+
/// <reference types="@agoric/governance/exported" />
|
|
3
|
+
/// <reference types="@agoric/zoe/exported" />
|
|
4
4
|
|
|
5
|
-
import { AmountMath } from '@agoric/ertp';
|
|
5
|
+
import { AmountMath, RatioShape } from '@agoric/ertp';
|
|
6
6
|
import { mustMatch } from '@agoric/store';
|
|
7
7
|
import { M, prepareExoClassKit } from '@agoric/vat-data';
|
|
8
8
|
|
|
@@ -27,6 +27,11 @@ import {
|
|
|
27
27
|
priceFrom,
|
|
28
28
|
} from './util.js';
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
32
|
+
* @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js';
|
|
33
|
+
*/
|
|
34
|
+
|
|
30
35
|
const { Fail } = assert;
|
|
31
36
|
const { makeEmpty } = AmountMath;
|
|
32
37
|
|
|
@@ -34,34 +39,38 @@ const DEFAULT_DECIMALS = 9;
|
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* @file The book represents the collateral-specific state of an ongoing
|
|
37
|
-
*
|
|
38
|
-
* the allocation of assets for sale.
|
|
42
|
+
* auction. It holds the book, the capturedPrice, and the collateralSeat that
|
|
43
|
+
* has the allocation of assets for sale.
|
|
44
|
+
*
|
|
45
|
+
* The book contains orders for the collateral. It holds two kinds of orders:
|
|
39
46
|
*
|
|
40
|
-
* The book contains orders for the collateral. It holds two kinds of
|
|
41
|
-
* orders:
|
|
42
47
|
* - Prices express the bidding offer in terms of a Bid amount
|
|
43
|
-
* - ScaledBids express the offer in terms of a discount (or markup) from the
|
|
44
|
-
*
|
|
48
|
+
* - ScaledBids express the offer in terms of a discount (or markup) from the most
|
|
49
|
+
* recent oracle price.
|
|
45
50
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
+
* Offers can be added in three ways. 1) When the auction is not active, prices
|
|
52
|
+
* are automatically added to the appropriate collection. When the auction is
|
|
53
|
+
* active, 2) if a new offer is at or above the current price, it will be
|
|
54
|
+
* settled immediately; 2) If the offer is below the current price, it will be
|
|
55
|
+
* added in the appropriate place and settled when the price reaches that
|
|
56
|
+
* level.
|
|
51
57
|
*/
|
|
52
58
|
|
|
53
59
|
const trace = makeTracer('AucBook', true);
|
|
54
60
|
|
|
55
61
|
/**
|
|
56
62
|
* @typedef {{
|
|
57
|
-
* maxBuy: Amount<'nat'
|
|
63
|
+
* maxBuy: Amount<'nat'>;
|
|
58
64
|
* } & {
|
|
59
|
-
* exitAfterBuy?: boolean
|
|
60
|
-
* } & (
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
+
* exitAfterBuy?: boolean;
|
|
66
|
+
* } & (
|
|
67
|
+
* | {
|
|
68
|
+
* offerPrice: Ratio;
|
|
69
|
+
* }
|
|
70
|
+
* | {
|
|
71
|
+
* offerBidScaling: Ratio;
|
|
72
|
+
* }
|
|
73
|
+
* )} OfferSpec
|
|
65
74
|
*/
|
|
66
75
|
/**
|
|
67
76
|
* @param {Brand<'nat'>} bidBrand
|
|
@@ -84,21 +93,21 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
|
|
|
84
93
|
);
|
|
85
94
|
};
|
|
86
95
|
|
|
87
|
-
/** @typedef {import('@agoric/vat-data').Baggage} Baggage */
|
|
88
|
-
|
|
89
96
|
/**
|
|
90
97
|
* @typedef {object} BookDataNotification
|
|
91
|
-
*
|
|
92
|
-
* @property {Ratio
|
|
93
|
-
*
|
|
94
|
-
* @property {Amount<'nat'> | null}
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @property {Amount<'nat'>}
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
98
|
+
* @property {Ratio | null} startPrice identifies the priceAuthority and price
|
|
99
|
+
* @property {Ratio | null} currentPriceLevel the price at the current auction
|
|
100
|
+
* tier
|
|
101
|
+
* @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers
|
|
102
|
+
* were targeting to raise
|
|
103
|
+
* @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of the
|
|
104
|
+
* proceeds the sellers were targeting to raise
|
|
105
|
+
* @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so
|
|
106
|
+
* far in the auction
|
|
107
|
+
* @property {Amount<'nat'>} startCollateral How much collateral was available
|
|
108
|
+
* for sale at the start. (If more is deposited later, it'll be added in.)
|
|
109
|
+
* @property {Amount<'nat'> | null} collateralAvailable The amount of collateral
|
|
110
|
+
* remaining
|
|
102
111
|
*/
|
|
103
112
|
|
|
104
113
|
/**
|
|
@@ -118,7 +127,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
118
127
|
bidHoldingSeat: M.any(),
|
|
119
128
|
bidAmountShape: M.any(),
|
|
120
129
|
priceAuthority: M.any(),
|
|
121
|
-
updatingOracleQuote: M.
|
|
130
|
+
updatingOracleQuote: M.or(RatioShape, M.null()),
|
|
122
131
|
bookDataKit: M.any(),
|
|
123
132
|
priceBook: M.any(),
|
|
124
133
|
scaledBidBook: M.any(),
|
|
@@ -141,11 +150,6 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
141
150
|
*/
|
|
142
151
|
(bidBrand, collateralBrand, pAuthority, node) => {
|
|
143
152
|
assertAllDefined({ bidBrand, collateralBrand, pAuthority });
|
|
144
|
-
const zeroBid = makeEmpty(bidBrand);
|
|
145
|
-
const zeroRatio = makeRatioFromAmounts(
|
|
146
|
-
zeroBid,
|
|
147
|
-
AmountMath.make(collateralBrand, 1n),
|
|
148
|
-
);
|
|
149
153
|
|
|
150
154
|
// these don't have to be durable, since we're currently assuming that upgrade
|
|
151
155
|
// from a quiescent state is sufficient. When the auction is quiescent, there
|
|
@@ -182,7 +186,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
182
186
|
bidAmountShape,
|
|
183
187
|
|
|
184
188
|
priceAuthority: pAuthority,
|
|
185
|
-
updatingOracleQuote:
|
|
189
|
+
updatingOracleQuote: /** @type {Ratio | null} */ (null),
|
|
186
190
|
|
|
187
191
|
bookDataKit,
|
|
188
192
|
|
|
@@ -231,8 +235,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
231
235
|
{
|
|
232
236
|
helper: {
|
|
233
237
|
/**
|
|
234
|
-
* remove the key from the appropriate book, indicated by whether the
|
|
235
|
-
* is defined.
|
|
238
|
+
* remove the key from the appropriate book, indicated by whether the
|
|
239
|
+
* price is defined.
|
|
236
240
|
*
|
|
237
241
|
* @param {string} key
|
|
238
242
|
* @param {Ratio | undefined} price
|
|
@@ -247,8 +251,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
247
251
|
},
|
|
248
252
|
|
|
249
253
|
/**
|
|
250
|
-
* Update the entry in the appropriate book, indicated by whether the
|
|
251
|
-
* is defined.
|
|
254
|
+
* Update the entry in the appropriate book, indicated by whether the
|
|
255
|
+
* price is defined.
|
|
252
256
|
*
|
|
253
257
|
* @param {string} key
|
|
254
258
|
* @param {Amount} collateralSold
|
|
@@ -264,7 +268,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
264
268
|
},
|
|
265
269
|
|
|
266
270
|
/**
|
|
267
|
-
* Settle with seat. The caller is responsible for updating the book, if
|
|
271
|
+
* Settle with seat. The caller is responsible for updating the book, if
|
|
272
|
+
* any.
|
|
268
273
|
*
|
|
269
274
|
* @param {ZCFSeat} seat
|
|
270
275
|
* @param {Amount<'nat'>} collateralWanted
|
|
@@ -341,15 +346,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
341
346
|
},
|
|
342
347
|
|
|
343
348
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
349
|
+
* Accept an offer expressed as a price. If the auction is active,
|
|
350
|
+
* attempt to buy collateral. If any of the offer remains add it to the
|
|
351
|
+
* book.
|
|
346
352
|
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
+
* @param {ZCFSeat} seat
|
|
354
|
+
* @param {Ratio} price
|
|
355
|
+
* @param {Amount<'nat'>} maxBuy
|
|
356
|
+
* @param {object} opts
|
|
357
|
+
* @param {boolean} opts.trySettle
|
|
358
|
+
* @param {boolean} [opts.exitAfterBuy]
|
|
353
359
|
*/
|
|
354
360
|
acceptPriceOffer(
|
|
355
361
|
seat,
|
|
@@ -388,16 +394,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
388
394
|
},
|
|
389
395
|
|
|
390
396
|
/**
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
397
|
+
* Accept an offer expressed as a discount (or markup). If the auction
|
|
398
|
+
* is active, attempt to buy collateral. If any of the offer remains add
|
|
399
|
+
* it to the book.
|
|
394
400
|
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
+
* @param {ZCFSeat} seat
|
|
402
|
+
* @param {Ratio} bidScaling
|
|
403
|
+
* @param {Amount<'nat'>} maxBuy
|
|
404
|
+
* @param {object} opts
|
|
405
|
+
* @param {boolean} opts.trySettle
|
|
406
|
+
* @param {boolean} [opts.exitAfterBuy]
|
|
401
407
|
*/
|
|
402
408
|
acceptScaledBidOffer(
|
|
403
409
|
seat,
|
|
@@ -460,16 +466,58 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
460
466
|
});
|
|
461
467
|
return state.bookDataKit.recorder.write(bookData);
|
|
462
468
|
},
|
|
469
|
+
observeQuoteNotifier() {
|
|
470
|
+
const { state, facets } = this;
|
|
471
|
+
const { collateralBrand, bidBrand, priceAuthority } = state;
|
|
472
|
+
|
|
473
|
+
trace('observing');
|
|
474
|
+
|
|
475
|
+
void E.when(
|
|
476
|
+
E(collateralBrand).getDisplayInfo(),
|
|
477
|
+
({ decimalPlaces = DEFAULT_DECIMALS }) => {
|
|
478
|
+
const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
|
|
479
|
+
AmountMath.make(collateralBrand, 10n ** BigInt(decimalPlaces)),
|
|
480
|
+
bidBrand,
|
|
481
|
+
);
|
|
482
|
+
void observeNotifier(quoteNotifier, {
|
|
483
|
+
updateState: quote => {
|
|
484
|
+
trace(
|
|
485
|
+
`BOOK notifier ${priceFrom(quote).numerator.value}/${
|
|
486
|
+
priceFrom(quote).denominator.value
|
|
487
|
+
}`,
|
|
488
|
+
);
|
|
489
|
+
state.updatingOracleQuote = priceFrom(quote);
|
|
490
|
+
},
|
|
491
|
+
fail: reason => {
|
|
492
|
+
trace(
|
|
493
|
+
`Failure from quoteNotifier (${reason}) setting to null`,
|
|
494
|
+
);
|
|
495
|
+
// lack of quote will trigger restart
|
|
496
|
+
state.updatingOracleQuote = null;
|
|
497
|
+
},
|
|
498
|
+
finish: done => {
|
|
499
|
+
trace(
|
|
500
|
+
`quoteNotifier invoked finish(${done}). setting quote to null`,
|
|
501
|
+
);
|
|
502
|
+
// lack of quote will trigger restart
|
|
503
|
+
state.updatingOracleQuote = null;
|
|
504
|
+
},
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
void facets.helper.publishBookData();
|
|
510
|
+
},
|
|
463
511
|
},
|
|
464
512
|
self: {
|
|
465
513
|
/**
|
|
466
514
|
* @param {Amount<'nat'>} assetAmount
|
|
467
515
|
* @param {ZCFSeat} sourceSeat
|
|
468
516
|
* @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
517
|
+
* would like to raise. The auction is requested to not sell more
|
|
518
|
+
* collateral than required to raise that much. The auctioneer might
|
|
519
|
+
* sell more if there is more than one supplier of collateral, and
|
|
520
|
+
* they request inconsistent limits.
|
|
473
521
|
*/
|
|
474
522
|
addAssets(assetAmount, sourceSeat, proceedsGoal) {
|
|
475
523
|
const { state, facets } = this;
|
|
@@ -547,9 +595,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
547
595
|
|
|
548
596
|
trace(this.state.collateralBrand, 'settleAtNewRate', reduction);
|
|
549
597
|
const { capturedPriceForRound, priceBook, scaledBidBook } = state;
|
|
550
|
-
capturedPriceForRound
|
|
551
|
-
|
|
552
|
-
|
|
598
|
+
if (!capturedPriceForRound) {
|
|
599
|
+
console.error(
|
|
600
|
+
`⚠️No price for ${this.state.collateralBrand}, skipping auction.`,
|
|
601
|
+
);
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
553
604
|
|
|
554
605
|
state.curAuctionPrice = multiplyRatios(
|
|
555
606
|
reduction,
|
|
@@ -619,6 +670,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
619
670
|
const { facets, state } = this;
|
|
620
671
|
|
|
621
672
|
trace(`capturing oracle price `, state.updatingOracleQuote);
|
|
673
|
+
if (!state.updatingOracleQuote) {
|
|
674
|
+
// if the price has feed has died, try restarting it.
|
|
675
|
+
facets.helper.observeQuoteNotifier();
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
622
679
|
state.capturedPriceForRound = state.updatingOracleQuote;
|
|
623
680
|
void facets.helper.publishBookData();
|
|
624
681
|
},
|
|
@@ -718,43 +775,18 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
718
775
|
finish: ({ state, facets }) => {
|
|
719
776
|
const { collateralBrand, bidBrand, priceAuthority } = state;
|
|
720
777
|
assertAllDefined({ collateralBrand, bidBrand, priceAuthority });
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
({ decimalPlaces = DEFAULT_DECIMALS }) => {
|
|
724
|
-
// TODO(#6946) use this to keep a current price that can be published in state.
|
|
725
|
-
const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
|
|
726
|
-
AmountMath.make(collateralBrand, 10n ** BigInt(decimalPlaces)),
|
|
727
|
-
bidBrand,
|
|
728
|
-
);
|
|
729
|
-
void observeNotifier(quoteNotifier, {
|
|
730
|
-
updateState: quote => {
|
|
731
|
-
trace(
|
|
732
|
-
`BOOK notifier ${priceFrom(quote).numerator.value}/${
|
|
733
|
-
priceFrom(quote).denominator.value
|
|
734
|
-
}`,
|
|
735
|
-
);
|
|
736
|
-
state.updatingOracleQuote = priceFrom(quote);
|
|
737
|
-
},
|
|
738
|
-
fail: reason => {
|
|
739
|
-
throw Error(
|
|
740
|
-
`auction observer of ${collateralBrand} failed: ${reason}`,
|
|
741
|
-
);
|
|
742
|
-
},
|
|
743
|
-
finish: done => {
|
|
744
|
-
throw Error(
|
|
745
|
-
`auction observer for ${collateralBrand} died: ${done}`,
|
|
746
|
-
);
|
|
747
|
-
},
|
|
748
|
-
});
|
|
749
|
-
},
|
|
750
|
-
);
|
|
751
|
-
void facets.helper.publishBookData();
|
|
778
|
+
|
|
779
|
+
facets.helper.observeQuoteNotifier();
|
|
752
780
|
},
|
|
753
781
|
stateShape: AuctionBookStateShape,
|
|
754
782
|
},
|
|
755
783
|
);
|
|
756
784
|
|
|
757
|
-
/**
|
|
785
|
+
/**
|
|
786
|
+
* @type {(
|
|
787
|
+
* ...args: Parameters<typeof makeAuctionBookKit>
|
|
788
|
+
* ) => ReturnType<typeof makeAuctionBookKit>['self']}
|
|
789
|
+
*/
|
|
758
790
|
const makeAuctionBook = (...args) => makeAuctionBookKit(...args).self;
|
|
759
791
|
return makeAuctionBook;
|
|
760
792
|
};
|