@agoric/inter-protocol 0.16.2-dev-7cc5def.0 → 0.16.2-u11.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.
Files changed (176) hide show
  1. package/CHANGELOG.md +1041 -0
  2. package/bundles/bundle-auctioneer-js-meta.json +722 -0
  3. package/bundles/bundle-auctioneer.js +1 -0
  4. package/bundles/bundle-econCommitteeCharter-js-meta.json +222 -242
  5. package/bundles/bundle-econCommitteeCharter.js +1 -1
  6. package/bundles/bundle-feeDistributor-js-meta.json +458 -0
  7. package/bundles/bundle-feeDistributor.js +1 -0
  8. package/bundles/bundle-fluxAggregatorKit-js-meta.json +327 -343
  9. package/bundles/bundle-fluxAggregatorKit.js +1 -1
  10. package/bundles/bundle-psm-js-meta.json +308 -328
  11. package/bundles/bundle-psm.js +1 -1
  12. package/bundles/bundle-reserve-js-meta.json +662 -0
  13. package/bundles/bundle-reserve.js +1 -0
  14. package/bundles/bundle-scaledPriceAuthority-js-meta.json +542 -0
  15. package/bundles/bundle-scaledPriceAuthority.js +1 -0
  16. package/bundles/bundle-vaultFactory-js-meta.json +790 -0
  17. package/bundles/bundle-vaultFactory.js +1 -0
  18. package/package.json +31 -31
  19. package/scripts/add-collateral-core.js +112 -0
  20. package/scripts/build-bundles.js +21 -5
  21. package/scripts/deploy-contracts.js +100 -0
  22. package/scripts/init-core.js +198 -0
  23. package/scripts/invite-committee-core.js +42 -0
  24. package/scripts/manual-price-feed.js +117 -0
  25. package/scripts/price-feed-core.js +104 -0
  26. package/scripts/start-local-chain.sh +84 -0
  27. package/src/auction/auctionBook.js +56 -68
  28. package/src/auction/auctioneer.js +44 -56
  29. package/src/auction/offerBook.js +11 -12
  30. package/src/auction/params.js +5 -3
  31. package/src/auction/scheduleMath.js +13 -13
  32. package/src/auction/scheduler.js +32 -22
  33. package/src/auction/sortedOffers.js +7 -8
  34. package/src/auction/util.js +4 -4
  35. package/src/clientSupport.js +96 -152
  36. package/src/contractSupport.js +5 -5
  37. package/src/econCommitteeCharter.js +15 -16
  38. package/src/feeDistributor.js +33 -34
  39. package/src/interest.js +14 -20
  40. package/src/price/fluxAggregatorContract.js +45 -51
  41. package/src/price/fluxAggregatorKit.js +32 -47
  42. package/src/price/priceOracleKit.js +13 -11
  43. package/src/price/roundsManager.js +64 -52
  44. package/src/proposals/addAssetToVault.js +3 -15
  45. package/src/proposals/committee-proposal.js +9 -5
  46. package/src/proposals/core-proposal.js +7 -7
  47. package/src/proposals/econ-behaviors.js +32 -57
  48. package/src/proposals/price-feed-proposal.js +26 -59
  49. package/src/proposals/startEconCommittee.js +1 -1
  50. package/src/proposals/startPSM.js +22 -32
  51. package/src/proposals/utils.js +7 -26
  52. package/src/psm/psm.js +63 -69
  53. package/src/reserve/assetReserve.js +18 -27
  54. package/src/reserve/assetReserveKit.js +22 -14
  55. package/src/typeGuards.js +13 -0
  56. package/src/vaultFactory/liquidation.js +17 -30
  57. package/src/vaultFactory/math.js +9 -8
  58. package/src/vaultFactory/orderedVaultStore.js +9 -6
  59. package/src/vaultFactory/params.js +18 -24
  60. package/src/vaultFactory/prioritizedVaults.js +2 -2
  61. package/src/vaultFactory/proceeds.js +18 -24
  62. package/src/vaultFactory/storeUtils.js +12 -8
  63. package/src/vaultFactory/types.js +28 -38
  64. package/src/vaultFactory/vault.js +89 -88
  65. package/src/vaultFactory/vaultDirector.js +41 -33
  66. package/src/vaultFactory/vaultFactory.js +26 -33
  67. package/src/vaultFactory/vaultHolder.js +13 -8
  68. package/src/vaultFactory/vaultKit.js +2 -3
  69. package/src/vaultFactory/vaultManager.js +120 -138
  70. package/src/auction/auctionBook.d.ts +0 -83
  71. package/src/auction/auctionBook.d.ts.map +0 -1
  72. package/src/auction/auctioneer.d.ts +0 -75
  73. package/src/auction/auctioneer.d.ts.map +0 -1
  74. package/src/auction/offerBook.d.ts +0 -72
  75. package/src/auction/offerBook.d.ts.map +0 -1
  76. package/src/auction/params.d.ts +0 -142
  77. package/src/auction/params.d.ts.map +0 -1
  78. package/src/auction/scheduleMath.d.ts +0 -4
  79. package/src/auction/scheduleMath.d.ts.map +0 -1
  80. package/src/auction/scheduler.d.ts +0 -49
  81. package/src/auction/scheduler.d.ts.map +0 -1
  82. package/src/auction/sortedOffers.d.ts +0 -8
  83. package/src/auction/sortedOffers.d.ts.map +0 -1
  84. package/src/auction/util.d.ts +0 -30
  85. package/src/auction/util.d.ts.map +0 -1
  86. package/src/clientSupport.d.ts +0 -167
  87. package/src/clientSupport.d.ts.map +0 -1
  88. package/src/collectFees.d.ts +0 -2
  89. package/src/collectFees.d.ts.map +0 -1
  90. package/src/contractSupport.d.ts +0 -33
  91. package/src/contractSupport.d.ts.map +0 -1
  92. package/src/econCommitteeCharter.d.ts +0 -41
  93. package/src/econCommitteeCharter.d.ts.map +0 -1
  94. package/src/feeDistributor.d.ts +0 -212
  95. package/src/feeDistributor.d.ts.map +0 -1
  96. package/src/index.d.ts +0 -2
  97. package/src/index.d.ts.map +0 -1
  98. package/src/interest-math.d.ts +0 -3
  99. package/src/interest-math.d.ts.map +0 -1
  100. package/src/interest.d.ts +0 -29
  101. package/src/interest.d.ts.map +0 -1
  102. package/src/price/fluxAggregatorContract.d.ts +0 -112
  103. package/src/price/fluxAggregatorContract.d.ts.map +0 -1
  104. package/src/price/fluxAggregatorKit.d.ts +0 -155
  105. package/src/price/fluxAggregatorKit.d.ts.map +0 -1
  106. package/src/price/priceOracleKit.d.ts +0 -52
  107. package/src/price/priceOracleKit.d.ts.map +0 -1
  108. package/src/price/roundsManager.d.ts +0 -330
  109. package/src/price/roundsManager.d.ts.map +0 -1
  110. package/src/proposals/addAssetToVault.d.ts +0 -155
  111. package/src/proposals/addAssetToVault.d.ts.map +0 -1
  112. package/src/proposals/committee-proposal.d.ts +0 -121
  113. package/src/proposals/committee-proposal.d.ts.map +0 -1
  114. package/src/proposals/core-proposal.d.ts +0 -149
  115. package/src/proposals/core-proposal.d.ts.map +0 -1
  116. package/src/proposals/econ-behaviors.d.ts +0 -201
  117. package/src/proposals/econ-behaviors.d.ts.map +0 -1
  118. package/src/proposals/price-feed-proposal.d.ts +0 -83
  119. package/src/proposals/price-feed-proposal.d.ts.map +0 -1
  120. package/src/proposals/startEconCommittee.d.ts +0 -34
  121. package/src/proposals/startEconCommittee.d.ts.map +0 -1
  122. package/src/proposals/startPSM.d.ts +0 -61
  123. package/src/proposals/startPSM.d.ts.map +0 -1
  124. package/src/proposals/utils.d.ts +0 -15
  125. package/src/proposals/utils.d.ts.map +0 -1
  126. package/src/provisionPool.d.ts +0 -165
  127. package/src/provisionPool.d.ts.map +0 -1
  128. package/src/provisionPool.js +0 -119
  129. package/src/provisionPoolKit.d.ts +0 -379
  130. package/src/provisionPoolKit.d.ts.map +0 -1
  131. package/src/provisionPoolKit.js +0 -461
  132. package/src/psm/psm.d.ts +0 -178
  133. package/src/psm/psm.d.ts.map +0 -1
  134. package/src/psm/types.d.ts +0 -2
  135. package/src/psm/types.d.ts.map +0 -1
  136. package/src/reserve/assetReserve.d.ts +0 -44
  137. package/src/reserve/assetReserve.d.ts.map +0 -1
  138. package/src/reserve/assetReserveKit.d.ts +0 -114
  139. package/src/reserve/assetReserveKit.d.ts.map +0 -1
  140. package/src/reserve/params.d.ts +0 -10
  141. package/src/reserve/params.d.ts.map +0 -1
  142. package/src/tokens.d.ts +0 -3
  143. package/src/tokens.d.ts.map +0 -1
  144. package/src/tokens.js +0 -5
  145. package/src/vaultFactory/burn.d.ts +0 -2
  146. package/src/vaultFactory/burn.d.ts.map +0 -1
  147. package/src/vaultFactory/liquidation.d.ts +0 -24
  148. package/src/vaultFactory/liquidation.d.ts.map +0 -1
  149. package/src/vaultFactory/math.d.ts +0 -10
  150. package/src/vaultFactory/math.d.ts.map +0 -1
  151. package/src/vaultFactory/orderedVaultStore.d.ts +0 -94
  152. package/src/vaultFactory/orderedVaultStore.d.ts.map +0 -1
  153. package/src/vaultFactory/params.d.ts +0 -159
  154. package/src/vaultFactory/params.d.ts.map +0 -1
  155. package/src/vaultFactory/prioritizedVaults.d.ts +0 -279
  156. package/src/vaultFactory/prioritizedVaults.d.ts.map +0 -1
  157. package/src/vaultFactory/proceeds.d.ts +0 -34
  158. package/src/vaultFactory/proceeds.d.ts.map +0 -1
  159. package/src/vaultFactory/storeUtils.d.ts +0 -25
  160. package/src/vaultFactory/storeUtils.d.ts.map +0 -1
  161. package/src/vaultFactory/type-imports.d.ts +0 -2
  162. package/src/vaultFactory/type-imports.d.ts.map +0 -1
  163. package/src/vaultFactory/types.d.ts +0 -137
  164. package/src/vaultFactory/types.d.ts.map +0 -1
  165. package/src/vaultFactory/vault.d.ts +0 -529
  166. package/src/vaultFactory/vault.d.ts.map +0 -1
  167. package/src/vaultFactory/vaultDirector.d.ts +0 -560
  168. package/src/vaultFactory/vaultDirector.d.ts.map +0 -1
  169. package/src/vaultFactory/vaultFactory.d.ts +0 -162
  170. package/src/vaultFactory/vaultFactory.d.ts.map +0 -1
  171. package/src/vaultFactory/vaultHolder.d.ts +0 -201
  172. package/src/vaultFactory/vaultHolder.d.ts.map +0 -1
  173. package/src/vaultFactory/vaultKit.d.ts +0 -32
  174. package/src/vaultFactory/vaultKit.d.ts.map +0 -1
  175. package/src/vaultFactory/vaultManager.d.ts +0 -554
  176. package/src/vaultFactory/vaultManager.d.ts.map +0 -1
