@agoric/inter-protocol 0.16.2-mainnet1B-dev-26244e8.0 → 0.16.2-orchestration-dev-096c4e8.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 +37 -30
- package/scripts/build-bundles.js +5 -21
- package/src/auction/auctionBook.d.ts +83 -0
- package/src/auction/auctionBook.d.ts.map +1 -0
- package/src/auction/auctionBook.js +127 -98
- package/src/auction/auctioneer.d.ts +75 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +56 -44
- package/src/auction/offerBook.d.ts +45 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +12 -11
- package/src/auction/params.d.ts +142 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +5 -7
- package/src/auction/scheduleMath.d.ts +4 -0
- package/src/auction/scheduleMath.d.ts.map +1 -0
- package/src/auction/scheduleMath.js +14 -14
- 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 +8 -7
- package/src/auction/util.d.ts +30 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +4 -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 +33 -0
- package/src/contractSupport.d.ts.map +1 -0
- package/src/contractSupport.js +5 -5
- package/src/econCommitteeCharter.d.ts +33 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +18 -17
- package/src/feeDistributor.d.ts +212 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +36 -35
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/interest-math.d.ts +3 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest.d.ts +29 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +22 -16
- package/src/price/README.md +13 -0
- package/src/price/fluxAggregatorContract.d.ts +67 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -0
- package/src/price/fluxAggregatorContract.js +61 -54
- package/src/price/fluxAggregatorKit.d.ts +133 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +51 -36
- 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 +202 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +77 -81
- package/src/proposals/addAssetToVault.d.ts +160 -0
- package/src/proposals/addAssetToVault.d.ts.map +1 -0
- package/src/proposals/addAssetToVault.js +170 -36
- 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 +7 -7
- package/src/proposals/econ-behaviors.d.ts +201 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -0
- package/src/proposals/econ-behaviors.js +58 -34
- package/src/proposals/price-feed-proposal.d.ts +82 -0
- package/src/proposals/price-feed-proposal.d.ts.map +1 -0
- package/src/proposals/price-feed-proposal.js +72 -37
- 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 +61 -0
- package/src/proposals/startPSM.d.ts.map +1 -0
- package/src/proposals/startPSM.js +32 -23
- package/src/proposals/utils.d.ts +17 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +32 -7
- package/src/provisionPool.d.ts +165 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +119 -0
- package/src/provisionPoolKit.d.ts +362 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +461 -0
- package/src/psm/psm.d.ts +123 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +69 -63
- package/src/psm/types.d.ts +2 -0
- package/src/psm/types.d.ts.map +1 -0
- package/src/psm/types.js +1 -1
- package/src/reserve/assetReserve.d.ts +44 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +27 -18
- package/src/reserve/assetReserveKit.d.ts +69 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +14 -22
- 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/liquidation.d.ts +24 -0
- package/src/vaultFactory/liquidation.d.ts.map +1 -0
- package/src/vaultFactory/liquidation.js +35 -22
- package/src/vaultFactory/math.d.ts +10 -0
- package/src/vaultFactory/math.d.ts.map +1 -0
- package/src/vaultFactory/math.js +8 -9
- package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +8 -11
- package/src/vaultFactory/params.d.ts +159 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +25 -19
- package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +3 -3
- package/src/vaultFactory/proceeds.d.ts +34 -0
- package/src/vaultFactory/proceeds.d.ts.map +1 -0
- package/src/vaultFactory/proceeds.js +24 -18
- package/src/vaultFactory/storeUtils.d.ts +25 -0
- package/src/vaultFactory/storeUtils.d.ts.map +1 -0
- package/src/vaultFactory/storeUtils.js +8 -12
- package/src/vaultFactory/type-imports.d.ts +2 -0
- package/src/vaultFactory/type-imports.d.ts.map +1 -0
- package/src/vaultFactory/type-imports.js +1 -1
- package/src/vaultFactory/types.d.ts +137 -0
- package/src/vaultFactory/types.d.ts.map +1 -0
- package/src/vaultFactory/types.js +47 -37
- package/src/vaultFactory/vault.d.ts +336 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +89 -90
- package/src/vaultFactory/vaultDirector.d.ts +311 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +36 -45
- package/src/vaultFactory/vaultFactory.d.ts +162 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +33 -26
- package/src/vaultFactory/vaultHolder.d.ts +126 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +8 -13
- package/src/vaultFactory/vaultKit.d.ts +32 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +3 -2
- package/src/vaultFactory/vaultManager.d.ts +357 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +236 -145
- package/CHANGELOG.md +0 -1057
- 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/typeGuards.js +0 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/inter-protocol",
|
|
3
|
-
"version": "0.16.2-
|
|
3
|
+
"version": "0.16.2-orchestration-dev-096c4e8.0+096c4e8",
|
|
4
4
|
"description": "Core cryptoeconomy contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -10,13 +10,15 @@
|
|
|
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*' src/types.js",
|
|
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,40 +31,40 @@
|
|
|
29
31
|
},
|
|
30
32
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "0.6.1-
|
|
33
|
-
"@agoric/ertp": "0.16.3-
|
|
34
|
-
"@agoric/governance": "0.10.4-
|
|
35
|
-
"@agoric/internal": "0.
|
|
36
|
-
"@agoric/notifier": "0.6.3-
|
|
37
|
-
"@agoric/store": "0.9.3-
|
|
38
|
-
"@agoric/time": "0.3.3-
|
|
39
|
-
"@agoric/vat-data": "0.5.3-
|
|
40
|
-
"@agoric/vats": "0.15.2-
|
|
41
|
-
"@agoric/zoe": "0.26.3-
|
|
42
|
-
"@endo/captp": "
|
|
43
|
-
"@endo/eventual-send": "
|
|
44
|
-
"@endo/far": "0.
|
|
45
|
-
"@endo/marshal": "
|
|
46
|
-
"@endo/nat": "
|
|
47
|
-
"
|
|
34
|
+
"@agoric/assert": "0.6.1-orchestration-dev-096c4e8.0+096c4e8",
|
|
35
|
+
"@agoric/ertp": "0.16.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
36
|
+
"@agoric/governance": "0.10.4-orchestration-dev-096c4e8.0+096c4e8",
|
|
37
|
+
"@agoric/internal": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
38
|
+
"@agoric/notifier": "0.6.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
39
|
+
"@agoric/store": "0.9.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
40
|
+
"@agoric/time": "0.3.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
41
|
+
"@agoric/vat-data": "0.5.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
42
|
+
"@agoric/vats": "0.15.2-orchestration-dev-096c4e8.0+096c4e8",
|
|
43
|
+
"@agoric/zoe": "0.26.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
44
|
+
"@endo/captp": "^4.0.4",
|
|
45
|
+
"@endo/eventual-send": "^1.1.2",
|
|
46
|
+
"@endo/far": "^1.0.4",
|
|
47
|
+
"@endo/marshal": "^1.3.0",
|
|
48
|
+
"@endo/nat": "^5.0.4",
|
|
49
|
+
"@endo/promise-kit": "^1.0.4",
|
|
48
50
|
"jessie.js": "^0.3.2"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@agoric/
|
|
52
|
-
"@agoric/
|
|
53
|
-
"@agoric/swingset-
|
|
54
|
-
"@agoric/
|
|
55
|
-
"@endo/bundle-source": "
|
|
56
|
-
"@endo/init": "0.
|
|
57
|
-
"@endo/promise-kit": "0.
|
|
58
|
-
"@fast-check/ava": "^1.1.
|
|
59
|
-
"ava": "^5.
|
|
53
|
+
"@agoric/smart-wallet": "0.5.4-orchestration-dev-096c4e8.0+096c4e8",
|
|
54
|
+
"@agoric/swingset-liveslots": "0.10.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
55
|
+
"@agoric/swingset-vat": "0.32.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
56
|
+
"@agoric/zone": "0.2.3-orchestration-dev-096c4e8.0+096c4e8",
|
|
57
|
+
"@endo/bundle-source": "^3.1.0",
|
|
58
|
+
"@endo/init": "^1.0.4",
|
|
59
|
+
"@endo/promise-kit": "^1.0.4",
|
|
60
|
+
"@fast-check/ava": "^1.1.5",
|
|
61
|
+
"ava": "^5.3.0",
|
|
60
62
|
"c8": "^7.13.0",
|
|
61
63
|
"deep-object-diff": "^1.1.9",
|
|
62
64
|
"import-meta-resolve": "^2.2.1"
|
|
63
65
|
},
|
|
64
66
|
"files": [
|
|
65
|
-
"scripts
|
|
67
|
+
"scripts",
|
|
66
68
|
"src/",
|
|
67
69
|
"exported.js",
|
|
68
70
|
"NEWS.md"
|
|
@@ -71,12 +73,17 @@
|
|
|
71
73
|
"files": [
|
|
72
74
|
"test/**/test-*.js"
|
|
73
75
|
],
|
|
74
|
-
"
|
|
76
|
+
"require": [
|
|
77
|
+
"@endo/init/debug.js"
|
|
78
|
+
],
|
|
75
79
|
"workerThreads": false,
|
|
76
80
|
"timeout": "10m"
|
|
77
81
|
},
|
|
78
82
|
"publishConfig": {
|
|
79
83
|
"access": "public"
|
|
80
84
|
},
|
|
81
|
-
"
|
|
85
|
+
"typeCoverage": {
|
|
86
|
+
"atLeast": 95.77
|
|
87
|
+
},
|
|
88
|
+
"gitHead": "096c4e8fce80e9a509b0e1a30fda11736c4570e1"
|
|
82
89
|
}
|
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,83 @@
|
|
|
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: Brand<"nat">, collateralBrand: Brand<"nat">, pAuthority: PriceAuthority, node: StorageNode) => import("@endo/exo/src/exo-makers.js").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?: Amount<"nat"> | 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(): 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 Baggage = import('@agoric/vat-data').Baggage;
|
|
46
|
+
export type BookDataNotification = {
|
|
47
|
+
/**
|
|
48
|
+
* identifies the priceAuthority and price
|
|
49
|
+
*/
|
|
50
|
+
startPrice: Ratio | null;
|
|
51
|
+
/**
|
|
52
|
+
* the price at the current auction
|
|
53
|
+
* tier
|
|
54
|
+
*/
|
|
55
|
+
currentPriceLevel: Ratio | null;
|
|
56
|
+
/**
|
|
57
|
+
* The proceeds the sellers
|
|
58
|
+
* were targeting to raise
|
|
59
|
+
*/
|
|
60
|
+
startProceedsGoal: Amount<'nat'> | null;
|
|
61
|
+
/**
|
|
62
|
+
* The remainder of the
|
|
63
|
+
* proceeds the sellers were targeting to raise
|
|
64
|
+
*/
|
|
65
|
+
remainingProceedsGoal: Amount<'nat'> | null;
|
|
66
|
+
/**
|
|
67
|
+
* The proceeds raised so
|
|
68
|
+
* far in the auction
|
|
69
|
+
*/
|
|
70
|
+
proceedsRaised: Amount<'nat'> | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* How much collateral was available
|
|
73
|
+
* for sale at the start. (If more is deposited later, it'll be added in.)
|
|
74
|
+
*/
|
|
75
|
+
startCollateral: Amount<'nat'>;
|
|
76
|
+
/**
|
|
77
|
+
* The amount of collateral
|
|
78
|
+
* remaining
|
|
79
|
+
*/
|
|
80
|
+
collateralAvailable: Amount<'nat'> | null;
|
|
81
|
+
};
|
|
82
|
+
export type AuctionBook = ReturnType<ReturnType<typeof prepareAuctionBook>>;
|
|
83
|
+
//# sourceMappingURL=auctionBook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auctionBook.d.ts","sourceRoot":"","sources":["auctionBook.js"],"names":[],"mappings":"AAyEO,6CAHI,MAAM,KAAK,CAAC,mBACZ,MAAM,KAAK,CAAC,oCAiBtB;AA0BM,4CAJI,OAAO,OACP,GAAG,mBACH,OAAO,6CAA6C,EAAE,eAAe;IA6YxE;;;;;;;;OAQG;2BAPQ,OAAO,KAAK,CAAC,cACb,OAAO;IA6ElB,yCAAyC;+BAAlB,KAAK,GAAK,IAAI;;;;;IA4GrC;;;;OAIG;wBAHQ,SAAS,QACT,OAAO,aACP,OAAO;;;;;;;;;;;GAyFzB;wBA5tBY;IACZ,MAAU,EAAE,OAAO,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;sBAuBQ,OAAO,kBAAkB,EAAE,OAAO;;;;;gBAIlC,KAAK,GAAG,IAAI;;;;;uBACZ,KAAK,GAAG,IAAI;;;;;uBAEZ,OAAO,KAAK,CAAC,GAAG,IAAI;;;;;2BAEpB,OAAO,KAAK,CAAC,GAAG,IAAI;;;;;oBAEpB,OAAO,KAAK,CAAC,GAAG,SAAS;;;;;qBAEzB,OAAO,KAAK,CAAC;;;;;yBAEb,OAAO,KAAK,CAAC,GAAG,IAAI;;0BA8qBpB,WAAW,WAAW,yBAAyB,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import '@agoric/governance/exported.js';
|
|
|
2
2
|
import '@agoric/zoe/exported.js';
|
|
3
3
|
import '@agoric/zoe/src/contracts/exported.js';
|
|
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
|
|
|
@@ -34,34 +34,38 @@ const DEFAULT_DECIMALS = 9;
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @file The book represents the collateral-specific state of an ongoing
|
|
37
|
-
*
|
|
38
|
-
* the allocation of assets for sale.
|
|
37
|
+
* auction. It holds the book, the capturedPrice, and the collateralSeat that
|
|
38
|
+
* has the allocation of assets for sale.
|
|
39
|
+
*
|
|
40
|
+
* The book contains orders for the collateral. It holds two kinds of orders:
|
|
39
41
|
*
|
|
40
|
-
* The book contains orders for the collateral. It holds two kinds of
|
|
41
|
-
* orders:
|
|
42
42
|
* - 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
|
-
*
|
|
43
|
+
* - ScaledBids express the offer in terms of a discount (or markup) from the most
|
|
44
|
+
* recent oracle price.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
46
|
+
* Offers can be added in three ways. 1) When the auction is not active, prices
|
|
47
|
+
* are automatically added to the appropriate collection. When the auction is
|
|
48
|
+
* active, 2) if a new offer is at or above the current price, it will be
|
|
49
|
+
* settled immediately; 2) If the offer is below the current price, it will be
|
|
50
|
+
* added in the appropriate place and settled when the price reaches that
|
|
51
|
+
* level.
|
|
51
52
|
*/
|
|
52
53
|
|
|
53
54
|
const trace = makeTracer('AucBook', true);
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* @typedef {{
|
|
57
|
-
* maxBuy: Amount<'nat'
|
|
58
|
+
* maxBuy: Amount<'nat'>;
|
|
58
59
|
* } & {
|
|
59
|
-
* exitAfterBuy?: boolean
|
|
60
|
-
* } & (
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
60
|
+
* exitAfterBuy?: boolean;
|
|
61
|
+
* } & (
|
|
62
|
+
* | {
|
|
63
|
+
* offerPrice: Ratio;
|
|
64
|
+
* }
|
|
65
|
+
* | {
|
|
66
|
+
* offerBidScaling: Ratio;
|
|
67
|
+
* }
|
|
68
|
+
* )} OfferSpec
|
|
65
69
|
*/
|
|
66
70
|
/**
|
|
67
71
|
* @param {Brand<'nat'>} bidBrand
|
|
@@ -88,17 +92,19 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
|
|
|
88
92
|
|
|
89
93
|
/**
|
|
90
94
|
* @typedef {object} BookDataNotification
|
|
91
|
-
*
|
|
92
|
-
* @property {Ratio
|
|
93
|
-
*
|
|
94
|
-
* @property {Amount<'nat'> | null}
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @property {Amount<'nat'>}
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
95
|
+
* @property {Ratio | null} startPrice identifies the priceAuthority and price
|
|
96
|
+
* @property {Ratio | null} currentPriceLevel the price at the current auction
|
|
97
|
+
* tier
|
|
98
|
+
* @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers
|
|
99
|
+
* were targeting to raise
|
|
100
|
+
* @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of the
|
|
101
|
+
* proceeds the sellers were targeting to raise
|
|
102
|
+
* @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so
|
|
103
|
+
* far in the auction
|
|
104
|
+
* @property {Amount<'nat'>} startCollateral How much collateral was available
|
|
105
|
+
* for sale at the start. (If more is deposited later, it'll be added in.)
|
|
106
|
+
* @property {Amount<'nat'> | null} collateralAvailable The amount of collateral
|
|
107
|
+
* remaining
|
|
102
108
|
*/
|
|
103
109
|
|
|
104
110
|
/**
|
|
@@ -118,7 +124,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
118
124
|
bidHoldingSeat: M.any(),
|
|
119
125
|
bidAmountShape: M.any(),
|
|
120
126
|
priceAuthority: M.any(),
|
|
121
|
-
updatingOracleQuote: M.
|
|
127
|
+
updatingOracleQuote: M.or(RatioShape, M.null()),
|
|
122
128
|
bookDataKit: M.any(),
|
|
123
129
|
priceBook: M.any(),
|
|
124
130
|
scaledBidBook: M.any(),
|
|
@@ -141,11 +147,6 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
141
147
|
*/
|
|
142
148
|
(bidBrand, collateralBrand, pAuthority, node) => {
|
|
143
149
|
assertAllDefined({ bidBrand, collateralBrand, pAuthority });
|
|
144
|
-
const zeroBid = makeEmpty(bidBrand);
|
|
145
|
-
const zeroRatio = makeRatioFromAmounts(
|
|
146
|
-
zeroBid,
|
|
147
|
-
AmountMath.make(collateralBrand, 1n),
|
|
148
|
-
);
|
|
149
150
|
|
|
150
151
|
// these don't have to be durable, since we're currently assuming that upgrade
|
|
151
152
|
// from a quiescent state is sufficient. When the auction is quiescent, there
|
|
@@ -182,7 +183,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
182
183
|
bidAmountShape,
|
|
183
184
|
|
|
184
185
|
priceAuthority: pAuthority,
|
|
185
|
-
updatingOracleQuote:
|
|
186
|
+
updatingOracleQuote: /** @type {Ratio | null} */ (null),
|
|
186
187
|
|
|
187
188
|
bookDataKit,
|
|
188
189
|
|
|
@@ -231,8 +232,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
231
232
|
{
|
|
232
233
|
helper: {
|
|
233
234
|
/**
|
|
234
|
-
* remove the key from the appropriate book, indicated by whether the
|
|
235
|
-
* is defined.
|
|
235
|
+
* remove the key from the appropriate book, indicated by whether the
|
|
236
|
+
* price is defined.
|
|
236
237
|
*
|
|
237
238
|
* @param {string} key
|
|
238
239
|
* @param {Ratio | undefined} price
|
|
@@ -247,8 +248,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
247
248
|
},
|
|
248
249
|
|
|
249
250
|
/**
|
|
250
|
-
* Update the entry in the appropriate book, indicated by whether the
|
|
251
|
-
* is defined.
|
|
251
|
+
* Update the entry in the appropriate book, indicated by whether the
|
|
252
|
+
* price is defined.
|
|
252
253
|
*
|
|
253
254
|
* @param {string} key
|
|
254
255
|
* @param {Amount} collateralSold
|
|
@@ -264,7 +265,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
264
265
|
},
|
|
265
266
|
|
|
266
267
|
/**
|
|
267
|
-
* Settle with seat. The caller is responsible for updating the book, if
|
|
268
|
+
* Settle with seat. The caller is responsible for updating the book, if
|
|
269
|
+
* any.
|
|
268
270
|
*
|
|
269
271
|
* @param {ZCFSeat} seat
|
|
270
272
|
* @param {Amount<'nat'>} collateralWanted
|
|
@@ -341,15 +343,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
341
343
|
},
|
|
342
344
|
|
|
343
345
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
+
* Accept an offer expressed as a price. If the auction is active,
|
|
347
|
+
* attempt to buy collateral. If any of the offer remains add it to the
|
|
348
|
+
* book.
|
|
346
349
|
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
350
|
+
* @param {ZCFSeat} seat
|
|
351
|
+
* @param {Ratio} price
|
|
352
|
+
* @param {Amount<'nat'>} maxBuy
|
|
353
|
+
* @param {object} opts
|
|
354
|
+
* @param {boolean} opts.trySettle
|
|
355
|
+
* @param {boolean} [opts.exitAfterBuy]
|
|
353
356
|
*/
|
|
354
357
|
acceptPriceOffer(
|
|
355
358
|
seat,
|
|
@@ -388,16 +391,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
388
391
|
},
|
|
389
392
|
|
|
390
393
|
/**
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
+
* Accept an offer expressed as a discount (or markup). If the auction
|
|
395
|
+
* is active, attempt to buy collateral. If any of the offer remains add
|
|
396
|
+
* it to the book.
|
|
394
397
|
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
398
|
+
* @param {ZCFSeat} seat
|
|
399
|
+
* @param {Ratio} bidScaling
|
|
400
|
+
* @param {Amount<'nat'>} maxBuy
|
|
401
|
+
* @param {object} opts
|
|
402
|
+
* @param {boolean} opts.trySettle
|
|
403
|
+
* @param {boolean} [opts.exitAfterBuy]
|
|
401
404
|
*/
|
|
402
405
|
acceptScaledBidOffer(
|
|
403
406
|
seat,
|
|
@@ -460,16 +463,58 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
460
463
|
});
|
|
461
464
|
return state.bookDataKit.recorder.write(bookData);
|
|
462
465
|
},
|
|
466
|
+
observeQuoteNotifier() {
|
|
467
|
+
const { state, facets } = this;
|
|
468
|
+
const { collateralBrand, bidBrand, priceAuthority } = state;
|
|
469
|
+
|
|
470
|
+
trace('observing');
|
|
471
|
+
|
|
472
|
+
void E.when(
|
|
473
|
+
E(collateralBrand).getDisplayInfo(),
|
|
474
|
+
({ decimalPlaces = DEFAULT_DECIMALS }) => {
|
|
475
|
+
const quoteNotifier = E(priceAuthority).makeQuoteNotifier(
|
|
476
|
+
AmountMath.make(collateralBrand, 10n ** BigInt(decimalPlaces)),
|
|
477
|
+
bidBrand,
|
|
478
|
+
);
|
|
479
|
+
void observeNotifier(quoteNotifier, {
|
|
480
|
+
updateState: quote => {
|
|
481
|
+
trace(
|
|
482
|
+
`BOOK notifier ${priceFrom(quote).numerator.value}/${
|
|
483
|
+
priceFrom(quote).denominator.value
|
|
484
|
+
}`,
|
|
485
|
+
);
|
|
486
|
+
state.updatingOracleQuote = priceFrom(quote);
|
|
487
|
+
},
|
|
488
|
+
fail: reason => {
|
|
489
|
+
trace(
|
|
490
|
+
`Failure from quoteNotifier (${reason}) setting to null`,
|
|
491
|
+
);
|
|
492
|
+
// lack of quote will trigger restart
|
|
493
|
+
state.updatingOracleQuote = null;
|
|
494
|
+
},
|
|
495
|
+
finish: done => {
|
|
496
|
+
trace(
|
|
497
|
+
`quoteNotifier invoked finish(${done}). setting quote to null`,
|
|
498
|
+
);
|
|
499
|
+
// lack of quote will trigger restart
|
|
500
|
+
state.updatingOracleQuote = null;
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
},
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
void facets.helper.publishBookData();
|
|
507
|
+
},
|
|
463
508
|
},
|
|
464
509
|
self: {
|
|
465
510
|
/**
|
|
466
511
|
* @param {Amount<'nat'>} assetAmount
|
|
467
512
|
* @param {ZCFSeat} sourceSeat
|
|
468
513
|
* @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
514
|
+
* would like to raise. The auction is requested to not sell more
|
|
515
|
+
* collateral than required to raise that much. The auctioneer might
|
|
516
|
+
* sell more if there is more than one supplier of collateral, and
|
|
517
|
+
* they request inconsistent limits.
|
|
473
518
|
*/
|
|
474
519
|
addAssets(assetAmount, sourceSeat, proceedsGoal) {
|
|
475
520
|
const { state, facets } = this;
|
|
@@ -547,9 +592,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
547
592
|
|
|
548
593
|
trace(this.state.collateralBrand, 'settleAtNewRate', reduction);
|
|
549
594
|
const { capturedPriceForRound, priceBook, scaledBidBook } = state;
|
|
550
|
-
capturedPriceForRound
|
|
551
|
-
|
|
552
|
-
|
|
595
|
+
if (!capturedPriceForRound) {
|
|
596
|
+
console.error(
|
|
597
|
+
`⚠️No price for ${this.state.collateralBrand}, skipping auction.`,
|
|
598
|
+
);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
553
601
|
|
|
554
602
|
state.curAuctionPrice = multiplyRatios(
|
|
555
603
|
reduction,
|
|
@@ -619,6 +667,12 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
619
667
|
const { facets, state } = this;
|
|
620
668
|
|
|
621
669
|
trace(`capturing oracle price `, state.updatingOracleQuote);
|
|
670
|
+
if (!state.updatingOracleQuote) {
|
|
671
|
+
// if the price has feed has died, try restarting it.
|
|
672
|
+
facets.helper.observeQuoteNotifier();
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
|
|
622
676
|
state.capturedPriceForRound = state.updatingOracleQuote;
|
|
623
677
|
void facets.helper.publishBookData();
|
|
624
678
|
},
|
|
@@ -718,43 +772,18 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
718
772
|
finish: ({ state, facets }) => {
|
|
719
773
|
const { collateralBrand, bidBrand, priceAuthority } = state;
|
|
720
774
|
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();
|
|
775
|
+
|
|
776
|
+
facets.helper.observeQuoteNotifier();
|
|
752
777
|
},
|
|
753
778
|
stateShape: AuctionBookStateShape,
|
|
754
779
|
},
|
|
755
780
|
);
|
|
756
781
|
|
|
757
|
-
/**
|
|
782
|
+
/**
|
|
783
|
+
* @type {(
|
|
784
|
+
* ...args: Parameters<typeof makeAuctionBookKit>
|
|
785
|
+
* ) => ReturnType<typeof makeAuctionBookKit>['self']}
|
|
786
|
+
*/
|
|
758
787
|
const makeAuctionBook = (...args) => makeAuctionBookKit(...args).self;
|
|
759
788
|
return makeAuctionBook;
|
|
760
789
|
};
|