@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/contractSupport.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
import { Fail, q } from '@endo/errors';
|
|
3
4
|
import { AmountMath } from '@agoric/ertp';
|
|
4
5
|
import { M } from '@agoric/store';
|
|
5
6
|
import { makeRatioFromAmounts } from '@agoric/zoe/src/contractSupport/index.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
/** @import {PriceAuthority, PriceDescription, PriceQuote, PriceQuoteValue, PriceQuery,} from '@agoric/zoe/tools/types.js'; */
|
|
8
9
|
|
|
9
10
|
export const amountPattern = harden({ brand: M.remotable(), value: M.any() });
|
|
10
11
|
export const ratioPattern = harden({
|
|
@@ -13,17 +14,17 @@ export const ratioPattern = harden({
|
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Apply a delta to the `base` Amount, where the delta is represented as
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Apply a delta to the `base` Amount, where the delta is represented as an
|
|
18
|
+
* amount to gain and an amount to lose. Typically one of those will be empty
|
|
19
|
+
* because gain/loss comes from the give/want for a specific asset on a
|
|
20
|
+
* proposal. We use two Amounts because an Amount cannot represent a negative
|
|
21
|
+
* number (so we use a "loss" that will be subtracted).
|
|
21
22
|
*
|
|
22
|
-
* @template {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
26
|
-
* @returns {
|
|
23
|
+
* @template {Amount} A
|
|
24
|
+
* @param {A} base
|
|
25
|
+
* @param {A} gain
|
|
26
|
+
* @param {A} loss
|
|
27
|
+
* @returns {A}
|
|
27
28
|
*/
|
|
28
29
|
export const addSubtract = (base, gain, loss) =>
|
|
29
30
|
AmountMath.subtract(AmountMath.add(base, gain), loss);
|
|
@@ -66,8 +67,13 @@ export const allEmpty = amounts => {
|
|
|
66
67
|
* @param {Amount<'nat'>} totalDebt
|
|
67
68
|
* @param {Amount<'nat'>} toMint
|
|
68
69
|
* @throws if minting would exceed total debt
|
|
70
|
+
*
|
|
71
|
+
* Note: Succeeds regardless of debtLimit if toMint is empty.
|
|
69
72
|
*/
|
|
70
73
|
export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {
|
|
74
|
+
if (AmountMath.isEmpty(toMint)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
71
77
|
const debtPost = AmountMath.add(totalDebt, toMint);
|
|
72
78
|
AmountMath.isGTE(debtLimit, debtPost) ||
|
|
73
79
|
Fail`Minting ${q(toMint)} past ${q(
|
|
@@ -77,14 +83,14 @@ export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {
|
|
|
77
83
|
|
|
78
84
|
/**
|
|
79
85
|
* @template T
|
|
80
|
-
* @typedef {object} MetricsPublisherKit
|
|
86
|
+
* @typedef {object} MetricsPublisherKit
|
|
81
87
|
* @property {IterationObserver<T>} metricsPublication
|
|
82
88
|
* @property {StoredSubscription<T>} metricsSubscription
|
|
83
89
|
*/
|
|
84
90
|
|
|
85
91
|
/**
|
|
86
92
|
* @template T
|
|
87
|
-
* @typedef {object} MetricsPublishKit
|
|
93
|
+
* @typedef {object} MetricsPublishKit
|
|
88
94
|
* @property {Publisher<T>} metricsPublisher
|
|
89
95
|
* @property {StoredSubscriber<T>} metricsSubscriber
|
|
90
96
|
*/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {MapStore, SetStore} from '@agoric/store';
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @file This contract makes it possible for those who govern contracts to call
|
|
6
|
+
* for votes on changes. A more complete implementation would validate
|
|
7
|
+
* parameters, constrain deadlines and possibly split the ability to call for
|
|
8
|
+
* votes into separate capabilities for finer grain encapsulation.
|
|
9
|
+
*/
|
|
10
|
+
export const INVITATION_MAKERS_DESC: "charter member invitation";
|
|
11
|
+
/** @type {ContractMeta<typeof start>} */
|
|
12
|
+
export const meta: ContractMeta<typeof start>;
|
|
13
|
+
export function start(zcf: ZCF<{
|
|
14
|
+
binaryVoteCounterInstallation: Installation;
|
|
15
|
+
}>, privateArgs: undefined, baggage: import("@agoric/vat-data").Baggage): Promise<{
|
|
16
|
+
creatorFacet: import("@endo/exo").Guarded<{
|
|
17
|
+
/**
|
|
18
|
+
* @param {Instance} governedInstance
|
|
19
|
+
* @param {GovernorCreatorFacet<any>} governorFacet
|
|
20
|
+
* @param {string} [label] for diagnostic use only
|
|
21
|
+
*/
|
|
22
|
+
addInstance: (governedInstance: Instance, governorFacet: GovernorCreatorFacet<any>, label?: string) => void;
|
|
23
|
+
makeCharterMemberInvitation: () => Promise<globalThis.Invitation<{
|
|
24
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
25
|
+
VoteOnParamChange: () => Promise<globalThis.Invitation<import("@agoric/governance/src/types").ContractGovernanceVoteResult, ParamChangesOfferArgs>>;
|
|
26
|
+
VoteOnPauseOffers: (instance: any, strings: any, deadline: any) => Promise<globalThis.Invitation<import("@agoric/governance/src/types").ContractGovernanceVoteResult, undefined>>;
|
|
27
|
+
VoteOnApiCall: (instance: Instance, methodName: string, methodArgs: string[], deadline: import("@agoric/time").TimestampValue) => Promise<globalThis.Invitation<import("@agoric/governance/src/types").ContractGovernanceVoteResult, undefined>>;
|
|
28
|
+
}>;
|
|
29
|
+
}, undefined>>;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
export type ParamChangesOfferArgs = {
|
|
33
|
+
deadline: bigint;
|
|
34
|
+
instance: Instance;
|
|
35
|
+
params: Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* paramPath is determined by contract
|
|
38
|
+
*/
|
|
39
|
+
path?: {
|
|
40
|
+
paramPath: unknown;
|
|
41
|
+
} | undefined;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=econCommitteeCharter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"econCommitteeCharter.d.ts","sourceRoot":"","sources":["econCommitteeCharter.js"],"names":[],"mappings":"AAaA;;GAEG;AAEH;;;;;GAKG;AAEH,qCAAsC,2BAA2B,CAAC;AAoBlE,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAMnC;AAQK,2BAJI,GAAG,CAAC;IAAE,6BAA6B,EAAE,YAAY,CAAA;CAAE,CAAC,eACpD,SAAS,WACT,OAAO,kBAAkB,EAAE,OAAO;;QAsHvC;;;;WAIG;wCAHQ,QAAQ,iBACR,oBAAoB,CAAC,GAAG,CAAC,UACzB,MAAM;;;;;0CAzEV,QAAQ,cACR,MAAM,cACN,MAAM,EAAE,YACR,OAAO,cAAc,EAAE,cAAc;;;;GAkFjD;;cAjKa,MAAM;cACN,QAAQ;YACR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;mBACV,OAAO"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
|
+
/// <reference types="@agoric/governance/exported" />
|
|
3
|
+
/// <reference types="@agoric/zoe/exported" />
|
|
2
4
|
|
|
3
|
-
import '@agoric/governance/exported.js';
|
|
4
5
|
import { M, mustMatch } from '@agoric/store';
|
|
5
6
|
import { TimestampShape } from '@agoric/time';
|
|
6
7
|
import { prepareExo, provideDurableMapStore } from '@agoric/vat-data';
|
|
7
|
-
import '@agoric/zoe/exported.js';
|
|
8
|
-
import '@agoric/zoe/src/contracts/exported.js';
|
|
9
8
|
import {
|
|
10
9
|
InstallationShape,
|
|
11
10
|
InstanceHandleShape,
|
|
@@ -13,12 +12,14 @@ import {
|
|
|
13
12
|
import { E } from '@endo/far';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* @import {MapStore, SetStore} from '@agoric/store';
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @file This contract makes it possible for those who govern contracts to call
|
|
20
|
+
* for votes on changes. A more complete implementation would validate
|
|
21
|
+
* parameters, constrain deadlines and possibly split the ability to call for
|
|
22
|
+
* votes into separate capabilities for finer grain encapsulation.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
export const INVITATION_MAKERS_DESC = 'charter member invitation';
|
|
@@ -28,7 +29,7 @@ export const INVITATION_MAKERS_DESC = 'charter member invitation';
|
|
|
28
29
|
* @property {bigint} deadline
|
|
29
30
|
* @property {Instance} instance
|
|
30
31
|
* @property {Record<string, unknown>} params
|
|
31
|
-
* @property {{paramPath:
|
|
32
|
+
* @property {{ paramPath: unknown }} [path] paramPath is determined by contract
|
|
32
33
|
*/
|
|
33
34
|
const ParamChangesOfferArgsShape = M.splitRecord(
|
|
34
35
|
{
|
|
@@ -41,19 +42,21 @@ const ParamChangesOfferArgsShape = M.splitRecord(
|
|
|
41
42
|
},
|
|
42
43
|
);
|
|
43
44
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/** @type {ContractMeta<typeof start>} */
|
|
46
|
+
export const meta = {
|
|
47
|
+
customTermsShape: {
|
|
48
|
+
binaryVoteCounterInstallation: InstallationShape,
|
|
49
|
+
},
|
|
50
|
+
upgradability: 'canUpgrade',
|
|
51
|
+
};
|
|
52
|
+
harden(meta);
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
|
-
* @param {ZCF<{binaryVoteCounterInstallation: Installation}>} zcf
|
|
55
|
+
* @param {ZCF<{ binaryVoteCounterInstallation: Installation }>} zcf
|
|
53
56
|
* @param {undefined} privateArgs
|
|
54
57
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
55
58
|
*/
|
|
56
|
-
export const
|
|
59
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
57
60
|
const { binaryVoteCounterInstallation: counter } = zcf.getTerms();
|
|
58
61
|
/** @type {MapStore<Instance, GovernorCreatorFacet<any>>} */
|
|
59
62
|
const instanceToGovernor = provideDurableMapStore(
|
|
@@ -79,6 +82,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
79
82
|
const governor = instanceToGovernor.get(instance);
|
|
80
83
|
return E(governor).voteOnParamChanges(counter, deadline, {
|
|
81
84
|
...path,
|
|
85
|
+
// @ts-expect-error XXX
|
|
82
86
|
changes: params,
|
|
83
87
|
});
|
|
84
88
|
};
|
|
@@ -156,7 +160,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
156
160
|
return harden({ invitationMakers });
|
|
157
161
|
};
|
|
158
162
|
|
|
159
|
-
const
|
|
163
|
+
const CharterCreatorI = M.interface('Charter creatorFacet', {
|
|
160
164
|
addInstance: M.call(InstanceHandleShape, M.any())
|
|
161
165
|
.optional(M.string())
|
|
162
166
|
.returns(),
|
|
@@ -166,7 +170,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
166
170
|
const creatorFacet = prepareExo(
|
|
167
171
|
baggage,
|
|
168
172
|
'Charter creatorFacet',
|
|
169
|
-
|
|
173
|
+
CharterCreatorI,
|
|
170
174
|
{
|
|
171
175
|
/**
|
|
172
176
|
* @param {Instance} governedInstance
|
|
@@ -184,3 +188,4 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
184
188
|
|
|
185
189
|
return harden({ creatorFacet });
|
|
186
190
|
};
|
|
191
|
+
harden(start);
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/** @type {ContractMeta<typeof start>} */
|
|
2
|
+
export const meta: ContractMeta<typeof start>;
|
|
3
|
+
export function makeContractFeeCollector(zoe: ERef<ZoeService>, creatorFacet: ERef<CollectibleContractFacet>): {
|
|
4
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
5
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
6
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
7
|
+
}>;
|
|
8
|
+
export function startDistributing(schedulePayments: () => Promise<unknown>, timerService: ERef<TimerService>, collectionInterval?: RelativeTime): void;
|
|
9
|
+
export function makeShareConfig(destinations?: Record<Keyword, ERef<FeeDestination>>, keywordShares?: Record<Keyword, NatValue>): {
|
|
10
|
+
shares: {
|
|
11
|
+
share: bigint;
|
|
12
|
+
destination: globalThis.ERef<FeeDestination>;
|
|
13
|
+
}[];
|
|
14
|
+
totalShares: bigint;
|
|
15
|
+
};
|
|
16
|
+
export function sharePayment(payment: Payment<"nat">, issuer: ERef<Issuer<"nat">>, { shares, totalShares }: ShareConfig): Promise<void>;
|
|
17
|
+
export function makeFeeDistributor(feeIssuer: ERef<Issuer<"nat">>, terms: {
|
|
18
|
+
keywordShares: Record<Keyword, NatValue>;
|
|
19
|
+
timerService: ERef<TimerService>;
|
|
20
|
+
collectionInterval: RelativeTime;
|
|
21
|
+
}): {
|
|
22
|
+
creatorFacet: {
|
|
23
|
+
makeContractFeeCollector: (zoe: ERef<ZoeService>, creatorFacet: ERef<CollectibleContractFacet>) => {
|
|
24
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
25
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
26
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Start distributing fees from this collector.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} debugName
|
|
32
|
+
* @param {ERef<FeeCollector>} collectorP
|
|
33
|
+
*/
|
|
34
|
+
startPeriodicCollection: (debugName: string, collectorP: ERef<FeeCollector>) => Promise<PeriodicFeeCollector>;
|
|
35
|
+
/**
|
|
36
|
+
* @param {import('@endo/far').EOnly<
|
|
37
|
+
* import('@agoric/ertp/src/types.js').DepositFacet
|
|
38
|
+
* >} depositFacet
|
|
39
|
+
*/
|
|
40
|
+
makeDepositFacetDestination: (depositFacet: import("@endo/far").EOnly<import("@agoric/ertp/src/types.js").DepositFacet>) => {
|
|
41
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
42
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
43
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Create a destination that generates invitations and makes Zoe offers.
|
|
47
|
+
*
|
|
48
|
+
* @param {ERef<ZoeService>} zoe
|
|
49
|
+
* @param {string} keyword
|
|
50
|
+
* @param {unknown} target
|
|
51
|
+
* @param {PropertyKey} makeInvitationMethod
|
|
52
|
+
* @param {unknown[]} [args]
|
|
53
|
+
*/
|
|
54
|
+
makeOfferDestination: (zoe: ERef<ZoeService>, keyword: string, target: unknown, makeInvitationMethod: PropertyKey, args?: unknown[]) => {
|
|
55
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
56
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
57
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
58
|
+
}>;
|
|
59
|
+
/** @param {Record<Keyword, ERef<FeeDestination>>} newDestinations */
|
|
60
|
+
setDestinations: (newDestinations: Record<Keyword, ERef<FeeDestination>>) => Promise<void>;
|
|
61
|
+
/** @param {Record<Keyword, bigint>} newShares */
|
|
62
|
+
setKeywordShares: (newShares: Record<Keyword, bigint>) => void;
|
|
63
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
64
|
+
makeContractFeeCollector: (zoe: ERef<ZoeService>, creatorFacet: ERef<CollectibleContractFacet>) => {
|
|
65
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
66
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
67
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Start distributing fees from this collector.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} debugName
|
|
73
|
+
* @param {ERef<FeeCollector>} collectorP
|
|
74
|
+
*/
|
|
75
|
+
startPeriodicCollection: (debugName: string, collectorP: ERef<FeeCollector>) => Promise<PeriodicFeeCollector>;
|
|
76
|
+
/**
|
|
77
|
+
* @param {import('@endo/far').EOnly<
|
|
78
|
+
* import('@agoric/ertp/src/types.js').DepositFacet
|
|
79
|
+
* >} depositFacet
|
|
80
|
+
*/
|
|
81
|
+
makeDepositFacetDestination: (depositFacet: import("@endo/far").EOnly<import("@agoric/ertp/src/types.js").DepositFacet>) => {
|
|
82
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
83
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
84
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Create a destination that generates invitations and makes Zoe offers.
|
|
88
|
+
*
|
|
89
|
+
* @param {ERef<ZoeService>} zoe
|
|
90
|
+
* @param {string} keyword
|
|
91
|
+
* @param {unknown} target
|
|
92
|
+
* @param {PropertyKey} makeInvitationMethod
|
|
93
|
+
* @param {unknown[]} [args]
|
|
94
|
+
*/
|
|
95
|
+
makeOfferDestination: (zoe: ERef<ZoeService>, keyword: string, target: unknown, makeInvitationMethod: PropertyKey, args?: unknown[]) => {
|
|
96
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
97
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
98
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
99
|
+
}>;
|
|
100
|
+
/** @param {Record<Keyword, ERef<FeeDestination>>} newDestinations */
|
|
101
|
+
setDestinations: (newDestinations: Record<Keyword, ERef<FeeDestination>>) => Promise<void>;
|
|
102
|
+
/** @param {Record<Keyword, bigint>} newShares */
|
|
103
|
+
setKeywordShares: (newShares: Record<Keyword, bigint>) => void;
|
|
104
|
+
}>;
|
|
105
|
+
publicFacet: {
|
|
106
|
+
distributeFees: (payment: Payment<"nat">) => Promise<void>;
|
|
107
|
+
getKeywordShares: () => Record<string, bigint>;
|
|
108
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
109
|
+
distributeFees: (payment: Payment<"nat">) => Promise<void>;
|
|
110
|
+
getKeywordShares: () => Record<string, bigint>;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
113
|
+
export function start(zcf: ZCF<Parameters<typeof makeFeeDistributor>[1]>): Promise<{
|
|
114
|
+
creatorFacet: {
|
|
115
|
+
makeContractFeeCollector: (zoe: ERef<ZoeService>, creatorFacet: ERef<CollectibleContractFacet>) => {
|
|
116
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
117
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
118
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Start distributing fees from this collector.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} debugName
|
|
124
|
+
* @param {ERef<FeeCollector>} collectorP
|
|
125
|
+
*/
|
|
126
|
+
startPeriodicCollection: (debugName: string, collectorP: ERef<FeeCollector>) => Promise<PeriodicFeeCollector>;
|
|
127
|
+
/**
|
|
128
|
+
* @param {import('@endo/far').EOnly<
|
|
129
|
+
* import('@agoric/ertp/src/types.js').DepositFacet
|
|
130
|
+
* >} depositFacet
|
|
131
|
+
*/
|
|
132
|
+
makeDepositFacetDestination: (depositFacet: import("@endo/far").EOnly<import("@agoric/ertp/src/types.js").DepositFacet>) => {
|
|
133
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
134
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
135
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a destination that generates invitations and makes Zoe offers.
|
|
139
|
+
*
|
|
140
|
+
* @param {ERef<ZoeService>} zoe
|
|
141
|
+
* @param {string} keyword
|
|
142
|
+
* @param {unknown} target
|
|
143
|
+
* @param {PropertyKey} makeInvitationMethod
|
|
144
|
+
* @param {unknown[]} [args]
|
|
145
|
+
*/
|
|
146
|
+
makeOfferDestination: (zoe: ERef<ZoeService>, keyword: string, target: unknown, makeInvitationMethod: PropertyKey, args?: unknown[]) => {
|
|
147
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
148
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
149
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
150
|
+
}>;
|
|
151
|
+
/** @param {Record<Keyword, ERef<FeeDestination>>} newDestinations */
|
|
152
|
+
setDestinations: (newDestinations: Record<Keyword, ERef<FeeDestination>>) => Promise<void>;
|
|
153
|
+
/** @param {Record<Keyword, bigint>} newShares */
|
|
154
|
+
setKeywordShares: (newShares: Record<Keyword, bigint>) => void;
|
|
155
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
156
|
+
makeContractFeeCollector: (zoe: ERef<ZoeService>, creatorFacet: ERef<CollectibleContractFacet>) => {
|
|
157
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
158
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
159
|
+
collectFees: () => Promise<globalThis.Payment<any, any>>;
|
|
160
|
+
}>;
|
|
161
|
+
/**
|
|
162
|
+
* Start distributing fees from this collector.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} debugName
|
|
165
|
+
* @param {ERef<FeeCollector>} collectorP
|
|
166
|
+
*/
|
|
167
|
+
startPeriodicCollection: (debugName: string, collectorP: ERef<FeeCollector>) => Promise<PeriodicFeeCollector>;
|
|
168
|
+
/**
|
|
169
|
+
* @param {import('@endo/far').EOnly<
|
|
170
|
+
* import('@agoric/ertp/src/types.js').DepositFacet
|
|
171
|
+
* >} depositFacet
|
|
172
|
+
*/
|
|
173
|
+
makeDepositFacetDestination: (depositFacet: import("@endo/far").EOnly<import("@agoric/ertp/src/types.js").DepositFacet>) => {
|
|
174
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
175
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
176
|
+
pushPayment: (payment: any, _issuer: any) => Promise<globalThis.Amount>;
|
|
177
|
+
}>;
|
|
178
|
+
/**
|
|
179
|
+
* Create a destination that generates invitations and makes Zoe offers.
|
|
180
|
+
*
|
|
181
|
+
* @param {ERef<ZoeService>} zoe
|
|
182
|
+
* @param {string} keyword
|
|
183
|
+
* @param {unknown} target
|
|
184
|
+
* @param {PropertyKey} makeInvitationMethod
|
|
185
|
+
* @param {unknown[]} [args]
|
|
186
|
+
*/
|
|
187
|
+
makeOfferDestination: (zoe: ERef<ZoeService>, keyword: string, target: unknown, makeInvitationMethod: PropertyKey, args?: unknown[]) => {
|
|
188
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
189
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
190
|
+
pushPayment: (payment: any, issuer: any) => Promise<any>;
|
|
191
|
+
}>;
|
|
192
|
+
/** @param {Record<Keyword, ERef<FeeDestination>>} newDestinations */
|
|
193
|
+
setDestinations: (newDestinations: Record<Keyword, ERef<FeeDestination>>) => Promise<void>;
|
|
194
|
+
/** @param {Record<Keyword, bigint>} newShares */
|
|
195
|
+
setKeywordShares: (newShares: Record<Keyword, bigint>) => void;
|
|
196
|
+
}>;
|
|
197
|
+
publicFacet: {
|
|
198
|
+
distributeFees: (payment: Payment<"nat">) => Promise<void>;
|
|
199
|
+
getKeywordShares: () => Record<string, bigint>;
|
|
200
|
+
} & RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
201
|
+
distributeFees: (payment: Payment<"nat">) => Promise<void>;
|
|
202
|
+
getKeywordShares: () => Record<string, bigint>;
|
|
203
|
+
}>;
|
|
204
|
+
}>;
|
|
205
|
+
export type FeeCollector = {
|
|
206
|
+
collectFees: () => ERef<Payment<"nat">>;
|
|
207
|
+
};
|
|
208
|
+
export type PeriodicFeeCollector = {
|
|
209
|
+
getCollector: () => FeeCollector;
|
|
210
|
+
collectAndDistributeNow: () => Promise<void>;
|
|
211
|
+
stop: () => void;
|
|
212
|
+
};
|
|
213
|
+
export type CollectibleContractFacet = {
|
|
214
|
+
makeCollectFeesInvitation: () => Promise<Invitation<string, never>>;
|
|
215
|
+
};
|
|
216
|
+
export type FeeDestination = {
|
|
217
|
+
pushPayment: (payment: Payment, issuer: ERef<Issuer>) => Promise<Amount>;
|
|
218
|
+
};
|
|
219
|
+
export type ShareConfig = ReturnType<typeof makeShareConfig>;
|
|
220
|
+
export type FeeDistributorCreatorFacet = ReturnType<typeof makeFeeDistributor>["creatorFacet"];
|
|
221
|
+
export type FeeDistributorPublicFacet = ReturnType<typeof makeFeeDistributor>["publicFacet"];
|
|
222
|
+
import type { TimerService } from '@agoric/time';
|
|
223
|
+
import type { RelativeTime } from '@agoric/time';
|
|
224
|
+
//# sourceMappingURL=feeDistributor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feeDistributor.d.ts","sourceRoot":"","sources":["feeDistributor.js"],"names":[],"mappings":"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"}
|
package/src/feeDistributor.js
CHANGED
|
@@ -7,25 +7,29 @@ import { mustMatch, makeScalarSetStore, M } from '@agoric/store';
|
|
|
7
7
|
import { RelativeTimeShape } from '@agoric/time';
|
|
8
8
|
import { KeywordShape } from '@agoric/zoe/src/typeGuards.js';
|
|
9
9
|
|
|
10
|
-
const KeywordSharesShape = M.recordOf(KeywordShape, M.nat());
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
11
|
+
* @import {MapStore, SetStore} from '@agoric/store';
|
|
14
12
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
|
|
14
|
+
const KeywordSharesShape = M.recordOf(KeywordShape, M.nat());
|
|
15
|
+
|
|
16
|
+
/** @type {ContractMeta<typeof start>} */
|
|
17
|
+
export const meta = {
|
|
18
|
+
customTermsShape: {
|
|
19
|
+
keywordShares: KeywordSharesShape,
|
|
20
|
+
timerService: M.eref(M.remotable('TimerService')),
|
|
21
|
+
collectionInterval: RelativeTimeShape,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
harden(meta);
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
27
|
+
* @import {RelativeTime} from '@agoric/time'
|
|
28
|
+
* @import {TimerService} from '@agoric/time'
|
|
24
29
|
*/
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* @typedef {object} FeeCollector
|
|
28
|
-
*
|
|
29
33
|
* @property {() => ERef<Payment<'nat'>>} collectFees
|
|
30
34
|
*/
|
|
31
35
|
|
|
@@ -65,10 +69,12 @@ export const makeContractFeeCollector = (zoe, creatorFacet) => {
|
|
|
65
69
|
* for fees that have been collected to date and send that payment to the
|
|
66
70
|
* depositFacet.
|
|
67
71
|
*
|
|
68
|
-
* @param {() => Promise<unknown>} schedulePayments - distribute to the
|
|
69
|
-
*
|
|
72
|
+
* @param {() => Promise<unknown>} schedulePayments - distribute to the
|
|
73
|
+
* destinations
|
|
74
|
+
* @param {ERef<TimerService>} timerService - timer that is used to schedule
|
|
75
|
+
* collections
|
|
70
76
|
* @param {RelativeTime} [collectionInterval] - how often to collect fees in the
|
|
71
|
-
*
|
|
77
|
+
* `timerService` unit
|
|
72
78
|
*/
|
|
73
79
|
export const startDistributing = (
|
|
74
80
|
schedulePayments,
|
|
@@ -99,8 +105,9 @@ export const startDistributing = (
|
|
|
99
105
|
};
|
|
100
106
|
|
|
101
107
|
/**
|
|
102
|
-
* @typedef {{
|
|
103
|
-
*
|
|
108
|
+
* @typedef {{
|
|
109
|
+
* pushPayment: (payment: Payment, issuer: ERef<Issuer>) => Promise<Amount>;
|
|
110
|
+
* }} FeeDestination
|
|
104
111
|
* @param {Record<Keyword, ERef<FeeDestination>>} [destinations]
|
|
105
112
|
* @param {Record<Keyword, NatValue>} [keywordShares]
|
|
106
113
|
*/
|
|
@@ -161,17 +168,16 @@ export const sharePayment = async (
|
|
|
161
168
|
.filter(([_, amt]) => !AmountMath.isEmpty(amt));
|
|
162
169
|
|
|
163
170
|
/**
|
|
164
|
-
* If the `sharedPayment[i]` payments that are sent to the fee
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* be undeposited.
|
|
171
|
+
* If the `sharedPayment[i]` payments that are sent to the fee `destination`
|
|
172
|
+
* with `pushPayment` never arrive, or never get deposited (or otherwise used
|
|
173
|
+
* up), then they remain in the recovery set of the `recoveryPurse`. The
|
|
174
|
+
* purpose of this, and of recovery sets in general, is to be able, in
|
|
175
|
+
* emergencies, to recover the assets of payments in flight that seem to be
|
|
176
|
+
* stuck. This is much like cancelling a check that may still be undeposited.
|
|
171
177
|
*
|
|
172
178
|
* TODO: However, for this to be possible, the `recoveryPurse` holding that
|
|
173
|
-
* recovery set must remain accessible to someone that should legitimately
|
|
174
|
-
*
|
|
179
|
+
* recovery set must remain accessible to someone that should legitimately be
|
|
180
|
+
* able to recover those payments. But this `recoveryPurse` is currently
|
|
175
181
|
* dropped on the floor instead.
|
|
176
182
|
*/
|
|
177
183
|
const recoveryPurse = E(issuer).makeEmptyPurse();
|
|
@@ -193,7 +199,11 @@ export const sharePayment = async (
|
|
|
193
199
|
|
|
194
200
|
/**
|
|
195
201
|
* @param {ERef<Issuer<'nat'>>} feeIssuer
|
|
196
|
-
* @param {{
|
|
202
|
+
* @param {{
|
|
203
|
+
* keywordShares: Record<Keyword, NatValue>;
|
|
204
|
+
* timerService: ERef<TimerService>;
|
|
205
|
+
* collectionInterval: RelativeTime;
|
|
206
|
+
* }} terms
|
|
197
207
|
*/
|
|
198
208
|
export const makeFeeDistributor = (feeIssuer, terms) => {
|
|
199
209
|
const { timerService, collectionInterval } = terms;
|
|
@@ -262,7 +272,9 @@ export const makeFeeDistributor = (feeIssuer, terms) => {
|
|
|
262
272
|
},
|
|
263
273
|
|
|
264
274
|
/**
|
|
265
|
-
* @param {import('@endo/far').EOnly<
|
|
275
|
+
* @param {import('@endo/far').EOnly<
|
|
276
|
+
* import('@agoric/ertp/src/types.js').DepositFacet
|
|
277
|
+
* >} depositFacet
|
|
266
278
|
*/
|
|
267
279
|
makeDepositFacetDestination: depositFacet => {
|
|
268
280
|
return Far(`DepositFacetDestination`, {
|
|
@@ -315,9 +327,7 @@ export const makeFeeDistributor = (feeIssuer, terms) => {
|
|
|
315
327
|
});
|
|
316
328
|
},
|
|
317
329
|
|
|
318
|
-
/**
|
|
319
|
-
* @param {Record<Keyword, ERef<FeeDestination>>} newDestinations
|
|
320
|
-
*/
|
|
330
|
+
/** @param {Record<Keyword, ERef<FeeDestination>>} newDestinations */
|
|
321
331
|
setDestinations: async newDestinations => {
|
|
322
332
|
destinations = newDestinations;
|
|
323
333
|
shareConfig = makeShareConfig(destinations, keywordShares);
|
|
@@ -344,9 +354,7 @@ export const makeFeeDistributor = (feeIssuer, terms) => {
|
|
|
344
354
|
/** @typedef {ReturnType<typeof makeFeeDistributor>['creatorFacet']} FeeDistributorCreatorFacet */
|
|
345
355
|
/** @typedef {ReturnType<typeof makeFeeDistributor>['publicFacet']} FeeDistributorPublicFacet */
|
|
346
356
|
|
|
347
|
-
/**
|
|
348
|
-
* @param {ZCF<Parameters<typeof makeFeeDistributor>[1]>} zcf
|
|
349
|
-
*/
|
|
357
|
+
/** @param {ZCF<Parameters<typeof makeFeeDistributor>[1]>} zcf */
|
|
350
358
|
export const start = async zcf => {
|
|
351
359
|
const feeIssuer = E(zcf.getZoeService()).getFeeIssuer();
|
|
352
360
|
return makeFeeDistributor(feeIssuer, zcf.getTerms());
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function calculateCurrentDebt(debtSnapshot: Amount<"nat">, interestSnapshot: Ratio, currentCompoundedInterest: Ratio): Amount<"nat">;
|
|
2
|
+
export function reverseInterest(debt: Amount<"nat">, interestApplied: Ratio): Amount<"nat">;
|
|
3
|
+
import type { Amount } from '@agoric/ertp';
|
|
4
|
+
//# sourceMappingURL=interest-math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interest-math.d.ts","sourceRoot":"","sources":["interest-math.js"],"names":[],"mappings":"AAoCO,mDALI,OAAO,KAAK,CAAC,oBACb,KAAK,6BACL,KAAK,GACH,OAAO,KAAK,CAAC,CAiBzB;AAOM,sCAJI,OAAO,KAAK,CAAC,mBACb,KAAK,GACH,OAAO,KAAK,CAAC,CAIzB;4BAjDwC,cAAc"}
|
package/src/interest-math.js
CHANGED
|
@@ -6,7 +6,11 @@ import {
|
|
|
6
6
|
invertRatio,
|
|
7
7
|
multiplyRatios,
|
|
8
8
|
ratiosSame,
|
|
9
|
-
} from '@agoric/
|
|
9
|
+
} from '@agoric/ertp/src/ratio.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @import {Amount, Brand, Payment} from '@agoric/ertp';
|
|
13
|
+
*/
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
16
|
* @param {Ratio} currentCompoundedInterest as coefficient
|