@agoric/inter-protocol 0.16.2-other-dev-1f26562.0 → 0.16.2-other-dev-3eb1a1d.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/README.md +6 -6
- package/package.json +42 -36
- 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 +156 -150
- 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 +69 -0
- package/src/auction/auctioneer.d.ts.map +1 -0
- package/src/auction/auctioneer.js +70 -59
- package/src/auction/offerBook.d.ts +45 -0
- package/src/auction/offerBook.d.ts.map +1 -0
- package/src/auction/offerBook.js +13 -12
- package/src/auction/params.d.ts +144 -0
- package/src/auction/params.d.ts.map +1 -0
- package/src/auction/params.js +10 -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 +30 -0
- package/src/auction/util.d.ts.map +1 -0
- package/src/auction/util.js +9 -6
- package/src/clientSupport.d.ts +167 -0
- package/src/clientSupport.d.ts.map +1 -0
- package/src/clientSupport.js +155 -97
- 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 +40 -0
- package/src/econCommitteeCharter.d.ts.map +1 -0
- package/src/econCommitteeCharter.js +21 -20
- package/src/feeDistributor.d.ts +224 -0
- package/src/feeDistributor.d.ts.map +1 -0
- package/src/feeDistributor.js +37 -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 +3 -0
- package/src/interest-math.d.ts.map +1 -0
- package/src/interest.d.ts +28 -0
- package/src/interest.d.ts.map +1 -0
- package/src/interest.js +23 -18
- package/src/price/README.md +13 -0
- 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 +103 -0
- package/src/price/fluxAggregatorKit.d.ts.map +1 -0
- package/src/price/fluxAggregatorKit.js +52 -40
- package/src/price/priceOracleKit.d.ts +38 -0
- package/src/price/priceOracleKit.d.ts.map +1 -0
- package/src/price/priceOracleKit.js +12 -14
- package/src/price/roundsManager.d.ts +204 -0
- package/src/price/roundsManager.d.ts.map +1 -0
- package/src/price/roundsManager.js +131 -85
- package/src/proposals/README.md +2 -3
- package/src/proposals/add-auction.d.ts +109 -0
- package/src/proposals/add-auction.d.ts.map +1 -0
- package/src/proposals/add-auction.js +256 -0
- package/src/proposals/addAssetToVault.d.ts +173 -0
- package/src/proposals/addAssetToVault.d.ts.map +1 -0
- package/src/proposals/addAssetToVault.js +192 -40
- package/src/proposals/committee-proposal.d.ts +113 -0
- package/src/proposals/committee-proposal.d.ts.map +1 -0
- package/src/proposals/committee-proposal.js +25 -31
- package/src/proposals/core-proposal.d.ts +149 -0
- package/src/proposals/core-proposal.d.ts.map +1 -0
- package/src/proposals/core-proposal.js +9 -11
- package/src/proposals/deploy-price-feeds.d.ts +76 -0
- package/src/proposals/deploy-price-feeds.d.ts.map +1 -0
- package/src/proposals/deploy-price-feeds.js +316 -0
- package/src/proposals/econ-behaviors.d.ts +541 -0
- package/src/proposals/econ-behaviors.d.ts.map +1 -0
- package/src/proposals/econ-behaviors.js +64 -45
- package/src/proposals/price-feed-proposal.d.ts +84 -0
- package/src/proposals/price-feed-proposal.d.ts.map +1 -0
- package/src/proposals/price-feed-proposal.js +109 -51
- package/src/proposals/replace-fee-distributor.d.ts +48 -0
- package/src/proposals/replace-fee-distributor.d.ts.map +1 -0
- package/src/proposals/replace-fee-distributor.js +195 -0
- package/src/proposals/replace-scaledPriceAuthorities.d.ts +30 -0
- package/src/proposals/replace-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/replace-scaledPriceAuthorities.js +124 -0
- package/src/proposals/replaceElectorate.d.ts +55 -0
- package/src/proposals/replaceElectorate.d.ts.map +1 -0
- package/src/proposals/replaceElectorate.js +521 -0
- package/src/proposals/startEconCommittee.d.ts +34 -0
- package/src/proposals/startEconCommittee.d.ts.map +1 -0
- package/src/proposals/startEconCommittee.js +2 -2
- package/src/proposals/startPSM.d.ts +59 -0
- package/src/proposals/startPSM.d.ts.map +1 -0
- package/src/proposals/startPSM.js +44 -29
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts +24 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.d.ts.map +1 -0
- package/src/proposals/upgrade-scaledPriceAuthorities.js +78 -0
- package/src/proposals/upgrade-vaults.d.ts +41 -0
- package/src/proposals/upgrade-vaults.d.ts.map +1 -0
- package/src/proposals/upgrade-vaults.js +202 -0
- package/src/proposals/utils.d.ts +19 -0
- package/src/proposals/utils.d.ts.map +1 -0
- package/src/proposals/utils.js +43 -9
- package/src/provisionPool.d.ts +163 -0
- package/src/provisionPool.d.ts.map +1 -0
- package/src/provisionPool.js +122 -0
- package/src/provisionPoolKit.d.ts +359 -0
- package/src/provisionPoolKit.d.ts.map +1 -0
- package/src/provisionPoolKit.js +522 -0
- package/src/psm/psm.d.ts +125 -0
- package/src/psm/psm.d.ts.map +1 -0
- package/src/psm/psm.js +80 -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 +47 -0
- package/src/reserve/assetReserve.d.ts.map +1 -0
- package/src/reserve/assetReserve.js +28 -19
- package/src/reserve/assetReserveKit.d.ts +74 -0
- package/src/reserve/assetReserveKit.d.ts.map +1 -0
- package/src/reserve/assetReserveKit.js +24 -30
- package/src/reserve/params.d.ts +10 -0
- package/src/reserve/params.d.ts.map +1 -0
- 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 +23 -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 +10 -9
- package/src/vaultFactory/orderedVaultStore.d.ts +93 -0
- package/src/vaultFactory/orderedVaultStore.d.ts.map +1 -0
- package/src/vaultFactory/orderedVaultStore.js +8 -11
- package/src/vaultFactory/params.d.ts +140 -0
- package/src/vaultFactory/params.d.ts.map +1 -0
- package/src/vaultFactory/params.js +52 -24
- package/src/vaultFactory/prioritizedVaults.d.ts +279 -0
- package/src/vaultFactory/prioritizedVaults.d.ts.map +1 -0
- package/src/vaultFactory/prioritizedVaults.js +4 -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} +42 -42
- package/src/vaultFactory/vault.d.ts +343 -0
- package/src/vaultFactory/vault.d.ts.map +1 -0
- package/src/vaultFactory/vault.js +105 -99
- package/src/vaultFactory/vaultDirector.d.ts +341 -0
- package/src/vaultFactory/vaultDirector.d.ts.map +1 -0
- package/src/vaultFactory/vaultDirector.js +86 -64
- package/src/vaultFactory/vaultFactory.d.ts +202 -0
- package/src/vaultFactory/vaultFactory.d.ts.map +1 -0
- package/src/vaultFactory/vaultFactory.js +52 -33
- package/src/vaultFactory/vaultHolder.d.ts +126 -0
- package/src/vaultFactory/vaultHolder.d.ts.map +1 -0
- package/src/vaultFactory/vaultHolder.js +11 -16
- package/src/vaultFactory/vaultKit.d.ts +32 -0
- package/src/vaultFactory/vaultKit.d.ts.map +1 -0
- package/src/vaultFactory/vaultKit.js +5 -4
- package/src/vaultFactory/vaultManager.d.ts +674 -0
- package/src/vaultFactory/vaultManager.d.ts.map +1 -0
- package/src/vaultFactory/vaultManager.js +257 -158
- 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
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {import('./vault').VaultNotification} VaultNotification
|
|
5
|
-
* @typedef {import('./vault').Vault} Vault
|
|
6
|
-
* @typedef {import('./vaultKit').VaultKit} VaultKit
|
|
7
|
-
* @typedef {import('./vaultManager').VaultManager} VaultManager
|
|
8
|
-
* @typedef {import('./vaultManager').CollateralManager} CollateralManager
|
|
9
|
-
* @typedef {import('../reserve/assetReserve.js').AssetReserveLimitedCreatorFacet} AssetReserveCreatorFacet
|
|
10
|
-
* @typedef {import('../reserve/assetReserve.js').AssetReservePublicFacet} AssetReservePublicFacet
|
|
11
|
-
* @typedef {import('../auction/auctioneer.js').AuctioneerPublicFacet} AuctioneerPublicFacet
|
|
12
4
|
* @typedef {import('./vaultFactory.js').VaultFactoryContract['publicFacet']} VaultFactoryPublicFacet
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
5
|
+
* @import {VaultNotification} from './vault.js'
|
|
6
|
+
* @import {Vault} from './vault.js'
|
|
7
|
+
* @import {VaultKit} from './vaultKit.js'
|
|
8
|
+
* @import {VaultManager} from './vaultManager.js'
|
|
9
|
+
* @import {CollateralManager} from './vaultManager.js'
|
|
10
|
+
* @import {AssetReserveLimitedCreatorFacet} from '../reserve/assetReserve.js'
|
|
11
|
+
* @import {AssetReservePublicFacet} from '../reserve/assetReserve.js'
|
|
12
|
+
* @import {AuctioneerPublicFacet} from '../auction/auctioneer.js'
|
|
13
|
+
* @import {Timestamp} from '@agoric/time'
|
|
14
|
+
* @import {RelativeTime} from '@agoric/time'
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
* @typedef
|
|
18
|
+
* @typedef {object} AutoswapLocal
|
|
20
19
|
* @property {(amount: Amount, brand: Brand) => Amount} getInputPrice
|
|
21
20
|
* @property {() => Invitation} makeSwapInvitation
|
|
22
21
|
*/
|
|
@@ -24,13 +23,16 @@
|
|
|
24
23
|
/**
|
|
25
24
|
* @typedef {object} VaultManagerParamValues
|
|
26
25
|
* @property {Ratio} liquidationMargin - margin below which collateral will be
|
|
27
|
-
*
|
|
28
|
-
* @property {Ratio} liquidationPenalty - penalty charged upon liquidation as
|
|
29
|
-
*
|
|
30
|
-
* @property {Ratio}
|
|
31
|
-
*
|
|
26
|
+
* liquidated to satisfy the debt.
|
|
27
|
+
* @property {Ratio} liquidationPenalty - penalty charged upon liquidation as
|
|
28
|
+
* proportion of debt
|
|
29
|
+
* @property {Ratio} interestRate - annual interest rate charged on debt
|
|
30
|
+
* positions
|
|
31
|
+
* @property {Ratio} mintFee - The fee (in BasisPoints) charged when creating or
|
|
32
|
+
* increasing a debt position.
|
|
32
33
|
* @property {Amount<'nat'>} debtLimit
|
|
33
|
-
* @property {Ratio} [liquidationPadding] - vault must maintain this in order to
|
|
34
|
+
* @property {Ratio} [liquidationPadding] - vault must maintain this in order to
|
|
35
|
+
* remove collateral or add debt
|
|
34
36
|
*/
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -42,32 +44,29 @@
|
|
|
42
44
|
*/
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
* @typedef
|
|
47
|
+
* @typedef {object} VaultFactoryCreatorFacet
|
|
46
48
|
* @property {AddVaultType} addVaultType
|
|
47
49
|
* @property {() => Allocation} getRewardAllocation
|
|
48
50
|
* @property {() => Promise<Invitation<string, never>>} makeCollectFeesInvitation
|
|
49
|
-
* @property {() => import('@agoric/time
|
|
50
|
-
* @property {() => import('@agoric/time
|
|
51
|
+
* @property {() => import('@agoric/time').TimerWaker} makeLiquidationWaker
|
|
52
|
+
* @property {() => import('@agoric/time').TimerWaker} makePriceLockWaker
|
|
51
53
|
*/
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
|
-
* @callback MintAndTransfer
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* @callback MintAndTransfer Mint new debt `toMint` and transfer the `fee`
|
|
57
|
+
* portion to the vaultFactory's reward pool. Then reallocate over all the
|
|
58
|
+
* seat arguments and the rewardPoolSeat. Update the `totalDebt` if the
|
|
59
|
+
* reallocate succeeds.
|
|
58
60
|
* @param {ZCFSeat} mintReceiver
|
|
59
61
|
* @param {Amount<'nat'>} toMint
|
|
60
62
|
* @param {Amount<'nat'>} fee
|
|
61
|
-
* @param {
|
|
63
|
+
* @param {TransferPart[]} transfers
|
|
62
64
|
* @returns {void}
|
|
63
65
|
*/
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
|
-
* @callback BurnDebt
|
|
67
|
-
*
|
|
68
|
-
* Burn debt tokens off a seat and update
|
|
69
|
-
* the `totalDebt` if the reallocate succeeds.
|
|
70
|
-
*
|
|
68
|
+
* @callback BurnDebt Burn debt tokens off a seat and update the `totalDebt` if
|
|
69
|
+
* the reallocate succeeds.
|
|
71
70
|
* @param {Amount} toBurn
|
|
72
71
|
* @param {ZCFSeat} fromSeat
|
|
73
72
|
* @returns {void}
|
|
@@ -77,17 +76,16 @@
|
|
|
77
76
|
* @typedef {object} GetVaultParams
|
|
78
77
|
* @property {() => Ratio} getLiquidationMargin
|
|
79
78
|
* @property {() => Ratio} getMintFee
|
|
80
|
-
* @property {() => Promise<PriceQuote>} getCollateralQuote
|
|
81
|
-
* @property {() => Ratio} getInterestRate - The annual interest rate on a debt
|
|
79
|
+
* @property {() => Promise<import('@agoric/zoe/tools/types.js').PriceQuote>} getCollateralQuote
|
|
80
|
+
* @property {() => Ratio} getInterestRate - The annual interest rate on a debt
|
|
81
|
+
* position
|
|
82
82
|
* @property {() => RelativeTime} getChargingPeriod - The period (in seconds) at
|
|
83
83
|
* which interest is charged to the debt position.
|
|
84
84
|
* @property {() => RelativeTime} getRecordingPeriod - The period (in seconds)
|
|
85
85
|
* at which interest is recorded to the debt position.
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* @typedef {string} VaultId
|
|
90
|
-
*/
|
|
88
|
+
/** @typedef {string} VaultId */
|
|
91
89
|
|
|
92
90
|
/**
|
|
93
91
|
* @typedef {object} InterestTiming
|
|
@@ -104,7 +102,9 @@
|
|
|
104
102
|
|
|
105
103
|
/**
|
|
106
104
|
* @typedef {object} Liquidator
|
|
107
|
-
* @property {() => Promise<
|
|
105
|
+
* @property {() => Promise<
|
|
106
|
+
* Invitation<void, { debt: Amount<'nat'>; penaltyRate: Ratio }>
|
|
107
|
+
* >} makeLiquidateInvitation
|
|
108
108
|
*/
|
|
109
109
|
|
|
110
110
|
/**
|
|
@@ -124,11 +124,11 @@
|
|
|
124
124
|
/**
|
|
125
125
|
* @typedef {object} CalculatorKit
|
|
126
126
|
* @property {Calculate} calculate calculate new debt for charging periods up to
|
|
127
|
-
*
|
|
127
|
+
* the present.
|
|
128
128
|
* @property {Calculate} calculateReportingPeriod calculate new debt for
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
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.
|
|
132
132
|
*/
|
|
133
133
|
|
|
134
|
-
/** @typedef {{key: 'governedParams' | {collateralBrand: Brand}}} VaultFactoryParamPath */
|
|
134
|
+
/** @typedef {{ key: 'governedParams' | { collateralBrand: Brand } }} VaultFactoryParamPath */
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for vault phase.
|
|
3
|
+
*
|
|
4
|
+
* - ACTIVE - vault is in use and can be changed
|
|
5
|
+
* - LIQUIDATING - vault is being liquidated by the vault manager, and cannot be
|
|
6
|
+
* changed by the user. If liquidation fails, vaults may remain in this state.
|
|
7
|
+
* An upgrade to the contract might be able to recover them.
|
|
8
|
+
* - TRANSFER - vault is able to be transferred (payments and debits frozen until
|
|
9
|
+
* it has a new owner)
|
|
10
|
+
* - CLOSED - vault was closed by the user and all assets have been paid out
|
|
11
|
+
* - LIQUIDATED - vault was closed by the manager, with remaining assets paid to
|
|
12
|
+
* owner
|
|
13
|
+
*/
|
|
14
|
+
export type Phase = (typeof Phase)[keyof typeof Phase];
|
|
15
|
+
export namespace Phase {
|
|
16
|
+
let ACTIVE: "active";
|
|
17
|
+
let LIQUIDATING: "liquidating";
|
|
18
|
+
let CLOSED: "closed";
|
|
19
|
+
let LIQUIDATED: "liquidated";
|
|
20
|
+
let TRANSFER: "transfer";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {object} VaultNotification
|
|
24
|
+
* @property {Amount<'nat'>} locked Amount of Collateral locked
|
|
25
|
+
* @property {{ debt: Amount<'nat'>; interest: Ratio }} debtSnapshot 'debt' at
|
|
26
|
+
* the point the compounded interest was 'interest'
|
|
27
|
+
* @property {Phase} vaultState
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {object} VaultManager
|
|
31
|
+
* @property {() => Subscriber<import('./vaultManager.js').AssetState>} getAssetSubscriber
|
|
32
|
+
* @property {(collateralAmount: Amount) => Amount<'nat'>} maxDebtFor
|
|
33
|
+
* @property {() => Brand<'nat'>} getCollateralBrand
|
|
34
|
+
* @property {(base: string) => string} scopeDescription
|
|
35
|
+
* @property {() => Brand<'nat'>} getDebtBrand
|
|
36
|
+
* @property {MintAndTransfer} mintAndTransfer
|
|
37
|
+
* @property {(amount: Amount, seat: ZCFSeat) => void} burn
|
|
38
|
+
* @property {() => Ratio} getCompoundedInterest
|
|
39
|
+
* @property {(
|
|
40
|
+
* oldDebt: import('./storeUtils.js').NormalizedDebt,
|
|
41
|
+
* oldCollateral: Amount<'nat'>,
|
|
42
|
+
* vaultId: VaultId,
|
|
43
|
+
* vaultPhase: VaultPhase,
|
|
44
|
+
* vault: Vault,
|
|
45
|
+
* ) => void} handleBalanceChange
|
|
46
|
+
* @property {() => import('./vaultManager.js').GovernedParamGetters} getGovernedParams
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {Readonly<{
|
|
50
|
+
* idInManager: VaultId;
|
|
51
|
+
* manager: VaultManager;
|
|
52
|
+
* storageNode: StorageNode;
|
|
53
|
+
* vaultSeat: ZCFSeat;
|
|
54
|
+
* }>} ImmutableState
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Snapshot is of the debt and compounded interest when the principal was last
|
|
58
|
+
* changed.
|
|
59
|
+
*
|
|
60
|
+
* @typedef {{
|
|
61
|
+
* interestSnapshot: Ratio;
|
|
62
|
+
* phase: VaultPhase;
|
|
63
|
+
* debtSnapshot: Amount<'nat'>;
|
|
64
|
+
* outerUpdater:
|
|
65
|
+
* | import('@agoric/zoe/src/contractSupport/recorder.js').Recorder<VaultNotification>
|
|
66
|
+
* | null;
|
|
67
|
+
* }} MutableState
|
|
68
|
+
*/
|
|
69
|
+
export const VaultI: import("@endo/patterns").InterfaceGuard<{
|
|
70
|
+
getCollateralAmount: import("@endo/patterns").MethodGuard;
|
|
71
|
+
getCurrentDebt: import("@endo/patterns").MethodGuard;
|
|
72
|
+
getNormalizedDebt: import("@endo/patterns").MethodGuard;
|
|
73
|
+
getVaultSeat: import("@endo/patterns").MethodGuard;
|
|
74
|
+
initVaultKit: import("@endo/patterns").MethodGuard;
|
|
75
|
+
liquidated: import("@endo/patterns").MethodGuard;
|
|
76
|
+
liquidating: import("@endo/patterns").MethodGuard;
|
|
77
|
+
makeAdjustBalancesInvitation: import("@endo/patterns").MethodGuard;
|
|
78
|
+
makeCloseInvitation: import("@endo/patterns").MethodGuard;
|
|
79
|
+
makeTransferInvitation: import("@endo/patterns").MethodGuard;
|
|
80
|
+
abortLiquidation: import("@endo/patterns").MethodGuard;
|
|
81
|
+
}>;
|
|
82
|
+
export function prepareVault(baggage: import("@agoric/swingset-liveslots").Baggage, makeRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").MakeRecorderKit, zcf: ZCF): (manager: VaultManager, idInManager: string, storageNode: globalThis.StorageNode) => import("@endo/exo").GuardedKit<{
|
|
83
|
+
helper: {
|
|
84
|
+
collateralBrand(): Brand<"nat">;
|
|
85
|
+
debtBrand(): Brand<"nat">;
|
|
86
|
+
emptyCollateral(): import("@agoric/ertp").NatAmount;
|
|
87
|
+
emptyDebt(): import("@agoric/ertp").NatAmount;
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {{
|
|
90
|
+
* give: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
|
|
91
|
+
* want: { Collateral: Amount<'nat'>; Minted: Amount<'nat'> };
|
|
92
|
+
* }} FullProposal
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* @param {ProposalRecord} partial
|
|
96
|
+
* @returns {FullProposal}
|
|
97
|
+
*/
|
|
98
|
+
fullProposal(partial: ProposalRecord): {
|
|
99
|
+
give: {
|
|
100
|
+
Collateral: Amount<"nat">;
|
|
101
|
+
Minted: Amount<"nat">;
|
|
102
|
+
};
|
|
103
|
+
want: {
|
|
104
|
+
Collateral: Amount<"nat">;
|
|
105
|
+
Minted: Amount<"nat">;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/** @param {VaultPhase} newPhase */
|
|
109
|
+
assignPhase(newPhase: VaultPhase): void;
|
|
110
|
+
assertActive(): void;
|
|
111
|
+
assertCloseable(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Called whenever the debt is paid or created through a transaction,
|
|
114
|
+
* but not for interest accrual.
|
|
115
|
+
*
|
|
116
|
+
* @param {Amount<'nat'>} newDebt - principal and all accrued interest
|
|
117
|
+
*/
|
|
118
|
+
updateDebtSnapshot(newDebt: Amount<"nat">): void;
|
|
119
|
+
/**
|
|
120
|
+
* Update the debt balance and propagate upwards to maintain aggregate
|
|
121
|
+
* debt and liquidation order.
|
|
122
|
+
*
|
|
123
|
+
* @param {NormalizedDebt} oldDebtNormalized - prior principal and all
|
|
124
|
+
* accrued interest, normalized to the launch of the vaultManager
|
|
125
|
+
* @param {Amount<'nat'>} oldCollateral - actual collateral
|
|
126
|
+
* @param {Amount<'nat'>} newDebtActual - actual principal and all
|
|
127
|
+
* accrued interest
|
|
128
|
+
*/
|
|
129
|
+
updateDebtAccounting(oldDebtNormalized: NormalizedDebt, oldCollateral: Amount<"nat">, newDebtActual: Amount<"nat">): void;
|
|
130
|
+
/**
|
|
131
|
+
* @param {ZCFSeat} seat
|
|
132
|
+
* @returns {Amount<'nat'>}
|
|
133
|
+
*/
|
|
134
|
+
getCollateralAllocated(seat: ZCFSeat): Amount<"nat">;
|
|
135
|
+
/**
|
|
136
|
+
* @param {ZCFSeat} seat
|
|
137
|
+
* @returns {Amount<'nat'>}
|
|
138
|
+
*/
|
|
139
|
+
getMintedAllocated(seat: ZCFSeat): Amount<"nat">;
|
|
140
|
+
assertVaultHoldsNoMinted(): void;
|
|
141
|
+
/**
|
|
142
|
+
* @param {Amount<'nat'>} collateralAmount
|
|
143
|
+
* @param {Amount<'nat'>} proposedDebt
|
|
144
|
+
*/
|
|
145
|
+
assertSufficientCollateral(collateralAmount: Amount<"nat">, proposedDebt: Amount<"nat">): void;
|
|
146
|
+
/** @param {Phase} newPhase */
|
|
147
|
+
getStateSnapshot(newPhase: Phase): {
|
|
148
|
+
debtSnapshot: {
|
|
149
|
+
debt: import("@agoric/ertp").NatAmount;
|
|
150
|
+
interest: Ratio;
|
|
151
|
+
};
|
|
152
|
+
locked: import("@agoric/ertp").NatAmount;
|
|
153
|
+
vaultState: Phase;
|
|
154
|
+
};
|
|
155
|
+
/** call this whenever anything changes! */
|
|
156
|
+
updateUiState(): void;
|
|
157
|
+
/** @param {ZCFSeat} seat */
|
|
158
|
+
closeHook(seat: ZCFSeat): Promise<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Calculate the fee, the amount to mint and the resulting debt. The
|
|
161
|
+
* give and the want together reflect a delta, where typically one is
|
|
162
|
+
* zero because they come from the gave/want of an offer proposal. If
|
|
163
|
+
* the `want` is zero, the `fee` will also be zero, so the simple math
|
|
164
|
+
* works.
|
|
165
|
+
*
|
|
166
|
+
* @param {Amount<'nat'>} currentDebt
|
|
167
|
+
* @param {Amount<'nat'>} giveAmount
|
|
168
|
+
* @param {Amount<'nat'>} wantAmount
|
|
169
|
+
*/
|
|
170
|
+
debtFee(currentDebt: Amount<"nat">, giveAmount: Amount<"nat">, wantAmount: Amount<"nat">): {
|
|
171
|
+
newDebt: import("@agoric/ertp").NatAmount;
|
|
172
|
+
toMint: import("@agoric/ertp").NatAmount;
|
|
173
|
+
fee: import("@agoric/ertp").NatAmount;
|
|
174
|
+
surplus: import("@agoric/ertp").NatAmount;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Adjust principal and collateral (atomically for offer safety)
|
|
178
|
+
*
|
|
179
|
+
* @param {ZCFSeat} clientSeat
|
|
180
|
+
* @returns {string} success message
|
|
181
|
+
*/
|
|
182
|
+
adjustBalancesHook(clientSeat: ZCFSeat): string;
|
|
183
|
+
/**
|
|
184
|
+
* @param {ZCFSeat} clientSeat
|
|
185
|
+
* @param {FullProposal} fp
|
|
186
|
+
* @param {ReturnType<typeof calculateDebtCosts>} costs
|
|
187
|
+
* @param {object} accounting
|
|
188
|
+
* @param {NormalizedDebt} accounting.normalizedDebtPre
|
|
189
|
+
* @param {Amount<'nat'>} accounting.collateralPre
|
|
190
|
+
* @returns {string} success message
|
|
191
|
+
*/
|
|
192
|
+
commitBalanceAdjustment(clientSeat: ZCFSeat, fp: {
|
|
193
|
+
give: {
|
|
194
|
+
Collateral: Amount<"nat">;
|
|
195
|
+
Minted: Amount<"nat">;
|
|
196
|
+
};
|
|
197
|
+
want: {
|
|
198
|
+
Collateral: Amount<"nat">;
|
|
199
|
+
Minted: Amount<"nat">;
|
|
200
|
+
};
|
|
201
|
+
}, { newDebt, fee, surplus, toMint }: ReturnType<typeof calculateDebtCosts>, { normalizedDebtPre, collateralPre }: {
|
|
202
|
+
normalizedDebtPre: NormalizedDebt;
|
|
203
|
+
collateralPre: Amount<"nat">;
|
|
204
|
+
}): string;
|
|
205
|
+
/**
|
|
206
|
+
* @param {ZCFSeat} seat
|
|
207
|
+
* @returns {VaultKit}
|
|
208
|
+
*/
|
|
209
|
+
makeTransferInvitationHook(seat: ZCFSeat): VaultKit;
|
|
210
|
+
};
|
|
211
|
+
self: {
|
|
212
|
+
getVaultSeat(): ZCFSeat;
|
|
213
|
+
/**
|
|
214
|
+
* @param {ZCFSeat} seat
|
|
215
|
+
* @param {StorageNode} storageNode
|
|
216
|
+
*/
|
|
217
|
+
initVaultKit(seat: ZCFSeat, storageNode: StorageNode): Promise<{
|
|
218
|
+
publicSubscribers: {
|
|
219
|
+
vault: {
|
|
220
|
+
description: string;
|
|
221
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
222
|
+
storagePath: Promise<string>;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
226
|
+
AdjustBalances(): Promise<Invitation<string, undefined>>;
|
|
227
|
+
CloseVault(): Promise<Invitation<string, undefined>>;
|
|
228
|
+
TransferVault(): Promise<Invitation<any, undefined>>;
|
|
229
|
+
}>;
|
|
230
|
+
vault: import("@endo/exo").Guarded<{
|
|
231
|
+
getPublicTopics(): {
|
|
232
|
+
vault: {
|
|
233
|
+
description: string;
|
|
234
|
+
subscriber: globalThis.Subscriber<VaultNotification>;
|
|
235
|
+
storagePath: Promise<string>;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
239
|
+
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
240
|
+
makeTransferInvitation(): Promise<Invitation<any, undefined>>;
|
|
241
|
+
getCollateralAmount(): import("@agoric/ertp").NatAmount;
|
|
242
|
+
getCurrentDebt(): import("@agoric/ertp").NatAmount;
|
|
243
|
+
getNormalizedDebt(): NormalizedDebt;
|
|
244
|
+
}>;
|
|
245
|
+
vaultUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification>;
|
|
246
|
+
}>;
|
|
247
|
+
/** Called by manager at start of liquidation. */
|
|
248
|
+
liquidating(): void;
|
|
249
|
+
/**
|
|
250
|
+
* Called by manager at end of liquidation, at which point all debts
|
|
251
|
+
* have been covered.
|
|
252
|
+
*/
|
|
253
|
+
liquidated(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Called by vaultManager when the auction wasn't able to sell the
|
|
256
|
+
* collateral. The liquidation fee was charged against the collateral,
|
|
257
|
+
* but the debt will be restored and the vault will be active again.
|
|
258
|
+
* Liquidation.md has details on the liquidation approach.
|
|
259
|
+
*/
|
|
260
|
+
abortLiquidation(): string;
|
|
261
|
+
makeAdjustBalancesInvitation(): Promise<Invitation<string, undefined>>;
|
|
262
|
+
makeCloseInvitation(): Promise<Invitation<string, undefined>>;
|
|
263
|
+
/** @returns {Promise<Invitation<VaultKit>>} */
|
|
264
|
+
makeTransferInvitation(): Promise<Invitation<VaultKit>>;
|
|
265
|
+
/** @returns {Amount<'nat'>} */
|
|
266
|
+
getCollateralAmount(): Amount<"nat">;
|
|
267
|
+
/**
|
|
268
|
+
* The actual current debt, including accrued interest.
|
|
269
|
+
*
|
|
270
|
+
* This looks like a simple getter but it does a lot of the heavy
|
|
271
|
+
* lifting for interest accrual. Rather than updating all records when
|
|
272
|
+
* interest accrues, the vault manager updates just its rolling
|
|
273
|
+
* compounded interest. Here we calculate what the current debt is given
|
|
274
|
+
* what's recorded in this vault and what interest has compounded since
|
|
275
|
+
* this vault record was written.
|
|
276
|
+
*
|
|
277
|
+
* @returns {Amount<'nat'>}
|
|
278
|
+
* @see getNormalizedDebt
|
|
279
|
+
*/
|
|
280
|
+
getCurrentDebt(): Amount<"nat">;
|
|
281
|
+
/**
|
|
282
|
+
* The normalization puts all debts on a common time-independent scale
|
|
283
|
+
* since the launch of this vault manager. This allows the manager to
|
|
284
|
+
* order vaults by their debt-to-collateral ratios without having to
|
|
285
|
+
* mutate the debts as the interest accrues.
|
|
286
|
+
*
|
|
287
|
+
* @returns {import('./storeUtils.js').NormalizedDebt} as if the vault
|
|
288
|
+
* was open at the launch of this manager, before any interest
|
|
289
|
+
* accrued
|
|
290
|
+
* @see getActualDebAmount
|
|
291
|
+
*/
|
|
292
|
+
getNormalizedDebt(): import("./storeUtils.js").NormalizedDebt;
|
|
293
|
+
};
|
|
294
|
+
}>;
|
|
295
|
+
export type VaultPhase = Exclude<Phase, "transfer">;
|
|
296
|
+
export type VaultNotification = {
|
|
297
|
+
/**
|
|
298
|
+
* Amount of Collateral locked
|
|
299
|
+
*/
|
|
300
|
+
locked: Amount<"nat">;
|
|
301
|
+
/**
|
|
302
|
+
* 'debt' at
|
|
303
|
+
* the point the compounded interest was 'interest'
|
|
304
|
+
*/
|
|
305
|
+
debtSnapshot: {
|
|
306
|
+
debt: Amount<"nat">;
|
|
307
|
+
interest: Ratio;
|
|
308
|
+
};
|
|
309
|
+
vaultState: Phase;
|
|
310
|
+
};
|
|
311
|
+
export type VaultManager = {
|
|
312
|
+
getAssetSubscriber: () => Subscriber<import("./vaultManager.js").AssetState>;
|
|
313
|
+
maxDebtFor: (collateralAmount: Amount) => Amount<"nat">;
|
|
314
|
+
getCollateralBrand: () => Brand<"nat">;
|
|
315
|
+
scopeDescription: (base: string) => string;
|
|
316
|
+
getDebtBrand: () => Brand<"nat">;
|
|
317
|
+
mintAndTransfer: MintAndTransfer;
|
|
318
|
+
burn: (amount: Amount, seat: ZCFSeat) => void;
|
|
319
|
+
getCompoundedInterest: () => Ratio;
|
|
320
|
+
handleBalanceChange: (oldDebt: import("./storeUtils.js").NormalizedDebt, oldCollateral: Amount<"nat">, vaultId: VaultId, vaultPhase: VaultPhase, vault: Vault) => void;
|
|
321
|
+
getGovernedParams: () => import("./vaultManager.js").GovernedParamGetters;
|
|
322
|
+
};
|
|
323
|
+
export type ImmutableState = Readonly<{
|
|
324
|
+
idInManager: VaultId;
|
|
325
|
+
manager: VaultManager;
|
|
326
|
+
storageNode: StorageNode;
|
|
327
|
+
vaultSeat: ZCFSeat;
|
|
328
|
+
}>;
|
|
329
|
+
/**
|
|
330
|
+
* Snapshot is of the debt and compounded interest when the principal was last
|
|
331
|
+
* changed.
|
|
332
|
+
*/
|
|
333
|
+
export type MutableState = {
|
|
334
|
+
interestSnapshot: Ratio;
|
|
335
|
+
phase: VaultPhase;
|
|
336
|
+
debtSnapshot: Amount<"nat">;
|
|
337
|
+
outerUpdater: import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<VaultNotification> | null;
|
|
338
|
+
};
|
|
339
|
+
export type Vault = ReturnType<ReturnType<typeof prepareVault>>["self"];
|
|
340
|
+
import type { Brand } from '@agoric/ertp/src/types.js';
|
|
341
|
+
import type { NormalizedDebt } from './storeUtils.js';
|
|
342
|
+
import { calculateDebtCosts } from './math.js';
|
|
343
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["vault.js"],"names":[],"mappings":"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"}
|