@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,103 @@
|
|
|
1
|
+
export function prepareAssetReserveKit(baggage: import("@agoric/vat-data").Baggage, { feeMint, makeRecorderKit, storageNode, zcf }: {
|
|
2
|
+
feeMint: ZCFMint<"nat">;
|
|
3
|
+
makeRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorderKit;
|
|
4
|
+
storageNode: StorageNode;
|
|
5
|
+
zcf: ZCF;
|
|
6
|
+
}): Promise<() => Promise<import("@endo/exo").GuardedKit<{
|
|
7
|
+
helper: {
|
|
8
|
+
/** @param {Brand} brand */
|
|
9
|
+
getKeywordForBrand(brand: Brand): string;
|
|
10
|
+
/**
|
|
11
|
+
* @param {Brand} brand
|
|
12
|
+
* @param {Keyword} keyword
|
|
13
|
+
*/
|
|
14
|
+
saveBrandKeyword(brand: Brand, keyword: Keyword): void;
|
|
15
|
+
writeMetrics(): void;
|
|
16
|
+
};
|
|
17
|
+
governedApis: {
|
|
18
|
+
/**
|
|
19
|
+
* @param {Amount<'nat'>} reduction
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
burnFeesToReduceShortfall(reduction: Amount<"nat">): void;
|
|
23
|
+
};
|
|
24
|
+
withdrawalHandler: {
|
|
25
|
+
handle(seat: any): Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
withdrawalFacet: {
|
|
28
|
+
Withdraw(): Promise<globalThis.Invitation<any, undefined>>;
|
|
29
|
+
};
|
|
30
|
+
repeatableWithdrawalHandler: {
|
|
31
|
+
/**
|
|
32
|
+
* @param {ZCFSeat} seat
|
|
33
|
+
*/
|
|
34
|
+
handle(seat: ZCFSeat): {
|
|
35
|
+
invitationMakers: Partial<any>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
machine: {
|
|
39
|
+
/**
|
|
40
|
+
* @param {Issuer} issuer
|
|
41
|
+
* @param {string} keyword
|
|
42
|
+
*/
|
|
43
|
+
addIssuer(issuer: Issuer, keyword: string): Promise<void>;
|
|
44
|
+
/** XXX redundant with getPublicTopics metrics `allocation` */
|
|
45
|
+
getAllocations(): Allocation;
|
|
46
|
+
makeShortfallReportingInvitation(): Promise<globalThis.Invitation<import("@endo/exo").Guarded<{
|
|
47
|
+
/** @param {Amount<'nat'>} shortfall */
|
|
48
|
+
increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
|
|
49
|
+
/** @param {Amount<'nat'>} reduction */
|
|
50
|
+
reduceLiquidationShortfall(reduction: Amount<"nat">): void;
|
|
51
|
+
}>, undefined>>;
|
|
52
|
+
makeSingleWithdrawalInvitation(): Promise<globalThis.Invitation<any, undefined>>;
|
|
53
|
+
makeRepeatableWithdrawalInvitation(): Promise<globalThis.Invitation<{
|
|
54
|
+
invitationMakers: Partial<any>;
|
|
55
|
+
}, undefined>>;
|
|
56
|
+
revokeOutstandingWithdrawalInvitations(): void;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* XXX missing governance public methods
|
|
60
|
+
* https://github.com/Agoric/agoric-sdk/issues/5200
|
|
61
|
+
*/
|
|
62
|
+
public: {
|
|
63
|
+
/** Anyone can deposit any assets to the reserve */
|
|
64
|
+
makeAddCollateralInvitation(): Promise<globalThis.Invitation<string, never>>;
|
|
65
|
+
getPublicTopics(): {
|
|
66
|
+
metrics: import("@agoric/zoe/src/contractSupport").PublicTopic<MetricsNotification>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
shortfallReportingFacet: {
|
|
70
|
+
/** @param {Amount<'nat'>} shortfall */
|
|
71
|
+
increaseLiquidationShortfall(shortfall: Amount<"nat">): void;
|
|
72
|
+
/** @param {Amount<'nat'>} reduction */
|
|
73
|
+
reduceLiquidationShortfall(reduction: Amount<"nat">): void;
|
|
74
|
+
};
|
|
75
|
+
}>>>;
|
|
76
|
+
export type MetricsNotification = {
|
|
77
|
+
allocations: AmountKeywordRecord;
|
|
78
|
+
/**
|
|
79
|
+
* shortfall from liquidation that
|
|
80
|
+
* has not yet been compensated.
|
|
81
|
+
*/
|
|
82
|
+
shortfallBalance: Amount<"nat">;
|
|
83
|
+
/**
|
|
84
|
+
* total Fee tokens minted to date
|
|
85
|
+
*/
|
|
86
|
+
totalFeeMinted: Amount<"nat">;
|
|
87
|
+
/**
|
|
88
|
+
* total Fee tokens burned to date
|
|
89
|
+
*/
|
|
90
|
+
totalFeeBurned: Amount<"nat">;
|
|
91
|
+
};
|
|
92
|
+
export type AssetReserveKit = EReturn<EReturn<typeof prepareAssetReserveKit>>;
|
|
93
|
+
import type { ZCFMint } from '@agoric/zoe';
|
|
94
|
+
import type { StorageNode } from '@agoric/internal/src/lib-chainStorage.js';
|
|
95
|
+
import type { ZCF } from '@agoric/zoe';
|
|
96
|
+
import type { Brand } from '@agoric/ertp';
|
|
97
|
+
import type { Keyword } from '@agoric/zoe';
|
|
98
|
+
import type { Amount } from '@agoric/ertp';
|
|
99
|
+
import type { ZCFSeat } from '@agoric/zoe';
|
|
100
|
+
import type { Issuer } from '@agoric/ertp';
|
|
101
|
+
import type { AmountKeywordRecord } from '@agoric/zoe/src/zoeService/types.js';
|
|
102
|
+
import type { EReturn } from '@endo/far';
|
|
103
|
+
//# sourceMappingURL=assetReserveKit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetReserveKit.d.ts","sourceRoot":"","sources":["assetReserveKit.js"],"names":[],"mappings":"AAiDO,gDARI,OAAO,kBAAkB,EAAE,OAAO,kDAClC;IACN,OAAO,EAAE,QAAQ,KAAK,CAAC,CAAC;IACxB,eAAe,EAAE,OAAO,6CAA6C,EAAE,eAAe,CAAC;IACvF,WAAW,EAAE,WAAW,CAAC;IACzB,GAAG,EAAE,GAAG,CAAC;CACV;;QA8GI,2BAA2B;kCAAf,KAAK;QAUjB;;;WAGG;gCAFQ,KAAK,WACL,OAAO;;;;QAqBlB;;;WAGG;6CAFQ,OAAO,KAAK,CAAC,GACX,IAAI;;;;;;;;;QAsDjB;;WAEG;qBADQ,OAAO;;;;;QAYlB;;;WAGG;0BAFQ,MAAM,WACN,MAAM;QAmBjB,8DAA8D;;;YA2E9D,uCAAuC;oDAA3B,OAAO,KAAK,CAAC;YAWzB,uCAAuC;kDAA3B,OAAO,KAAK,CAAC;;;;;;;;IArD3B;;;OAGG;;QAED,mDAAmD;;;;;;;QAqCnD,uCAAuC;gDAA3B,OAAO,KAAK,CAAC;QAWzB,uCAAuC;8CAA3B,OAAO,KAAK,CAAC;;KA8BhC;;iBA3Wa,mBAAmB;;;;;sBACnB,OAAO,KAAK,CAAC;;;;oBAEb,OAAO,KAAK,CAAC;;;;oBACb,OAAO,KAAK,CAAC;;8BAyWb,QAAQ,QAAQ,OAAO,sBAAsB,CAAC,CAAC;6BAlXE,aAAa;iCAJ9C,0CAA0C;yBAIT,aAAa;2BAHpC,cAAc;6BAGS,aAAa;4BAHpC,cAAc;6BAGS,aAAa;4BAHpC,cAAc;yCAEhB,qCAAqC;6BALjD,WAAW"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Fail, q } from '@endo/errors';
|
|
2
3
|
import { AmountMath, AmountShape, IssuerShape } from '@agoric/ertp';
|
|
3
4
|
import { makeTracer } from '@agoric/internal';
|
|
4
5
|
import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
|
|
@@ -7,17 +8,29 @@ import {
|
|
|
7
8
|
makeRecorderTopic,
|
|
8
9
|
TopicsRecordShape,
|
|
9
10
|
} from '@agoric/zoe/src/contractSupport/topics.js';
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
AmountKeywordRecordShape,
|
|
13
|
+
OfferHandlerI,
|
|
14
|
+
} from '@agoric/zoe/src/typeGuards.js';
|
|
11
15
|
import { E } from '@endo/eventual-send';
|
|
12
|
-
import { UnguardedHelperI } from '
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js';
|
|
17
|
+
import { prepareRevocableMakerKit } from '@agoric/base-zone/zone-helpers.js';
|
|
18
|
+
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
15
19
|
|
|
16
20
|
const trace = makeTracer('ReserveKit', true);
|
|
17
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @import {EReturn} from '@endo/far';
|
|
24
|
+
* @import {TypedPattern} from '@agoric/internal';
|
|
25
|
+
* @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js';
|
|
26
|
+
* @import {Amount, Brand, Issuer} from '@agoric/ertp';
|
|
27
|
+
* @import {MapStore, SetStore} from '@agoric/store';
|
|
28
|
+
* @import {AmountKeywordRecord} from '@agoric/zoe/src/zoeService/types.js';
|
|
29
|
+
* @import {ZCF, OfferHandler, Keyword, ZCFMint, ZCFSeat} from '@agoric/zoe';
|
|
30
|
+
*/
|
|
31
|
+
|
|
18
32
|
/**
|
|
19
33
|
* @typedef {object} MetricsNotification
|
|
20
|
-
*
|
|
21
34
|
* @property {AmountKeywordRecord} allocations
|
|
22
35
|
* @property {Amount<'nat'>} shortfallBalance shortfall from liquidation that
|
|
23
36
|
* has not yet been compensated.
|
|
@@ -28,10 +41,11 @@ const trace = makeTracer('ReserveKit', true);
|
|
|
28
41
|
/**
|
|
29
42
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
30
43
|
* @param {{
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
44
|
+
* feeMint: ZCFMint<'nat'>;
|
|
45
|
+
* makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
|
|
46
|
+
* storageNode: StorageNode;
|
|
47
|
+
* zcf: ZCF;
|
|
48
|
+
* }} powers
|
|
35
49
|
*/
|
|
36
50
|
export const prepareAssetReserveKit = async (
|
|
37
51
|
baggage,
|
|
@@ -41,6 +55,40 @@ export const prepareAssetReserveKit = async (
|
|
|
41
55
|
const feeKit = feeMint.getIssuerRecord();
|
|
42
56
|
const emptyAmount = AmountMath.makeEmpty(feeKit.brand);
|
|
43
57
|
|
|
58
|
+
const zone = makeDurableZone(baggage);
|
|
59
|
+
|
|
60
|
+
// Durable revocation bookkeeping for the revocable single and repeatable
|
|
61
|
+
// invitations.
|
|
62
|
+
/** @type {SetStore<{ revoke: () => boolean }>} */
|
|
63
|
+
const outstandingRevokers = zone.setStore('outstandingRevokers');
|
|
64
|
+
|
|
65
|
+
const { makeRevocableKit: makeRevocableWithdrawalFacet } =
|
|
66
|
+
prepareRevocableMakerKit(zone, 'WithdrawalFacet', ['Withdraw']);
|
|
67
|
+
|
|
68
|
+
const { makeRevocableKit: makeRevocableWithdrawalHandler } =
|
|
69
|
+
prepareRevocableMakerKit(zone, 'WithdrawalHandler', ['handle'], {
|
|
70
|
+
extraMethods: {
|
|
71
|
+
/**
|
|
72
|
+
* Add some additional cleanup to avoid proliferation of revokers for
|
|
73
|
+
* spent invitations.
|
|
74
|
+
*
|
|
75
|
+
* @param {ZCFSeat} seat
|
|
76
|
+
* @param {never} offerArgs
|
|
77
|
+
*/
|
|
78
|
+
handle(seat, offerArgs) {
|
|
79
|
+
const { revoker } = this.facets;
|
|
80
|
+
// We remove our outstanding revoker because we are consumed by Zoe
|
|
81
|
+
// and cannot be used again.
|
|
82
|
+
if (this.state.underlying === undefined) {
|
|
83
|
+
Fail`${q('WithdrawalHandler_caretaker')} revoked`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
outstandingRevokers.delete(revoker);
|
|
87
|
+
return this.state.underlying.handle(seat, offerArgs);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
44
92
|
const makeAssetReserveKitInternal = prepareExoClassKit(
|
|
45
93
|
baggage,
|
|
46
94
|
'AssetReserveKit',
|
|
@@ -49,10 +97,18 @@ export const prepareAssetReserveKit = async (
|
|
|
49
97
|
governedApis: M.interface('AssetReserve governedApis', {
|
|
50
98
|
burnFeesToReduceShortfall: M.call(AmountShape).returns(),
|
|
51
99
|
}),
|
|
100
|
+
withdrawalFacet: M.interface('AssetReserve withdrawalFacet', {
|
|
101
|
+
Withdraw: M.call().returns(M.promise()),
|
|
102
|
+
}),
|
|
103
|
+
withdrawalHandler: OfferHandlerI,
|
|
104
|
+
repeatableWithdrawalHandler: OfferHandlerI,
|
|
52
105
|
machine: M.interface('AssetReserve machine', {
|
|
53
106
|
addIssuer: M.call(IssuerShape, M.string()).returns(M.promise()),
|
|
54
107
|
getAllocations: M.call().returns(AmountKeywordRecordShape),
|
|
55
108
|
makeShortfallReportingInvitation: M.call().returns(M.promise()),
|
|
109
|
+
makeSingleWithdrawalInvitation: M.call().returns(M.promise()),
|
|
110
|
+
makeRepeatableWithdrawalInvitation: M.call().returns(M.promise()),
|
|
111
|
+
revokeOutstandingWithdrawalInvitations: M.call().returns(),
|
|
56
112
|
}),
|
|
57
113
|
public: M.interface('AssetReserve public', {
|
|
58
114
|
makeAddCollateralInvitation: M.call().returns(M.promise()),
|
|
@@ -63,10 +119,7 @@ export const prepareAssetReserveKit = async (
|
|
|
63
119
|
reduceLiquidationShortfall: M.call(AmountShape).returns(),
|
|
64
120
|
}),
|
|
65
121
|
},
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {StorageNode} metricsNode
|
|
69
|
-
*/
|
|
122
|
+
/** @param {StorageNode} metricsNode */
|
|
70
123
|
metricsNode => {
|
|
71
124
|
/**
|
|
72
125
|
* Used to look up the unique keyword for each brand, including Fee brand.
|
|
@@ -77,7 +130,8 @@ export const prepareAssetReserveKit = async (
|
|
|
77
130
|
durable: true,
|
|
78
131
|
});
|
|
79
132
|
/**
|
|
80
|
-
* Used to look up the brands for keywords, excluding Fee because it's a
|
|
133
|
+
* Used to look up the brands for keywords, excluding Fee because it's a
|
|
134
|
+
* special case.
|
|
81
135
|
*
|
|
82
136
|
* @type {MapStore<Keyword, Brand>}
|
|
83
137
|
*/
|
|
@@ -92,9 +146,7 @@ export const prepareAssetReserveKit = async (
|
|
|
92
146
|
keywordForBrand,
|
|
93
147
|
metricsKit: makeRecorderKit(
|
|
94
148
|
metricsNode,
|
|
95
|
-
/** @type {
|
|
96
|
-
M.any()
|
|
97
|
-
),
|
|
149
|
+
/** @type {TypedPattern<MetricsNotification>} */ (M.any()),
|
|
98
150
|
),
|
|
99
151
|
totalFeeMinted: emptyAmount,
|
|
100
152
|
totalFeeBurned: emptyAmount,
|
|
@@ -137,7 +189,6 @@ export const prepareAssetReserveKit = async (
|
|
|
137
189
|
},
|
|
138
190
|
governedApis: {
|
|
139
191
|
/**
|
|
140
|
-
*
|
|
141
192
|
* @param {Amount<'nat'>} reduction
|
|
142
193
|
* @returns {void}
|
|
143
194
|
*/
|
|
@@ -146,8 +197,10 @@ export const prepareAssetReserveKit = async (
|
|
|
146
197
|
trace('burnFeesToReduceShortfall', reduction);
|
|
147
198
|
reduction = AmountMath.coerce(feeKit.brand, reduction);
|
|
148
199
|
const feeKeyword = state.keywordForBrand.get(feeKit.brand);
|
|
149
|
-
const feeBalance =
|
|
150
|
-
|
|
200
|
+
const feeBalance = state.collateralSeat.getAmountAllocated(
|
|
201
|
+
feeKeyword,
|
|
202
|
+
feeKit.brand,
|
|
203
|
+
);
|
|
151
204
|
const amountToBurn = AmountMath.min(reduction, feeBalance);
|
|
152
205
|
if (AmountMath.isEmpty(amountToBurn)) {
|
|
153
206
|
return;
|
|
@@ -164,6 +217,44 @@ export const prepareAssetReserveKit = async (
|
|
|
164
217
|
facets.helper.writeMetrics();
|
|
165
218
|
},
|
|
166
219
|
},
|
|
220
|
+
withdrawalHandler: {
|
|
221
|
+
async handle(seat) {
|
|
222
|
+
const { collateralSeat } = this.state;
|
|
223
|
+
const { helper } = this.facets;
|
|
224
|
+
const { want } = seat.getProposal();
|
|
225
|
+
|
|
226
|
+
// COMMIT POINT
|
|
227
|
+
// UNTIL #10684: ability to terminate an incarnation w/o terminating the contract
|
|
228
|
+
zcf.atomicRearrange(harden([[collateralSeat, seat, want]]));
|
|
229
|
+
|
|
230
|
+
helper.writeMetrics();
|
|
231
|
+
seat.exit();
|
|
232
|
+
|
|
233
|
+
trace('withdrew collateral', want);
|
|
234
|
+
return 'withdrew Collateral from the Reserve';
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
withdrawalFacet: {
|
|
238
|
+
Withdraw() {
|
|
239
|
+
const { revoker, revocable: handler } =
|
|
240
|
+
makeRevocableWithdrawalHandler(this.facets.withdrawalHandler);
|
|
241
|
+
outstandingRevokers.add(revoker);
|
|
242
|
+
// @ts-expect-error Argument of type Guarded<
|
|
243
|
+
return zcf.makeInvitation(handler, 'Withdraw Collateral');
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
repeatableWithdrawalHandler: {
|
|
247
|
+
/**
|
|
248
|
+
* @param {ZCFSeat} seat
|
|
249
|
+
*/
|
|
250
|
+
handle(seat) {
|
|
251
|
+
seat.exit();
|
|
252
|
+
const { revoker, revocable: invitationMakers } =
|
|
253
|
+
makeRevocableWithdrawalFacet(this.facets.withdrawalFacet);
|
|
254
|
+
outstandingRevokers.add(revoker);
|
|
255
|
+
return harden({ invitationMakers });
|
|
256
|
+
},
|
|
257
|
+
},
|
|
167
258
|
machine: {
|
|
168
259
|
// add makeRedeemLiquidityTokensInvitation later. For now just store them
|
|
169
260
|
/**
|
|
@@ -203,14 +294,29 @@ export const prepareAssetReserveKit = async (
|
|
|
203
294
|
'getFacetForReportingShortfalls',
|
|
204
295
|
);
|
|
205
296
|
},
|
|
297
|
+
|
|
298
|
+
makeSingleWithdrawalInvitation() {
|
|
299
|
+
return this.facets.withdrawalFacet.Withdraw();
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
makeRepeatableWithdrawalInvitation() {
|
|
303
|
+
const handler = this.facets.repeatableWithdrawalHandler;
|
|
304
|
+
return zcf.makeInvitation(handler, 'Repeatable Withdraw Collateral');
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
revokeOutstandingWithdrawalInvitations() {
|
|
308
|
+
for (const revoker of outstandingRevokers.keys()) {
|
|
309
|
+
revoker.revoke();
|
|
310
|
+
}
|
|
311
|
+
outstandingRevokers.clear();
|
|
312
|
+
},
|
|
206
313
|
},
|
|
207
314
|
/**
|
|
208
|
-
* XXX missing governance public methods
|
|
315
|
+
* XXX missing governance public methods
|
|
316
|
+
* https://github.com/Agoric/agoric-sdk/issues/5200
|
|
209
317
|
*/
|
|
210
318
|
public: {
|
|
211
|
-
/**
|
|
212
|
-
* Anyone can deposit any assets to the reserve
|
|
213
|
-
*/
|
|
319
|
+
/** Anyone can deposit any assets to the reserve */
|
|
214
320
|
makeAddCollateralInvitation() {
|
|
215
321
|
/** @type {OfferHandler<Promise<string>>} */
|
|
216
322
|
const handler = async seat => {
|
|
@@ -247,9 +353,7 @@ export const prepareAssetReserveKit = async (
|
|
|
247
353
|
},
|
|
248
354
|
},
|
|
249
355
|
shortfallReportingFacet: {
|
|
250
|
-
/**
|
|
251
|
-
* @param {Amount<"nat">} shortfall
|
|
252
|
-
*/
|
|
356
|
+
/** @param {Amount<'nat'>} shortfall */
|
|
253
357
|
increaseLiquidationShortfall(shortfall) {
|
|
254
358
|
const { facets, state } = this;
|
|
255
359
|
state.shortfallBalance = AmountMath.add(
|
|
@@ -260,9 +364,7 @@ export const prepareAssetReserveKit = async (
|
|
|
260
364
|
},
|
|
261
365
|
|
|
262
366
|
// currently exposed for testing. Maybe it only gets called internally?
|
|
263
|
-
/**
|
|
264
|
-
* @param {Amount<"nat">} reduction
|
|
265
|
-
*/
|
|
367
|
+
/** @param {Amount<'nat'>} reduction */
|
|
266
368
|
reduceLiquidationShortfall(reduction) {
|
|
267
369
|
const { state } = this;
|
|
268
370
|
if (AmountMath.isGTE(reduction, state.shortfallBalance)) {
|
|
@@ -294,4 +396,4 @@ export const prepareAssetReserveKit = async (
|
|
|
294
396
|
return makeAssetReserveKit;
|
|
295
397
|
};
|
|
296
398
|
harden(prepareAssetReserveKit);
|
|
297
|
-
/** @typedef {
|
|
399
|
+
/** @typedef {EReturn<EReturn<typeof prepareAssetReserveKit>>} AssetReserveKit */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {AdminFacet, ContractOf, InvitationAmount, ZCFMint} from '@agoric/zoe';
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @param {InvitationAmount} poserInvitationAmount
|
|
6
|
+
*/
|
|
7
|
+
export function makeReserveTerms(poserInvitationAmount: InvitationAmount): {
|
|
8
|
+
governedParams: {
|
|
9
|
+
Electorate: {
|
|
10
|
+
type: "invitation";
|
|
11
|
+
value: import("@agoric/ertp").SetAmount<import("@agoric/zoe").InvitationDetails>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
import type { InvitationAmount } from '@agoric/zoe';
|
|
16
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,wDAFW,gBAAgB;;;;;;;EASzB;sCAbkE,aAAa"}
|
package/src/reserve/params.js
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @import {AdminFacet, ContractOf, InvitationAmount, ZCFMint} from '@agoric/zoe';
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {InvitationAmount} poserInvitationAmount
|
|
11
|
+
*/
|
|
12
|
+
const makeReserveTerms = poserInvitationAmount => ({
|
|
7
13
|
governedParams: harden({
|
|
8
14
|
[CONTRACT_ELECTORATE]: {
|
|
9
15
|
type: ParamTypes.INVITATION,
|
package/src/tokens.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["tokens.js"],"names":[],"mappings":"2BAEc,KAAK,GAAG,KAAK"}
|
package/src/tokens.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"burn.d.ts","sourceRoot":"","sources":["burn.js"],"names":[],"mappings":"AAWO,wCAJI,GAAG,WACH,OAAO,UACP,MAAM,yCAOhB"}
|
package/src/vaultFactory/burn.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function setWakeupsForNextAuction(auctioneerPublicFacet: ERef<import("../auction/auctioneer.js").AuctioneerPublicFacet>, timer: ERef<TimerService>, priceLockWaker: TimerWaker, liquidationWaker: TimerWaker, reschedulerWaker: TimerWaker): Promise<void>;
|
|
2
|
+
export function liquidationResults(debt: Amount<"nat">, minted: Amount<"nat">): {
|
|
3
|
+
overage: Amount<"nat">;
|
|
4
|
+
shortfall: Amount<"nat">;
|
|
5
|
+
};
|
|
6
|
+
export function watchForGovernanceChange(auctioneerPublicFacet: ERef<import("../auction/auctioneer.js").AuctioneerPublicFacet>, timer: ERef<TimerService>, reschedulerWaker: TimerWaker): void;
|
|
7
|
+
export function getLiquidatableVaults(zcf: ZCF, collateralizationDetails: {
|
|
8
|
+
quote: PriceQuote;
|
|
9
|
+
interest: Ratio;
|
|
10
|
+
margin: Ratio;
|
|
11
|
+
}, prioritizedVaults: ReturnType<typeof import("./prioritizedVaults.js").makePrioritizedVaults>, liquidatingVaults: SetStore<Vault>, debtBrand: Brand<"nat">, collateralBrand: Brand<"nat">): {
|
|
12
|
+
vaultData: MapStore<Vault, {
|
|
13
|
+
collateralAmount: Amount<"nat">;
|
|
14
|
+
debtAmount: Amount<"nat">;
|
|
15
|
+
}>;
|
|
16
|
+
totalDebt: Amount<"nat">;
|
|
17
|
+
totalCollateral: Amount<"nat">;
|
|
18
|
+
liqSeat: ZCFSeat;
|
|
19
|
+
};
|
|
20
|
+
import type { TimerService } from '@agoric/time';
|
|
21
|
+
import type { TimerWaker } from '@agoric/time';
|
|
22
|
+
import type { PriceQuote } from '@agoric/zoe/tools/types.js';
|
|
23
|
+
import type { SetStore } from '@agoric/store';
|
|
24
|
+
import type { MapStore } from '@agoric/store';
|
|
25
|
+
//# sourceMappingURL=liquidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquidation.d.ts","sourceRoot":"","sources":["liquidation.js"],"names":[],"mappings":"AAoJO,gEAPI,IAAI,CAAC,OAAO,0BAA0B,EAAE,qBAAqB,CAAC,SAC9D,IAAI,CAAC,YAAY,CAAC,kBAClB,UAAU,oBACV,UAAU,oBACV,UAAU,GACR,OAAO,CAAC,IAAI,CAAC,CAqCzB;AAQM,yCAJI,MAAM,CAAC,KAAK,CAAC,UACb,MAAM,CAAC,KAAK,CAAC,GACX;IAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;CAAE,CAYhE;AAWM,gEALI,IAAI,CAAC,OAAO,0BAA0B,EAAE,qBAAqB,CAAC,SAC9D,IAAI,CAAC,YAAY,CAAC,oBAClB,UAAU,GACR,IAAI,CA0BhB;AAwBM,2CArBI,GAAG,4BAEX;IAA6C,KAAK,EAA1C,UAAU;IACsB,QAAQ,EAAxC,KAAK;IAC2B,MAAM,EAAtC,KAAK;CACb,qBAAQ,UAAU,CACpB,cAAkB,wBAAwB,EAAE,qBAAqB,CAC9D,qBACO,SAAS,KAAK,CAAC,aACf,KAAK,CAAC,KAAK,CAAC,mBACZ,KAAK,CAAC,KAAK,CAAC,GACV;IACR,SAAS,EAAE,SACf,KAAW,EACX;QAAQ,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;KAAE,CAC/D,CAAC;IACF,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB,CAiDH;kCAnS8D,cAAc;gCAAd,cAAc;gCAChD,4BAA4B;8BAFpB,eAAe;8BAAf,eAAe"}
|
|
@@ -5,7 +5,6 @@ import { makeTracer } from '@agoric/internal';
|
|
|
5
5
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
6
6
|
import { makeScalarMapStore } from '@agoric/store';
|
|
7
7
|
import { TimeMath } from '@agoric/time';
|
|
8
|
-
import { atomicRearrange } from '@agoric/zoe/src/contractSupport/index.js';
|
|
9
8
|
import { E } from '@endo/eventual-send';
|
|
10
9
|
|
|
11
10
|
import { AUCTION_START_DELAY, PRICE_LOCK_PERIOD } from '../auction/params.js';
|
|
@@ -13,16 +12,18 @@ import { makeCancelTokenMaker } from '../auction/util.js';
|
|
|
13
12
|
|
|
14
13
|
const trace = makeTracer('LIQ');
|
|
15
14
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @import {MapStore, SetStore} from '@agoric/store';
|
|
17
|
+
* @import {RelativeTimeRecord, TimerService, TimerWaker} from '@agoric/time';
|
|
18
|
+
* @import {PriceQuote} from '@agoric/zoe/tools/types.js';
|
|
19
|
+
*/
|
|
20
20
|
|
|
21
21
|
const makeCancelToken = makeCancelTokenMaker('liq');
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* This will normally be set. If the schedule goes sideways, we'll unschedule
|
|
25
|
-
* all events and unset it. When auction params are changed, we'll restart the
|
|
25
|
+
* all events and unset it. When auction params are changed, we'll restart the
|
|
26
|
+
* schedule
|
|
26
27
|
*
|
|
27
28
|
* @type {object | undefined}
|
|
28
29
|
*/
|
|
@@ -47,15 +48,16 @@ const cancelWakeups = timer => {
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
|
-
* Schedule wakeups for the
|
|
51
|
+
* Schedule wakeups for the _next_ auction round.
|
|
51
52
|
*
|
|
52
|
-
* In practice, there are these cases to handle (with N as "live" and N+1 is
|
|
53
|
+
* In practice, there are these cases to handle (with N as "live" and N+1 is
|
|
54
|
+
* "next"):
|
|
53
55
|
*
|
|
54
|
-
* | when (now within the range)
|
|
55
|
-
* |
|
|
56
|
-
* | [start N, nominalStart N+1]
|
|
57
|
-
* | (nominalStart N+1, endTime N+1]
|
|
58
|
-
* | (endTime N+1, ∞)
|
|
56
|
+
* | when (now within the range) | what |
|
|
57
|
+
* | ------------------------------- | ---------------------------------------- |
|
|
58
|
+
* | [start N, nominalStart N+1] | good: schedule normally the three wakers |
|
|
59
|
+
* | (nominalStart N+1, endTime N+1] | recover: skip round N+1 and schedule N+2 |
|
|
60
|
+
* | (endTime N+1, ∞) | give up: wait for repair by governance |
|
|
59
61
|
*
|
|
60
62
|
* @param {object} opts
|
|
61
63
|
* @param {ERef<TimerService>} opts.timer
|
|
@@ -63,7 +65,7 @@ const cancelWakeups = timer => {
|
|
|
63
65
|
* @param {TimerWaker} opts.liquidationWaker
|
|
64
66
|
* @param {TimerWaker} opts.reschedulerWaker
|
|
65
67
|
* @param {import('../auction/scheduler.js').Schedule} opts.nextAuctionSchedule
|
|
66
|
-
* @param {import('@agoric/time
|
|
68
|
+
* @param {import('@agoric/time').TimestampRecord} opts.now
|
|
67
69
|
* @param {ParamStateRecord} opts.params
|
|
68
70
|
* @returns {void}
|
|
69
71
|
*/
|
|
@@ -132,7 +134,7 @@ const setWakeups = ({
|
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
/**
|
|
135
|
-
* Schedule wakeups for the
|
|
137
|
+
* Schedule wakeups for the _next_ auction round.
|
|
136
138
|
*
|
|
137
139
|
* Called by vaultDirector's resetWakeupsForNextAuction at start() and every
|
|
138
140
|
* time there's a "reschedule" wakeup.
|
|
@@ -185,7 +187,7 @@ harden(setWakeupsForNextAuction);
|
|
|
185
187
|
/**
|
|
186
188
|
* @param {Amount<'nat'>} debt
|
|
187
189
|
* @param {Amount<'nat'>} minted
|
|
188
|
-
* @returns {{ overage: Amount<'nat'
|
|
190
|
+
* @returns {{ overage: Amount<'nat'>; shortfall: Amount<'nat'> }}
|
|
189
191
|
*/
|
|
190
192
|
export const liquidationResults = (debt, minted) => {
|
|
191
193
|
if (AmountMath.isEmpty(minted)) {
|
|
@@ -240,15 +242,21 @@ export const watchForGovernanceChange = (
|
|
|
240
242
|
* @param {PriceQuote} collateralizationDetails.quote
|
|
241
243
|
* @param {Ratio} collateralizationDetails.interest
|
|
242
244
|
* @param {Ratio} collateralizationDetails.margin
|
|
243
|
-
* @param {ReturnType<
|
|
245
|
+
* @param {ReturnType<
|
|
246
|
+
* typeof import('./prioritizedVaults.js').makePrioritizedVaults
|
|
247
|
+
* >} prioritizedVaults
|
|
244
248
|
* @param {SetStore<Vault>} liquidatingVaults
|
|
245
249
|
* @param {Brand<'nat'>} debtBrand
|
|
246
250
|
* @param {Brand<'nat'>} collateralBrand
|
|
247
251
|
* @returns {{
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
+
* vaultData: MapStore<
|
|
253
|
+
* Vault,
|
|
254
|
+
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
|
|
255
|
+
* >;
|
|
256
|
+
* totalDebt: Amount<'nat'>;
|
|
257
|
+
* totalCollateral: Amount<'nat'>;
|
|
258
|
+
* liqSeat: ZCFSeat;
|
|
259
|
+
* }}
|
|
252
260
|
*/
|
|
253
261
|
export const getLiquidatableVaults = (
|
|
254
262
|
zcf,
|
|
@@ -261,13 +269,18 @@ export const getLiquidatableVaults = (
|
|
|
261
269
|
const vaultsToLiquidate = prioritizedVaults.removeVaultsBelow(
|
|
262
270
|
collateralizationDetails,
|
|
263
271
|
);
|
|
264
|
-
/**
|
|
272
|
+
/**
|
|
273
|
+
* @type {MapStore<
|
|
274
|
+
* Vault,
|
|
275
|
+
* { collateralAmount: Amount<'nat'>; debtAmount: Amount<'nat'> }
|
|
276
|
+
* >}
|
|
277
|
+
*/
|
|
265
278
|
const vaultData = makeScalarMapStore();
|
|
266
279
|
|
|
267
280
|
const { zcfSeat: liqSeat } = zcf.makeEmptySeatKit();
|
|
268
281
|
let totalDebt = AmountMath.makeEmpty(debtBrand);
|
|
269
282
|
let totalCollateral = AmountMath.makeEmpty(collateralBrand);
|
|
270
|
-
/** @type {
|
|
283
|
+
/** @type {TransferPart[]} */
|
|
271
284
|
const transfers = [];
|
|
272
285
|
|
|
273
286
|
for (const vault of vaultsToLiquidate.values()) {
|
|
@@ -288,7 +301,7 @@ export const getLiquidatableVaults = (
|
|
|
288
301
|
}
|
|
289
302
|
|
|
290
303
|
if (transfers.length > 0) {
|
|
291
|
-
atomicRearrange(
|
|
304
|
+
zcf.atomicRearrange(harden(transfers));
|
|
292
305
|
}
|
|
293
306
|
|
|
294
307
|
return { vaultData, totalDebt, totalCollateral, liqSeat };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function calculateMinimumCollateralization(liquidationMargin: Ratio, liquidationPadding: Ratio): Ratio;
|
|
2
|
+
export function minimumPrice(quoteA: PriceQuote, quoteB?: PriceQuote): Ratio;
|
|
3
|
+
export function maxDebtForVault(quoteAmount: PriceQuote, liquidationMargin: Ratio, liquidationPadding: Ratio): Amount<"nat">;
|
|
4
|
+
export function calculateDebtCosts(currentDebt: Amount<"nat">, give: Amount<"nat">, want: Amount<"nat">, debtFee: Ratio): {
|
|
5
|
+
newDebt: import("@agoric/ertp").NatAmount;
|
|
6
|
+
toMint: import("@agoric/ertp").NatAmount;
|
|
7
|
+
fee: import("@agoric/ertp").NatAmount;
|
|
8
|
+
surplus: import("@agoric/ertp").NatAmount;
|
|
9
|
+
};
|
|
10
|
+
import type { PriceQuote } from '@agoric/zoe/tools/types.js';
|
|
11
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["math.js"],"names":[],"mappings":"AA4BO,qEAJI,KAAK,sBACL,KAAK,GACH,KAAK,CAKmC;AAS9C,qCAJI,UAAU,WACV,UAAU,GACR,KAAK,CAajB;AAYM,6CALI,UAAU,qBACV,KAAK,sBACL,KAAK,GACH,MAAM,CAAC,KAAK,CAAC,CAczB;AAaM,gDALI,MAAM,CAAC,KAAK,CAAC,QACb,MAAM,CAAC,KAAK,CAAC,QACb,MAAM,CAAC,KAAK,CAAC,WACb,KAAK;;;;;EASf;gCA7E6F,4BAA4B"}
|