@@ -0,0 +1,117 @@
1
+ import { E } from '@endo/far';
2
+ import { deeplyFulfilled } from '@endo/marshal';
3
+ import { makeNotifierFromAsyncIterable } from '@agoric/notifier';
4
+
5
+ import process from 'process';
6
+
7
+ /**
8
+ * After extracting the oracleAdmins to entries in home.scratch, you can use one
9
+ * from the REPL like:
10
+ *
11
+ * lookup('agoricNames', 'oracleBrand', 'ATOM').then(brand => atom = brand)
12
+ * -> [Object Alleged: ATOM brand]{}
13
+ * lookup('agoricNames', 'oracleBrand', 'USD').then(brand => usd = brand)
14
+ * -> [Object Alleged: USD brand]{}
15
+ * pa = home.priceAuthority
16
+ * -> [Object Alleged: PriceAuthority]{}
17
+ * qn = E(pa).makeQuoteNotifier({ value: 1n * 10n ** 6n, brand: atom }, usd)
18
+ * -> [Object Alleged: QuoteNotifier]{}
19
+ * oa = E(home.scratch).get("offerResult unknown#1652669688625")
20
+ * -> [Object Alleged: OracleAdmin]{}
21
+ * E(oa).pushResult('19.37')
22
+ * E(qn).getUpdateSince()
23
+ *
24
+ * @typedef {{ board: import('@agoric/vats').Board, chainTimerService, scratch, zoe }} Home
25
+ * @param {Promise<Home>} homePromise
26
+ * @param {object} root0
27
+ * @param {(...path: string[]) => Promise<any>} root0.lookup
28
+ * A promise for the references available from REPL home
29
+ */
30
+ export default async function priceAuthorityFromNotifier(
31
+ homePromise,
32
+ { lookup },
33
+ ) {
34
+ const { AGGREGATOR_INSTANCE_LOOKUP } = process.env;
35
+
36
+ // Let's wait for the promise to resolve.
37
+ const home = await deeplyFulfilled(homePromise);
38
+
39
+ let aggregatorInstance;
40
+ if (AGGREGATOR_INSTANCE_LOOKUP) {
41
+ aggregatorInstance = await lookup(JSON.parse(AGGREGATOR_INSTANCE_LOOKUP));
42
+ }
43
+
44
+ if (!aggregatorInstance) {
45
+ console.log('Autodetecting aggregator instance...');
46
+ const purse = E(home.wallet).getPurse('Default Zoe invite purse');
47
+ const { value } = await E(purse).getCurrentAmount();
48
+ const invitations = value.filter(
49
+ ({ description }) => description === 'oracle invitation',
50
+ );
51
+ if (invitations.length > 1) {
52
+ console.error('Multiple oracle invitations found', invitations);
53
+ throw Error('You need an AGGREGATOR_INSTANCE_LOOKUP to disambiguate');
54
+ }
55
+ if (invitations.length === 0) {
56
+ console.error(
57
+ 'No oracle invitations found; you may need an AGGREGATOR_INSTANCE_LOOKUP',
58
+ );
59
+ } else {
60
+ console.log('Found oracle invitation', invitations);
61
+ aggregatorInstance = invitations[0].instance;
62
+ }
63
+ }
64
+
65
+ if (!aggregatorInstance) {
66
+ return;
67
+ }
68
+
69
+ const offer = {
70
+ id: Date.now(),
71
+ proposalTemplate: {},
72
+ invitationQuery: {
73
+ description: 'oracle invitation',
74
+ instance: aggregatorInstance,
75
+ },
76
+ };
77
+
78
+ console.log('Getting wallet bridge...');
79
+ const bridge = await E(home.wallet).getBridge();
80
+
81
+ // Consume an aggregator invitation for this instance.
82
+ await E(bridge)
83
+ .addOffer(offer)
84
+ .then(
85
+ () =>
86
+ console.log(
87
+ `Please approve your wallet's proposal to connect the aggregator ${aggregatorInstance}...`,
88
+ ),
89
+ () => {},
90
+ );
91
+
92
+ const walletAdmin = E(home.wallet).getAdminFacet();
93
+
94
+ console.log('=====================================================');
95
+ console.log('=== Extracting oracleAdmins from price feed offers...');
96
+ console.log('=== Control-C to cancel');
97
+ const offerIt = E(walletAdmin).getOffersNotifier();
98
+ for await (const offers of makeNotifierFromAsyncIterable(offerIt)) {
99
+ // console.log(offers);
100
+ offers
101
+ .filter(
102
+ ({ status, invitationQuery: { instance } }) =>
103
+ status === 'complete' && instance === aggregatorInstance,
104
+ )
105
+ .forEach(async ({ id }) => {
106
+ const orKey = `offerResult ${id}`;
107
+ await E(home.scratch).set(
108
+ orKey,
109
+ E(home.wallet).lookup('offerResult', id),
110
+ );
111
+ console.log(
112
+ 'Use this oracleAdmin:',
113
+ `E(home.scratch).get(${JSON.stringify(orKey)})`,
114
+ );
115
+ });
116
+ }
117
+ }
@@ -0,0 +1,104 @@
1
+ /* global process */
2
+ import { makeHelpers } from '@agoric/deploy-script-support';
3
+
4
+ const DEFAULT_CONTRACT_TERMS = {
5
+ POLL_INTERVAL: 30n,
6
+ maxSubmissionCount: 1000,
7
+ minSubmissionCount: 2,
8
+ restartDelay: 1, // the number of rounds an Oracle has to wait before they can initiate another round
9
+ timeout: 10, // in seconds according to chainTimerService
10
+ minSubmissionValue: 1n,
11
+ maxSubmissionValue: 2n ** 256n,
12
+ };
13
+
14
+ /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
15
+ export const defaultProposalBuilder = async (
16
+ { publishRef, install },
17
+ options = {},
18
+ ) => {
19
+ const {
20
+ brandIn,
21
+ brandOut,
22
+ contractTerms = DEFAULT_CONTRACT_TERMS,
23
+ AGORIC_INSTANCE_NAME,
24
+ IN_BRAND_LOOKUP,
25
+ OUT_BRAND_LOOKUP,
26
+ IN_BRAND_NAME = IN_BRAND_LOOKUP[IN_BRAND_LOOKUP.length - 1],
27
+ OUT_BRAND_NAME = OUT_BRAND_LOOKUP[OUT_BRAND_LOOKUP.length - 1],
28
+ oracleAddresses,
29
+ ...optionsRest
30
+ } = options;
31
+
32
+ assert(AGORIC_INSTANCE_NAME, 'AGORIC_INSTANCE_NAME is required');
33
+ assert(Array.isArray(oracleAddresses), 'oracleAddresses array is required');
34
+
35
+ if (!brandIn) {
36
+ assert.equal(IN_BRAND_LOOKUP[0], 'agoricNames');
37
+ assert(IN_BRAND_NAME);
38
+ }
39
+ if (!brandOut) {
40
+ assert.equal(OUT_BRAND_LOOKUP[0], 'agoricNames');
41
+ assert(OUT_BRAND_NAME);
42
+ }
43
+
44
+ return harden({
45
+ sourceSpec: '../src/proposals/price-feed-proposal.js',
46
+ getManifestCall: [
47
+ 'getManifestForPriceFeed',
48
+ {
49
+ ...optionsRest,
50
+ AGORIC_INSTANCE_NAME,
51
+ contractTerms,
52
+ oracleAddresses,
53
+ IN_BRAND_LOOKUP,
54
+ OUT_BRAND_LOOKUP,
55
+ IN_BRAND_NAME,
56
+ OUT_BRAND_NAME,
57
+ brandInRef: brandIn && publishRef(brandIn),
58
+ brandOutRef: brandOut && publishRef(brandOut),
59
+ priceAggregatorRef: publishRef(
60
+ install(
61
+ '@agoric/inter-protocol/src/price/fluxAggregatorContract.js',
62
+ '../bundles/bundle-fluxAggregatorKit.js',
63
+ ),
64
+ ),
65
+ },
66
+ ],
67
+ });
68
+ };
69
+
70
+ export const createGov = async (homeP, endowments) => {
71
+ const { lookup } = endowments;
72
+
73
+ const {
74
+ AGORIC_INSTANCE_NAME,
75
+ IN_BRAND_DECIMALS = '6',
76
+ IN_BRAND_LOOKUP = JSON.stringify(['wallet', 'brand', 'BLD']),
77
+ OUT_BRAND_DECIMALS = '6',
78
+ OUT_BRAND_LOOKUP = JSON.stringify(['agoricNames', 'oracleBrand', 'USD']),
79
+ ORACLE_ADDRESSES,
80
+ } = process.env;
81
+
82
+ assert(AGORIC_INSTANCE_NAME, 'AGORIC_INSTANCE_NAME is required');
83
+ assert(ORACLE_ADDRESSES, 'ORACLE_ADDRESSES is required');
84
+
85
+ const oracleAddresses = ORACLE_ADDRESSES.split(',');
86
+
87
+ const { writeCoreProposal } = await makeHelpers(homeP, endowments);
88
+
89
+ const inLookup = JSON.parse(IN_BRAND_LOOKUP);
90
+ const outLookup = JSON.parse(OUT_BRAND_LOOKUP);
91
+
92
+ const proposalBuilder = powers =>
93
+ defaultProposalBuilder(powers, {
94
+ AGORIC_INSTANCE_NAME,
95
+ IN_BRAND_DECIMALS: parseInt(IN_BRAND_DECIMALS, 10),
96
+ OUT_BRAND_DECIMALS: parseInt(OUT_BRAND_DECIMALS, 10),
97
+ oracleAddresses,
98
+ brandIn: lookup(inLookup).catch(() => undefined),
99
+ brandOut: lookup(outLookup).catch(() => undefined),
100
+ });
101
+ await writeCoreProposal('gov-price-feed', proposalBuilder); // gov-price-feed.js gov-price-feed-permit.json
102
+ };
103
+
104
+ export default createGov;
@@ -0,0 +1,84 @@
1
+ #!/bin/bash
2
+ #
3
+ # Start a chain with "economy" and provision wallet to use it
4
+ #
5
+
6
+ # run an Archive node to keep all history https://docs.desmos.network/fullnode/overview/
7
+ # (the Makefile passes this to agd start)
8
+ export AGC_START_ARGS="--pruning=nothing"
9
+
10
+ CHAIN_LOG=$(mktemp -t Agoric-start-local-chain-log-XXXXXXX)
11
+ if [[ $(uname) == "Darwin" ]]; then
12
+ open -a /System/Applications/Utilities/Console.app "$CHAIN_LOG"
13
+ fi
14
+
15
+ # ugly way to get SDK path regardless of cwd
16
+ SDK=$(readlink -f "$(dirname -- "$(readlink -f -- "$0")")/../../..")
17
+
18
+ WALLET=gov1
19
+ WALLET_BECH32=$(agd keys --keyring-backend=test show "$WALLET" --output json | jq -r .address)
20
+
21
+ if [ -z "$WALLET_BECH32" ]; then
22
+ echo "USAGE: $0 wallet-key"
23
+ # The key must be from the 'test' keyring, for non-interactive use.
24
+ # To migrate one of your 'os' keys:
25
+ # agd keys export the-wallet-key-name > wallet.key
26
+ # agd keys import --keyring-backend=test the-wallet-key-name wallet.key
27
+ exit 1
28
+ fi
29
+
30
+ # this is in economy-template.json in the oracleAddresses list (agoric1dy0yegdsev4xvce3dx7zrz2ad9pesf5svzud6y)
31
+ # to use it run `agd keys --keyring-backend=test add oracle2 --interactive` and enter this mnenomic:
32
+ # dizzy scale gentle good play scene certain acquire approve alarm retreat recycle inch journey fitness grass minimum learn funny way unlock what buzz upon
33
+ WALLET2=gov2
34
+ WALLET2_BECH32=$(agd keys --keyring-backend=test show "$WALLET2" --output json | jq -r .address)
35
+ if [ -z "$WALLET2_BECH32" ]; then
36
+ echo "missing oracle2 key in test keyring"
37
+ exit 1
38
+ fi
39
+
40
+ echo CHAIN_LOG "$CHAIN_LOG"
41
+ echo SDK "$SDK"
42
+ echo WALLET "$WALLET"
43
+ echo WALLET_BECH32 "$WALLET_BECH32"
44
+
45
+ cd "$SDK"/packages/cosmic-swingset || exit 1
46
+
47
+ echo "Logs written to $CHAIN_LOG"
48
+ # specifies the address to use for chain config
49
+ export PRIMARY_ADDRESS=$WALLET_BECH32
50
+ # nobuild variety skips Golang artifacts; if you get errors try make scenario2-setup
51
+ make scenario2-setup-nobuild >>"$CHAIN_LOG" 2>&1
52
+
53
+ # TODO detect it's already running, indicate when it started and offer to restart
54
+ # e.g. killall node xsnap-worker
55
+ echo "Starting the chain..."
56
+ # use -economy target to get the kitchen sink
57
+ # disable pruning to keep all history https://docs.desmos.network/fullnode/overview/
58
+ make AGC_START_ARGS="--pruning=nothing" CHAIN_BOOTSTRAP_VAT_CONFIG=@agoric/vats/decentral-itest-vaults-config.json scenario2-run-chain >>"$CHAIN_LOG" 2>&1 &
59
+ make wait-for-cosmos
60
+
61
+ # xxx sleep to let it settle
62
+ sleep 15
63
+
64
+ echo "Funding the pool..."
65
+ make fund-provision-pool
66
+
67
+ echo "Funding your wallet account..."
68
+ # After `fund-provision-pool` there is 900 IST remaining for other account funding.
69
+ # A wallet can be tested with 20 BLD for provisioning wallet and 20 USDC for psm trading
70
+ # Also include 1M ATOM
71
+ make ACCT_ADDR="$WALLET_BECH32" FUNDS=20000000ubld,20000000ibc/toyusdc,1000000000000ibc/toyatom fund-acct
72
+ agd query bank balances "$WALLET_BECH32" | grep ubld || exit 1
73
+
74
+ echo "Provisioning your smart wallet..."
75
+ agoric wallet --keyring-backend=test provision --spend --account "$WALLET"
76
+ echo "waiting for blocks"
77
+ sleep 15
78
+ # verify
79
+ agoric wallet --keyring-backend=test list
80
+ agoric wallet --keyring-backend=test show --from "$WALLET"
81
+
82
+ echo "Repeating for gov2 account..."
83
+ make ACCT_ADDR="$WALLET2_BECH32" FUNDS=20000000ubld,20000000ibc/toyusdc fund-acct
84
+ agoric wallet --keyring-backend=test provision --spend --account "$WALLET2"
@@ -34,38 +34,34 @@ const DEFAULT_DECIMALS = 9;
34
34
 
