@agoric/inter-protocol 0.16.2-dev-57802f9.0 → 0.16.2-other-dev-70beeb7.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/CHANGELOG.md +1041 -0
- package/package.json +30 -33
- package/scripts/add-collateral-core.js +112 -0
- package/scripts/build-bundles.js +21 -5
- package/scripts/deploy-contracts.js +100 -0
- package/scripts/init-core.js +198 -0
- package/scripts/invite-committee-core.js +42 -0
- package/scripts/manual-price-feed.js +117 -0
- package/scripts/price-feed-core.js +104 -0
- package/scripts/start-local-chain.sh +84 -0
- package/src/auction/auctionBook.js +59 -74
- package/src/auction/auctioneer.js +44 -56
- package/src/auction/offerBook.js +11 -12
- package/src/auction/params.js +5 -3
- package/src/auction/scheduleMath.js +13 -13
- package/src/auction/scheduler.js +32 -32
- package/src/auction/sortedOffers.js +7 -8
- package/src/auction/util.js +4 -4
- package/src/clientSupport.js +96 -152
- package/src/contractSupport.js +5 -5
- package/src/econCommitteeCharter.js +17 -18
- package/src/feeDistributor.js +33 -34
- package/src/interest.js +14 -20
- package/src/price/fluxAggregatorContract.js +45 -51
- package/src/price/fluxAggregatorKit.js +33 -48
- package/src/price/priceOracleKit.js +13 -11
- package/src/price/roundsManager.js +64 -52
- package/src/proposals/addAssetToVault.js +6 -15
- package/src/proposals/committee-proposal.js +27 -21
- package/src/proposals/core-proposal.js +7 -7
- package/src/proposals/econ-behaviors.js +32 -57
- package/src/proposals/price-feed-proposal.js +34 -66
- package/src/proposals/startEconCommittee.js +1 -1
- package/src/proposals/startPSM.js +22 -32
- package/src/proposals/utils.js +7 -26
- package/src/psm/psm.js +63 -69
- package/src/reserve/assetReserve.js +18 -27
- package/src/reserve/assetReserveKit.js +22 -14
- package/src/typeGuards.js +13 -0
- package/src/vaultFactory/liquidation.js +17 -30
- package/src/vaultFactory/math.js +9 -8
- package/src/vaultFactory/orderedVaultStore.js +9 -6
- package/src/vaultFactory/params.js +18 -24
- package/src/vaultFactory/prioritizedVaults.js +2 -2
- package/src/vaultFactory/proceeds.js +18 -24
- package/src/vaultFactory/storeUtils.js +12 -8
- package/src/vaultFactory/types.js +28 -38
- package/src/vaultFactory/vault.js +89 -88
- package/src/vaultFactory/vaultDirector.js +44 -35
- package/src/vaultFactory/vaultFactory.js +26 -33
- package/src/vaultFactory/vaultHolder.js +13 -8
- package/src/vaultFactory/vaultKit.js +2 -3
- package/src/vaultFactory/vaultManager.js +120 -138
- package/src/auction/auctionBook.d.ts +0 -83
- package/src/auction/auctionBook.d.ts.map +0 -1
- package/src/auction/auctioneer.d.ts +0 -75
- package/src/auction/auctioneer.d.ts.map +0 -1
- package/src/auction/offerBook.d.ts +0 -72
- package/src/auction/offerBook.d.ts.map +0 -1
- package/src/auction/params.d.ts +0 -142
- package/src/auction/params.d.ts.map +0 -1
- package/src/auction/scheduleMath.d.ts +0 -4
- package/src/auction/scheduleMath.d.ts.map +0 -1
- package/src/auction/scheduler.d.ts +0 -49
- package/src/auction/scheduler.d.ts.map +0 -1
- package/src/auction/sortedOffers.d.ts +0 -8
- package/src/auction/sortedOffers.d.ts.map +0 -1
- package/src/auction/util.d.ts +0 -30
- package/src/auction/util.d.ts.map +0 -1
- package/src/clientSupport.d.ts +0 -167
- package/src/clientSupport.d.ts.map +0 -1
- package/src/collectFees.d.ts +0 -2
- package/src/collectFees.d.ts.map +0 -1
- package/src/contractSupport.d.ts +0 -33
- package/src/contractSupport.d.ts.map +0 -1
- package/src/econCommitteeCharter.d.ts +0 -41
- package/src/econCommitteeCharter.d.ts.map +0 -1
- package/src/feeDistributor.d.ts +0 -212
- package/src/feeDistributor.d.ts.map +0 -1
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +0 -1
- package/src/interest-math.d.ts +0 -3
- package/src/interest-math.d.ts.map +0 -1
- package/src/interest.d.ts +0 -29
- package/src/interest.d.ts.map +0 -1
- package/src/price/fluxAggregatorContract.d.ts +0 -112
- package/src/price/fluxAggregatorContract.d.ts.map +0 -1
- package/src/price/fluxAggregatorKit.d.ts +0 -155
- package/src/price/fluxAggregatorKit.d.ts.map +0 -1
- package/src/price/priceOracleKit.d.ts +0 -52
- package/src/price/priceOracleKit.d.ts.map +0 -1
- package/src/price/roundsManager.d.ts +0 -330
- package/src/price/roundsManager.d.ts.map +0 -1
- package/src/proposals/addAssetToVault.d.ts +0 -143
- package/src/proposals/addAssetToVault.d.ts.map +0 -1
- package/src/proposals/committee-proposal.d.ts +0 -113
- package/src/proposals/committee-proposal.d.ts.map +0 -1
- package/src/proposals/core-proposal.d.ts +0 -149
- package/src/proposals/core-proposal.d.ts.map +0 -1
- package/src/proposals/econ-behaviors.d.ts +0 -201
- package/src/proposals/econ-behaviors.d.ts.map +0 -1
- package/src/proposals/price-feed-proposal.d.ts +0 -82
- package/src/proposals/price-feed-proposal.d.ts.map +0 -1
- package/src/proposals/startEconCommittee.d.ts +0 -34
- package/src/proposals/startEconCommittee.d.ts.map +0 -1
- package/src/proposals/startPSM.d.ts +0 -61
- package/src/proposals/startPSM.d.ts.map +0 -1
- package/src/proposals/utils.d.ts +0 -15
- package/src/proposals/utils.d.ts.map +0 -1
- package/src/provisionPool.d.ts +0 -165
- package/src/provisionPool.d.ts.map +0 -1
- package/src/provisionPool.js +0 -119
- package/src/provisionPoolKit.d.ts +0 -379
- package/src/provisionPoolKit.d.ts.map +0 -1
- package/src/provisionPoolKit.js +0 -461
- package/src/psm/psm.d.ts +0 -178
- package/src/psm/psm.d.ts.map +0 -1
- package/src/psm/types.d.ts +0 -2
- package/src/psm/types.d.ts.map +0 -1
- package/src/reserve/assetReserve.d.ts +0 -44
- package/src/reserve/assetReserve.d.ts.map +0 -1
- package/src/reserve/assetReserveKit.d.ts +0 -114
- package/src/reserve/assetReserveKit.d.ts.map +0 -1
- package/src/reserve/params.d.ts +0 -10
- package/src/reserve/params.d.ts.map +0 -1
- package/src/tokens.d.ts +0 -3
- package/src/tokens.d.ts.map +0 -1
- package/src/tokens.js +0 -5
- package/src/vaultFactory/burn.d.ts +0 -2
- package/src/vaultFactory/burn.d.ts.map +0 -1
- package/src/vaultFactory/liquidation.d.ts +0 -24
- package/src/vaultFactory/liquidation.d.ts.map +0 -1
- package/src/vaultFactory/math.d.ts +0 -10
- package/src/vaultFactory/math.d.ts.map +0 -1
- package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
- package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
- package/src/vaultFactory/params.d.ts +0 -159
- package/src/vaultFactory/params.d.ts.map +0 -1
- package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
- package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
- package/src/vaultFactory/proceeds.d.ts +0 -34
- package/src/vaultFactory/proceeds.d.ts.map +0 -1
- package/src/vaultFactory/storeUtils.d.ts +0 -25
- package/src/vaultFactory/storeUtils.d.ts.map +0 -1
- package/src/vaultFactory/type-imports.d.ts +0 -2
- package/src/vaultFactory/type-imports.d.ts.map +0 -1
- package/src/vaultFactory/types.d.ts +0 -137
- package/src/vaultFactory/types.d.ts.map +0 -1
- package/src/vaultFactory/vault.d.ts +0 -529
- package/src/vaultFactory/vault.d.ts.map +0 -1
- package/src/vaultFactory/vaultDirector.d.ts +0 -560
- package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
- package/src/vaultFactory/vaultFactory.d.ts +0 -162
- package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
- package/src/vaultFactory/vaultHolder.d.ts +0 -201
- package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
- package/src/vaultFactory/vaultKit.d.ts +0 -32
- package/src/vaultFactory/vaultKit.d.ts.map +0 -1
- package/src/vaultFactory/vaultManager.d.ts +0 -554
- package/src/vaultFactory/vaultManager.d.ts.map +0 -1
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
|
|
5
|
+
* See also ../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
|
-
*
|
|
20
|
+
* Calculate the minimum collateralization given the liquidation margin and the "padding"
|
|
21
|
+
* from that liquidation threshold.
|
|
22
22
|
*
|
|
23
23
|
* @param {Ratio} liquidationMargin
|
|
24
24
|
* @param {Ratio} liquidationPadding
|
|
@@ -74,10 +74,11 @@ export const maxDebtForVault = (
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Calculate the fee, the amount to mint and the resulting debt.
|
|
78
|
-
* the want together reflect a delta, where typically
|
|
79
|
-
* come from the gave/want of an offer
|
|
80
|
-
* `fee` will also be zero,
|
|
77
|
+
* Calculate the fee, the amount to mint and the resulting debt.
|
|
78
|
+
* The give and the want together reflect a delta, where typically
|
|
79
|
+
* one is zero because they come from the gave/want of an offer
|
|
80
|
+
* proposal. If the `want` is zero, the `fee` will also be zero,
|
|
81
|
+
* so the simple math works.
|
|
81
82
|
*
|
|
82
83
|
* @param {Amount<'nat'>} currentDebt
|
|
83
84
|
* @param {Amount<'nat'>} give excess of currentDebt is returned in 'surplus'
|
|
@@ -3,20 +3,22 @@ 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
|
|
7
|
-
* available.
|
|
6
|
+
* Designed to be replaceable by naked Collections API when composite keys are available.
|
|
8
7
|
*
|
|
9
|
-
* In this module debts are encoded as the inverse quotient (collateral over
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* In this module debts are encoded as the inverse quotient (collateral over debt) so that
|
|
9
|
+
* greater collateralization sorts after lower. (Higher debt-to-collateral come
|
|
10
|
+
* first.)
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
/** @typedef {import('./vault').Vault} Vault */
|
|
15
14
|
/** @typedef {import('./storeUtils').CompositeKey} CompositeKey */
|
|
16
15
|
|
|
17
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* @param {MapStore<string, Vault>} store
|
|
18
|
+
*/
|
|
18
19
|
export const makeOrderedVaultStore = store => {
|
|
19
20
|
/**
|
|
21
|
+
*
|
|
20
22
|
* @param {string} vaultId
|
|
21
23
|
* @param {Vault} vault
|
|
22
24
|
*/
|
|
@@ -29,6 +31,7 @@ export const makeOrderedVaultStore = store => {
|
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
/**
|
|
34
|
+
*
|
|
32
35
|
* @param {string} key
|
|
33
36
|
* @returns {Vault}
|
|
34
37
|
*/
|
|
@@ -75,11 +75,7 @@ const makeVaultDirectorParams = (
|
|
|
75
75
|
};
|
|
76
76
|
harden(makeVaultDirectorParams);
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
* @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager').ParamTypesMapFromRecord<
|
|
80
|
-
* ReturnType<typeof makeVaultDirectorParams>
|
|
81
|
-
* >} VaultDirectorParams
|
|
82
|
-
*/
|
|
78
|
+
/** @typedef {import('@agoric/governance/src/contractGovernance/typedParamManager').ParamTypesMapFromRecord<ReturnType<typeof makeVaultDirectorParams>>} VaultDirectorParams */
|
|
83
79
|
|
|
84
80
|
/** @type {(liquidationMargin: Ratio) => Ratio} */
|
|
85
81
|
const zeroRatio = liquidationMargin =>
|
|
@@ -126,16 +122,16 @@ export const vaultParamPattern = M.splitRecord(
|
|
|
126
122
|
|
|
127
123
|
/**
|
|
128
124
|
* @param {{
|
|
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
|
|
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,
|
|
139
135
|
* }} opts
|
|
140
136
|
*/
|
|
141
137
|
export const makeGovernedTerms = ({
|
|
@@ -167,8 +163,8 @@ export const makeGovernedTerms = ({
|
|
|
167
163
|
};
|
|
168
164
|
harden(makeGovernedTerms);
|
|
169
165
|
/**
|
|
170
|
-
* Stop-gap which restores initial param values
|
|
171
|
-
* https://github.com/Agoric/agoric-sdk/issues/5200
|
|
166
|
+
* Stop-gap which restores initial param values
|
|
167
|
+
* UNTIL https://github.com/Agoric/agoric-sdk/issues/5200
|
|
172
168
|
*
|
|
173
169
|
* NB: changes from initial values will be lost upon restart
|
|
174
170
|
*
|
|
@@ -180,12 +176,7 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
|
|
|
180
176
|
const managers = makeScalarMapStore();
|
|
181
177
|
|
|
182
178
|
// the managers aren't durable but their arguments are
|
|
183
|
-
/**
|
|
184
|
-
* @type {MapStore<
|
|
185
|
-
* Brand,
|
|
186
|
-
* { storageNode: StorageNode; initialParamValues: VaultManagerParamValues }
|
|
187
|
-
* >}
|
|
188
|
-
*/
|
|
179
|
+
/** @type {MapStore<Brand, {storageNode: StorageNode, initialParamValues: VaultManagerParamValues}>} */
|
|
189
180
|
const managerArgs = provideDurableMapStore(
|
|
190
181
|
baggage,
|
|
191
182
|
'vault param manager parts',
|
|
@@ -205,6 +196,7 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
|
|
|
205
196
|
|
|
206
197
|
return {
|
|
207
198
|
/**
|
|
199
|
+
*
|
|
208
200
|
* @param {Brand} brand
|
|
209
201
|
* @param {StorageNode} storageNode
|
|
210
202
|
* @param {VaultManagerParamValues} initialParamValues
|
|
@@ -214,7 +206,9 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
|
|
|
214
206
|
managerArgs.init(brand, args);
|
|
215
207
|
return makeManager(brand, args);
|
|
216
208
|
},
|
|
217
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* @param {Brand} brand
|
|
211
|
+
*/
|
|
218
212
|
get(brand) {
|
|
219
213
|
return managers.get(brand);
|
|
220
214
|
},
|
|
@@ -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
|
|
51
|
+
* vault has a higher debt ratio than the previous highest
|
|
52
52
|
*/
|
|
53
53
|
export const makePrioritizedVaults = store => {
|
|
54
54
|
const vaults = makeOrderedVaultStore(store);
|
|
@@ -11,32 +11,27 @@ 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: [number, AmountKeywordRecord]
|
|
26
|
-
* vaultsToReinstate: number
|
|
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: Array<[number, AmountKeywordRecord]>,
|
|
26
|
+
* vaultsToReinstate: Array<number>
|
|
27
27
|
* }} DistributionPlan
|
|
28
|
-
* The plan to execute for distributing proceeds of a liquidation.
|
|
29
28
|
*
|
|
30
|
-
*
|
|
29
|
+
* The plan to execute for distributing proceeds of a liquidation.
|
|
30
|
+
*
|
|
31
|
+
* Vaults are referenced by index in the list sent to the calculator.
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
|
-
/**
|
|
34
|
-
* @typedef {{
|
|
35
|
-
* collateral: Amount<'nat'>;
|
|
36
|
-
* presaleDebt: Amount<'nat'>;
|
|
37
|
-
* currentDebt: Amount<'nat'>;
|
|
38
|
-
* }} VaultBalances
|
|
39
|
-
*/
|
|
34
|
+
/** @typedef {{ collateral: Amount<'nat'>, presaleDebt: Amount<'nat'>, currentDebt: Amount<'nat'> }} VaultBalances */
|
|
40
35
|
|
|
41
36
|
/**
|
|
42
37
|
* Liquidation.md describes how to process liquidation proceeds.
|
|
@@ -51,8 +46,7 @@ import { liquidationResults } from './liquidation.js';
|
|
|
51
46
|
* @param {Amount<'nat'>} inputs.totalDebt
|
|
52
47
|
* @param {Amount<'nat'>} inputs.totalCollateral
|
|
53
48
|
* @param {PriceDescription} inputs.oraclePriceAtStart
|
|
54
|
-
* @param {VaultBalances
|
|
55
|
-
* collateralized
|
|
49
|
+
* @param {Array<VaultBalances>} inputs.vaultsBalances ordered best to worst collateralized
|
|
56
50
|
* @param {Ratio} inputs.penaltyRate
|
|
57
51
|
* @returns {DistributionPlan}
|
|
58
52
|
*/
|
|
@@ -19,9 +19,13 @@ const { multiply } = natSafeMath;
|
|
|
19
19
|
|
|
20
20
|
const trace = makeTracer('Store', true);
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {import('@endo/marshal').PureData} PureData
|
|
24
|
+
*/
|
|
23
25
|
|
|
24
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {[normalizedCollateralization: number, vaultId: VaultId]} CompositeKey
|
|
28
|
+
*/
|
|
25
29
|
|
|
26
30
|
// `makeEncodePassable` has three named options:
|
|
27
31
|
// `encodeRemotable`, `encodeError`, and `encodePromise`.
|
|
@@ -65,12 +69,12 @@ const decodeNumber = encoded => {
|
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
// Type annotations to support static testing of amount values
|
|
68
|
-
/** @typedef {Amount<'nat'> & {
|
|
69
|
-
/** @typedef {Amount<'nat'> & {
|
|
72
|
+
/** @typedef {Amount<'nat'> & {normalized: true}} NormalizedDebt */
|
|
73
|
+
/** @typedef {Amount<'nat'> & {normalized: false}} ActualDebt */
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
|
-
* Overcollateralized are greater than one.
|
|
73
|
-
* smaller in [0-1].
|
|
76
|
+
* Overcollateralized are greater than one.
|
|
77
|
+
* The more undercollaterized the smaller in [0-1].
|
|
74
78
|
*
|
|
75
79
|
* @param {NormalizedDebt} normalizedDebt normalized (not actual) total debt
|
|
76
80
|
* @param {Amount<'nat'>} collateral
|
|
@@ -91,7 +95,7 @@ const collateralizationRatio = (normalizedDebt, collateral) => {
|
|
|
91
95
|
* @param {Amount<'nat'>} collateral
|
|
92
96
|
* @param {VaultId} vaultId
|
|
93
97
|
* @returns {string} lexically sortable string in which highest
|
|
94
|
-
*
|
|
98
|
+
* debt-to-collateral is earliest
|
|
95
99
|
*/
|
|
96
100
|
export const toVaultKey = (normalizedDebt, collateral, vaultId) => {
|
|
97
101
|
assert(normalizedDebt);
|
|
@@ -158,7 +162,7 @@ harden(normalizedCollRatio);
|
|
|
158
162
|
* @param {Ratio} compoundedInterest
|
|
159
163
|
* @param {Ratio} margin
|
|
160
164
|
* @returns {string} lexically sortable string in which highest
|
|
161
|
-
*
|
|
165
|
+
* debt-to-collateral is earliest
|
|
162
166
|
*/
|
|
163
167
|
export const normalizedCollRatioKey = (quote, compoundedInterest, margin) => {
|
|
164
168
|
const collRatio = normalizedCollRatio(quote, compoundedInterest, margin);
|
|
@@ -2,30 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('./vault').VaultNotification} VaultNotification
|
|
5
|
-
*
|
|
6
5
|
* @typedef {import('./vault').Vault} Vault
|
|
7
|
-
*
|
|
8
6
|
* @typedef {import('./vaultKit').VaultKit} VaultKit
|
|
9
|
-
*
|
|
10
7
|
* @typedef {import('./vaultManager').VaultManager} VaultManager
|
|
11
|
-
*
|
|
12
8
|
* @typedef {import('./vaultManager').CollateralManager} CollateralManager
|
|
13
|
-
*
|
|
14
9
|
* @typedef {import('../reserve/assetReserve.js').AssetReserveLimitedCreatorFacet} AssetReserveCreatorFacet
|
|
15
|
-
*
|
|
16
10
|
* @typedef {import('../reserve/assetReserve.js').AssetReservePublicFacet} AssetReservePublicFacet
|
|
17
|
-
*
|
|
18
11
|
* @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
|
|
19
|
-
*
|
|
20
12
|
* @typedef {import('./vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
|
|
21
13
|
*
|
|
22
14
|
* @typedef {import('@agoric/time/src/types').Timestamp} Timestamp
|
|
23
|
-
*
|
|
24
15
|
* @typedef {import('@agoric/time/src/types').RelativeTime} RelativeTime
|
|
25
16
|
*/
|
|
26
17
|
|
|
27
18
|
/**
|
|
28
|
-
* @typedef
|
|
19
|
+
* @typedef {object} AutoswapLocal
|
|
29
20
|
* @property {(amount: Amount, brand: Brand) => Amount} getInputPrice
|
|
30
21
|
* @property {() => Invitation} makeSwapInvitation
|
|
31
22
|
*/
|
|
@@ -33,16 +24,13 @@
|
|
|
33
24
|
/**
|
|
34
25
|
* @typedef {object} VaultManagerParamValues
|
|
35
26
|
* @property {Ratio} liquidationMargin - margin below which collateral will be
|
|
36
|
-
*
|
|
37
|
-
* @property {Ratio} liquidationPenalty - penalty charged upon liquidation as
|
|
38
|
-
*
|
|
39
|
-
* @property {Ratio}
|
|
40
|
-
*
|
|
41
|
-
* @property {Ratio} mintFee - The fee (in BasisPoints) charged when creating or
|
|
42
|
-
* increasing a debt position.
|
|
27
|
+
* liquidated to satisfy the debt.
|
|
28
|
+
* @property {Ratio} liquidationPenalty - penalty charged upon liquidation as proportion of debt
|
|
29
|
+
* @property {Ratio} interestRate - annual interest rate charged on debt positions
|
|
30
|
+
* @property {Ratio} mintFee - The fee (in BasisPoints) charged when creating
|
|
31
|
+
* or increasing a debt position.
|
|
43
32
|
* @property {Amount<'nat'>} debtLimit
|
|
44
|
-
* @property {Ratio} [liquidationPadding] - vault must maintain this in order to
|
|
45
|
-
* remove collateral or add debt
|
|
33
|
+
* @property {Ratio} [liquidationPadding] - vault must maintain this in order to remove collateral or add debt
|
|
46
34
|
*/
|
|
47
35
|
|
|
48
36
|
/**
|
|
@@ -54,7 +42,7 @@
|
|
|
54
42
|
*/
|
|
55
43
|
|
|
56
44
|
/**
|
|
57
|
-
* @typedef
|
|
45
|
+
* @typedef {object} VaultFactoryCreatorFacet
|
|
58
46
|
* @property {AddVaultType} addVaultType
|
|
59
47
|
* @property {() => Allocation} getRewardAllocation
|
|
60
48
|
* @property {() => Promise<Invitation<string, never>>} makeCollectFeesInvitation
|
|
@@ -63,20 +51,23 @@
|
|
|
63
51
|
*/
|
|
64
52
|
|
|
65
53
|
/**
|
|
66
|
-
* @callback MintAndTransfer
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
54
|
+
* @callback MintAndTransfer
|
|
55
|
+
* Mint new debt `toMint` and transfer the `fee` portion to the vaultFactory's reward
|
|
56
|
+
* pool. Then reallocate over all the seat arguments and the rewardPoolSeat. Update
|
|
57
|
+
* the `totalDebt` if the reallocate succeeds.
|
|
70
58
|
* @param {ZCFSeat} mintReceiver
|
|
71
59
|
* @param {Amount<'nat'>} toMint
|
|
72
60
|
* @param {Amount<'nat'>} fee
|
|
73
|
-
* @param {TransferPart[]} transfers
|
|
61
|
+
* @param {import('@agoric/zoe/src/contractSupport/atomicTransfer.js').TransferPart[]} transfers
|
|
74
62
|
* @returns {void}
|
|
75
63
|
*/
|
|
76
64
|
|
|
77
65
|
/**
|
|
78
|
-
* @callback BurnDebt
|
|
79
|
-
*
|
|
66
|
+
* @callback BurnDebt
|
|
67
|
+
*
|
|
68
|
+
* Burn debt tokens off a seat and update
|
|
69
|
+
* the `totalDebt` if the reallocate succeeds.
|
|
70
|
+
*
|
|
80
71
|
* @param {Amount} toBurn
|
|
81
72
|
* @param {ZCFSeat} fromSeat
|
|
82
73
|
* @returns {void}
|
|
@@ -87,15 +78,16 @@
|
|
|
87
78
|
* @property {() => Ratio} getLiquidationMargin
|
|
88
79
|
* @property {() => Ratio} getMintFee
|
|
89
80
|
* @property {() => Promise<PriceQuote>} getCollateralQuote
|
|
90
|
-
* @property {() => Ratio} getInterestRate - The annual interest rate on a debt
|
|
91
|
-
* position
|
|
81
|
+
* @property {() => Ratio} getInterestRate - The annual interest rate on a debt position
|
|
92
82
|
* @property {() => RelativeTime} getChargingPeriod - The period (in seconds) at
|
|
93
83
|
* which interest is charged to the debt position.
|
|
94
84
|
* @property {() => RelativeTime} getRecordingPeriod - The period (in seconds)
|
|
95
85
|
* at which interest is recorded to the debt position.
|
|
96
86
|
*/
|
|
97
87
|
|
|
98
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {string} VaultId
|
|
90
|
+
*/
|
|
99
91
|
|
|
100
92
|
/**
|
|
101
93
|
* @typedef {object} InterestTiming
|
|
@@ -112,9 +104,7 @@
|
|
|
112
104
|
|
|
113
105
|
/**
|
|
114
106
|
* @typedef {object} Liquidator
|
|
115
|
-
* @property {() => Promise<
|
|
116
|
-
* Invitation<void, { debt: Amount<'nat'>; penaltyRate: Ratio }>
|
|
117
|
-
* >} makeLiquidateInvitation
|
|
107
|
+
* @property {() => Promise<Invitation<void, { debt: Amount<'nat'>; penaltyRate: Ratio; }>>} makeLiquidateInvitation
|
|
118
108
|
*/
|
|
119
109
|
|
|
120
110
|
/**
|
|
@@ -134,11 +124,11 @@
|
|
|
134
124
|
/**
|
|
135
125
|
* @typedef {object} CalculatorKit
|
|
136
126
|
* @property {Calculate} calculate calculate new debt for charging periods up to
|
|
137
|
-
*
|
|
127
|
+
* the present.
|
|
138
128
|
* @property {Calculate} calculateReportingPeriod calculate new debt for
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
129
|
+
* reporting periods up to the present. If some charging periods have elapsed
|
|
130
|
+
* that don't constitute whole reporting periods, the time is not updated past
|
|
131
|
+
* them and interest is not accumulated for them.
|
|
142
132
|
*/
|
|
143
133
|
|
|
144
|
-
/** @typedef {{
|
|
134
|
+
/** @typedef {{key: 'governedParams' | {collateralBrand: Brand}}} VaultFactoryParamPath */
|