@agoric/inter-protocol 0.13.3 → 0.13.4-dev-d32a66a.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 +26 -20
- package/bundles/bundle-auctioneer-js-meta.json +722 -0
- package/bundles/bundle-auctioneer.js +1 -0
- package/bundles/bundle-econCommitteeCharter-js-meta.json +514 -0
- package/bundles/bundle-econCommitteeCharter.js +1 -0
- package/bundles/bundle-feeDistributor-js-meta.json +458 -0
- package/bundles/bundle-feeDistributor.js +1 -1
- package/bundles/bundle-fluxAggregatorKit-js-meta.json +674 -0
- package/bundles/bundle-fluxAggregatorKit.js +1 -0
- package/bundles/bundle-psm-js-meta.json +666 -0
- package/bundles/bundle-psm.js +1 -1
- package/bundles/bundle-reserve-js-meta.json +662 -0
- package/bundles/bundle-reserve.js +1 -1
- package/bundles/bundle-scaledPriceAuthority-js-meta.json +542 -0
- package/bundles/bundle-scaledPriceAuthority.js +1 -1
- package/bundles/bundle-vaultFactory-js-meta.json +786 -0
- package/bundles/bundle-vaultFactory.js +1 -1
- package/exported.js +0 -2
- package/package.json +34 -31
- package/scripts/add-collateral-core.js +14 -4
- package/scripts/build-bundles.js +9 -2
- package/scripts/deploy-contracts.js +1 -4
- package/scripts/init-core.js +20 -38
- package/scripts/invite-committee-core.js +1 -1
- package/scripts/manual-price-feed.js +2 -2
- package/scripts/price-feed-core.js +7 -6
- package/scripts/start-local-chain.sh +84 -0
- package/src/auction/auctionBook.js +755 -0
- package/src/auction/auctioneer.js +720 -0
- package/src/auction/offerBook.js +221 -0
- package/src/auction/params.js +174 -0
- package/src/auction/scheduleMath.js +167 -0
- package/src/auction/scheduler.js +370 -0
- package/src/auction/sortedOffers.js +136 -0
- package/src/auction/util.js +55 -0
- package/src/clientSupport.js +324 -0
- package/src/collectFees.js +8 -14
- package/src/contractSupport.js +24 -68
- package/src/econCommitteeCharter.js +161 -77
- package/src/feeDistributor.js +60 -20
- package/src/index.js +2 -0
- package/src/interest-math.js +1 -4
- package/src/interest.js +20 -13
- package/src/price/README.md +57 -0
- package/src/price/fluxAggregatorContract.js +190 -0
- package/src/price/fluxAggregatorKit.js +375 -0
- package/src/price/priceOracleKit.js +127 -0
- package/src/price/roundsManager.js +726 -0
- package/src/proposals/addAssetToVault.js +89 -94
- package/src/proposals/committee-proposal.js +141 -40
- package/src/proposals/core-proposal.js +100 -167
- package/src/proposals/econ-behaviors.js +320 -564
- package/src/proposals/price-feed-proposal.js +175 -78
- package/src/proposals/startEconCommittee.js +25 -12
- package/src/proposals/startPSM.js +231 -211
- package/src/proposals/utils.js +31 -17
- package/src/psm/README.md +71 -0
- package/src/psm/psm.js +272 -160
- package/src/psm/types.js +2 -0
- package/src/reserve/assetReserve.js +56 -413
- package/src/reserve/assetReserveKit.js +303 -0
- package/src/reserve/doc.md +1 -3
- package/src/reserve/params.js +2 -5
- package/src/typeGuards.js +13 -0
- package/src/vaultFactory/Liquidation.md +100 -0
- package/src/vaultFactory/burn.js +2 -1
- package/src/vaultFactory/liquidation.js +270 -108
- package/src/vaultFactory/math.js +95 -0
- package/src/vaultFactory/orderedVaultStore.js +0 -1
- package/src/vaultFactory/params.js +133 -112
- package/src/vaultFactory/prioritizedVaults.js +36 -79
- package/src/vaultFactory/storeUtils.js +67 -9
- package/src/vaultFactory/type-imports.js +2 -0
- package/src/vaultFactory/types.js +22 -26
- package/src/vaultFactory/vault.js +772 -709
- package/src/vaultFactory/vaultDirector.js +480 -483
- package/src/vaultFactory/vaultFactory.js +99 -60
- package/src/vaultFactory/vaultHolder.js +121 -95
- package/src/vaultFactory/vaultKit.js +39 -31
- package/src/vaultFactory/vaultManager.js +1249 -868
- package/bundles/bundle-amm-meta.js +0 -618
- package/bundles/bundle-amm.js +0 -1
- package/bundles/bundle-feeDistributor-meta.js +0 -346
- package/bundles/bundle-interchainPool-meta.js +0 -534
- package/bundles/bundle-interchainPool.js +0 -1
- package/bundles/bundle-liquidateIncrementally-meta.js +0 -442
- package/bundles/bundle-liquidateIncrementally.js +0 -1
- package/bundles/bundle-liquidateMinimum-meta.js +0 -442
- package/bundles/bundle-liquidateMinimum.js +0 -1
- package/bundles/bundle-psm-meta.js +0 -538
- package/bundles/bundle-psmCharter-meta.js +0 -418
- package/bundles/bundle-psmCharter.js +0 -1
- package/bundles/bundle-reserve-meta.js +0 -542
- package/bundles/bundle-scaledPriceAuthority-meta.js +0 -442
- package/bundles/bundle-stakeFactory-meta.js +0 -574
- package/bundles/bundle-stakeFactory.js +0 -1
- package/bundles/bundle-vaultFactory-meta.js +0 -598
- package/scripts/add-initial-liquidity.js +0 -180
- package/src/collect.js +0 -13
- package/src/interchainPool.js +0 -135
- package/src/makeTracer.js +0 -36
- package/src/my-lien.js +0 -85
- package/src/proposals/demoIssuers.js +0 -685
- package/src/proposals/sim-behaviors.js +0 -40
- package/src/psm/psmCharter.js +0 -139
- package/src/stakeFactory/README.md +0 -62
- package/src/stakeFactory/attestation.js +0 -267
- package/src/stakeFactory/attestationTool.js +0 -66
- package/src/stakeFactory/constants.js +0 -16
- package/src/stakeFactory/params.js +0 -31
- package/src/stakeFactory/stakeFactory.js +0 -236
- package/src/stakeFactory/stakeFactoryKit.js +0 -455
- package/src/stakeFactory/stakeFactoryManager.js +0 -296
- package/src/stakeFactory/types.js +0 -42
- package/src/vaultFactory/liquidateIncrementally.js +0 -350
- package/src/vaultFactory/liquidateMinimum.js +0 -100
- package/src/vpool-xyk-amm/AttackersGuide.md +0 -89
- package/src/vpool-xyk-amm/addLiquidity.js +0 -222
- package/src/vpool-xyk-amm/addPool.js +0 -197
- package/src/vpool-xyk-amm/constantProduct/AMM-Trade.jpeg +0 -0
- package/src/vpool-xyk-amm/constantProduct/README.md +0 -204
- package/src/vpool-xyk-amm/constantProduct/calcFees.js +0 -99
- package/src/vpool-xyk-amm/constantProduct/calcSwapPrices.js +0 -85
- package/src/vpool-xyk-amm/constantProduct/core.js +0 -153
- package/src/vpool-xyk-amm/constantProduct/defaults.js +0 -5
- package/src/vpool-xyk-amm/constantProduct/getXY.js +0 -52
- package/src/vpool-xyk-amm/constantProduct/internal-types.js +0 -116
- package/src/vpool-xyk-amm/constantProduct/invariants.js +0 -43
- package/src/vpool-xyk-amm/constantProduct/swap.js +0 -272
- package/src/vpool-xyk-amm/constantProduct/types.js +0 -32
- package/src/vpool-xyk-amm/doublePool.js +0 -194
- package/src/vpool-xyk-amm/estimate.js +0 -155
- package/src/vpool-xyk-amm/multipoolMarketMaker.js +0 -520
- package/src/vpool-xyk-amm/params.js +0 -61
- package/src/vpool-xyk-amm/pool.js +0 -396
- package/src/vpool-xyk-amm/priceAuthority.js +0 -94
- package/src/vpool-xyk-amm/removeLiquidity.js +0 -31
- package/src/vpool-xyk-amm/singlePool.js +0 -73
- package/src/vpool-xyk-amm/swap.js +0 -69
- package/src/vpool-xyk-amm/types.js +0 -154
package/src/proposals/utils.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
+
import { WalletName } from '@agoric/internal';
|
|
1
2
|
import { getCopyMapEntries, makeCopyMap } from '@agoric/store';
|
|
2
3
|
import { E } from '@endo/far';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
export const DEPOSIT_FACET = 'depositFacet';
|
|
6
|
-
|
|
7
|
-
const { details: X } = assert;
|
|
5
|
+
const { Fail } = assert;
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
|
-
* @param {ERef<NameAdmin>} nameAdmin
|
|
8
|
+
* @param {ERef<import('@agoric/vats').NameAdmin>} nameAdmin
|
|
11
9
|
* @param {string[][]} paths
|
|
12
10
|
*/
|
|
13
11
|
export const reserveThenGetNamePaths = async (nameAdmin, paths) => {
|
|
14
12
|
/**
|
|
15
13
|
*
|
|
16
|
-
* @param {ERef<NameAdmin>} nextAdmin
|
|
14
|
+
* @param {ERef<import('@agoric/vats').NameAdmin>} nextAdmin
|
|
17
15
|
* @param {string[]} path
|
|
18
16
|
*/
|
|
19
17
|
const nextPath = async (nextAdmin, path) => {
|
|
@@ -36,14 +34,14 @@ export const reserveThenGetNamePaths = async (nameAdmin, paths) => {
|
|
|
36
34
|
|
|
37
35
|
return Promise.all(
|
|
38
36
|
paths.map(async path => {
|
|
39
|
-
|
|
37
|
+
Array.isArray(path) || Fail`path ${path} is not an array`;
|
|
40
38
|
return nextPath(nameAdmin, path);
|
|
41
39
|
}),
|
|
42
40
|
);
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
|
-
* @param {ERef<NameAdmin>} nameAdmin
|
|
44
|
+
* @param {ERef<import('@agoric/vats').NameAdmin>} nameAdmin
|
|
47
45
|
* @param {string[]} names
|
|
48
46
|
*/
|
|
49
47
|
export const reserveThenGetNames = async (nameAdmin, names) =>
|
|
@@ -52,22 +50,36 @@ export const reserveThenGetNames = async (nameAdmin, names) =>
|
|
|
52
50
|
names.map(name => [name]),
|
|
53
51
|
);
|
|
54
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @param {string} debugName
|
|
55
|
+
* @param {ERef<import('@agoric/vats').NameAdmin>} namesByAddressAdmin
|
|
56
|
+
* @param {string} addr
|
|
57
|
+
* @param {Array<ERef<Payment>>} payments
|
|
58
|
+
*/
|
|
55
59
|
export const reserveThenDeposit = async (
|
|
56
60
|
debugName,
|
|
57
61
|
namesByAddressAdmin,
|
|
58
62
|
addr,
|
|
59
63
|
payments,
|
|
60
64
|
) => {
|
|
61
|
-
console.info('
|
|
65
|
+
console.info('awaiting depositFacet for', debugName);
|
|
62
66
|
const [depositFacet] = await reserveThenGetNamePaths(namesByAddressAdmin, [
|
|
63
|
-
[addr,
|
|
67
|
+
[addr, WalletName.depositFacet],
|
|
64
68
|
]);
|
|
65
69
|
console.info('depositing to', debugName);
|
|
66
|
-
await Promise.
|
|
67
|
-
|
|
70
|
+
await Promise.allSettled(
|
|
71
|
+
payments.map(async (paymentP, i) => {
|
|
72
|
+
const payment = await paymentP;
|
|
73
|
+
await E(depositFacet).receive(payment);
|
|
74
|
+
console.info(
|
|
75
|
+
`confirmed deposit ${i + 1}/${payments.length} for`,
|
|
76
|
+
debugName,
|
|
77
|
+
);
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
68
80
|
};
|
|
69
81
|
|
|
70
|
-
/** @type {<T>(store: ERef<
|
|
82
|
+
/** @type {<T>(store: ERef<Map<string, T> | import('@agoric/internal/src/scratch.js').ScratchPad>, key: string, make: () => T) => Promise<T>} */
|
|
71
83
|
const provideWhen = async (store, key, make) => {
|
|
72
84
|
const found = await E(store).get(key);
|
|
73
85
|
if (found) {
|
|
@@ -79,8 +91,7 @@ const provideWhen = async (store, key, make) => {
|
|
|
79
91
|
};
|
|
80
92
|
|
|
81
93
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @param {{ scratch: ERef<MapStore<string, unknown>> }} homeP
|
|
94
|
+
* @param {{ scratch: ERef<import('@agoric/internal/src/scratch.js').ScratchPad> }} homeP
|
|
84
95
|
* @param {object} opts
|
|
85
96
|
* @param {(specifier: string) => Promise<{default: Bundle}>} opts.loadBundle
|
|
86
97
|
* @param {string} [opts.installCacheKey]
|
|
@@ -108,9 +119,12 @@ export const makeInstallCache = async (
|
|
|
108
119
|
};
|
|
109
120
|
|
|
110
121
|
const wrapInstall = install => async (mPath, bPath, opts) => {
|
|
111
|
-
const
|
|
112
|
-
|
|
122
|
+
const bundle = await loadBundle(bPath).then(m => m.default);
|
|
123
|
+
assert(
|
|
124
|
+
'endoZipBase64Sha512' in bundle,
|
|
125
|
+
'bundle must be EndoZipBase64Bundle',
|
|
113
126
|
);
|
|
127
|
+
const { endoZipBase64Sha512: sha512 } = bundle;
|
|
114
128
|
const detail = await provideWhen(working, sha512, () =>
|
|
115
129
|
install(mPath, bPath, opts).then(installation => ({
|
|
116
130
|
installation,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Parity Stability Module
|
|
2
|
+
|
|
3
|
+
The Parity Stability Module supports efficiently minting/burning a stable token
|
|
4
|
+
at a specified fixed ratio to a reference stable token, which thereby acts as an
|
|
5
|
+
anchor to provide additional stability. For flexible economic policies, the fee
|
|
6
|
+
percentage for trading into and out of the stable token are specified
|
|
7
|
+
separately.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
See the [Smart Wallet integration test](/packages/inter-protocol/test/smartWallet/test-psm-integration.js) for how it's used.
|
|
13
|
+
|
|
14
|
+
End users can make swap offers in the CLI or GUI.
|
|
15
|
+
|
|
16
|
+
### CLI
|
|
17
|
+
|
|
18
|
+
See [psm.js command file](/packages/agoric-cli/src/commands/psm.js) and its [integration test script](/packages/agoric-cli/scripts/).
|
|
19
|
+
|
|
20
|
+
```mermaid
|
|
21
|
+
sequenceDiagram
|
|
22
|
+
|
|
23
|
+
actor user
|
|
24
|
+
|
|
25
|
+
participant cli as Dapp PSM
|
|
26
|
+
participant disk
|
|
27
|
+
participant B as Cosmos / Swingset <br/> bridge
|
|
28
|
+
participant C as smart-wallet<br/>contract
|
|
29
|
+
participant PSM as PSM<br/>contract
|
|
30
|
+
|
|
31
|
+
user ->> cli: create a swap offer
|
|
32
|
+
user -->> disk: write offer data
|
|
33
|
+
user ->> cli: sign and send swap offer
|
|
34
|
+
disk -->> cli: read offer data
|
|
35
|
+
cli ->> B: spending transaction
|
|
36
|
+
B ->> C: unpack ocap data
|
|
37
|
+
C ->> PSM: route offer
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### GUI
|
|
42
|
+
|
|
43
|
+
The GUI is in https://github.com/Agoric/dapp-psm
|
|
44
|
+
|
|
45
|
+
It introduces another layer of communication (between the dapp and Wallet UI):
|
|
46
|
+
|
|
47
|
+
```mermaid
|
|
48
|
+
sequenceDiagram
|
|
49
|
+
|
|
50
|
+
actor user
|
|
51
|
+
|
|
52
|
+
participant dapp as Dapp PSM
|
|
53
|
+
participant ls as localStorage
|
|
54
|
+
participant ui as Wallet UI
|
|
55
|
+
participant Keplr
|
|
56
|
+
participant B as Cosmos / Swingset <br/> bridge
|
|
57
|
+
participant C as smart-wallet<br/>contract
|
|
58
|
+
participant PSM as PSM<br/>contract
|
|
59
|
+
|
|
60
|
+
user ->> dapp: configure offer and click
|
|
61
|
+
dapp ->> ls: write offer record
|
|
62
|
+
ls ->> ui: notify offer record
|
|
63
|
+
ui ->> user: display offer for signing
|
|
64
|
+
user ->> ui: click Approve
|
|
65
|
+
ui ->> Keplr: request signing
|
|
66
|
+
Keplr ->> user: pop-up transaction
|
|
67
|
+
user ->> Keplr: click to sign
|
|
68
|
+
Keplr ->> B: spending transaction
|
|
69
|
+
B ->> C: unpack ocap data
|
|
70
|
+
C ->> PSM: route offer
|
|
71
|
+
```
|