35
35
  /**
36
36
  * @file The book represents the collateral-specific state of an ongoing
37
- * auction. It holds the book, the capturedPrice, and the collateralSeat that
38
- * has the allocation of assets for sale.
39
- *
40
- * The book contains orders for the collateral. It holds two kinds of orders:
37
+ * auction. It holds the book, the capturedPrice, and the collateralSeat that has
38
+ * the allocation of assets for sale.
41
39
  *
40
+ * The book contains orders for the collateral. It holds two kinds of
41
+ * orders:
42
42
  * - Prices express the bidding offer in terms of a Bid amount
43
- * - ScaledBids express the offer in terms of a discount (or markup) from the most
44
- * recent oracle price.
43
+ * - ScaledBids express the offer in terms of a discount (or markup) from the
44
+ * most recent oracle price.
45
45
  *
46
- * Offers can be added in three ways. 1) When the auction is not active, prices
47
- * are automatically added to the appropriate collection. When the auction is
48
- * active, 2) if a new offer is at or above the current price, it will be
49
- * settled immediately; 2) If the offer is below the current price, it will be
50
- * added in the appropriate place and settled when the price reaches that
51
- * level.
46
+ * Offers can be added in three ways. 1) When the auction is not active, prices
47
+ * are automatically added to the appropriate collection. When the auction is
48
+ * active, 2) if a new offer is at or above the current price, it will be
49
+ * settled immediately; 2) If the offer is below the current price, it will be
50
+ * added in the appropriate place and settled when the price reaches that level.
52
51
  */
