@agoric/inter-protocol 0.16.2-dev-857e650.0 → 0.16.2-dev-fb922d3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/bundle-auctioneer-js-meta.json +181 -181
- package/bundles/bundle-auctioneer.js +1 -1
- package/bundles/bundle-econCommitteeCharter-js-meta.json +129 -129
- package/bundles/bundle-econCommitteeCharter.js +1 -1
- package/bundles/bundle-feeDistributor-js-meta.json +115 -115
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +169 -169
- package/bundles/bundle-fluxAggregatorKit.js +1 -1
- package/bundles/bundle-psm-js-meta.json +167 -167
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-js-meta.json +169 -169
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +142 -142
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-vaultFactory-js-meta.json +200 -200
- package/bundles/bundle-vaultFactory.js +1 -1
- package/package.json +17 -17
- package/scripts/deploy-contracts.js +12 -2
- package/scripts/init-core.js +5 -6
- package/scripts/manual-price-feed.js +20 -15
- package/src/auction/auctionBook.d.ts +16 -13
- package/src/auction/auctionBook.d.ts.map +1 -1
- package/src/auction/auctionBook.js +68 -56
- package/src/auction/auctioneer.d.ts.map +1 -1
- package/src/auction/auctioneer.js +54 -42
- package/src/auction/offerBook.d.ts.map +1 -1
- package/src/auction/offerBook.js +12 -11
- package/src/auction/params.d.ts +1 -1
- package/src/auction/params.d.ts.map +1 -1
- package/src/auction/params.js +3 -5
- package/src/auction/scheduleMath.d.ts.map +1 -1
- package/src/auction/scheduleMath.js +13 -13
- package/src/auction/scheduler.d.ts +4 -4
- package/src/auction/scheduler.d.ts.map +1 -1
- package/src/auction/scheduler.js +20 -20
- package/src/auction/sortedOffers.d.ts.map +1 -1
- package/src/auction/sortedOffers.js +8 -7
- package/src/auction/util.d.ts +1 -1
- package/src/auction/util.js +4 -4
- package/src/clientSupport.d.ts +65 -27
- package/src/clientSupport.d.ts.map +1 -1
- package/src/clientSupport.js +92 -34
- package/src/contractSupport.js +5 -5
- package/src/econCommitteeCharter.d.ts +4 -6
- package/src/econCommitteeCharter.d.ts.map +1 -1
- package/src/econCommitteeCharter.js +7 -11
- package/src/feeDistributor.d.ts +8 -24
- package/src/feeDistributor.d.ts.map +1 -1
- package/src/feeDistributor.js +26 -28
- package/src/interest.d.ts +1 -0
- package/src/interest.d.ts.map +1 -1
- package/src/interest.js +22 -15
- package/src/price/fluxAggregatorContract.d.ts +1 -0
- package/src/price/fluxAggregatorContract.d.ts.map +1 -1
- package/src/price/fluxAggregatorContract.js +24 -19
- package/src/price/fluxAggregatorKit.d.ts +23 -18
- package/src/price/fluxAggregatorKit.d.ts.map +1 -1
- package/src/price/fluxAggregatorKit.js +47 -32
- package/src/price/priceOracleKit.d.ts +2 -8
- package/src/price/priceOracleKit.d.ts.map +1 -1
- package/src/price/priceOracleKit.js +11 -13
- package/src/price/roundsManager.d.ts +28 -46
- package/src/price/roundsManager.d.ts.map +1 -1
- package/src/price/roundsManager.js +51 -63
- package/src/proposals/committee-proposal.d.ts.map +1 -1
- package/src/proposals/committee-proposal.js +5 -9
- package/src/proposals/core-proposal.d.ts.map +1 -1
- package/src/proposals/core-proposal.js +3 -5
- package/src/proposals/econ-behaviors.d.ts.map +1 -1
- package/src/proposals/econ-behaviors.js +55 -28
- package/src/proposals/price-feed-proposal.d.ts.map +1 -1
- package/src/proposals/price-feed-proposal.js +30 -11
- package/src/proposals/startPSM.d.ts.map +1 -1
- package/src/proposals/startPSM.js +24 -17
- package/src/proposals/utils.d.ts +1 -1
- package/src/proposals/utils.d.ts.map +1 -1
- package/src/proposals/utils.js +26 -7
- package/src/psm/psm.d.ts +14 -22
- package/src/psm/psm.d.ts.map +1 -1
- package/src/psm/psm.js +34 -31
- package/src/reserve/assetReserve.d.ts.map +1 -1
- package/src/reserve/assetReserve.js +16 -13
- package/src/reserve/assetReserveKit.d.ts +14 -26
- package/src/reserve/assetReserveKit.d.ts.map +1 -1
- package/src/reserve/assetReserveKit.js +13 -21
- package/src/tokens.d.ts +3 -3
- package/src/tokens.d.ts.map +1 -1
- package/src/tokens.js +5 -5
- package/src/typeGuards.d.ts +1 -3
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +1 -3
- package/src/vaultFactory/liquidation.d.ts.map +1 -1
- package/src/vaultFactory/liquidation.js +29 -16
- package/src/vaultFactory/math.d.ts.map +1 -1
- package/src/vaultFactory/math.js +8 -9
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -1
- package/src/vaultFactory/orderedVaultStore.js +6 -9
- package/src/vaultFactory/params.d.ts +1 -4
- package/src/vaultFactory/params.d.ts.map +1 -1
- package/src/vaultFactory/params.js +24 -18
- package/src/vaultFactory/prioritizedVaults.js +2 -2
- package/src/vaultFactory/proceeds.d.ts +3 -3
- package/src/vaultFactory/proceeds.d.ts.map +1 -1
- package/src/vaultFactory/proceeds.js +24 -18
- package/src/vaultFactory/storeUtils.d.ts +2 -6
- package/src/vaultFactory/storeUtils.d.ts.map +1 -1
- package/src/vaultFactory/storeUtils.js +8 -12
- package/src/vaultFactory/types.d.ts +16 -11
- package/src/vaultFactory/types.d.ts.map +1 -1
- package/src/vaultFactory/types.js +37 -27
- package/src/vaultFactory/vault.d.ts +103 -159
- package/src/vaultFactory/vault.d.ts.map +1 -1
- package/src/vaultFactory/vault.js +84 -85
- package/src/vaultFactory/vaultDirector.d.ts +21 -43
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -1
- package/src/vaultFactory/vaultDirector.js +30 -40
- package/src/vaultFactory/vaultFactory.d.ts +8 -6
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -1
- package/src/vaultFactory/vaultFactory.js +13 -11
- package/src/vaultFactory/vaultHolder.d.ts +12 -16
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -1
- package/src/vaultFactory/vaultHolder.js +7 -12
- package/src/vaultFactory/vaultKit.d.ts +1 -1
- package/src/vaultFactory/vaultKit.d.ts.map +1 -1
- package/src/vaultFactory/vaultKit.js +3 -2
- package/src/vaultFactory/vaultManager.d.ts +454 -68
- package/src/vaultFactory/vaultManager.d.ts.map +1 -1
- package/src/vaultFactory/vaultManager.js +120 -110
|
@@ -22,7 +22,8 @@ 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
|
|
@@ -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,7 +269,12 @@ 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();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["math.js"],"names":[],"mappings":"AA0BO,qEAJI,KAAK,sBACL,KAAK,GACH,KAAK,CAKmC;AAS9C,qCAJI,UAAU,oCAER,KAAK,CAajB;AAYM,6CALI,UAAU,qBACV,KAAK,sBACL,KAAK,GACH,OAAO,KAAK,CAAC,CAczB;
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["math.js"],"names":[],"mappings":"AA0BO,qEAJI,KAAK,sBACL,KAAK,GACH,KAAK,CAKmC;AAS9C,qCAJI,UAAU,oCAER,KAAK,CAajB;AAYM,6CALI,UAAU,qBACV,KAAK,sBACL,KAAK,GACH,OAAO,KAAK,CAAC,CAczB;AAaM,gDALI,OAAO,KAAK,CAAC,QACb,OAAO,KAAK,CAAC,QACb,OAAO,KAAK,CAAC,WACb,KAAK;;;;;EASf"}
|
package/src/vaultFactory/math.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file calculations specific to the Vault Factory contract
|
|
5
|
-
*
|
|
4
|
+
* @file calculations specific to the Vault Factory contract See also
|
|
5
|
+
* ../interest-math.js
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { AmountMath } from '@agoric/ertp';
|
|
@@ -17,8 +17,8 @@ import { priceFrom } from '../auction/util.js';
|
|
|
17
17
|
import { addSubtract } from '../contractSupport.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Calculate the minimum collateralization given the liquidation margin and the
|
|
21
|
-
* from that liquidation threshold.
|
|
20
|
+
* Calculate the minimum collateralization given the liquidation margin and the
|
|
21
|
+
* "padding" from that liquidation threshold.
|
|
22
22
|
*
|
|
23
23
|
* @param {Ratio} liquidationMargin
|
|
24
24
|
* @param {Ratio} liquidationPadding
|
|
@@ -74,11 +74,10 @@ export const maxDebtForVault = (
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Calculate the fee, the amount to mint and the resulting debt.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* so the simple math works.
|
|
77
|
+
* Calculate the fee, the amount to mint and the resulting debt. The give and
|
|
78
|
+
* the want together reflect a delta, where typically one is zero because they
|
|
79
|
+
* come from the gave/want of an offer proposal. If the `want` is zero, the
|
|
80
|
+
* `fee` will also be zero, so the simple math works.
|
|
82
81
|
*
|
|
83
82
|
* @param {Amount<'nat'>} currentDebt
|
|
84
83
|
* @param {Amount<'nat'>} give excess of currentDebt is returned in 'surplus'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderedVaultStore.d.ts","sourceRoot":"","sources":["orderedVaultStore.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orderedVaultStore.d.ts","sourceRoot":"","sources":["orderedVaultStore.js"],"names":[],"mappings":"AAiBO,6CADK,SAAS,MAAM,EAAE,KAAK,CAAC;wBAGtB,MAAM,SACN,KAAK;uBAWL,MAAM,KACJ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCnB;oBApDa,OAAO,SAAS,EAAE,KAAK;2BACvB,OAAO,cAAc,EAAE,YAAY"}
|
|
@@ -3,22 +3,20 @@ import { fromVaultKey, toVaultKey } from './storeUtils.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Used by prioritizedVaults to wrap the Collections API for this use case.
|
|
5
5
|
*
|
|
6
|
-
* Designed to be replaceable by naked Collections API when composite keys are
|
|
6
|
+
* Designed to be replaceable by naked Collections API when composite keys are
|
|
7
|
+
* available.
|
|
7
8
|
*
|
|
8
|
-
* In this module debts are encoded as the inverse quotient (collateral over
|
|
9
|
-
* greater collateralization sorts after lower. (Higher
|
|
10
|
-
* first.)
|
|
9
|
+
* In this module debts are encoded as the inverse quotient (collateral over
|
|
10
|
+
* debt) so that greater collateralization sorts after lower. (Higher
|
|
11
|
+
* debt-to-collateral come first.)
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
/** @typedef {import('./vault').Vault} Vault */
|
|
14
15
|
/** @typedef {import('./storeUtils').CompositeKey} CompositeKey */
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
* @param {MapStore<string, Vault>} store
|
|
18
|
-
*/
|
|
17
|
+
/** @param {MapStore<string, Vault>} store */
|
|
19
18
|
export const makeOrderedVaultStore = store => {
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
22
20
|
* @param {string} vaultId
|
|
23
21
|
* @param {Vault} vault
|
|
24
22
|
*/
|
|
@@ -31,7 +29,6 @@ export const makeOrderedVaultStore = store => {
|
|
|
31
29
|
};
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
|
-
*
|
|
35
32
|
* @param {string} key
|
|
36
33
|
* @returns {Vault}
|
|
37
34
|
*/
|
|
@@ -98,7 +98,6 @@ export function makeGovernedTerms({ auctioneerPublicFacet, bootstrapPaymentValue
|
|
|
98
98
|
};
|
|
99
99
|
export function provideVaultParamManagers(baggage: MapStore<string, unknown>, marshaller: ERef<Marshaller>): {
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
101
|
* @param {Brand} brand
|
|
103
102
|
* @param {StorageNode} storageNode
|
|
104
103
|
* @param {VaultManagerParamValues} initialParamValues
|
|
@@ -111,9 +110,7 @@ export function provideVaultParamManagers(baggage: MapStore<string, unknown>, ma
|
|
|
111
110
|
LiquidationPenalty: "ratio";
|
|
112
111
|
MintFee: "ratio";
|
|
113
112
|
}>;
|
|
114
|
-
/**
|
|
115
|
-
* @param {Brand} brand
|
|
116
|
-
*/
|
|
113
|
+
/** @param {Brand} brand */
|
|
117
114
|
get(brand: Brand): import("@agoric/governance/src/contractGovernance/typedParamManager").TypedParamManager<{
|
|
118
115
|
DebtLimit: "amount";
|
|
119
116
|
StabilityFee: "ratio";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAgBA,mDAAoD;AACpD,qDAAsD;AAEtD,yCAA0C;AAC1C,yDAA0D;AAC1D,2DAA4D;AAC5D,2DAA4D;AAC5D,+CAAgD;AAChD,qCAAsC;AACtC,oDAAqD;AACrD,6DAA8D;AAC9D,+CAAgD;;;;;;;
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["params.js"],"names":[],"mappings":"AAgBA,mDAAoD;AACpD,qDAAsD;AAEtD,yCAA0C;AAC1C,yDAA0D;AAC1D,2DAA4D;AAC5D,2DAA4D;AAC5D,+CAAgD;AAChD,qCAAsC;AACtC,oDAAqD;AACrD,6DAA8D;AAC9D,+CAAgD;;;;;;;AAgEzC,oDAHI,OAAO,kBAAkB,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,oGAC1E,uBAAuB;;;;;;;GAoB9B;AACJ,4EAA4E;AAE5E,iEAYE;AAgBK,qOAbI;IACV,qBAAyB,EAAE,KAAK,qBAAqB,CAAC,CAAC;IACvD,0BAA8B,EAAE,OAAO,KAAK,CAAC,CAAC;IAC9C,cAAkB,EAAE,OAAO,KAAK,CAAC,CAAC;IAClC,qBAAyB,EAAE,MAAM,CAAC;IAClC,cAAkB,EAAE,KAAK,cAAc,CAAC,CAAC;IACzC,KAAS,EAAE,KAAK,OAAO,wBAAwB,EAAE,YAAY,CAAC,CAAC;IAC/D,kBAAsB,EAAE,uBAAuB,CAAC;IAChD,cAAkB,EAAE,cAAc,CAAC;IACnC,yBAA6B,EAAE,OAAO,KAAK,CAAC,CAAC;IAC7C,YAAgB,CAAC,EAAE,MAAM,CAAC;CACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BH;AAWM,0FAFI,KAAK,UAAU,CAAC;IA+BvB;;;;OAIG;2BAHQ,KAAK,eACL,WAAW,sBACX,uBAAuB;;;;;;;;IAOlC,2BAA2B;eAAf,KAAK;;;;;;;;EAKpB;kCA/IY,OAAO,6DAA6D,EAAE,uBAAuB,CACzG,WAAiB,8BAA8B,CAAC,CAC3C;gCA8BQ,WAAW,4BAA4B,CAAC;AAzEtD;;;;;;GAMG;AACH,qEANW,OAAO,KAAK,CAAC,kBACb,OAAO,KAAK,CAAC,6BACb,OAAO,KAAK,CAAC,gBACb,MAAM,kBACN,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;EAgCxB"}
|
|
@@ -75,7 +75,11 @@ const makeVaultDirectorParams = (
|
|
|
75
75
|
};
|
|
76
76
|
harden(makeVaultDirectorParams);
|
|
77
77
|
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager').ParamTypesMapFromRecord<
|
|
80
|
+
* ReturnType<typeof makeVaultDirectorParams>
|
|
81
|
+
* >} VaultDirectorParams
|
|
82
|
+
*/
|
|
79
83
|
|
|
80
84
|
/** @type {(liquidationMargin: Ratio) => Ratio} */
|
|
81
85
|
const zeroRatio = liquidationMargin =>
|
|
@@ -122,16 +126,16 @@ export const vaultParamPattern = M.splitRecord(
|
|
|
122
126
|
|
|
123
127
|
/**
|
|
124
128
|
* @param {{
|
|
125
|
-
* auctioneerPublicFacet: ERef<AuctioneerPublicFacet
|
|
126
|
-
* electorateInvitationAmount: Amount<'set'
|
|
127
|
-
* minInitialDebt: Amount<'nat'
|
|
128
|
-
* bootstrapPaymentValue: bigint
|
|
129
|
-
* priceAuthority: ERef<PriceAuthority
|
|
130
|
-
* timer: ERef<import('@agoric/time/src/types').TimerService
|
|
131
|
-
* reservePublicFacet: AssetReservePublicFacet
|
|
132
|
-
* interestTiming: InterestTiming
|
|
133
|
-
* shortfallInvitationAmount: Amount<'set'
|
|
134
|
-
* referencedUi?: string
|
|
129
|
+
* auctioneerPublicFacet: ERef<AuctioneerPublicFacet>;
|
|
130
|
+
* electorateInvitationAmount: Amount<'set'>;
|
|
131
|
+
* minInitialDebt: Amount<'nat'>;
|
|
132
|
+
* bootstrapPaymentValue: bigint;
|
|
133
|
+
* priceAuthority: ERef<PriceAuthority>;
|
|
134
|
+
* timer: ERef<import('@agoric/time/src/types').TimerService>;
|
|
135
|
+
* reservePublicFacet: AssetReservePublicFacet;
|
|
136
|
+
* interestTiming: InterestTiming;
|
|
137
|
+
* shortfallInvitationAmount: Amount<'set'>;
|
|
138
|
+
* referencedUi?: string;
|
|
135
139
|
* }} opts
|
|
136
140
|
*/
|
|
137
141
|
export const makeGovernedTerms = ({
|
|
@@ -163,8 +167,8 @@ export const makeGovernedTerms = ({
|
|
|
163
167
|
};
|
|
164
168
|
harden(makeGovernedTerms);
|
|
165
169
|
/**
|
|
166
|
-
* Stop-gap which restores initial param values
|
|
167
|
-
*
|
|
170
|
+
* Stop-gap which restores initial param values UNTIL
|
|
171
|
+
* https://github.com/Agoric/agoric-sdk/issues/5200
|
|
168
172
|
*
|
|
169
173
|
* NB: changes from initial values will be lost upon restart
|
|
170
174
|
*
|
|
@@ -176,7 +180,12 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
|
|
|
176
180
|
const managers = makeScalarMapStore();
|
|
177
181
|
|
|
178
182
|
// the managers aren't durable but their arguments are
|
|
179
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* @type {MapStore<
|
|
185
|
+
* Brand,
|
|
186
|
+
* { storageNode: StorageNode; initialParamValues: VaultManagerParamValues }
|
|
187
|
+
* >}
|
|
188
|
+
*/
|
|
180
189
|
const managerArgs = provideDurableMapStore(
|
|
181
190
|
baggage,
|
|
182
191
|
'vault param manager parts',
|
|
@@ -196,7 +205,6 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
|
|
|
196
205
|
|
|
197
206
|
return {
|
|
198
207
|
/**
|
|
199
|
-
*
|
|
200
208
|
* @param {Brand} brand
|
|
201
209
|
* @param {StorageNode} storageNode
|
|
202
210
|
* @param {VaultManagerParamValues} initialParamValues
|
|
@@ -206,9 +214,7 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
|
|
|
206
214
|
managerArgs.init(brand, args);
|
|
207
215
|
return makeManager(brand, args);
|
|
208
216
|
},
|
|
209
|
-
/**
|
|
210
|
-
* @param {Brand} brand
|
|
211
|
-
*/
|
|
217
|
+
/** @param {Brand} brand */
|
|
212
218
|
get(brand) {
|
|
213
219
|
return managers.get(brand);
|
|
214
220
|
},
|
|
@@ -47,8 +47,8 @@ export const currentDebtToCollateral = vault =>
|
|
|
47
47
|
* Vaults, ordered by their debt ratio so that all the vaults below a threshold
|
|
48
48
|
* can be quickly found and liquidated.
|
|
49
49
|
*
|
|
50
|
-
* @param {MapStore<string, Vault>} store
|
|
51
|
-
*
|
|
50
|
+
* @param {MapStore<string, Vault>} store vault has a higher debt ratio than the
|
|
51
|
+
* previous highest
|
|
52
52
|
*/
|
|
53
53
|
export const makePrioritizedVaults = store => {
|
|
54
54
|
const vaults = makeOrderedVaultStore(store);
|
|
@@ -3,7 +3,7 @@ export function calculateDistributionPlan({ proceeds, totalDebt, totalCollateral
|
|
|
3
3
|
totalDebt: Amount<'nat'>;
|
|
4
4
|
totalCollateral: Amount<'nat'>;
|
|
5
5
|
oraclePriceAtStart: PriceDescription;
|
|
6
|
-
vaultsBalances:
|
|
6
|
+
vaultsBalances: VaultBalances[];
|
|
7
7
|
penaltyRate: Ratio;
|
|
8
8
|
}): DistributionPlan;
|
|
9
9
|
/**
|
|
@@ -23,8 +23,8 @@ export type DistributionPlan = {
|
|
|
23
23
|
mintedProceeds: Amount<'nat'>;
|
|
24
24
|
phantomDebt: Amount<'nat'>;
|
|
25
25
|
totalPenalty: Amount<'nat'>;
|
|
26
|
-
transfersToVault:
|
|
27
|
-
vaultsToReinstate:
|
|
26
|
+
transfersToVault: [number, AmountKeywordRecord][];
|
|
27
|
+
vaultsToReinstate: number[];
|
|
28
28
|
};
|
|
29
29
|
export type VaultBalances = {
|
|
30
30
|
collateral: Amount<'nat'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proceeds.d.ts","sourceRoot":"","sources":["proceeds.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proceeds.d.ts","sourceRoot":"","sources":["proceeds.js"],"names":[],"mappings":"AA0DO;IATgC,QAAQ,EAApC,mBAAmB;IACG,SAAS,EAA/B,OAAO,KAAK,CAAC;IACS,eAAe,EAArC,OAAO,KAAK,CAAC;IACY,kBAAkB,EAA3C,gBAAgB;IACQ,cAAc,EAAtC,aAAa,EAAE;IAED,WAAW,EAAzB,KAAK;IACH,gBAAgB,CA8N5B;;;;;;+BA1QY;IACZ,OAAW,EAAE,OAAO,KAAK,CAAC,CAAC;IAC3B,kBAAsB,EAAE,OAAO,KAAK,CAAC,CAAC;IACtC,oBAAwB,EAAE,OAAO,KAAK,CAAC,CAAC;IACxC,oBAAwB,EAAE,OAAO,KAAK,CAAC,CAAC;IACxC,cAAkB,EAAE,OAAO,KAAK,CAAC,CAAC;IAClC,eAAmB,EAAE,OAAO,KAAK,CAAC,CAAC;IACnC,UAAc,EAAE,OAAO,KAAK,CAAC,CAAC;IAC9B,gBAAoB,EAAE,OAAO,KAAK,CAAC,CAAC;IACpC,cAAkB,EAAE,OAAO,KAAK,CAAC,CAAC;IAClC,WAAe,EAAE,OAAO,KAAK,CAAC,CAAC;IAC/B,YAAgB,EAAE,OAAO,KAAK,CAAC,CAAC;IAChC,gBAAoB,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE,CAAC;IACtD,iBAAqB,EAAE,MAAM,EAAE,CAAC;CAC7B;4BAOS;IACZ,UAAc,EAAE,OAAO,KAAK,CAAC,CAAC;IAC9B,WAAe,EAAE,OAAO,KAAK,CAAC,CAAC;IAC/B,WAAe,EAAE,OAAO,KAAK,CAAC,CAAC;CAC5B"}
|
|
@@ -11,27 +11,32 @@ import { liquidationResults } from './liquidation.js';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @typedef {{
|
|
14
|
-
* overage: Amount<'nat'
|
|
15
|
-
* shortfallToReserve: Amount<'nat'
|
|
16
|
-
* collateralForReserve: Amount<'nat'
|
|
17
|
-
* actualCollateralSold: Amount<'nat'
|
|
18
|
-
* collateralSold: Amount<'nat'
|
|
19
|
-
* collatRemaining: Amount<'nat'
|
|
20
|
-
* debtToBurn: Amount<'nat'
|
|
21
|
-
* mintedForReserve: Amount<'nat'
|
|
22
|
-
* mintedProceeds: Amount<'nat'
|
|
23
|
-
* phantomDebt: Amount<'nat'
|
|
24
|
-
* totalPenalty: Amount<'nat'
|
|
25
|
-
* transfersToVault:
|
|
26
|
-
* vaultsToReinstate:
|
|
14
|
+
* overage: Amount<'nat'>;
|
|
15
|
+
* shortfallToReserve: Amount<'nat'>;
|
|
16
|
+
* collateralForReserve: Amount<'nat'>;
|
|
17
|
+
* actualCollateralSold: Amount<'nat'>;
|
|
18
|
+
* collateralSold: Amount<'nat'>;
|
|
19
|
+
* collatRemaining: Amount<'nat'>;
|
|
20
|
+
* debtToBurn: Amount<'nat'>;
|
|
21
|
+
* mintedForReserve: Amount<'nat'>;
|
|
22
|
+
* mintedProceeds: Amount<'nat'>;
|
|
23
|
+
* phantomDebt: Amount<'nat'>;
|
|
24
|
+
* totalPenalty: Amount<'nat'>;
|
|
25
|
+
* transfersToVault: [number, AmountKeywordRecord][];
|
|
26
|
+
* vaultsToReinstate: number[];
|
|
27
27
|
* }} DistributionPlan
|
|
28
|
+
* The plan to execute for distributing proceeds of a liquidation.
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Vaults are referenced by index in the list sent to the calculator.
|
|
30
|
+
* Vaults are referenced by index in the list sent to the calculator.
|
|
32
31
|
*/
|
|
33
32
|
|
|
34
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {{
|
|
35
|
+
* collateral: Amount<'nat'>;
|
|
36
|
+
* presaleDebt: Amount<'nat'>;
|
|
37
|
+
* currentDebt: Amount<'nat'>;
|
|
38
|
+
* }} VaultBalances
|
|
39
|
+
*/
|
|
35
40
|
|
|
36
41
|
/**
|
|
37
42
|
* Liquidation.md describes how to process liquidation proceeds.
|
|
@@ -46,7 +51,8 @@ import { liquidationResults } from './liquidation.js';
|
|
|
46
51
|
* @param {Amount<'nat'>} inputs.totalDebt
|
|
47
52
|
* @param {Amount<'nat'>} inputs.totalCollateral
|
|
48
53
|
* @param {PriceDescription} inputs.oraclePriceAtStart
|
|
49
|
-
* @param {
|
|
54
|
+
* @param {VaultBalances[]} inputs.vaultsBalances ordered best to worst
|
|
55
|
+
* collateralized
|
|
50
56
|
* @param {Ratio} inputs.penaltyRate
|
|
51
57
|
* @returns {DistributionPlan}
|
|
52
58
|
*/
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {[normalizedCollateralization: number, vaultId: VaultId]} CompositeKey
|
|
6
|
-
*/
|
|
1
|
+
/** @typedef {import('@endo/marshal').PureData} PureData */
|
|
2
|
+
/** @typedef {[normalizedCollateralization: number, vaultId: VaultId]} CompositeKey */
|
|
7
3
|
/**
|
|
8
4
|
* @param {PureData} key
|
|
9
5
|
* @returns {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeUtils.d.ts","sourceRoot":"","sources":["storeUtils.js"],"names":[],"mappings":"AAqBA
|
|
1
|
+
{"version":3,"file":"storeUtils.d.ts","sourceRoot":"","sources":["storeUtils.js"],"names":[],"mappings":"AAqBA,2DAA2D;AAE3D,sFAAsF;AAOtF;;;GAGG;AACH,mDAA+C;AAO/C;;;GAGG;AACH,kDAA+C;AAkDxC,2CANI,cAAc,cACd,OAAO,KAAK,CAAC,WACb,OAAO,GACL,MAAM,CAelB;AAOM,kCAHI,MAAM,GACJ,CAAC,2BAA2B,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAKnE;AAgBM,2CALI,UAAU,0BACV,KAAK,UACL,KAAK,GACH,MAAM,CAiBlB;AAcM,8CANI,UAAU,0BACV,KAAK,UACL,KAAK,GACH,MAAM,CAUlB;uBApJa,OAAO,eAAe,EAAE,QAAQ;2BAEhC,CAAC,2BAA2B,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;6BA4CvD,OAAO,KAAK,CAAC,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE;yBACpC,OAAO,KAAK,CAAC,GAAG;IAAE,UAAU,EAAE,KAAK,CAAA;CAAE"}
|
|
@@ -19,13 +19,9 @@ const { multiply } = natSafeMath;
|
|
|
19
19
|
|
|
20
20
|
const trace = makeTracer('Store', true);
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {import('@endo/marshal').PureData} PureData
|
|
24
|
-
*/
|
|
22
|
+
/** @typedef {import('@endo/marshal').PureData} PureData */
|
|
25
23
|
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {[normalizedCollateralization: number, vaultId: VaultId]} CompositeKey
|
|
28
|
-
*/
|
|
24
|
+
/** @typedef {[normalizedCollateralization: number, vaultId: VaultId]} CompositeKey */
|
|
29
25
|
|
|
30
26
|
// `makeEncodePassable` has three named options:
|
|
31
27
|
// `encodeRemotable`, `encodeError`, and `encodePromise`.
|
|
@@ -69,12 +65,12 @@ const decodeNumber = encoded => {
|
|
|
69
65
|
};
|
|
70
66
|
|
|
71
67
|
// Type annotations to support static testing of amount values
|
|
72
|
-
/** @typedef {Amount<'nat'> & {normalized: true}} NormalizedDebt */
|
|
73
|
-
/** @typedef {Amount<'nat'> & {normalized: false}} ActualDebt */
|
|
68
|
+
/** @typedef {Amount<'nat'> & { normalized: true }} NormalizedDebt */
|
|
69
|
+
/** @typedef {Amount<'nat'> & { normalized: false }} ActualDebt */
|
|
74
70
|
|
|
75
71
|
/**
|
|
76
|
-
* Overcollateralized are greater than one.
|
|
77
|
-
*
|
|
72
|
+
* Overcollateralized are greater than one. The more undercollaterized the
|
|
73
|
+
* smaller in [0-1].
|
|
78
74
|
*
|
|
79
75
|
* @param {NormalizedDebt} normalizedDebt normalized (not actual) total debt
|
|
80
76
|
* @param {Amount<'nat'>} collateral
|
|
@@ -95,7 +91,7 @@ const collateralizationRatio = (normalizedDebt, collateral) => {
|
|
|
95
91
|
* @param {Amount<'nat'>} collateral
|
|
96
92
|
* @param {VaultId} vaultId
|
|
97
93
|
* @returns {string} lexically sortable string in which highest
|
|
98
|
-
*
|
|
94
|
+
* debt-to-collateral is earliest
|
|
99
95
|
*/
|
|
100
96
|
export const toVaultKey = (normalizedDebt, collateral, vaultId) => {
|
|
101
97
|
assert(normalizedDebt);
|
|
@@ -162,7 +158,7 @@ harden(normalizedCollRatio);
|
|
|
162
158
|
* @param {Ratio} compoundedStabilityFee
|
|
163
159
|
* @param {Ratio} margin
|
|
164
160
|
* @returns {string} lexically sortable string in which highest
|
|
165
|
-
*
|
|
161
|
+
* debt-to-collateral is earliest
|
|
166
162
|
*/
|
|
167
163
|
export const normalizedCollRatioKey = (
|
|
168
164
|
quote,
|
|
@@ -20,21 +20,24 @@ type VaultManagerParamValues = {
|
|
|
20
20
|
*/
|
|
21
21
|
liquidationMargin: Ratio;
|
|
22
22
|
/**
|
|
23
|
-
* - penalty charged upon liquidation as
|
|
23
|
+
* - penalty charged upon liquidation as
|
|
24
|
+
* proportion of debt
|
|
24
25
|
*/
|
|
25
26
|
liquidationPenalty: Ratio;
|
|
26
27
|
/**
|
|
27
|
-
* - annual interest rate charged on debt
|
|
28
|
+
* - annual interest rate charged on debt
|
|
29
|
+
* positions
|
|
28
30
|
*/
|
|
29
31
|
stabilityFee: Ratio;
|
|
30
32
|
/**
|
|
31
|
-
* - The fee (in BasisPoints) charged when creating
|
|
32
|
-
*
|
|
33
|
+
* - The fee (in BasisPoints) charged when creating or
|
|
34
|
+
* increasing a debt position.
|
|
33
35
|
*/
|
|
34
36
|
mintFee: Ratio;
|
|
35
37
|
debtLimit: Amount<'nat'>;
|
|
36
38
|
/**
|
|
37
|
-
* - vault must maintain this in order to
|
|
39
|
+
* - vault must maintain this in order to
|
|
40
|
+
* remove collateral or add debt
|
|
38
41
|
*/
|
|
39
42
|
liquidationPadding?: Ratio | undefined;
|
|
40
43
|
};
|
|
@@ -47,14 +50,15 @@ type VaultFactoryCreatorFacet = {
|
|
|
47
50
|
makePriceLockWaker: () => import('@agoric/time/src/types').TimerWaker;
|
|
48
51
|
};
|
|
49
52
|
/**
|
|
50
|
-
* Mint new debt `toMint` and transfer the `fee`
|
|
51
|
-
* pool. Then reallocate over all the
|
|
52
|
-
* the `totalDebt` if the
|
|
53
|
+
* Mint new debt `toMint` and transfer the `fee`
|
|
54
|
+
* portion to the vaultFactory's reward pool. Then reallocate over all the
|
|
55
|
+
* seat arguments and the rewardPoolSeat. Update the `totalDebt` if the
|
|
56
|
+
* reallocate succeeds.
|
|
53
57
|
*/
|
|
54
58
|
type MintAndTransfer = (mintReceiver: ZCFSeat, toMint: Amount<'nat'>, fee: Amount<'nat'>, transfers: import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]) => void;
|
|
55
59
|
/**
|
|
56
|
-
* Burn debt tokens off a seat and update
|
|
57
|
-
*
|
|
60
|
+
* Burn debt tokens off a seat and update the `totalDebt` if
|
|
61
|
+
* the reallocate succeeds.
|
|
58
62
|
*/
|
|
59
63
|
type BurnDebt = (toBurn: Amount, fromSeat: ZCFSeat) => void;
|
|
60
64
|
type GetVaultParams = {
|
|
@@ -62,7 +66,8 @@ type GetVaultParams = {
|
|
|
62
66
|
getMintFee: () => Ratio;
|
|
63
67
|
getCollateralQuote: () => Promise<PriceQuote>;
|
|
64
68
|
/**
|
|
65
|
-
* - The annual interest rate on a debt
|
|
69
|
+
* - The annual interest rate on a debt
|
|
70
|
+
* position
|
|
66
71
|
*/
|
|
67
72
|
getStabilityFee: () => Ratio;
|
|
68
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"yBAGa,OAAO,SAAS,EAAE,iBAAiB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"yBAGa,OAAO,SAAS,EAAE,iBAAiB;aAEnC,OAAO,SAAS,EAAE,KAAK;gBAEvB,OAAO,YAAY,EAAE,QAAQ;oBAE7B,OAAO,gBAAgB,EAAE,YAAY;yBAErC,OAAO,gBAAgB,EAAE,iBAAiB;gCAE1C,OAAO,4BAA4B,EAAE,+BAA+B;+BAEpE,OAAO,4BAA4B,EAAE,uBAAuB;6BAE5D,OAAO,0BAA0B,EAAE,qBAAqB;+BAExD,OAAO,mBAAmB,EAAE,oBAAoB,CAAC,aAAa,CAAC;iBAE/D,OAAO,wBAAwB,EAAE,SAAS;oBAE1C,OAAO,wBAAwB,EAAE,YAAY;;4BAKnC,MAAM,SAAS,KAAK,KAAK,MAAM;wBACxC,MAAM,UAAU;;;;;;;uBAKhB,KAAK;;;;;wBAEL,KAAK;;;;;kBAEL,KAAK;;;;;aAEL,KAAK;eAEL,OAAO,KAAK,CAAC;;;;;;;uCAOhB,MAAM,qBACN,OAAO,UACP,uBAAuB,KACrB,QAAQ,YAAY,CAAC;;kBAKpB,YAAY;yBACZ,MAAM,UAAU;+BAChB,MAAM,QAAQ,WAAW,MAAM,EAAE,KAAK,CAAC,CAAC;0BACxC,MAAM,OAAO,wBAAwB,EAAE,UAAU;wBACjD,MAAM,OAAO,wBAAwB,EAAE,UAAU;;;;;;;;sCAQpD,OAAO,UACP,OAAO,KAAK,CAAC,OACb,OAAO,KAAK,CAAC,aACb,OAAO,mDAAmD,EAAE,YAAY,EAAE,KACxE,IAAI;;;;;yBAMN,MAAM,YACN,OAAO,KACL,IAAI;;0BAKH,MAAM,KAAK;gBACX,MAAM,KAAK;wBACX,MAAM,QAAQ,UAAU,CAAC;;;;;qBACzB,MAAM,KAAK;;;;;uBAEX,MAAM,YAAY;;;;;wBAElB,MAAM,YAAY;;eAIlB,MAAM;;;;;oBAIN,YAAY;;;;qBACZ,YAAY;;;oBAKZ,MAAM,oBAAoB;+BACb,MAAM,OAAO,MAAM,KAAK,QAAQ;2BACtC,MAAM,KAAK,QAAQ,UAAU,CAAC;;;6BAKrC,MAAM,QACnB,WAAe,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,KAAK,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAA;KAAE,CAAC,CAC9D;;;8BAKU,SAAS;;;;cACT,QAAQ;;;;aACR,QAAQ;;8BAKX,UAAU,eACV,SAAS,KACP,UAAU;;;;;;eAKT,SAAS;;;;;;;8BAET,SAAS;;6BAMT;IAAE,GAAG,EAAE,gBAAgB,GAAG;QAAE,eAAe,EAAE,KAAK,CAAA;KAAE,CAAA;CAAE"}
|