@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Timestamp} from '@agoric/time'
|
|
3
|
+
* @import {RelativeTime} from '@agoric/time'
|
|
4
|
+
* @import {AdminFacet, InvitationAmount, ZCFMint} from '@agoric/zoe';
|
|
5
|
+
*/
|
|
6
|
+
export const SECONDS_PER_YEAR: bigint;
|
|
7
|
+
export function makeInterestCalculator(annualRate: Ratio, chargingPeriod: RelativeTime, recordingPeriod: RelativeTime): CalculatorKit;
|
|
8
|
+
export function calculateCompoundedInterest(priorCompoundedInterest: Ratio, priorDebt: NatValue, newDebt: NatValue): import("@agoric/ertp/src/ratio.js").Ratio;
|
|
9
|
+
export function chargeInterest(powers: {
|
|
10
|
+
mint: ZCFMint<"nat">;
|
|
11
|
+
mintAndTransferWithFee: MintAndTransfer;
|
|
12
|
+
poolIncrementSeat: ZCFSeat;
|
|
13
|
+
seatAllocationKeyword: Keyword;
|
|
14
|
+
}, params: {
|
|
15
|
+
interestRate: Ratio;
|
|
16
|
+
chargingPeriod: RelativeTime;
|
|
17
|
+
recordingPeriod: RelativeTime;
|
|
18
|
+
}, prior: {
|
|
19
|
+
latestInterestUpdate: Timestamp;
|
|
20
|
+
compoundedInterest: Ratio;
|
|
21
|
+
totalDebt: Amount<"nat">;
|
|
22
|
+
}, accruedUntil: Timestamp): {
|
|
23
|
+
compoundedInterest: Ratio;
|
|
24
|
+
latestInterestUpdate: Timestamp;
|
|
25
|
+
totalDebt: Amount<"nat">;
|
|
26
|
+
};
|
|
27
|
+
import type { RelativeTime } from '@agoric/time';
|
|
28
|
+
import type { ZCFMint } from '@agoric/zoe';
|
|
29
|
+
import type { Timestamp } from '@agoric/time';
|
|
30
|
+
//# sourceMappingURL=interest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interest.d.ts","sourceRoot":"","sources":["interest.js"],"names":[],"mappings":"AAQA;;;;GAIG;AAEH,sCAAuD;AAchD,mDALI,KAAK,kBACL,YAAY,mBACZ,YAAY,GACV,aAAa,CA+EzB;AASM,qEAJI,KAAK,aACL,QAAQ,WACR,QAAQ,6CAalB;AAyCM,uCAvBI;IACN,IAAI,EAAE,QAAQ,KAAK,CAAC,CAAC;IACrB,sBAAsB,EAAE,eAAe,CAAC;IACxC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,OAAO,CAAC;CAChC,UACO;IACN,YAAY,EAAE,KAAK,CAAC;IACpB,cAAc,EAAE,YAAY,CAAC;IAC7B,eAAe,EAAE,YAAY,CAAC;CAC/B,SACO;IACN,oBAAoB,EAAE,SAAS,CAAC;IAChC,kBAAkB,EAAE,KAAK,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC1B,gBACO,SAAS,GACP;IACR,kBAAkB,EAAE,KAAK,CAAC;IAC1B,oBAAoB,EAAE,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC1B,CA8DH;kCAxN8B,cAAc;6BACW,aAAa;+BAFzC,cAAc"}
|
package/src/interest.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { Fail } from '@endo/errors';
|
|
3
4
|
import { AmountMath } from '@agoric/ertp';
|
|
4
5
|
import { natSafeMath } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
|
-
import {
|
|
6
|
-
makeRatio,
|
|
7
|
-
multiplyRatios,
|
|
8
|
-
quantize,
|
|
9
|
-
} from '@agoric/zoe/src/contractSupport/ratio.js';
|
|
10
|
-
import { Fail } from '@agoric/assert';
|
|
6
|
+
import { makeRatio, multiplyRatios, quantize } from '@agoric/ertp/src/ratio.js';
|
|
11
7
|
import { TimeMath } from '@agoric/time';
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
10
|
+
* @import {Timestamp} from '@agoric/time'
|
|
11
|
+
* @import {RelativeTime} from '@agoric/time'
|
|
12
|
+
* @import {AdminFacet, InvitationAmount, ZCFMint} from '@agoric/zoe';
|
|
16
13
|
*/
|
|
17
14
|
|
|
18
15
|
export const SECONDS_PER_YEAR = 60n * 60n * 24n * 365n;
|
|
@@ -20,9 +17,7 @@ const BASIS_POINTS = 10000;
|
|
|
20
17
|
// single digit APR is less than a basis point per day.
|
|
21
18
|
const LARGE_DENOMINATOR = BASIS_POINTS * BASIS_POINTS;
|
|
22
19
|
|
|
23
|
-
/**
|
|
24
|
-
* Number chosen from 6 digits for a basis point, doubled for multiplication.
|
|
25
|
-
*/
|
|
20
|
+
/** Number chosen from 6 digits for a basis point, doubled for multiplication. */
|
|
26
21
|
const COMPOUNDED_INTEREST_DENOMINATOR = 10n ** 20n;
|
|
27
22
|
|
|
28
23
|
/**
|
|
@@ -147,20 +142,27 @@ const validatedBrand = (mint, debt) => {
|
|
|
147
142
|
* Charge interest accrued between `latestInterestUpdate` and `accruedUntil`.
|
|
148
143
|
*
|
|
149
144
|
* @param {{
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
145
|
+
* mint: ZCFMint<'nat'>;
|
|
146
|
+
* mintAndTransferWithFee: MintAndTransfer;
|
|
147
|
+
* poolIncrementSeat: ZCFSeat;
|
|
148
|
+
* seatAllocationKeyword: Keyword;
|
|
149
|
+
* }} powers
|
|
154
150
|
* @param {{
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
151
|
+
* interestRate: Ratio;
|
|
152
|
+
* chargingPeriod: RelativeTime;
|
|
153
|
+
* recordingPeriod: RelativeTime;
|
|
154
|
+
* }} params
|
|
158
155
|
* @param {{
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
156
|
+
* latestInterestUpdate: Timestamp;
|
|
157
|
+
* compoundedInterest: Ratio;
|
|
158
|
+
* totalDebt: Amount<'nat'>;
|
|
159
|
+
* }} prior
|
|
162
160
|
* @param {Timestamp} accruedUntil
|
|
163
|
-
* @returns {{
|
|
161
|
+
* @returns {{
|
|
162
|
+
* compoundedInterest: Ratio;
|
|
163
|
+
* latestInterestUpdate: Timestamp;
|
|
164
|
+
* totalDebt: Amount<'nat'>;
|
|
165
|
+
* }}
|
|
164
166
|
*/
|
|
165
167
|
export const chargeInterest = (powers, params, prior, accruedUntil) => {
|
|
166
168
|
const brand = validatedBrand(powers.mint, prior.totalDebt);
|
|
@@ -192,7 +194,7 @@ export const chargeInterest = (powers, params, prior, accruedUntil) => {
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
// NB: This method of inferring the compounded rate from the ratio of debts
|
|
195
|
-
//
|
|
197
|
+
// accrued suffers slightly from the integer nature of debts. However in
|
|
196
198
|
// testing with small numbers there's 5 digits of precision, and with large
|
|
197
199
|
// numbers the ratios tend towards ample precision.
|
|
198
200
|
// TODO adopt banker's rounding https://github.com/Agoric/agoric-sdk/issues/4573
|
package/src/price/README.md
CHANGED
|
@@ -4,6 +4,19 @@ This directory contains the `fluxAggregatorKit.js` contract which takes prices a
|
|
|
4
4
|
input and outputs a best known price. There are multiple ways to get the price,
|
|
5
5
|
including a PriceAuthority interface.
|
|
6
6
|
|
|
7
|
+
## Design
|
|
8
|
+
|
|
9
|
+
The authorities are hierarchical. Many authorities can be registered in the priceAuthorityRegistry.
|
|
10
|
+
|
|
11
|
+
For oracles, there must be two: the negotiable brand and the _oracle_ brand (an inert one).
|
|
12
|
+
|
|
13
|
+
The intended flow is that:
|
|
14
|
+
1. a negotiable brand is created (e.g. ATOM)
|
|
15
|
+
2. a price provider says “i can give you quotes for that” and runs price-feed-proposal. That makes “oracleBrands” (which are inert and have a separate identity so that they don’t have the authority to say they’re the real quote for it).
|
|
16
|
+
3. Some higher authority (eg EC, Stakers) decides that should be the quote source for negotiable brand so it registers it under the real brand identity in the registry (with a new instance of a scaledPriceAuthority ).
|
|
17
|
+
|
|
18
|
+
In practice we do these all in one core proposal. And each vault manager is started with a limit on minting to the EC has another way to gate transactions.
|
|
19
|
+
|
|
7
20
|
## Usage
|
|
8
21
|
|
|
9
22
|
See the [Smart Wallet integration test](/packages/inter-protocol/test/smartWallet/test-oracle-integration.js) for how it's used.
|
|
@@ -12,7 +25,7 @@ Oracle operates can make PushPrice offers in the CLI. There is no GUI.
|
|
|
12
25
|
|
|
13
26
|
### CLI
|
|
14
27
|
|
|
15
|
-
See [oracle.js command file](/packages/agoric-cli/src/commands/oracle.js)
|
|
28
|
+
See [oracle.js command file](/packages/agoric-cli/src/commands/oracle.js)
|
|
16
29
|
|
|
17
30
|
```mermaid
|
|
18
31
|
sequenceDiagram
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Baggage} from '@agoric/vat-data'
|
|
3
|
+
* @import {TimerService} from '@agoric/time'
|
|
4
|
+
*/
|
|
5
|
+
/** @type {ContractMeta} */
|
|
6
|
+
export const meta: ContractMeta;
|
|
7
|
+
export function start(zcf: ZCF<import("./fluxAggregatorKit.js").ChainlinkConfig & {
|
|
8
|
+
timer: TimerService;
|
|
9
|
+
brandIn: Brand<"nat">;
|
|
10
|
+
brandOut: Brand<"nat">;
|
|
11
|
+
description: string;
|
|
12
|
+
unitAmountIn?: Amount<"nat">;
|
|
13
|
+
}>, privateArgs: {
|
|
14
|
+
highPrioritySendersManager?: import("@agoric/internal/src/priority-senders.js").PrioritySendersManager;
|
|
15
|
+
initialPoserInvitation: Invitation;
|
|
16
|
+
marshaller: ERef<Marshaller>;
|
|
17
|
+
namesByAddressAdmin: ERef<import("@agoric/vats").NameAdmin>;
|
|
18
|
+
storageNode: StorageNode;
|
|
19
|
+
}, baggage: Baggage): Promise<{
|
|
20
|
+
creatorFacet: import("@endo/exo").Guarded<{
|
|
21
|
+
getParamMgrRetriever: () => {
|
|
22
|
+
get: () => import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
23
|
+
Electorate: "invitation";
|
|
24
|
+
}>;
|
|
25
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
26
|
+
get: () => import("@agoric/governance/src/contractGovernance/typedParamManager.js").TypedParamManager<{
|
|
27
|
+
Electorate: "invitation";
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|
|
30
|
+
getInvitation: (name: any) => Promise<globalThis.Invitation>;
|
|
31
|
+
getLimitedCreatorFacet: () => import("@endo/exo").Guarded<{
|
|
32
|
+
makeOracleInvitation(oracleId: string): Promise<globalThis.Invitation<{
|
|
33
|
+
invitationMakers: {
|
|
34
|
+
PushPrice(result: import("./roundsManager.js").PriceRound): Promise<globalThis.Invitation<void, undefined>>;
|
|
35
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
36
|
+
PushPrice(result: import("./roundsManager.js").PriceRound): Promise<globalThis.Invitation<void, undefined>>;
|
|
37
|
+
}>;
|
|
38
|
+
oracle: import("@endo/exo").Guarded<{
|
|
39
|
+
pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
|
|
40
|
+
getStatus(): OracleStatus;
|
|
41
|
+
}>;
|
|
42
|
+
}, undefined>>;
|
|
43
|
+
removeOracle(oracleId: string): Promise<void>;
|
|
44
|
+
getRoundData: (roundIdRaw: any) => Promise<import("./roundsManager.js").RoundData>;
|
|
45
|
+
initOracle(oracleId: string): Promise<import("@endo/exo").GuardedKit<{
|
|
46
|
+
admin: {
|
|
47
|
+
disable(): void;
|
|
48
|
+
};
|
|
49
|
+
oracle: {
|
|
50
|
+
pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
|
|
51
|
+
getStatus(): OracleStatus;
|
|
52
|
+
};
|
|
53
|
+
}>>;
|
|
54
|
+
oracleRoundState(oracleId: string, queriedRoundId: bigint): Promise<RoundState>;
|
|
55
|
+
}>;
|
|
56
|
+
getGovernedApis: () => GovernedApis;
|
|
57
|
+
getGovernedApiNames: () => string[];
|
|
58
|
+
setOfferFilter: (strings: any) => Promise<void>;
|
|
59
|
+
}>;
|
|
60
|
+
publicFacet: import("@endo/exo").Guarded<{
|
|
61
|
+
getPriceAuthority(): import("@agoric/zoe/tools/types.js").PriceAuthority;
|
|
62
|
+
getPublicTopics(): {
|
|
63
|
+
quotes: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("@agoric/zoe/tools/types.js").PriceDescription>;
|
|
64
|
+
latestRound: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./roundsManager.js").LatestRound>;
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
}>;
|
|
68
|
+
export type FluxStartFn = typeof start;
|
|
69
|
+
import type { TimerService } from '@agoric/time';
|
|
70
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
71
|
+
//# sourceMappingURL=fluxAggregatorContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluxAggregatorContract.d.ts","sourceRoot":"","sources":["fluxAggregatorContract.js"],"names":[],"mappings":"AAcA;;;GAGG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAmBrB;AA0BK,2BAlBI,GAAG,CACb,OAAW,wBAAwB,EAAE,eAAe,GAAG;IACjD,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC9B,CACF,eACO;IACN,0BAA0B,CAAC,EAAE,OAAO,0CAA0C,EAAE,sBAAsB,CAAC;IACvG,sBAAsB,EAAE,UAAU,CAAC;IACnC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,mBAAmB,EAAE,IAAI,CAAC,OAAO,cAAc,EAAE,SAAS,CAAC,CAAC;IAC5D,WAAW,EAAE,WAAW,CAAC;CAC1B,WACO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqIjB;0BAGa,OAAO,KAAK;kCAtLK,cAAc;6BADnB,kBAAkB"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
hasIssuer,
|
|
5
|
-
makeDurableIssuerKit,
|
|
6
|
-
prepareIssuerKit,
|
|
7
|
-
} from '@agoric/ertp';
|
|
3
|
+
import { prepareIssuerKit } from '@agoric/ertp';
|
|
8
4
|
import { handleParamGovernance } from '@agoric/governance';
|
|
9
5
|
import { makeTracer, StorageNodeShape } from '@agoric/internal';
|
|
10
6
|
import { prepareDurablePublishKit } from '@agoric/notifier';
|
|
@@ -17,56 +13,69 @@ import { prepareFluxAggregatorKit } from './fluxAggregatorKit.js';
|
|
|
17
13
|
|
|
18
14
|
const trace = makeTracer('FluxAgg', false);
|
|
19
15
|
/**
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
16
|
+
* @import {Baggage} from '@agoric/vat-data'
|
|
17
|
+
* @import {TimerService} from '@agoric/time'
|
|
22
18
|
*/
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
M.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
20
|
+
/** @type {ContractMeta} */
|
|
21
|
+
export const meta = {
|
|
22
|
+
privateArgsShape: M.splitRecord(
|
|
23
|
+
{
|
|
24
|
+
storageNode: StorageNodeShape,
|
|
25
|
+
marshaller: M.eref(M.remotable('marshaller')),
|
|
26
|
+
namesByAddressAdmin: M.any(),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
// always optional. XXX some code is including the key, set to null
|
|
30
|
+
highPrioritySendersManager: M.or(
|
|
31
|
+
M.remotable('prioritySenders manager'),
|
|
32
|
+
M.null(),
|
|
33
|
+
),
|
|
34
|
+
// only necessary on first invocation, not subsequent
|
|
35
|
+
initialPoserInvitation: M.remotable('Invitation'),
|
|
36
|
+
},
|
|
37
|
+
),
|
|
38
|
+
upgradability: 'canUpgrade',
|
|
39
|
+
};
|
|
40
|
+
harden(meta);
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
* PriceAuthority for their median. Unlike the simpler `priceAggregator.js`,
|
|
43
|
-
* the
|
|
43
|
+
* PriceAuthority for their median. Unlike the simpler `priceAggregator.js`,
|
|
44
|
+
* this approximates the _Node Operator Aggregation_ logic of [Chainlink price
|
|
44
45
|
* feeds](https://blog.chain.link/levels-of-data-aggregation-in-chainlink-price-feeds/).
|
|
45
46
|
*
|
|
46
|
-
* @param {ZCF<
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
47
|
+
* @param {ZCF<
|
|
48
|
+
* import('./fluxAggregatorKit.js').ChainlinkConfig & {
|
|
49
|
+
* timer: TimerService;
|
|
50
|
+
* brandIn: Brand<'nat'>;
|
|
51
|
+
* brandOut: Brand<'nat'>;
|
|
52
|
+
* description: string;
|
|
53
|
+
* unitAmountIn?: Amount<'nat'>;
|
|
54
|
+
* }
|
|
55
|
+
* >} zcf
|
|
53
56
|
* @param {{
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* highPrioritySendersManager?: import('@agoric/internal/src/priority-senders.js').PrioritySendersManager;
|
|
58
|
+
* initialPoserInvitation: Invitation;
|
|
59
|
+
* marshaller: ERef<Marshaller>;
|
|
60
|
+
* namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>;
|
|
61
|
+
* storageNode: StorageNode;
|
|
59
62
|
* }} privateArgs
|
|
60
63
|
* @param {Baggage} baggage
|
|
61
64
|
*/
|
|
62
|
-
export const
|
|
65
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
63
66
|
trace('prepare with baggage keys', [...baggage.keys()]);
|
|
64
67
|
|
|
65
68
|
// xxx uses contract baggage as issuerBagage, assumes one issuer in this contract
|
|
66
69
|
/** @type {import('./roundsManager.js').QuoteKit} */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
// @ts-expect-error cast
|
|
71
|
+
const quoteIssuerKit = prepareIssuerKit(
|
|
72
|
+
baggage,
|
|
73
|
+
'quote',
|
|
74
|
+
'set',
|
|
75
|
+
undefined,
|
|
76
|
+
undefined,
|
|
77
|
+
{ recoverySetsOption: 'noRecoverySets' },
|
|
78
|
+
);
|
|
70
79
|
|
|
71
80
|
const {
|
|
72
81
|
highPrioritySendersManager,
|
|
@@ -131,10 +140,8 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
131
140
|
addr,
|
|
132
141
|
[invitation],
|
|
133
142
|
);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
await E(highPrioritySendersManager).add(description, addr);
|
|
137
|
-
}
|
|
143
|
+
await (highPrioritySendersManager &&
|
|
144
|
+
E(highPrioritySendersManager).add(description, addr));
|
|
138
145
|
return `added ${addr}`;
|
|
139
146
|
};
|
|
140
147
|
|
|
@@ -146,29 +153,29 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
146
153
|
const removeOracle = async addr => {
|
|
147
154
|
trace('removeOracle', addr);
|
|
148
155
|
await E(faKit.creator).removeOracle(addr);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
await E(highPrioritySendersManager).remove(description, addr);
|
|
152
|
-
}
|
|
156
|
+
await (highPrioritySendersManager &&
|
|
157
|
+
E(highPrioritySendersManager).remove(description, addr));
|
|
153
158
|
return `removed ${addr}`;
|
|
154
159
|
};
|
|
155
160
|
|
|
156
161
|
const governedApis = {
|
|
157
162
|
/**
|
|
158
|
-
* Add the specified oracles. May partially fail, such that some oracles are
|
|
163
|
+
* Add the specified oracles. May partially fail, such that some oracles are
|
|
164
|
+
* added and others aren't.
|
|
159
165
|
*
|
|
160
166
|
* @param {string[]} addrs
|
|
161
|
-
* @returns {Promise<
|
|
167
|
+
* @returns {Promise<PromiseSettledResult<string>[]>}
|
|
162
168
|
*/
|
|
163
169
|
addOracles: addrs => {
|
|
164
170
|
return Promise.allSettled(addrs.map(addOracle));
|
|
165
171
|
},
|
|
166
172
|
/**
|
|
167
|
-
* Remove the specified oracles. May partially fail, such that some oracles
|
|
168
|
-
* If the oracle was never part of the set
|
|
173
|
+
* Remove the specified oracles. May partially fail, such that some oracles
|
|
174
|
+
* are removed and others aren't. If the oracle was never part of the set
|
|
175
|
+
* that's a PromiseRejectedResult
|
|
169
176
|
*
|
|
170
177
|
* @param {string[]} addrs
|
|
171
|
-
* @returns {Promise<
|
|
178
|
+
* @returns {Promise<PromiseSettledResult<string>[]>}
|
|
172
179
|
*/
|
|
173
180
|
removeOracles: addrs => {
|
|
174
181
|
return Promise.allSettled(addrs.map(removeOracle));
|
|
@@ -187,4 +194,6 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
187
194
|
publicFacet: faKit.public,
|
|
188
195
|
});
|
|
189
196
|
};
|
|
190
|
-
harden(
|
|
197
|
+
harden(start);
|
|
198
|
+
|
|
199
|
+
/** @typedef {typeof start} FluxStartFn */
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export const INVITATION_MAKERS_DESC: "oracle invitation";
|
|
2
|
+
export function prepareFluxAggregatorKit(baggage: Baggage, zcf: ZCF<ChainlinkConfig & {
|
|
3
|
+
timer: TimerService;
|
|
4
|
+
brandIn: Brand<"nat">;
|
|
5
|
+
brandOut: Brand<"nat">;
|
|
6
|
+
unitAmountIn?: Amount<"nat">;
|
|
7
|
+
}>, timerPresence: TimerService, quoteKit: import("./roundsManager.js").QuoteKit, storageNode: StorageNode, makeDurablePublishKit: () => PublishKit<any>, makeRecorder: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorder): Promise<() => import("@endo/exo").GuardedKit<{
|
|
8
|
+
creator: {
|
|
9
|
+
/**
|
|
10
|
+
* An "oracle invitation" is an invitation to be able to submit data to
|
|
11
|
+
* include in the priceAggregator's results.
|
|
12
|
+
*
|
|
13
|
+
* The offer result from this invitation is a OracleAdmin, which can be
|
|
14
|
+
* used directly to manage the price submissions as well as to terminate
|
|
15
|
+
* the relationship.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} oracleId unique per contract instance
|
|
18
|
+
*/
|
|
19
|
+
makeOracleInvitation(oracleId: string): Promise<globalThis.Invitation<{
|
|
20
|
+
invitationMakers: {
|
|
21
|
+
/** @param {import('./roundsManager.js').PriceRound} result */
|
|
22
|
+
PushPrice(result: import("./roundsManager.js").PriceRound): Promise<globalThis.Invitation<void, undefined>>;
|
|
23
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
24
|
+
/** @param {import('./roundsManager.js').PriceRound} result */
|
|
25
|
+
PushPrice(result: import("./roundsManager.js").PriceRound): Promise<globalThis.Invitation<void, undefined>>;
|
|
26
|
+
}>;
|
|
27
|
+
oracle: import("@endo/exo").Guarded<{
|
|
28
|
+
pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
|
|
29
|
+
getStatus(): OracleStatus;
|
|
30
|
+
}>;
|
|
31
|
+
}, undefined>>;
|
|
32
|
+
/** @param {string} oracleId */
|
|
33
|
+
removeOracle(oracleId: string): Promise<void>;
|
|
34
|
+
getRoundData: (roundIdRaw: any) => Promise<import("./roundsManager.js").RoundData>;
|
|
35
|
+
/** @param {string} oracleId */
|
|
36
|
+
initOracle(oracleId: string): Promise<import("@endo/exo").GuardedKit<{
|
|
37
|
+
admin: {
|
|
38
|
+
disable(): void;
|
|
39
|
+
};
|
|
40
|
+
oracle: {
|
|
41
|
+
pushPrice({ roundId: roundIdRaw, unitPrice: valueRaw, }: PriceDatum): Promise<void>;
|
|
42
|
+
getStatus(): OracleStatus;
|
|
43
|
+
};
|
|
44
|
+
}>>;
|
|
45
|
+
/**
|
|
46
|
+
* a method to provide all current info oracleStatuses need. Intended
|
|
47
|
+
* only only to be callable by oracleStatuses. Not for use by contracts
|
|
48
|
+
* to read state.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} oracleId
|
|
51
|
+
* @param {bigint} queriedRoundId
|
|
52
|
+
* @returns {Promise<RoundState>}
|
|
53
|
+
*/
|
|
54
|
+
oracleRoundState(oracleId: string, queriedRoundId: bigint): Promise<RoundState>;
|
|
55
|
+
};
|
|
56
|
+
public: {
|
|
57
|
+
getPriceAuthority(): PriceAuthority;
|
|
58
|
+
getPublicTopics(): {
|
|
59
|
+
quotes: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<PriceDescription>;
|
|
60
|
+
latestRound: import("@agoric/zoe/src/contractSupport/topics.js").PublicTopic<import("./roundsManager.js").LatestRound>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}>>;
|
|
64
|
+
export type RoundState = {
|
|
65
|
+
eligibleForSpecificRound: boolean;
|
|
66
|
+
queriedRoundId: bigint;
|
|
67
|
+
latestSubmission: bigint;
|
|
68
|
+
startedAt: Timestamp;
|
|
69
|
+
roundTimeout: number;
|
|
70
|
+
oracleCount: number;
|
|
71
|
+
};
|
|
72
|
+
export type ChainlinkConfig = {
|
|
73
|
+
maxSubmissionCount: number;
|
|
74
|
+
minSubmissionCount: number;
|
|
75
|
+
/**
|
|
76
|
+
* the number of rounds an Oracle has to wait
|
|
77
|
+
* before they can initiate a round
|
|
78
|
+
*/
|
|
79
|
+
restartDelay: bigint;
|
|
80
|
+
/**
|
|
81
|
+
* an immutable check for a lower bound of
|
|
82
|
+
* what submission values are accepted from an oracle
|
|
83
|
+
*/
|
|
84
|
+
minSubmissionValue: number;
|
|
85
|
+
/**
|
|
86
|
+
* an immutable check for an upper bound
|
|
87
|
+
* of what submission values are accepted from an oracle
|
|
88
|
+
*/
|
|
89
|
+
maxSubmissionValue: number;
|
|
90
|
+
/**
|
|
91
|
+
* the number of seconds after the previous round
|
|
92
|
+
* that allowed to lapse before allowing an oracle to skip an unfinished
|
|
93
|
+
* round
|
|
94
|
+
*/
|
|
95
|
+
timeout: number;
|
|
96
|
+
};
|
|
97
|
+
export type FluxAggregatorKit = EReturn<EReturn<typeof prepareFluxAggregatorKit>>;
|
|
98
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
99
|
+
import type { TimerService } from '@agoric/time';
|
|
100
|
+
import type { PriceAuthority } from '@agoric/zoe/tools/types.js';
|
|
101
|
+
import type { PriceDescription } from '@agoric/zoe/tools/types.js';
|
|
102
|
+
import type { Timestamp } from '@agoric/time';
|
|
103
|
+
import type { EReturn } from '@endo/far';
|
|
104
|
+
//# sourceMappingURL=fluxAggregatorKit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluxAggregatorKit.d.ts","sourceRoot":"","sources":["fluxAggregatorKit.js"],"names":[],"mappings":"AA6BA,qCAAsC,mBAAmB,CAAC;AAgEnD,kDAfI,OAAO,OACP,GAAG,CACT,eAAe,GAAG;IAChB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC9B,CACF,iBACO,YAAY,YACZ,OAAO,oBAAoB,EAAE,QAAQ,eACrC,WAAW,yBACX,MAAM,UAAU,CAAC,GAAG,CAAC,gBACrB,OAAO,6CAA6C,EAAE,YAAY;;QA8IrE;;;;;;;;;WASG;uCADQ,MAAM;;gBAiBX,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;gBAAnD,8DAA8D;kCAAlD,OAAO,oBAAoB,EAAE,UAAU;;;;;;;QAqBzD,+BAA+B;+BAAnB,MAAM;;QAalB,+BAA+B;6BAAnB,MAAM;;;;;;;;;QAoBlB;;;;;;;;WAQG;mCAHQ,MAAM,kBACN,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC;;;;;;;;;IAqDvC;;8BAvUa,OAAO;oBACP,MAAM;sBACN,MAAM;eACN,SAAS;kBACT,MAAM;iBACN,MAAM;;;wBAMN,MAAM;wBACN,MAAM;;;;;kBACN,MAAM;;;;;wBAEN,MAAM;;;;;wBAEN,MAAM;;;;;;aAEN,MAAM;;gCAsTN,QAAQ,QAAQ,OAAO,wBAAwB,CAAC,CAAC;6BAtVrC,kBAAkB;kCAKb,cAAc;oCAdgD,4BAA4B;sCAA5B,4BAA4B;+BAU7F,cAAc;6BAZhB,WAAW"}
|