53
52
 
54
53
  const trace = makeTracer('AucBook', true);
55
54
 
56
55
  /**
57
56
  * @typedef {{
58
- * maxBuy: Amount<'nat'>;
57
+ * maxBuy: Amount<'nat'>
59
58
  * } & {
60
- * exitAfterBuy?: boolean;
61
- * } & (
62
- * | {
63
- * offerPrice: Ratio;
64
- * }
65
- * | {
66
- * offerBidScaling: Ratio;
67
- * }
68
- * )} OfferSpec
59
+ * exitAfterBuy?: boolean,
60
+ * } & ({
61
+ * offerPrice: Ratio,
62
+ * } | {
63
+ * offerBidScaling: Ratio,
64
+ * })} OfferSpec
69
65
  */
70
66
  /**
71
67
  * @param {Brand<'nat'>} bidBrand
@@ -92,19 +88,17 @@ export const makeOfferSpecShape = (bidBrand, collateralBrand) => {
92
88
 
93
89
  /**
94
90
  * @typedef {object} BookDataNotification
95
- * @property {Ratio | null} startPrice identifies the priceAuthority and price
96
- * @property {Ratio | null} currentPriceLevel the price at the current auction
97
- * tier
98
- * @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers
99
- * were targeting to raise
100
- * @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of the
101
- * proceeds the sellers were targeting to raise
102
- * @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so
103
- * far in the auction
104
- * @property {Amount<'nat'>} startCollateral How much collateral was available
105
- * for sale at the start. (If more is deposited later, it'll be added in.)
106
- * @property {Amount<'nat'> | null} collateralAvailable The amount of collateral
107
- * remaining
91
+ *
92
+ * @property {Ratio | null} startPrice identifies the priceAuthority and price
93
+ * @property {Ratio | null} currentPriceLevel the price at the current auction tier
94
+ * @property {Amount<'nat'> | null} startProceedsGoal The proceeds the sellers were targeting to raise
95
+ * @property {Amount<'nat'> | null} remainingProceedsGoal The remainder of
96
+ * the proceeds the sellers were targeting to raise
97
+ * @property {Amount<'nat'> | undefined} proceedsRaised The proceeds raised so far in the auction
98
+ * @property {Amount<'nat'>} startCollateral How much collateral was
99
+ * available for sale at the start. (If more is deposited later, it'll be
100
+ * added in.)
101
+ * @property {Amount<'nat'> | null} collateralAvailable The amount of collateral remaining
108
102
  */
