@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
|
@@ -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
|
-
*
|
|
38
|
-
*
|
|
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
|
|
44
|
-
*
|
|
43
|
+
* - ScaledBids express the offer in terms of a discount (or markup) from the
|
|
44
|
+
* most recent oracle price.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
96
|
-
* @property {Ratio
|
|
97
|
-
*
|
|
98
|
-
* @property {Amount<'nat'> | null}
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @property {Amount<'nat'>
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
352
|
-
*
|
|
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
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
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
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
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
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
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
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
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;
|
|
@@ -555,12 +547,9 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
555
547
|
|
|
556
548
|
trace(this.state.collateralBrand, 'settleAtNewRate', reduction);
|
|
557
549
|
const { capturedPriceForRound, priceBook, scaledBidBook } = state;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
);
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
550
|
+
capturedPriceForRound !== null ||
|
|
551
|
+
Fail`price must be captured before auction starts`;
|
|
552
|
+
assert(capturedPriceForRound);
|
|
564
553
|
|
|
565
554
|
state.curAuctionPrice = multiplyRatios(
|
|
566
555
|
reduction,
|
|
@@ -765,11 +754,7 @@ export const prepareAuctionBook = (baggage, zcf, makeRecorderKit) => {
|
|
|
765
754
|
},
|
|
766
755
|
);
|
|
767
756
|
|
|
768
|
-
/**
|
|
769
|
-
* @type {(
|
|
770
|
-
* ...args: Parameters<typeof makeAuctionBookKit>
|
|
771
|
-
* ) => ReturnType<typeof makeAuctionBookKit>['self']}
|
|
772
|
-
*/
|
|
757
|
+
/** @type {(...args: Parameters<typeof makeAuctionBookKit>) => ReturnType<typeof makeAuctionBookKit>['self']} */
|
|
773
758
|
const makeAuctionBook = (...args) => makeAuctionBookKit(...args).self;
|
|
774
759
|
return makeAuctionBook;
|
|
775
760
|
};
|