@agoric/inter-protocol 0.16.2-other-dev-8f8782b.0 → 0.16.2-other-dev-fbe72e7.0.fbe72e7
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 +46 -39
- 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 +182 -151
- package/src/auction/auctionMath.d.ts +17 -0
- package/src/auction/auctionMath.d.ts.map +1 -0
- package/src/auction/auctionMath.js +81 -0
- package/src/auction/auctioneer.d.ts +70 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +72 -59
- package/src/auction/offerBook.d.ts +46 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +17 -12
- package/src/auction/params.d.ts +145 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +11 -9
- package/src/auction/scheduleMath.d.ts +5 -0
- package/src/auction/scheduleMath.d.ts.map +1 -0
- package/src/auction/scheduleMath.js +18 -16
- package/src/auction/scheduler.d.ts +50 -0
- package/src/auction/scheduler.d.ts.map +1 -0
- package/src/auction/scheduler.js +53 -47
- package/src/auction/sortedOffers.d.ts +8 -0
- package/src/auction/sortedOffers.d.ts.map +1 -0
- package/src/auction/sortedOffers.js +10 -9
- package/src/auction/util.d.ts +31 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +12 -6
- package/src/clientSupport.d.ts +168 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +161 -98
- 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 +19 -13
- package/src/econCommitteeCharter.d.ts +43 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +25 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +41 -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 +4 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest-math.js +5 -1
- package/src/interest.d.ts +30 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +25 -23
- package/src/price/README.md +14 -1
- package/src/price/fluxAggregatorContract.d.ts +71 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -0
- package/src/price/fluxAggregatorContract.js +64 -55
- package/src/price/fluxAggregatorKit.d.ts +104 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +55 -42
- package/src/price/priceOracleKit.d.ts +39 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +17 -15
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +132 -85
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.js +285 -0
- package/src/proposals/addAssetToVault.js +192 -40
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/deploy-price-feeds.js +341 -0
- package/src/proposals/econ-behaviors.js +84 -49
- package/src/proposals/price-feed-proposal.js +109 -51
- package/src/proposals/replace-fee-distributor.js +198 -0
- package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
- package/src/proposals/replaceElectorate.js +610 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.js +44 -29
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.js +207 -0
- package/src/proposals/utils.d.ts +21 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +66 -9
- package/src/proposals/withdraw-reserve-proposal.js +63 -0
- package/src/provisionPool.d.ts +69 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +138 -0
- package/src/provisionPoolKit.d.ts +129 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +608 -0
- package/src/psm/psm.d.ts +133 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +85 -79
- 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 +58 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +42 -34
- package/src/reserve/assetReserveKit.d.ts +103 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +134 -32
- package/src/reserve/params.d.ts +16 -0
- package/src/reserve/params.d.ts.map +1 -0
- package/src/reserve/params.js +8 -2
- 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 +25 -0
- package/src/vaultFactory/liquidation.d.ts.map +1 -0
- package/src/vaultFactory/liquidation.js +37 -24
- package/src/vaultFactory/math.d.ts +11 -0
- package/src/vaultFactory/math.d.ts.map +1 -0
- package/src/vaultFactory/math.js +11 -10
- package/src/vaultFactory/orderedVaultStore.d.ts +94 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +9 -10
- package/src/vaultFactory/params.d.ts +143 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +56 -25
- package/src/vaultFactory/prioritizedVaults.d.ts +280 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +7 -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} +47 -44
- package/src/vaultFactory/vault.d.ts +344 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +107 -100
- package/src/vaultFactory/vaultDirector.d.ts +347 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +94 -64
- package/src/vaultFactory/vaultFactory.d.ts +250 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +56 -33
- package/src/vaultFactory/vaultHolder.d.ts +170 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +14 -15
- package/src/vaultFactory/vaultKit.d.ts +33 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +9 -4
- package/src/vaultFactory/vaultManager.d.ts +676 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +286 -167
- package/CHANGELOG.md +0 -1041
- 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
package/src/psm/psm.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The Parity Stability Module supports efficiently minting/burning a
|
|
3
|
+
* stable token at a specified fixed ratio to a reference stable token, which
|
|
4
|
+
* thereby acts as an anchor to provide additional stability. For flexible
|
|
5
|
+
* economic policies, the fee percentage for trading into and out of the
|
|
6
|
+
* stable token are specified separately.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @import {EReturn} from '@endo/far';
|
|
10
|
+
* @import {ContractMeta, FeeMintAccess, Installation} from '@agoric/zoe';
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} MetricsNotification Metrics naming scheme is that nouns are
|
|
14
|
+
* present values and past-participles are accumulative.
|
|
15
|
+
* @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token available
|
|
16
|
+
* to be swapped
|
|
17
|
+
* @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
|
|
18
|
+
* outstanding (the amount minted minus the amount burned).
|
|
19
|
+
* @property {Amount<'nat'>} feePoolBalance amount of Minted token fees
|
|
20
|
+
* available to be collected
|
|
21
|
+
* @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor ever
|
|
22
|
+
* given by this contract
|
|
23
|
+
* @property {Amount<'nat'>} totalMintedProvided running sum of Minted ever
|
|
24
|
+
* given by this contract
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
28
|
+
* @import {Baggage} from '@agoric/vat-data'
|
|
29
|
+
*/
|
|
30
|
+
/** @type {ContractMeta} */
|
|
31
|
+
export const meta: ContractMeta;
|
|
32
|
+
export function start(zcf: ZCF<GovernanceTerms<{
|
|
33
|
+
GiveMintedFee: "ratio";
|
|
34
|
+
WantMintedFee: "ratio";
|
|
35
|
+
MintLimit: "amount";
|
|
36
|
+
}> & {
|
|
37
|
+
anchorBrand: Brand<"nat">;
|
|
38
|
+
anchorPerMinted: Ratio;
|
|
39
|
+
}>, privateArgs: {
|
|
40
|
+
feeMintAccess: FeeMintAccess;
|
|
41
|
+
initialPoserInvitation: Invitation;
|
|
42
|
+
storageNode: StorageNode;
|
|
43
|
+
marshaller: Marshaller;
|
|
44
|
+
}, baggage: Baggage): Promise<{
|
|
45
|
+
creatorFacet: import("@endo/exo").Guarded<{
|
|
46
|
+
getParamMgrRetriever: () => {
|
|
47
|
+
get: () => import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
48
|
+
GiveMintedFee: "ratio";
|
|
49
|
+
MintLimit: "amount";
|
|
50
|
+
WantMintedFee: "ratio";
|
|
51
|
+
} & {
|
|
52
|
+
Electorate: "invitation";
|
|
53
|
+
}>;
|
|
54
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
55
|
+
get: () => import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
56
|
+
GiveMintedFee: "ratio";
|
|
57
|
+
MintLimit: "amount";
|
|
58
|
+
WantMintedFee: "ratio";
|
|
59
|
+
} & {
|
|
60
|
+
Electorate: "invitation";
|
|
61
|
+
}>;
|
|
62
|
+
}>;
|
|
63
|
+
getInvitation: (name: any) => Promise<globalThis.Invitation>;
|
|
64
|
+
getLimitedCreatorFacet: () => import("@endo/exo").Guarded<{
|
|
65
|
+
getRewardAllocation(): Allocation;
|
|
66
|
+
makeCollectFeesInvitation(): Promise<globalThis.Invitation<string>>;
|
|
67
|
+
makeRestoreMetricsInvitation(): Promise<globalThis.Invitation<void, Omit<MetricsNotification, "anchorPoolBalance">>>;
|
|
68
|
+
}>;
|
|
69
|
+
getGovernedApis: () => GovernedApis;
|
|
70
|
+
getGovernedApiNames: () => string[];
|
|
71
|
+
setOfferFilter: (strings: any) => Promise<void>;
|
|
72
|
+
}>;
|
|
73
|
+
publicFacet: import("@endo/exo").Guarded<{
|
|
74
|
+
getAmount: (name: string) => Amount;
|
|
75
|
+
getBrand: (name: string) => Brand;
|
|
76
|
+
getInstance: (name: string) => Instance;
|
|
77
|
+
getInstallation: (name: string) => Installation;
|
|
78
|
+
getInvitationAmount: (name: string) => InvitationAmount;
|
|
79
|
+
getNat: (name: string) => bigint;
|
|
80
|
+
getRatio: (name: string) => Ratio;
|
|
81
|
+
getString: (name: string) => string;
|
|
82
|
+
getTimestamp: (name: string) => import("@agoric/time").TimestampRecord;
|
|
83
|
+
getRelativeTime: (name: string) => import("@agoric/time").RelativeTimeRecord;
|
|
84
|
+
getUnknown: (name: string) => any;
|
|
85
|
+
getSubscription: () => globalThis.StoredSubscription<globalThis.GovernanceSubscriptionState>;
|
|
86
|
+
getGovernedParams: () => globalThis.ERef<globalThis.ParamStateRecord>;
|
|
87
|
+
getMetrics(): globalThis.Subscriber<MetricsNotification>;
|
|
88
|
+
getPoolBalance(): import("@agoric/ertp").NatAmount;
|
|
89
|
+
getPublicTopics(): {
|
|
90
|
+
metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<MetricsNotification>;
|
|
91
|
+
};
|
|
92
|
+
makeWantMintedInvitation(): Promise<globalThis.Invitation<void, undefined>>;
|
|
93
|
+
makeGiveMintedInvitation(): Promise<globalThis.Invitation<void, undefined>>;
|
|
94
|
+
}>;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Metrics naming scheme is that nouns are
|
|
98
|
+
* present values and past-participles are accumulative.
|
|
99
|
+
*/
|
|
100
|
+
export type MetricsNotification = {
|
|
101
|
+
/**
|
|
102
|
+
* amount of Anchor token available
|
|
103
|
+
* to be swapped
|
|
104
|
+
*/
|
|
105
|
+
anchorPoolBalance: Amount<"nat">;
|
|
106
|
+
/**
|
|
107
|
+
* amount of Minted token
|
|
108
|
+
* outstanding (the amount minted minus the amount burned).
|
|
109
|
+
*/
|
|
110
|
+
mintedPoolBalance: Amount<"nat">;
|
|
111
|
+
/**
|
|
112
|
+
* amount of Minted token fees
|
|
113
|
+
* available to be collected
|
|
114
|
+
*/
|
|
115
|
+
feePoolBalance: Amount<"nat">;
|
|
116
|
+
/**
|
|
117
|
+
* running sum of Anchor ever
|
|
118
|
+
* given by this contract
|
|
119
|
+
*/
|
|
120
|
+
totalAnchorProvided: Amount<"nat">;
|
|
121
|
+
/**
|
|
122
|
+
* running sum of Minted ever
|
|
123
|
+
* given by this contract
|
|
124
|
+
*/
|
|
125
|
+
totalMintedProvided: Amount<"nat">;
|
|
126
|
+
};
|
|
127
|
+
export type PsmPublicFacet = EReturn<typeof start>["publicFacet"];
|
|
128
|
+
import type { ContractMeta } from '@agoric/zoe';
|
|
129
|
+
import type { FeeMintAccess } from '@agoric/zoe';
|
|
130
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
131
|
+
import type { Installation } from '@agoric/zoe';
|
|
132
|
+
import type { EReturn } from '@endo/far';
|
|
133
|
+
//# sourceMappingURL=psm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psm.d.ts","sourceRoot":"","sources":["psm.js"],"names":[],"mappings":"AAqCA;;;;;;GAMG;AAEH;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAkCrB;AAsBK,2BAlBI,GAAG,CACT,eAAe,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,QAAQ,CAAC;CACrB,CAAC,GAAG;IACH,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,eAAe,EAAE,KAAK,CAAC;CACxB,CACF,eACO;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,sBAAsB,EAAE,UAAU,CAAC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkUjB;;;;;;;;;;uBAzYa,MAAM,CAAC,KAAK,CAAC;;;;;uBAEb,MAAM,CAAC,KAAK,CAAC;;;;;oBAEb,MAAM,CAAC,KAAK,CAAC;;;;;yBAEb,MAAM,CAAC,KAAK,CAAC;;;;;yBAEb,MAAM,CAAC,KAAK,CAAC;;6BAoYb,QAAQ,OAAO,KAAK,CAAb,CAAe,aAAa,CAAC;kCAlZU,aAAa;mCAAb,aAAa;6BAoB/C,kBAAkB;kCApBgB,aAAa;6BAD/C,WAAW"}
|
package/src/psm/psm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
|
+
/// <reference types="@agoric/governance/exported" />
|
|
3
|
+
/// <reference types="@agoric/zoe/exported" />
|
|
2
4
|
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
5
|
-
import '@agoric/zoe/src/contracts/exported.js';
|
|
6
|
-
|
|
5
|
+
import { Fail } from '@endo/errors';
|
|
6
|
+
import { E } from '@endo/eventual-send';
|
|
7
7
|
import { AmountMath, AmountShape, BrandShape, RatioShape } from '@agoric/ertp';
|
|
8
8
|
import {
|
|
9
9
|
CONTRACT_ELECTORATE,
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
import { StorageNodeShape } from '@agoric/internal';
|
|
15
15
|
import { M, prepareExo, provide } from '@agoric/vat-data';
|
|
16
16
|
import {
|
|
17
|
-
atomicRearrange,
|
|
18
17
|
atomicTransfer,
|
|
19
18
|
ceilMultiplyBy,
|
|
20
19
|
floorDivideBy,
|
|
@@ -31,90 +30,101 @@ import {
|
|
|
31
30
|
InstanceHandleShape,
|
|
32
31
|
InvitationShape,
|
|
33
32
|
} from '@agoric/zoe/src/typeGuards.js';
|
|
34
|
-
import { E } from '@endo/eventual-send';
|
|
35
33
|
|
|
36
34
|
import { mustMatch } from '@agoric/store';
|
|
37
35
|
import { makeCollectFeesInvitation } from '../collectFees.js';
|
|
38
36
|
import { makeNatAmountShape } from '../contractSupport.js';
|
|
39
37
|
|
|
40
|
-
const { Fail } = assert;
|
|
41
|
-
|
|
42
38
|
/**
|
|
43
39
|
* @file The Parity Stability Module supports efficiently minting/burning a
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* token are specified separately.
|
|
40
|
+
* stable token at a specified fixed ratio to a reference stable token, which
|
|
41
|
+
* thereby acts as an anchor to provide additional stability. For flexible
|
|
42
|
+
* economic policies, the fee percentage for trading into and out of the
|
|
43
|
+
* stable token are specified separately.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @import {EReturn} from '@endo/far';
|
|
48
|
+
* @import {ContractMeta, FeeMintAccess, Installation} from '@agoric/zoe';
|
|
48
49
|
*/
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
|
-
* @typedef {object} MetricsNotification
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @property {Amount<'nat'>}
|
|
56
|
-
*
|
|
57
|
-
* @property {Amount<'nat'>}
|
|
58
|
-
*
|
|
59
|
-
* @property {Amount<'nat'>}
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* ever given by this contract
|
|
64
|
-
* @property {Amount<'nat'>} totalMintedProvided running sum of Minted
|
|
65
|
-
* ever given by this contract
|
|
52
|
+
* @typedef {object} MetricsNotification Metrics naming scheme is that nouns are
|
|
53
|
+
* present values and past-participles are accumulative.
|
|
54
|
+
* @property {Amount<'nat'>} anchorPoolBalance amount of Anchor token available
|
|
55
|
+
* to be swapped
|
|
56
|
+
* @property {Amount<'nat'>} mintedPoolBalance amount of Minted token
|
|
57
|
+
* outstanding (the amount minted minus the amount burned).
|
|
58
|
+
* @property {Amount<'nat'>} feePoolBalance amount of Minted token fees
|
|
59
|
+
* available to be collected
|
|
60
|
+
* @property {Amount<'nat'>} totalAnchorProvided running sum of Anchor ever
|
|
61
|
+
* given by this contract
|
|
62
|
+
* @property {Amount<'nat'>} totalMintedProvided running sum of Minted ever
|
|
63
|
+
* given by this contract
|
|
66
64
|
*/
|
|
67
65
|
|
|
68
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
68
|
+
* @import {Baggage} from '@agoric/vat-data'
|
|
69
|
+
*/
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
/** @type {ContractMeta} */
|
|
72
|
+
export const meta = {
|
|
73
|
+
upgradability: 'canUpgrade',
|
|
74
|
+
customTermsShape: {
|
|
75
|
+
anchorBrand: BrandShape,
|
|
76
|
+
anchorPerMinted: RatioShape,
|
|
77
|
+
electionManager: InstanceHandleShape,
|
|
78
|
+
governedParams: {
|
|
79
|
+
[CONTRACT_ELECTORATE]: {
|
|
80
|
+
type: ParamTypes.INVITATION,
|
|
81
|
+
value: AmountShape,
|
|
82
|
+
},
|
|
83
|
+
WantMintedFee: {
|
|
84
|
+
type: ParamTypes.RATIO,
|
|
85
|
+
value: RatioShape,
|
|
86
|
+
},
|
|
87
|
+
GiveMintedFee: {
|
|
88
|
+
type: ParamTypes.RATIO,
|
|
89
|
+
value: RatioShape,
|
|
90
|
+
},
|
|
91
|
+
MintLimit: { type: ParamTypes.AMOUNT, value: AmountShape },
|
|
78
92
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
},
|
|
94
|
+
privateArgsShape: M.splitRecord(
|
|
95
|
+
{
|
|
96
|
+
marshaller: M.remotable('Marshaller'),
|
|
97
|
+
storageNode: StorageNodeShape,
|
|
82
98
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
{
|
|
100
|
+
// only necessary on first invocation, not subsequent
|
|
101
|
+
feeMintAccess: FeeMintAccessShape,
|
|
102
|
+
initialPoserInvitation: InvitationShape,
|
|
86
103
|
},
|
|
87
|
-
|
|
88
|
-
},
|
|
104
|
+
),
|
|
89
105
|
};
|
|
90
|
-
harden(
|
|
91
|
-
|
|
92
|
-
export const privateArgsShape = M.splitRecord(
|
|
93
|
-
harden({
|
|
94
|
-
marshaller: M.remotable('Marshaller'),
|
|
95
|
-
storageNode: StorageNodeShape,
|
|
96
|
-
}),
|
|
97
|
-
harden({
|
|
98
|
-
// only necessary on first invocation, not subsequent
|
|
99
|
-
feeMintAccess: FeeMintAccessShape,
|
|
100
|
-
initialPoserInvitation: InvitationShape,
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
harden(privateArgsShape);
|
|
106
|
+
harden(meta);
|
|
104
107
|
|
|
105
108
|
/**
|
|
106
|
-
* @param {ZCF<
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
109
|
+
* @param {ZCF<
|
|
110
|
+
* GovernanceTerms<{
|
|
111
|
+
* GiveMintedFee: 'ratio';
|
|
112
|
+
* WantMintedFee: 'ratio';
|
|
113
|
+
* MintLimit: 'amount';
|
|
110
114
|
* }> & {
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
+
* anchorBrand: Brand<'nat'>;
|
|
116
|
+
* anchorPerMinted: Ratio;
|
|
117
|
+
* }
|
|
118
|
+
* >} zcf
|
|
119
|
+
* @param {{
|
|
120
|
+
* feeMintAccess: FeeMintAccess;
|
|
121
|
+
* initialPoserInvitation: Invitation;
|
|
122
|
+
* storageNode: StorageNode;
|
|
123
|
+
* marshaller: Marshaller;
|
|
124
|
+
* }} privateArgs
|
|
115
125
|
* @param {Baggage} baggage
|
|
116
126
|
*/
|
|
117
|
-
export const
|
|
127
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
118
128
|
const { anchorBrand, anchorPerMinted } = zcf.getTerms();
|
|
119
129
|
console.log('PSM Starting', anchorBrand, anchorPerMinted);
|
|
120
130
|
|
|
@@ -171,9 +181,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
171
181
|
E.when(E(privateArgs.storageNode).makeChildNode('metrics'), node =>
|
|
172
182
|
makeRecorderKit(
|
|
173
183
|
node,
|
|
174
|
-
/** @type {
|
|
175
|
-
M.any()
|
|
176
|
-
),
|
|
184
|
+
/** @type {TypedPattern<MetricsNotification>} */ (M.any()),
|
|
177
185
|
),
|
|
178
186
|
),
|
|
179
187
|
});
|
|
@@ -231,9 +239,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
231
239
|
updateMetrics();
|
|
232
240
|
};
|
|
233
241
|
|
|
234
|
-
/**
|
|
235
|
-
* @param {Amount<'nat'>} toMint
|
|
236
|
-
*/
|
|
242
|
+
/** @param {Amount<'nat'>} toMint */
|
|
237
243
|
const assertUnderLimit = toMint => {
|
|
238
244
|
const mintedAfter = AmountMath.add(
|
|
239
245
|
baggage.get('mintedPoolBalance'),
|
|
@@ -262,7 +268,8 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
262
268
|
/**
|
|
263
269
|
* @param {ZCFSeat} seat
|
|
264
270
|
* @param {Amount<'nat'>} given
|
|
265
|
-
* @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange
|
|
271
|
+
* @param {Amount<'nat'>} [wanted] defaults to maximum anchor (given exchange
|
|
272
|
+
* rate minus fees)
|
|
266
273
|
*/
|
|
267
274
|
const giveMinted = (seat, given, wanted = emptyAnchor) => {
|
|
268
275
|
const fee = ceilMultiplyBy(given, params.getGiveMintedFee());
|
|
@@ -270,8 +277,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
270
277
|
const maxAnchor = floorMultiplyBy(afterFee, anchorPerMinted);
|
|
271
278
|
AmountMath.isGTE(maxAnchor, wanted) ||
|
|
272
279
|
Fail`wanted ${wanted} is more than ${given} minus fees ${fee}`;
|
|
273
|
-
atomicRearrange(
|
|
274
|
-
zcf,
|
|
280
|
+
zcf.atomicRearrange(
|
|
275
281
|
harden([
|
|
276
282
|
[seat, stage, { In: afterFee }, { Minted: afterFee }],
|
|
277
283
|
[seat, feePool, { In: fee }, { Minted: fee }],
|
|
@@ -302,8 +308,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
302
308
|
Fail`wanted ${wanted} is more than ${given} minus fees ${fee}`;
|
|
303
309
|
mintMinted(asStable);
|
|
304
310
|
try {
|
|
305
|
-
atomicRearrange(
|
|
306
|
-
zcf,
|
|
311
|
+
zcf.atomicRearrange(
|
|
307
312
|
harden([
|
|
308
313
|
[seat, anchorPool, { In: given }, { Anchor: given }],
|
|
309
314
|
[stage, seat, { Minted: afterFee }, { Out: afterFee }],
|
|
@@ -440,5 +445,6 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
440
445
|
publicFacet,
|
|
441
446
|
});
|
|
442
447
|
};
|
|
448
|
+
harden(start);
|
|
443
449
|
|
|
444
|
-
/** @typedef {
|
|
450
|
+
/** @typedef {EReturn<typeof start>['publicFacet']} PsmPublicFacet */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-ambient.d.ts","sourceRoot":"","sources":["types-ambient.js"],"names":[],"mappings":"oCAEkC,UAAU"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @type {ContractMeta<typeof start>} */
|
|
2
|
+
export const meta: ContractMeta<typeof start>;
|
|
3
|
+
export function start(zcf: ZCF<GovernanceTerms<{}> & {
|
|
4
|
+
governedApis: ["burnFeesToReduceShortfall"];
|
|
5
|
+
}>, privateArgs: {
|
|
6
|
+
feeMintAccess: FeeMintAccess;
|
|
7
|
+
initialPoserInvitation: Invitation;
|
|
8
|
+
marshaller: ERef<Marshaller>;
|
|
9
|
+
storageNode: ERef<StorageNode>;
|
|
10
|
+
}, baggage: Baggage): Promise<{
|
|
11
|
+
/** @type {GovernedCreatorFacet<typeof assetReserveKit.machine>} */
|
|
12
|
+
creatorFacet: GovernedCreatorFacet<import("@endo/exo").Guarded<{
|
|
13
|
+
addIssuer(issuer: Issuer, keyword: string): Promise<void>;
|
|
14
|
+
getAllocations(): Allocation;
|
|
15
|
+
makeShortfallReportingInvitation(): Promise<globalThis.Invitation<import("@endo/exo").Guarded<{
|
|
16
|
+
increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
|
|
17
|
+
reduceLiquidationShortfall(reduction: Amount<"nat">): void;
|
|
18
|
+
}>, undefined>>;
|
|
19
|
+
makeSingleWithdrawalInvitation(): Promise<globalThis.Invitation<any, undefined>>;
|
|
20
|
+
makeRepeatableWithdrawalInvitation(): Promise<globalThis.Invitation<{
|
|
21
|
+
invitationMakers: Partial<any>;
|
|
22
|
+
}, undefined>>;
|
|
23
|
+
revokeOutstandingWithdrawalInvitations(): void;
|
|
24
|
+
}>>;
|
|
25
|
+
/** @type {GovernedPublicFacet<typeof assetReserveKit.public>} */
|
|
26
|
+
publicFacet: GovernedPublicFacet<import("@endo/exo").Guarded<{
|
|
27
|
+
makeAddCollateralInvitation(): Promise<globalThis.Invitation<string, never>>;
|
|
28
|
+
getPublicTopics(): {
|
|
29
|
+
metrics: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./assetReserveKit.js").MetricsNotification>;
|
|
30
|
+
};
|
|
31
|
+
}>>;
|
|
32
|
+
}>;
|
|
33
|
+
export type ShortfallReportingFacet = {
|
|
34
|
+
increaseLiquidationShortfall: (increase: Amount) => void;
|
|
35
|
+
reduceLiquidationShortfall: (reduction: Amount) => void;
|
|
36
|
+
};
|
|
37
|
+
export type ShortfallReporter = {
|
|
38
|
+
increaseLiquidationShortfall: (shortfall: Amount) => void;
|
|
39
|
+
reduceLiquidationShortfall: (shortfall: Amount) => void;
|
|
40
|
+
};
|
|
41
|
+
export type AssetReserveLimitedCreatorFacet = {
|
|
42
|
+
addIssuer: (issuer: Issuer, kwd: string) => void;
|
|
43
|
+
getAllocations: () => Allocation;
|
|
44
|
+
makeShortfallReportingInvitation: () => Promise<Invitation<ShortfallReporter>>;
|
|
45
|
+
};
|
|
46
|
+
export type AssetReservePublicFacet = EReturn<typeof start>["publicFacet"];
|
|
47
|
+
/**
|
|
48
|
+
* the creator facet for the governor
|
|
49
|
+
*/
|
|
50
|
+
export type AssetReserveCreatorFacet = EReturn<typeof start>["creatorFacet"];
|
|
51
|
+
export type ReserveContract = ContractOf<typeof start>;
|
|
52
|
+
import type { ContractMeta } from '@agoric/zoe';
|
|
53
|
+
import type { FeeMintAccess } from '@agoric/zoe';
|
|
54
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
55
|
+
import type { Allocation } from '@agoric/zoe';
|
|
56
|
+
import type { EReturn } from '@endo/far';
|
|
57
|
+
import type { ContractOf } from '@agoric/zoe/src/zoeService/utils.js';
|
|
58
|
+
//# sourceMappingURL=assetReserve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetReserve.d.ts","sourceRoot":"","sources":["assetReserve.js"],"names":[],"mappings":"AAkBA,yCAAyC;AACzC,mBADW,aAAa,OAAO,KAAK,CAAC,CAGnC;AAgCK,2BAbI,GAAG,CACT,eAAe,CAAC,EAAE,CAAC,GAAG;IACpB,YAAY,EAAE,CAAC,2BAA2B,CAAC,CAAC;CAC7C,CACF,eACO;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,sBAAsB,EAAE,UAAU,CAAC;IACnC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;CAChC,WACO,OAAO;IAoDd,mEAAmE;kBAAxD,oBAAoB;;;;;;;;;;;;OAAgC;IAE/D,iEAAiE;iBAAtD,mBAAmB;;;;;OAA+B;GAKhE;sCArFY;IACR,4BAA4B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,0BAA0B,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD;;kCAuFU,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI;gCAC3B,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI;;;eAK3B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI;oBACrC,MAAM,UAAU;sCAChB,MAAM,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;;sCAG5C,QAAQ,OAAO,KAAK,CAAb,CAAe,aAAa,CAAC;;;;uCAErC,QAAQ,OAAO,KAAK,CAAb,CAAe,cAAc,CAAC;8BAIpC,WAAW,OAAO,KAAK,CAAC;kCAvHkC,aAAa;mCAAb,aAAa;6BAkB1D,kBAAkB;gCAlB2B,aAAa;6BAF3D,WAAW;gCACR,qCAAqC"}
|
|
@@ -8,38 +8,50 @@ import {
|
|
|
8
8
|
} from '@agoric/zoe/src/contractSupport/index.js';
|
|
9
9
|
import { prepareAssetReserveKit } from './assetReserveKit.js';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @import {EReturn} from '@endo/far';
|
|
13
|
+
* @import {ContractOf} from '@agoric/zoe/src/zoeService/utils.js';
|
|
14
|
+
* @import {Allocation, ContractMeta, FeeMintAccess, Installation} from '@agoric/zoe';
|
|
15
|
+
*/
|
|
16
|
+
|
|
11
17
|
const trace = makeTracer('AR', true);
|
|
12
18
|
|
|
19
|
+
/** @type {ContractMeta<typeof start>} */
|
|
20
|
+
export const meta = {
|
|
21
|
+
upgradability: 'canUpgrade',
|
|
22
|
+
};
|
|
23
|
+
harden(meta);
|
|
24
|
+
|
|
13
25
|
/**
|
|
14
26
|
* @typedef {{
|
|
15
|
-
* increaseLiquidationShortfall: (increase: Amount) => void
|
|
16
|
-
* reduceLiquidationShortfall: (reduction: Amount) => void
|
|
27
|
+
* increaseLiquidationShortfall: (increase: Amount) => void;
|
|
28
|
+
* reduceLiquidationShortfall: (reduction: Amount) => void;
|
|
17
29
|
* }} ShortfallReportingFacet
|
|
18
30
|
*/
|
|
19
31
|
|
|
20
|
-
/** @
|
|
32
|
+
/** @import {Baggage} from '@agoric/vat-data' */
|
|
21
33
|
|
|
22
34
|
/**
|
|
23
|
-
* Asset Reserve holds onto assets for the Inter Protocol, and can
|
|
24
|
-
*
|
|
35
|
+
* Asset Reserve holds onto assets for the Inter Protocol, and can dispense it
|
|
36
|
+
* for various purposes under governance control.
|
|
25
37
|
*
|
|
26
38
|
* This contract has the ability to mint Fee tokens, granted through its private
|
|
27
39
|
* arguments.
|
|
28
40
|
*
|
|
29
|
-
* @param {ZCF<
|
|
30
|
-
* {
|
|
31
|
-
*
|
|
32
|
-
*
|
|
41
|
+
* @param {ZCF<
|
|
42
|
+
* GovernanceTerms<{}> & {
|
|
43
|
+
* governedApis: ['burnFeesToReduceShortfall'];
|
|
44
|
+
* }
|
|
33
45
|
* >} zcf
|
|
34
46
|
* @param {{
|
|
35
|
-
* feeMintAccess: FeeMintAccess
|
|
36
|
-
* initialPoserInvitation: Invitation
|
|
37
|
-
* marshaller: ERef<Marshaller
|
|
38
|
-
* storageNode: ERef<StorageNode
|
|
47
|
+
* feeMintAccess: FeeMintAccess;
|
|
48
|
+
* initialPoserInvitation: Invitation;
|
|
49
|
+
* marshaller: ERef<Marshaller>;
|
|
50
|
+
* storageNode: ERef<StorageNode>;
|
|
39
51
|
* }} privateArgs
|
|
40
52
|
* @param {Baggage} baggage
|
|
41
53
|
*/
|
|
42
|
-
export const
|
|
54
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
43
55
|
trace('prepare', Object.keys(privateArgs), [...baggage.keys()]);
|
|
44
56
|
// This contract mixes two styles of access to durable state. durableStores
|
|
45
57
|
// are declared at the top level and referenced lexically. local state is
|
|
@@ -51,26 +63,17 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
51
63
|
privateArgs.marshaller,
|
|
52
64
|
);
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'Fee',
|
|
62
|
-
privateArgs.feeMintAccess,
|
|
63
|
-
);
|
|
64
|
-
baggage.init('feeMint', feeMintTemp);
|
|
65
|
-
return feeMintTemp;
|
|
66
|
-
};
|
|
67
|
-
trace('awaiting takeFeeMint');
|
|
68
|
-
const feeMint = await takeFeeMint();
|
|
66
|
+
const storageNode = await privateArgs.storageNode;
|
|
67
|
+
|
|
68
|
+
trace('awaiting feeMint');
|
|
69
|
+
const { feeMint } = await provideAll(baggage, {
|
|
70
|
+
feeMint: () => zcf.registerFeeMint('Fee', privateArgs.feeMintAccess),
|
|
71
|
+
});
|
|
72
|
+
|
|
69
73
|
const makeAssetReserveKit = await prepareAssetReserveKit(baggage, {
|
|
70
74
|
feeMint,
|
|
71
75
|
makeRecorderKit,
|
|
72
|
-
|
|
73
|
-
storageNode: await privateArgs.storageNode,
|
|
76
|
+
storageNode,
|
|
74
77
|
zcf,
|
|
75
78
|
});
|
|
76
79
|
|
|
@@ -106,7 +109,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
106
109
|
publicFacet: /** @type {any} */ (assetReserveKit.public),
|
|
107
110
|
};
|
|
108
111
|
};
|
|
109
|
-
harden(
|
|
112
|
+
harden(start);
|
|
110
113
|
|
|
111
114
|
/**
|
|
112
115
|
* @typedef {object} ShortfallReporter
|
|
@@ -121,5 +124,10 @@ harden(prepare);
|
|
|
121
124
|
* @property {() => Promise<Invitation<ShortfallReporter>>} makeShortfallReportingInvitation
|
|
122
125
|
*/
|
|
123
126
|
|
|
124
|
-
/** @typedef {
|
|
125
|
-
/**
|
|
127
|
+
/** @typedef {EReturn<typeof start>['publicFacet']} AssetReservePublicFacet */
|
|
128
|
+
/**
|
|
129
|
+
* @typedef {EReturn<typeof start>['creatorFacet']} AssetReserveCreatorFacet
|
|
130
|
+
* the creator facet for the governor
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/** @typedef {ContractOf<typeof start>} ReserveContract */
|