109
103
 
110
104
  /**
@@ -237,8 +231,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
237
231
  {
238
232
  helper: {
239
233
  /**
240
- * remove the key from the appropriate book, indicated by whether the
241
- * price is defined.
234
+ * remove the key from the appropriate book, indicated by whether the price
235
+ * is defined.
242
236
  *
243
237
  * @param {string} key
244
238
  * @param {Ratio | undefined} price
@@ -253,8 +247,8 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
253
247
  },
254
248
 
255
249
  /**
256
- * Update the entry in the appropriate book, indicated by whether the
257
- * price is defined.
250
+ * Update the entry in the appropriate book, indicated by whether the price
251
+ * is defined.
258
252
  *
259
253
  * @param {string} key
260
254
  * @param {Amount} collateralSold
@@ -270,8 +264,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
270
264
  },
271
265
 
272
266
  /**
273
- * Settle with seat. The caller is responsible for updating the book, if
274
- * any.
267
+ * Settle with seat. The caller is responsible for updating the book, if any.
275
268
  *
276
269
  * @param {ZCFSeat} seat
277
270
  * @param {Amount<'nat'>} collateralWanted
@@ -348,16 +341,15 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
348
341
  },
349
342
 
350
343
  /**
351
- * Accept an offer expressed as a price. If the auction is active,
352
- * attempt to buy collateral. If any of the offer remains add it to the
353
- * book.
344
+ * Accept an offer expressed as a price. If the auction is active, attempt to
345
+ * buy collateral. If any of the offer remains add it to the book.
354
346
  *
355
- * @param {ZCFSeat} seat
356
- * @param {Ratio} price
357
- * @param {Amount<'nat'>} maxBuy
358
- * @param {object} opts
359
- * @param {boolean} opts.trySettle
360
- * @param {boolean} [opts.exitAfterBuy]
347
+ * @param {ZCFSeat} seat
348
+ * @param {Ratio} price
349
+ * @param {Amount<'nat'>} maxBuy
350
+ * @param {object} opts
351
+ * @param {boolean} opts.trySettle
352
+ * @param {boolean} [opts.exitAfterBuy]
361
353
  */
