@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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { AmountMath } from '@agoric/ertp';
|
|
3
|
-
import { makeNotifierFromAsyncIterable } from '@agoric/notifier';
|
|
4
|
-
import { E } from '@endo/far';
|
|
5
|
-
|
|
6
|
-
const { entries } = Object;
|
|
7
|
-
|
|
8
|
-
const dec6 = 10n ** 6n;
|
|
9
|
-
const dec4 = 10n ** 4n;
|
|
10
|
-
|
|
11
|
-
const config = {
|
|
12
|
-
Central: { IST: 10_000n * dec6 },
|
|
13
|
-
Secondary: { IbcATOM: 500n * dec4 }, // 20 IST per ATOM
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const getOfferResult = async (instance, wallet, walletAdmin) => {
|
|
17
|
-
const offerIt = E(walletAdmin).getOffersNotifier();
|
|
18
|
-
let result;
|
|
19
|
-
console.log('awaiting offers...');
|
|
20
|
-
for await (const offers of makeNotifierFromAsyncIterable(offerIt)) {
|
|
21
|
-
console.log('offers iterator next:', offers);
|
|
22
|
-
offers
|
|
23
|
-
.filter(
|
|
24
|
-
({ status, invitationQuery }) =>
|
|
25
|
-
status === 'complete' && invitationQuery.instance === instance,
|
|
26
|
-
)
|
|
27
|
-
.forEach(async ({ id }) => {
|
|
28
|
-
result = await E(wallet).lookup('offerResult', id);
|
|
29
|
-
console.log({ facet: result });
|
|
30
|
-
});
|
|
31
|
-
if (result) break;
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param { { agoricNames: ERef<NameHub>, scratch: ERef<import('@agoric/solo/src/scratch').ScratchPad>, wallet: ERef<WalletAdmin>, zoe: ERef<ZoeService>} } homeP
|
|
39
|
-
* @param { {now?: () => number }} _endowments
|
|
40
|
-
*
|
|
41
|
-
* @typedef {ReturnType<typeof import('../../wallet/api/src/lib-wallet').makeWalletRoot>['admin']} Wallet
|
|
42
|
-
*/
|
|
43
|
-
const addInitialLiquidity = async (homeP, { now = () => Date.now() }) => {
|
|
44
|
-
const { wallet, agoricNames, zoe, scratch } = E.get(homeP);
|
|
45
|
-
|
|
46
|
-
const walletBridge = E(wallet).getBridge();
|
|
47
|
-
|
|
48
|
-
const getService = async name => {
|
|
49
|
-
console.log('lookup instance', name);
|
|
50
|
-
const instance = await E(agoricNames).lookup('instance', name);
|
|
51
|
-
const pub = E(zoe).getPublicFacet(instance);
|
|
52
|
-
return { instance, pub };
|
|
53
|
-
};
|
|
54
|
-
const amm = await getService('amm');
|
|
55
|
-
|
|
56
|
-
const addUsingWallet = async () => {
|
|
57
|
-
console.log('getting purses from walletBridge...');
|
|
58
|
-
const { value: pStates } = await E(
|
|
59
|
-
E(walletBridge).getPursesNotifier(),
|
|
60
|
-
).getUpdateSince();
|
|
61
|
-
console.log(pStates);
|
|
62
|
-
|
|
63
|
-
const toAmt = detail => {
|
|
64
|
-
const [[name, value]] = entries(detail);
|
|
65
|
-
const { pursePetname } =
|
|
66
|
-
pStates.find(p => p.brandPetname === name) ||
|
|
67
|
-
assert.fail(`cannot find purse ${name}`);
|
|
68
|
-
return { pursePetname, value };
|
|
69
|
-
};
|
|
70
|
-
const proposalTemplate = {
|
|
71
|
-
give: {
|
|
72
|
-
Central: toAmt(config.Central),
|
|
73
|
-
Secondary: toAmt(config.Secondary),
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
console.log({ proposalTemplate });
|
|
77
|
-
|
|
78
|
-
console.log('amm.makeAddLiquidityInvitation...');
|
|
79
|
-
const invitation = await E(amm.pub).makeAddLiquidityInvitation();
|
|
80
|
-
console.log({ invitation });
|
|
81
|
-
|
|
82
|
-
const offerConfig = {
|
|
83
|
-
id: `${now()}`,
|
|
84
|
-
invitation,
|
|
85
|
-
instanceHandle: amm.instance,
|
|
86
|
-
proposalTemplate,
|
|
87
|
-
requestContext: undefined,
|
|
88
|
-
};
|
|
89
|
-
console.log('addOffer', offerConfig);
|
|
90
|
-
const added = await E(walletBridge).addOffer(offerConfig);
|
|
91
|
-
console.log({ added });
|
|
92
|
-
|
|
93
|
-
const result = await getOfferResult(
|
|
94
|
-
amm.instance,
|
|
95
|
-
wallet,
|
|
96
|
-
E(wallet).getAdminFacet(),
|
|
97
|
-
);
|
|
98
|
-
console.log({ result });
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const addUsingZoe = async () => {
|
|
102
|
-
const { keys, values } = Object;
|
|
103
|
-
/** @type {<K extends string, V>(entries: [K, V][]) => Record<K, V>} */
|
|
104
|
-
const toRecord = Object.fromEntries;
|
|
105
|
-
|
|
106
|
-
console.log('getting purses, issuers from wallet...');
|
|
107
|
-
const [purseEntries, { value: issuerEntries }] = await Promise.all([
|
|
108
|
-
E(wallet).getPurses(),
|
|
109
|
-
E(E(walletBridge).getIssuersNotifier()).getUpdateSince(),
|
|
110
|
-
]);
|
|
111
|
-
|
|
112
|
-
// @ts-expect-error Petname can be string[]
|
|
113
|
-
const purses = toRecord(purseEntries);
|
|
114
|
-
// @ts-expect-error Petname can be string[]
|
|
115
|
-
const issuers = toRecord(issuerEntries);
|
|
116
|
-
console.log({ purses: keys(purses), issuers: keys(issuers) });
|
|
117
|
-
assert(
|
|
118
|
-
issuers.IbcATOM,
|
|
119
|
-
'Issuers not complete. Try again after purses are provisioned',
|
|
120
|
-
);
|
|
121
|
-
const liqIssuer = E(amm.pub).getLiquidityIssuer(issuers.IbcATOM.brand);
|
|
122
|
-
const liqBrand = await E(liqIssuer).getBrand();
|
|
123
|
-
|
|
124
|
-
/** @param {Record<string, bigint>} detail */
|
|
125
|
-
const toAmt = detail => {
|
|
126
|
-
const [[name, value]] = entries(detail);
|
|
127
|
-
const issuer = issuers[name];
|
|
128
|
-
assert(issuer);
|
|
129
|
-
return AmountMath.make(issuer.brand, value);
|
|
130
|
-
};
|
|
131
|
-
/** @param {Amount} amt */
|
|
132
|
-
const withdraw = async amt => {
|
|
133
|
-
for await (const purse of values(purses)) {
|
|
134
|
-
const b2 = await E(purse).getAllegedBrand();
|
|
135
|
-
if (b2 === amt.brand) {
|
|
136
|
-
return E(purse).withdraw(amt);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
throw Error(`no purse found for ${amt.brand}`);
|
|
140
|
-
};
|
|
141
|
-
const proposal = {
|
|
142
|
-
want: {
|
|
143
|
-
Liquidity: AmountMath.makeEmpty(liqBrand),
|
|
144
|
-
},
|
|
145
|
-
give: {
|
|
146
|
-
Central: toAmt(config.Central),
|
|
147
|
-
Secondary: toAmt(config.Secondary),
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
console.log({ proposal });
|
|
151
|
-
console.log('withdraw payments...', proposal.give);
|
|
152
|
-
const payments = {
|
|
153
|
-
Central: await withdraw(proposal.give.Central),
|
|
154
|
-
Secondary: await withdraw(proposal.give.Secondary),
|
|
155
|
-
};
|
|
156
|
-
console.log('payments', payments);
|
|
157
|
-
console.log('amm.makeAddLiquidityInvitation...');
|
|
158
|
-
const invitation = await E(amm.pub).makeAddLiquidityInvitation();
|
|
159
|
-
console.log({ invitation });
|
|
160
|
-
|
|
161
|
-
const seat = await E(zoe).offer(invitation, proposal, payments);
|
|
162
|
-
console.log({ seat });
|
|
163
|
-
|
|
164
|
-
const result = await E(seat).getOfferResult();
|
|
165
|
-
console.log({ result });
|
|
166
|
-
|
|
167
|
-
const payouts = await E(seat).getPayouts();
|
|
168
|
-
console.log('initialLiquidityPayouts', keys(payouts));
|
|
169
|
-
E(scratch).set('initialLiquidityPayouts', payouts);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
console.log(
|
|
173
|
-
addUsingWallet,
|
|
174
|
-
'does not handle want Liquidity so we do not use it',
|
|
175
|
-
);
|
|
176
|
-
await addUsingZoe();
|
|
177
|
-
};
|
|
178
|
-
harden(addInitialLiquidity);
|
|
179
|
-
|
|
180
|
-
export default addInitialLiquidity;
|
package/src/collect.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
const { fromEntries, keys, values } = Object;
|
|
4
|
-
|
|
5
|
-
/** @type { <X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
6
|
-
export const zip = (xs, ys) => harden(xs.map((x, i) => [x, ys[+i]]));
|
|
7
|
-
|
|
8
|
-
/** @type { <K extends string, V>(obj: Record<K, ERef<V>>) => Promise<Record<K, V>> } */
|
|
9
|
-
export const allValues = async obj => {
|
|
10
|
-
const resolved = await Promise.all(values(obj));
|
|
11
|
-
// @ts-expect-error cast
|
|
12
|
-
return harden(fromEntries(zip(keys(obj), resolved)));
|
|
13
|
-
};
|
package/src/interchainPool.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { E, Far } from '@endo/far';
|
|
3
|
-
import { AmountMath, AssetKind, makeIssuerKit } from '@agoric/ertp';
|
|
4
|
-
import { offerTo } from '@agoric/zoe/src/contractSupport/index.js';
|
|
5
|
-
import { MIN_INITIAL_POOL_LIQUIDITY_KEY } from './vpool-xyk-amm/params.js';
|
|
6
|
-
|
|
7
|
-
const { details: X, quote: q } = assert;
|
|
8
|
-
|
|
9
|
-
const COSMOS_DECIMALS = 6;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Given sufficient IST, create an issuer for an IBC denom
|
|
13
|
-
* and an invitation to add a pool for it to the AMM.
|
|
14
|
-
*
|
|
15
|
-
* @param {ZCF<InterchainPoolTerms>} zcf
|
|
16
|
-
* @param {{
|
|
17
|
-
* bankManager: ERef<BankManager>,
|
|
18
|
-
* }} privateArgs
|
|
19
|
-
*
|
|
20
|
-
* @typedef {{
|
|
21
|
-
* amm: Instance,
|
|
22
|
-
* }} InterchainPoolTerms
|
|
23
|
-
*
|
|
24
|
-
* @typedef {{
|
|
25
|
-
* denom: string,
|
|
26
|
-
* decimalPlaces: number,
|
|
27
|
-
* }} AssetDetail
|
|
28
|
-
*/
|
|
29
|
-
export const start = (zcf, { bankManager }) => {
|
|
30
|
-
const { amm } = zcf.getTerms();
|
|
31
|
-
|
|
32
|
-
const zoe = zcf.getZoeService();
|
|
33
|
-
/** @type {ERef<GovernedPublicFacet<XYKAMMPublicFacet>>} */
|
|
34
|
-
const ammPub = E(zoe).getPublicFacet(amm);
|
|
35
|
-
|
|
36
|
-
let kwNonce = 0;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @param {ZCFSeat} seat
|
|
40
|
-
* @param {AssetDetail} detail
|
|
41
|
-
*/
|
|
42
|
-
const step1Handler = async (seat, detail) => {
|
|
43
|
-
assert.typeof(
|
|
44
|
-
detail,
|
|
45
|
-
'object',
|
|
46
|
-
'offer arg must be { denom, decimalPlaces? }',
|
|
47
|
-
);
|
|
48
|
-
const { denom, decimalPlaces = COSMOS_DECIMALS } = detail;
|
|
49
|
-
assert.typeof(denom, 'string');
|
|
50
|
-
assert.typeof(decimalPlaces, 'number');
|
|
51
|
-
|
|
52
|
-
const minimumCentral = await E(ammPub).getAmount(
|
|
53
|
-
MIN_INITIAL_POOL_LIQUIDITY_KEY,
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
give: { Central: centralAmt },
|
|
58
|
-
} = seat.getProposal();
|
|
59
|
-
AmountMath.isGTE(centralAmt, minimumCentral) ||
|
|
60
|
-
assert.fail(
|
|
61
|
-
X`at least ${q(minimumCentral)} required; only ${q(centralAmt)} given`,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const interAsset = makeIssuerKit(
|
|
65
|
-
denom,
|
|
66
|
-
AssetKind.NAT,
|
|
67
|
-
harden({ decimalPlaces }),
|
|
68
|
-
);
|
|
69
|
-
kwNonce += 1;
|
|
70
|
-
|
|
71
|
-
await zcf.saveIssuer(interAsset.issuer, `Interchain${kwNonce}`);
|
|
72
|
-
|
|
73
|
-
/** @type { OfferHandler } */
|
|
74
|
-
const step2Handler = async seat2 => {
|
|
75
|
-
const {
|
|
76
|
-
give: { Secondary: secondaryAmt },
|
|
77
|
-
} = seat2.getProposal();
|
|
78
|
-
AmountMath.coerce(interAsset.brand, secondaryAmt);
|
|
79
|
-
|
|
80
|
-
const liquidityIssuer = await E(ammPub).addIssuer(
|
|
81
|
-
interAsset.issuer,
|
|
82
|
-
`Interchain${kwNonce}`,
|
|
83
|
-
);
|
|
84
|
-
await zcf.saveIssuer(liquidityIssuer, `Liquidity${kwNonce}`);
|
|
85
|
-
|
|
86
|
-
const proposal = harden({
|
|
87
|
-
give: {
|
|
88
|
-
Central: centralAmt,
|
|
89
|
-
Secondary: secondaryAmt,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
seat2.incrementBy(seat.decrementBy(harden({ Central: centralAmt })));
|
|
94
|
-
zcf.reallocate(seat, seat2);
|
|
95
|
-
|
|
96
|
-
const invitation = await E(ammPub).addPoolInvitation();
|
|
97
|
-
const { userSeatPromise, deposited } = await offerTo(
|
|
98
|
-
zcf,
|
|
99
|
-
invitation,
|
|
100
|
-
undefined,
|
|
101
|
-
proposal,
|
|
102
|
-
seat2,
|
|
103
|
-
);
|
|
104
|
-
return deposited.then(_ => {
|
|
105
|
-
seat.exit();
|
|
106
|
-
seat2.exit();
|
|
107
|
-
|
|
108
|
-
return E(userSeatPromise).getOfferResult();
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const keyword = denom; // ISSUE #5412: should not show up in all wallets.
|
|
113
|
-
const proposedName = denom;
|
|
114
|
-
const [invitation] = await Promise.all([
|
|
115
|
-
zcf.makeInvitation(step2Handler, 'interchain pool step 2'),
|
|
116
|
-
E(bankManager).addAsset(
|
|
117
|
-
denom,
|
|
118
|
-
keyword,
|
|
119
|
-
proposedName,
|
|
120
|
-
interAsset, // with mint
|
|
121
|
-
),
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
|
-
return harden({
|
|
125
|
-
issuer: interAsset.issuer,
|
|
126
|
-
invitation,
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const publicFacet = Far('InterchainPoolGateway', {
|
|
131
|
-
makeInterchainPoolInvitation: () =>
|
|
132
|
-
zcf.makeInvitation(step1Handler, 'interchain pool step 1'),
|
|
133
|
-
});
|
|
134
|
-
return { publicFacet };
|
|
135
|
-
};
|
package/src/makeTracer.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
let debugInstance = 1;
|
|
2
|
-
|
|
3
|
-
const makeTracer = (name, enable = true) => {
|
|
4
|
-
debugInstance += 1;
|
|
5
|
-
let debugCount = 1;
|
|
6
|
-
const key = `----- ${name}.${debugInstance} `;
|
|
7
|
-
// the cases below define a named variable to provide better debug info
|
|
8
|
-
switch (enable) {
|
|
9
|
-
case false: {
|
|
10
|
-
const logDisabled = (..._args) => {};
|
|
11
|
-
return logDisabled;
|
|
12
|
-
}
|
|
13
|
-
case 'verbose': {
|
|
14
|
-
const infoTick = (optLog, ...args) => {
|
|
15
|
-
if (optLog.log) {
|
|
16
|
-
console.info(key, (debugCount += 1), ...args);
|
|
17
|
-
} else {
|
|
18
|
-
console.info(key, (debugCount += 1), optLog, ...args);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
return infoTick;
|
|
22
|
-
}
|
|
23
|
-
default: {
|
|
24
|
-
const debugTick = (optLog, ...args) => {
|
|
25
|
-
if (optLog.log) {
|
|
26
|
-
optLog.log(key, (debugCount += 1), ...args);
|
|
27
|
-
} else {
|
|
28
|
-
console.info(key, (debugCount += 1), optLog, ...args);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return debugTick;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { makeTracer };
|
package/src/my-lien.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { AmountMath } from '@agoric/ertp';
|
|
3
|
-
import { E, Far } from '@endo/far';
|
|
4
|
-
|
|
5
|
-
const { details: X } = assert;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* per golang/cosmos/x/lien/lien.go
|
|
9
|
-
*
|
|
10
|
-
* @typedef { 'bonded' | 'liened' | 'locked' | 'total' | 'unbonding' } AccountProperty
|
|
11
|
-
*/
|
|
12
|
-
const XLien = /** @type { const } */ ({
|
|
13
|
-
name: 'lien',
|
|
14
|
-
LIEN_CHANGE_LIENED: 'LIEN_CHANGE_LIENED',
|
|
15
|
-
LIEN_GET_ACCOUNT_STATE: 'LIEN_GET_ACCOUNT_STATE',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef { Record<AccountProperty, T> & { currentTime: bigint } } AccountState<T>
|
|
20
|
-
* @template T
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {ERef<BridgeManager>} bridgeManager
|
|
25
|
-
* @param {Brand<'nat'>} brand
|
|
26
|
-
* @param {string} [denom]
|
|
27
|
-
* @returns {StakingAuthority}
|
|
28
|
-
*/
|
|
29
|
-
export const makeStakeReporter = (bridgeManager, brand, denom = 'ubld') => {
|
|
30
|
-
const { make: makeAmt } = AmountMath;
|
|
31
|
-
/** @param {string} numeral */
|
|
32
|
-
const toStake = numeral => makeAmt(brand, BigInt(numeral));
|
|
33
|
-
/**
|
|
34
|
-
* @param {string} address
|
|
35
|
-
* @param {bigint} delta
|
|
36
|
-
* @returns {Promise<Amount<`nat`>>}
|
|
37
|
-
*/
|
|
38
|
-
const changeLiened = async (address, delta) => {
|
|
39
|
-
assert.typeof(address, 'string');
|
|
40
|
-
const newAmount = await E(bridgeManager).toBridge(XLien.name, {
|
|
41
|
-
type: XLien.LIEN_CHANGE_LIENED,
|
|
42
|
-
address,
|
|
43
|
-
denom,
|
|
44
|
-
delta: `${delta}`,
|
|
45
|
-
});
|
|
46
|
-
return harden(toStake(newAmount));
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** @type {StakingAuthority} */
|
|
50
|
-
const stakeReporter = Far('stakeReporter', {
|
|
51
|
-
increaseLiened: async (address, increase) => {
|
|
52
|
-
const delta = AmountMath.getValue(brand, increase);
|
|
53
|
-
return changeLiened(address, delta);
|
|
54
|
-
},
|
|
55
|
-
decreaseLiened: async (address, decrease) => {
|
|
56
|
-
const delta = -1n * AmountMath.getValue(brand, decrease);
|
|
57
|
-
return changeLiened(address, delta);
|
|
58
|
-
},
|
|
59
|
-
getAccountState: async (address, wantedBrand) => {
|
|
60
|
-
wantedBrand === brand ||
|
|
61
|
-
assert.fail(
|
|
62
|
-
X`Cannot getAccountState for ${wantedBrand}. Expected ${brand}.`,
|
|
63
|
-
);
|
|
64
|
-
/** @type { AccountState<string> } */
|
|
65
|
-
const { currentTime, bonded, liened, locked, total, unbonding } = await E(
|
|
66
|
-
bridgeManager,
|
|
67
|
-
).toBridge(XLien.name, {
|
|
68
|
-
type: XLien.LIEN_GET_ACCOUNT_STATE,
|
|
69
|
-
address,
|
|
70
|
-
denom,
|
|
71
|
-
amount: '0',
|
|
72
|
-
});
|
|
73
|
-
return harden({
|
|
74
|
-
bonded: toStake(bonded),
|
|
75
|
-
liened: toStake(liened),
|
|
76
|
-
locked: toStake(locked),
|
|
77
|
-
total: toStake(total),
|
|
78
|
-
unbonding: toStake(unbonding),
|
|
79
|
-
currentTime: BigInt(currentTime),
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
return stakeReporter;
|
|
85
|
-
};
|