362
354
  acceptPriceOffer(
363
355
  seat,
@@ -396,16 +388,16 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
396
388
  },
397
389
 
398
390
  /**
399
- * Accept an offer expressed as a discount (or markup). If the auction
400
- * is active, attempt to buy collateral. If any of the offer remains add
401
- * it to the book.
391
+ * Accept an offer expressed as a discount (or markup). If the auction is
392
+ * active, attempt to buy collateral. If any of the offer remains add it to
393
+ * the book.
402
394
  *
403
- * @param {ZCFSeat} seat
404
- * @param {Ratio} bidScaling
405
- * @param {Amount<'nat'>} maxBuy
406
- * @param {object} opts
407
- * @param {boolean} opts.trySettle
408
- * @param {boolean} [opts.exitAfterBuy]
395
+ * @param {ZCFSeat} seat
396
+ * @param {Ratio} bidScaling
397
+ * @param {Amount<'nat'>} maxBuy
398
+ * @param {object} opts
399
+ * @param {boolean} opts.trySettle
400
+ * @param {boolean} [opts.exitAfterBuy]
409
401
  */
410
402
  acceptScaledBidOffer(
411
403
  seat,
@@ -474,10 +466,10 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
474
466
  * @param {Amount<'nat'>} assetAmount
475
467
  * @param {ZCFSeat} sourceSeat
476
468
  * @param {Amount<'nat'>} [proceedsGoal] an amount that the depositor
477
- * would like to raise. The auction is requested to not sell more
478
- * collateral than required to raise that much. The auctioneer might
479
- * sell more if there is more than one supplier of collateral, and
480
- * they request inconsistent limits.
469
+ * would like to raise. The auction is requested to not sell more
470
+ * collateral than required to raise that much. The auctioneer might
471
+ * sell more if there is more than one supplier of collateral, and
472
+ * they request inconsistent limits.
481
473
  */
482
474
  addAssets(assetAmount, sourceSeat, proceedsGoal) {
483
475
  const { state, facets } = this;
@@ -762,11 +754,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
762
754
  },
763
755
  );
764
756
 
765
- /**
766
- * @type {(
767
- * ...args: Parameters<typeof makeAuctionBookKit>
768
- * ) => ReturnType<typeof makeAuctionBookKit>['self']}
769
- */
757
+ /** @type {(...args: Parameters<typeof makeAuctionBookKit>) => ReturnType<typeof makeAuctionBookKit>['self']} */
770
758
  const makeAuctionBook = (...args) => makeAuctionBookKit(...args).self;
771
759
  return makeAuctionBook;
772
760
  };