@agoric/zoe 0.26.3-dev-8baf0aa.0 → 0.26.3-dev-cc54325.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 (43) hide show
  1. package/README.md +2 -2
  2. package/bundles/bundle-contractFacet-js-meta.json +88 -80
  3. package/bundles/bundle-contractFacet.js +1 -1
  4. package/package.json +11 -10
  5. package/src/contractFacet/reallocate.d.ts +3 -0
  6. package/src/contractFacet/reallocate.d.ts.map +1 -0
  7. package/src/contractFacet/reallocate.js +94 -0
  8. package/src/contractFacet/types.d.ts +16 -1
  9. package/src/contractFacet/types.d.ts.map +1 -1
  10. package/src/contractFacet/types.js +20 -0
  11. package/src/contractFacet/zcfSeat.d.ts.map +1 -1
  12. package/src/contractFacet/zcfSeat.js +104 -3
  13. package/src/contractFacet/zcfZygote.d.ts.map +1 -1
  14. package/src/contractFacet/zcfZygote.js +31 -22
  15. package/src/contractSupport/atomicTransfer.d.ts +0 -6
  16. package/src/contractSupport/atomicTransfer.d.ts.map +1 -1
  17. package/src/contractSupport/atomicTransfer.js +5 -90
  18. package/src/contractSupport/zoeHelpers.d.ts.map +1 -1
  19. package/src/contractSupport/zoeHelpers.js +3 -10
  20. package/src/contracts/auction/firstPriceLogic.d.ts.map +1 -1
  21. package/src/contracts/auction/firstPriceLogic.js +1 -3
  22. package/src/contracts/auction/secondPriceLogic.d.ts.map +1 -1
  23. package/src/contracts/auction/secondPriceLogic.js +1 -3
  24. package/src/contracts/autoswap.d.ts.map +1 -1
  25. package/src/contracts/autoswap.js +3 -7
  26. package/src/contracts/barterExchange.d.ts.map +1 -1
  27. package/src/contracts/barterExchange.js +2 -3
  28. package/src/contracts/callSpread/fundedCallSpread.d.ts.map +1 -1
  29. package/src/contracts/callSpread/fundedCallSpread.js +1 -3
  30. package/src/contracts/callSpread/pricedCallSpread.d.ts.map +1 -1
  31. package/src/contracts/callSpread/pricedCallSpread.js +1 -3
  32. package/src/contracts/loan/borrow.d.ts.map +1 -1
  33. package/src/contracts/loan/borrow.js +1 -3
  34. package/src/contracts/loan/close.d.ts.map +1 -1
  35. package/src/contracts/loan/close.js +2 -6
  36. package/src/contracts/scaledPriceAuthority.d.ts +10 -1
  37. package/src/contracts/scaledPriceAuthority.d.ts.map +1 -1
  38. package/src/contracts/scaledPriceAuthority.js +8 -1
  39. package/src/contracts/sellItems.d.ts.map +1 -1
  40. package/src/contracts/sellItems.js +1 -3
  41. package/src/internal-types.d.ts +1 -1
  42. package/src/internal-types.d.ts.map +1 -1
  43. package/src/internal-types.js +1 -1
@@ -1,23 +1,11 @@
1
- import { mustMatch, M } from '@agoric/store';
2
- import { assertRightsConserved } from '../contractFacet/rightsConservation.js';
1
+ import { M } from '@agoric/store';
3
2
  import { AmountKeywordRecordShape, SeatShape } from '../typeGuards.js';
4
3
 
5
- const { Fail, quote: q } = assert;
6
-
7
4
  export const TransferPartShape = M.splitArray(
8
5
  harden([M.opt(SeatShape), M.opt(SeatShape), M.opt(AmountKeywordRecordShape)]),
9
6
  harden([M.opt(AmountKeywordRecordShape)]),
10
7
  );
11
8
 
12
- /**
13
- * @typedef {[
14
- * fromSeat?: ZCFSeat,
15
- * toSeat?: ZCFSeat,
16
- * fromAmounts?: AmountKeywordRecord,
17
- * toAmounts?: AmountKeywordRecord
18
- * ]} TransferPart
19
- */
20
-
21
9
  /**
22
10
  * Asks Zoe (via zcf) to rearrange the allocations among the seats
23
11
  * mentioned. This is a set of changes to allocations that must satisfy
@@ -52,86 +40,13 @@ export const TransferPartShape = M.splitArray(
52
40
  * which will remain helpers. These helper are for convenience
53
41
  * in expressing atomic rearrangements clearly.
54
42
  *
43
+ * @deprecated use the zcf builtin instead
44
+ *
55
45
  * @param {ZCF} zcf
56
46
  * @param {TransferPart[]} transfers
57
47
  */
58
48
  export const atomicRearrange = (zcf, transfers) => {
59
- mustMatch(transfers, M.arrayOf(M.array()), 'transfers');
60
- const uniqueSeatSet = new Set();
61
- for (const [
62
- fromSeat = undefined,
63
- toSeat = undefined,
64
- fromAmounts = undefined,
65
- toAmounts = undefined,
66
- ] of transfers) {
67
- if (fromSeat) {
68
- if (!fromAmounts) {
69
- throw Fail`Transfer from ${fromSeat} must say how much`;
70
- }
71
- uniqueSeatSet.add(fromSeat);
72
- if (toSeat) {
73
- // Conserved transfer between seats
74
- if (toAmounts) {
75
- // distinct amounts, so we check conservation.
76
- assertRightsConserved(
77
- Object.values(fromAmounts),
78
- Object.values(toAmounts),
79
- );
80
- } // else fromAmounts will be used as toAmounts
81
- uniqueSeatSet.add(toSeat);
82
- } else {
83
- // Transfer only from fromSeat
84
- !toAmounts ||
85
- Fail`Transfer without toSeat cannot have toAmounts ${toAmounts}`;
86
- }
87
- } else {
88
- toSeat || Fail`Transfer must have at least one of fromSeat or toSeat`;
89
- // Transfer only to toSeat
90
- !fromAmounts ||
91
- Fail`Transfer without fromSeat cannot have fromAmounts ${fromAmounts}`;
92
- toAmounts || Fail`Transfer to ${toSeat} must say how much`;
93
- uniqueSeatSet.add(toSeat);
94
- }
95
- }
96
-
97
- const uniqueSeats = harden([...uniqueSeatSet.keys()]);
98
- for (const seat of uniqueSeats) {
99
- !seat.hasStagedAllocation() ||
100
- Fail`Cannot mix atomicRearrange with seat stagings: ${seat}`;
101
- }
102
-
103
- // At this point the basic shape has been validated
104
-
105
- try {
106
- for (const [
107
- fromSeat = undefined,
108
- toSeat = undefined,
109
- fromAmounts = undefined,
110
- toAmounts = toSeat && fromAmounts,
111
- ] of transfers) {
112
- if (fromSeat && fromAmounts) {
113
- // testing both just to satisfy the type checker
114
- fromSeat.decrementBy(fromAmounts);
115
- }
116
- if (toSeat && toAmounts) {
117
- // testing both just to satisfy the type checker
118
- toSeat.incrementBy(toAmounts);
119
- }
120
- }
121
-
122
- // Perhaps deprecate this >= 2 restriction?
123
- uniqueSeats.length >= 2 ||
124
- Fail`Can only commit a reallocation among at least 2 seats: ${q(
125
- uniqueSeats.length,
126
- )}`;
127
- // Take it apart and put it back together to satisfy the type checker
128
- const [seat0, seat1, ...restSeats] = uniqueSeats;
129
- zcf.reallocate(seat0, seat1, ...restSeats);
130
- } finally {
131
- for (const seat of uniqueSeats) {
132
- seat.clear();
133
- }
134
- }
49
+ zcf.atomicRearrange(transfers);
135
50
  };
136
51
 
137
52
  /**
@@ -179,4 +94,4 @@ export const atomicTransfer = (
179
94
  toSeat = undefined,
180
95
  fromAmounts = undefined,
181
96
  toAmounts = undefined,
182
- ) => atomicRearrange(zcf, harden([[fromSeat, toSeat, fromAmounts, toAmounts]]));
97
+ ) => zcf.atomicRearrange(harden([[fromSeat, toSeat, fromAmounts, toAmounts]]));
@@ -1 +1 @@
1
- {"version":3,"file":"zoeHelpers.d.ts","sourceRoot":"","sources":["zoeHelpers.js"],"names":[],"mappings":"AAaA,iIAAkI;AAM3H,oEAON;AAuBM,+BALI,GAAG,QACH,cAAc,UACd,mBAAmB,GACjB,CAAC,GAAC,CAAC,CAOf;AAED,mBAAmB;AACnB,mBADW,IAAI,CAmBb;AAEF,wBAAwB;AACxB,wBADW,SAAS,CAsBlB;AAiBK,uCAHI,OAAO,iBACP,OAAO,QAIgD;AAsB3D,0CAHI,OAAO,YACP,cAAc,QA+BxB;AAGM,+DAGN;AAED,6EAA8E;AAavE,mCANI,GAAG,iBACH,OAAO,WACP,mBAAmB,YACnB,qBAAqB,GACnB,QAAQ,MAAM,CAAC,CA8B3B;AAYM,sCALI,GAAG,QACH,OAAO,WACP,mBAAmB,GACjB,QAAQ,qBAAqB,CAAC,CAQ1C;AAWM,oCAJI,GAAG,wBACH,mBAAmB,8CAgB7B;AAED,0BAA0B;AAC1B,0BADW,WAAW,CAYpB;AAiDK,2EAjCI,GAAG,sDAMH,oBAAoB,GAAG,SAAS,YAKhC,QAAQ,YAGR,OAAO;;eAU2D,QAAQ,mBAAmB,CAAC;GA+DxG;;iBA3Va,MAAM,cAAc;0BACpB,MAAM,UAAU"}
1
+ {"version":3,"file":"zoeHelpers.d.ts","sourceRoot":"","sources":["zoeHelpers.js"],"names":[],"mappings":"AAQA,iIAAkI;AAM3H,oEAON;AAuBM,+BALI,GAAG,QACH,cAAc,UACd,mBAAmB,GACjB,CAAC,GAAC,CAAC,CAOf;AAED,mBAAmB;AACnB,mBADW,IAAI,CAkBb;AAEF,wBAAwB;AACxB,wBADW,SAAS,CAqBlB;AAiBK,uCAHI,OAAO,iBACP,OAAO,QAIgD;AAsB3D,0CAHI,OAAO,YACP,cAAc,QA+BxB;AAGM,+DAGN;AAED,6EAA8E;AAavE,mCANI,GAAG,iBACH,OAAO,WACP,mBAAmB,YACnB,qBAAqB,GACnB,QAAQ,MAAM,CAAC,CA8B3B;AAYM,sCALI,GAAG,QACH,OAAO,WACP,mBAAmB,GACjB,QAAQ,qBAAqB,CAAC,CAQ1C;AAWM,oCAJI,GAAG,wBACH,mBAAmB,8CAgB7B;AAED,0BAA0B;AAC1B,0BADW,WAAW,CAYpB;AAiDK,2EAjCI,GAAG,sDAMH,oBAAoB,GAAG,SAAS,YAKhC,QAAQ,YAGR,OAAO;;eAU2D,QAAQ,mBAAmB,CAAC;GA+DxG;;iBAzVa,MAAM,cAAc;0BACpB,MAAM,UAAU"}
@@ -4,12 +4,7 @@ import { makePromiseKit } from '@endo/promise-kit';
4
4
  import { AssetKind } from '@agoric/ertp';
5
5
  import { fromUniqueEntries } from '@agoric/internal';
6
6
  import { satisfiesWant } from '../contractFacet/offerSafety.js';
7
- import {
8
- atomicRearrange,
9
- atomicTransfer,
10
- fromOnly,
11
- toOnly,
12
- } from './atomicTransfer.js';
7
+ import { atomicTransfer, fromOnly, toOnly } from './atomicTransfer.js';
13
8
 
14
9
  export const defaultAcceptanceMsg = `The offer has been accepted. Once the contract has been completed, please check your payout`;
15
10
 
@@ -57,8 +52,7 @@ export const satisfies = (zcf, seat, update) => {
57
52
  /** @type {Swap} */
58
53
  export const swap = (zcf, leftSeat, rightSeat) => {
59
54
  try {
60
- atomicRearrange(
61
- zcf,
55
+ zcf.atomicRearrange(
62
56
  harden([
63
57
  [rightSeat, leftSeat, leftSeat.getProposal().want],
64
58
  [leftSeat, rightSeat, rightSeat.getProposal().want],
@@ -78,8 +72,7 @@ export const swap = (zcf, leftSeat, rightSeat) => {
78
72
  /** @type {SwapExact} */
79
73
  export const swapExact = (zcf, leftSeat, rightSeat) => {
80
74
  try {
81
- atomicRearrange(
82
- zcf,
75
+ zcf.atomicRearrange(
83
76
  harden([
84
77
  fromOnly(rightSeat, rightSeat.getProposal().give),
85
78
  fromOnly(leftSeat, leftSeat.getProposal().give),
@@ -1 +1 @@
1
- {"version":3,"file":"firstPriceLogic.d.ts","sourceRoot":"","sources":["firstPriceLogic.js"],"names":[],"mappings":"AAQO,wCAJI,GAAG,YACH,OAAO,YACP,MAAM,OAAO,CAAC,QAqDxB"}
1
+ {"version":3,"file":"firstPriceLogic.d.ts","sourceRoot":"","sources":["firstPriceLogic.js"],"names":[],"mappings":"AAOO,wCAJI,GAAG,YACH,OAAO,YACP,MAAM,OAAO,CAAC,QAoDxB"}
@@ -1,5 +1,4 @@
1
1
  import { AmountMath } from '@agoric/ertp';
2
- import { atomicRearrange } from '../../contractSupport/index.js';
3
2
 
4
3
  /**
5
4
  * @param {ZCF} zcf
@@ -42,8 +41,7 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
42
41
  }
43
42
 
44
43
  // Everyone else gets a refund so their values remain the same.
45
- atomicRearrange(
46
- zcf,
44
+ zcf.atomicRearrange(
47
45
  harden([
48
46
  [highestBidSeat, sellSeat, { Bid: highestBid }, { Ask: highestBid }],
49
47
  [sellSeat, highestBidSeat, { Asset: assetAmount }],
@@ -1 +1 @@
1
- {"version":3,"file":"secondPriceLogic.d.ts","sourceRoot":"","sources":["secondPriceLogic.js"],"names":[],"mappings":"AAQO,wCAJI,GAAG,YACH,OAAO,YACP,MAAM,OAAO,CAAC,QAgExB"}
1
+ {"version":3,"file":"secondPriceLogic.d.ts","sourceRoot":"","sources":["secondPriceLogic.js"],"names":[],"mappings":"AAOO,wCAJI,GAAG,YACH,OAAO,YACP,MAAM,OAAO,CAAC,QA+DxB"}
@@ -1,5 +1,4 @@
1
1
  import { AmountMath } from '@agoric/ertp';
2
- import { atomicRearrange } from '../../contractSupport/index.js';
3
2
 
4
3
  /**
5
4
  * @param {ZCF} zcf
@@ -48,8 +47,7 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
48
47
  }
49
48
 
50
49
  // Everyone else gets a refund so their values remain the same.
51
- atomicRearrange(
52
- zcf,
50
+ zcf.atomicRearrange(
53
51
  harden([
54
52
  [
55
53
  highestBidSeat,
@@ -1 +1 @@
1
- {"version":3,"file":"autoswap.d.ts","sourceRoot":"","sources":["autoswap.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,2BAFW,GAAG;;GAuVb"}
1
+ {"version":3,"file":"autoswap.d.ts","sourceRoot":"","sources":["autoswap.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,2BAFW,GAAG;;GAoVb"}
@@ -11,7 +11,6 @@ import {
11
11
  assertProposalShape,
12
12
  assertNatAssetKind,
13
13
  calcSecondaryRequired,
14
- atomicRearrange,
15
14
  } from '../contractSupport/index.js';
16
15
 
17
16
  /**
@@ -88,8 +87,7 @@ const start = async zcf => {
88
87
  };
89
88
 
90
89
  function consummate(tradeAmountIn, tradeAmountOut, swapSeat) {
91
- atomicRearrange(
92
- zcf,
90
+ zcf.atomicRearrange(
93
91
  harden([
94
92
  [
95
93
  swapSeat,
@@ -205,8 +203,7 @@ const start = async zcf => {
205
203
  Central: AmountMath.make(brands.Central, centralIn),
206
204
  Secondary: secondaryAmount,
207
205
  };
208
- atomicRearrange(
209
- zcf,
206
+ zcf.atomicRearrange(
210
207
  harden([
211
208
  [seat, poolSeat, liquidityDeposited],
212
209
  [poolSeat, seat, { Liquidity: liquidityAmountOut }],
@@ -308,8 +305,7 @@ const start = async zcf => {
308
305
  Secondary: newUserSecondaryAmount,
309
306
  };
310
307
 
311
- atomicRearrange(
312
- zcf,
308
+ zcf.atomicRearrange(
313
309
  harden([
314
310
  [removeLiqSeat, poolSeat, { Liquidity: userAllocation.Liquidity }],
315
311
  [poolSeat, removeLiqSeat, liquidityRemoved],
@@ -1 +1 @@
1
- {"version":3,"file":"barterExchange.d.ts","sourceRoot":"","sources":["barterExchange.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,2BAFW,GAAG;;;;;;EAgHb"}
1
+ {"version":3,"file":"barterExchange.d.ts","sourceRoot":"","sources":["barterExchange.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,2BAFW,GAAG;;;;;;EA+Gb"}
@@ -1,7 +1,7 @@
1
1
  import { Far } from '@endo/marshal';
2
2
  import { makeLegacyMap } from '@agoric/store';
3
3
  // Eventually will be importable from '@agoric/zoe-contract-support'
4
- import { satisfies, atomicRearrange } from '../contractSupport/index.js';
4
+ import { satisfies } from '../contractSupport/index.js';
5
5
 
6
6
  /**
7
7
  * This Barter Exchange accepts offers to trade arbitrary goods for other
@@ -63,8 +63,7 @@ const start = zcf => {
63
63
  const matchingTrade = findMatchingTrade(offerDetails, orders);
64
64
  if (matchingTrade) {
65
65
  // reallocate by giving each side what it wants
66
- atomicRearrange(
67
- zcf,
66
+ zcf.atomicRearrange(
68
67
  harden([
69
68
  [
70
69
  offerDetails.seat,
@@ -1 +1 @@
1
- {"version":3,"file":"fundedCallSpread.d.ts","sourceRoot":"","sources":["fundedCallSpread.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;;GASG;AACH;kBARiB,MAAM;kBACN,MAAM;sBACF,MAAM;oBACR,cAAc;gBAClB,MAAM;sBACA,MAAM;;;GA+E1B"}
1
+ {"version":3,"file":"fundedCallSpread.d.ts","sourceRoot":"","sources":["fundedCallSpread.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;;GASG;AACH;kBARiB,MAAM;kBACN,MAAM;sBACF,MAAM;oBACR,cAAc;gBAClB,MAAM;sBACA,MAAM;;;GA8E1B"}
@@ -7,7 +7,6 @@ import {
7
7
  assertProposalShape,
8
8
  depositToSeat,
9
9
  assertNatAssetKind,
10
- atomicRearrange,
11
10
  } from '../../contractSupport/index.js';
12
11
  import { makePayoffHandler } from './payoffHandler.js';
13
12
  import { Position } from './position.js';
@@ -112,8 +111,7 @@ const start = async zcf => {
112
111
  give: { Collateral: null },
113
112
  want: { LongOption: null, ShortOption: null },
114
113
  });
115
- atomicRearrange(
116
- zcf,
114
+ zcf.atomicRearrange(
117
115
  harden([
118
116
  [creatorSeat, collateralSeat, { Collateral: settlementAmount }],
119
117
  [
@@ -1 +1 @@
1
- {"version":3,"file":"pricedCallSpread.d.ts","sourceRoot":"","sources":["pricedCallSpread.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;kBARiB,OAAO,KAAK,CAAC;kBACb,OAAO,KAAK,CAAC;sBACT,OAAO,KAAK,CAAC;oBACf,cAAc;gBAClB,MAAM;sBACA,OAAO,KAAK,CAAC;;;;;;;;;;;;;EA2GjC"}
1
+ {"version":3,"file":"pricedCallSpread.d.ts","sourceRoot":"","sources":["pricedCallSpread.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;kBARiB,OAAO,KAAK,CAAC;kBACb,OAAO,KAAK,CAAC;sBACT,OAAO,KAAK,CAAC;oBACf,cAAc;gBAClB,MAAM;sBACA,OAAO,KAAK,CAAC;;;;;;;;;;;;;EA0GjC"}
@@ -10,7 +10,6 @@ import {
10
10
  assertNatAssetKind,
11
11
  makeRatio,
12
12
  ceilMultiplyBy,
13
- atomicRearrange,
14
13
  } from '../../contractSupport/index.js';
15
14
  import { makePayoffHandler } from './payoffHandler.js';
16
15
  import { Position } from './position.js';
@@ -132,8 +131,7 @@ const start = zcf => {
132
131
  'wanted option not a match',
133
132
  );
134
133
 
135
- atomicRearrange(
136
- zcf,
134
+ zcf.atomicRearrange(
137
135
  harden([
138
136
  [collateralSeat, depositSeat, spreadAmount],
139
137
  [depositSeat, collateralSeat, { Collateral: newCollateral }],
@@ -1 +1 @@
1
- {"version":3,"file":"borrow.d.ts","sourceRoot":"","sources":["borrow.js"],"names":[],"mappings":"AAmBA,mCAAmC;AACnC,mCADW,oBAAoB,CAkI7B"}
1
+ {"version":3,"file":"borrow.d.ts","sourceRoot":"","sources":["borrow.js"],"names":[],"mappings":"AAkBA,mCAAmC;AACnC,mCADW,oBAAoB,CAiI7B"}
@@ -9,7 +9,6 @@ import {
9
9
  getAmountOut,
10
10
  ceilMultiplyBy,
11
11
  getTimestamp,
12
- atomicRearrange,
13
12
  } from '../../contractSupport/index.js';
14
13
 
15
14
  import { scheduleLiquidation } from './scheduleLiquidation.js';
@@ -72,8 +71,7 @@ export const makeBorrowInvitation = (zcf, config) => {
72
71
 
73
72
  const { zcfSeat: collateralSeat } = zcf.makeEmptySeatKit();
74
73
 
75
- atomicRearrange(
76
- zcf,
74
+ zcf.atomicRearrange(
77
75
  harden([
78
76
  // Transfer the wanted Loan amount to the borrower
79
77
  [lenderSeat, borrowerSeat, { Loan: loanWanted }],
@@ -1 +1 @@
1
- {"version":3,"file":"close.d.ts","sourceRoot":"","sources":["close.js"],"names":[],"mappings":"AAeA,sCAAsC;AACtC,sCADW,uBAAuB,CAkDhC"}
1
+ {"version":3,"file":"close.d.ts","sourceRoot":"","sources":["close.js"],"names":[],"mappings":"AAYA,sCAAsC;AACtC,sCADW,uBAAuB,CAiDhC"}
@@ -3,10 +3,7 @@ import './types.js';
3
3
  import { Fail } from '@agoric/assert';
4
4
  import { AmountMath } from '@agoric/ertp';
5
5
 
6
- import {
7
- assertProposalShape,
8
- atomicRearrange,
9
- } from '../../contractSupport/index.js';
6
+ import { assertProposalShape } from '../../contractSupport/index.js';
10
7
 
11
8
  // The debt, the amount which must be repaid, is just the amount
12
9
  // loaned plus interest (aka stability fee). All debt must be repaid
@@ -44,8 +41,7 @@ export const makeCloseLoanInvitation = (zcf, config) => {
44
41
  'Collateral',
45
42
  collateralBrand,
46
43
  );
47
- atomicRearrange(
48
- zcf,
44
+ zcf.atomicRearrange(
49
45
  harden([
50
46
  [collateralSeat, repaySeat, { Collateral: collateralAmount }],
51
47
  [repaySeat, lenderSeat, { Loan: debt }],
@@ -1,4 +1,13 @@
1
- export function prepare(zcf: ZCF<ScaledPriceAuthorityOpts>, privateArgs: object, baggage: MapStore<string, unknown>): Promise<{
1
+ /**
2
+ * @typedef {object} ScaledPriceAuthorityOpts
3
+ * @property {ERef<PriceAuthority>} sourcePriceAuthority
4
+ * @property {Ratio} scaleIn - sourceAmountIn:targetAmountIn
5
+ * @property {Ratio} scaleOut - sourceAmountOut:targetAmountOut
6
+ * @property {Ratio} [initialPrice] - targetAmountIn:targetAmountOut
7
+ */
8
+ /** @type {ContractMeta} */
9
+ export const meta: ContractMeta;
10
+ export function start(zcf: ZCF<ScaledPriceAuthorityOpts>, privateArgs: object, baggage: MapStore<string, unknown>): Promise<{
2
11
  publicFacet: {
3
12
  getPriceAuthority: () => Promise<PriceAuthority>;
4
13
  } & import("@endo/eventual-send").RemotableBrand<{}, {
@@ -1 +1 @@
1
- {"version":3,"file":"scaledPriceAuthority.d.ts","sourceRoot":"","sources":["scaledPriceAuthority.js"],"names":[],"mappings":"AAgCO,6BAJI,IAAI,wBAAwB,CAAC,eAC7B,MAAM;;;;;;GAyDhB;;0BAzEa,KAAK,cAAc,CAAC;;;;aACpB,KAAK;;;;cACL,KAAK"}
1
+ {"version":3,"file":"scaledPriceAuthority.d.ts","sourceRoot":"","sources":["scaledPriceAuthority.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAGrB;AAgBK,2BAJI,IAAI,wBAAwB,CAAC,eAC7B,MAAM;;;;;;GAyDhB;;0BA/Ea,KAAK,cAAc,CAAC;;;;aACpB,KAAK;;;;cACL,KAAK"}
@@ -17,6 +17,12 @@ import { provideQuoteMint } from '../contractSupport/priceAuthorityQuoteMint.js'
17
17
  * @property {Ratio} [initialPrice] - targetAmountIn:targetAmountOut
18
18
  */
19
19
 
20
+ /** @type {ContractMeta} */
21
+ export const meta = {
22
+ upgradability: 'canUpgrade',
23
+ };
24
+ harden(meta);
25
+
20
26
  /**
21
27
  * A contract that scales a source price authority to a target price authority
22
28
  * via ratios.
@@ -30,7 +36,7 @@ import { provideQuoteMint } from '../contractSupport/priceAuthorityQuoteMint.js'
30
36
  * @param {object} privateArgs
31
37
  * @param {import('@agoric/vat-data').Baggage} baggage
32
38
  */
33
- export const prepare = async (zcf, privateArgs, baggage) => {
39
+ export const start = async (zcf, privateArgs, baggage) => {
34
40
  const quoteMint = provideQuoteMint(baggage);
35
41
 
36
42
  const { sourcePriceAuthority, scaleIn, scaleOut, initialPrice } =
@@ -85,3 +91,4 @@ export const prepare = async (zcf, privateArgs, baggage) => {
85
91
  );
86
92
  return harden({ publicFacet });
87
93
  };
94
+ harden(start);
@@ -1 +1 @@
1
- {"version":3,"file":"sellItems.d.ts","sourceRoot":"","sources":["sellItems.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;kBAF8B,OAAO,KAAK,CAAC;;;;;EAwH1C"}
1
+ {"version":3,"file":"sellItems.d.ts","sourceRoot":"","sources":["sellItems.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;kBAF8B,OAAO,KAAK,CAAC;;;;;EAuH1C"}
@@ -11,7 +11,6 @@ import {
11
11
  defaultAcceptanceMsg,
12
12
  assertProposalShape,
13
13
  assertNatAssetKind,
14
- atomicRearrange,
15
14
  } from '../contractSupport/index.js';
16
15
 
17
16
  const { Fail } = assert;
@@ -107,8 +106,7 @@ const start = zcf => {
107
106
  Fail`More money (${totalCost}) is required to buy these items`;
108
107
 
109
108
  // Reallocate.
110
- atomicRearrange(
111
- zcf,
109
+ zcf.atomicRearrange(
112
110
  harden([
113
111
  [buyerSeat, sellerSeat, { Money: providedMoney }],
114
112
  [sellerSeat, buyerSeat, { Items: wantedItems }],
@@ -114,7 +114,7 @@ type ZCFRoot = {
114
114
  };
115
115
  type ExecuteContractResult = {
116
116
  creatorFacet: object;
117
- creatorInvitation: Promise<Invitation>;
117
+ creatorInvitation?: Promise<Invitation<R, A>> | undefined;
118
118
  publicFacet: object;
119
119
  handleOfferObj: HandleOfferObj;
120
120
  };
@@ -1 +1 @@
1
- {"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["internal-types.js"],"names":[],"mappings":";cAIc,cAAc;uBACd,UAAU;gBACV,UAAU;gBACV,MAAM;;;;;qCAOT,UAAU,KACR,qBAAqB;;mCAKR,UAAU,KAAK,qBAAqB;;;qCAKjC,YAAY,KAAK,IAAI;8BACrB,YAAY,KAAK,OAAO;;;cAKvC,QAAQ;kBACR,YAAY;;;;;+CAMf,UAAU,uBACV,mBAAmB,YACnB,cAAc,iBACd,aAAa,WACb,KAAK,OAAO,CAAC,gBACb,KAAK,OAAO,CAAC,yCAEX,eAAe;sCAKjB,UAAU,KACR,IAAI;;oCAKU,UAAU,KAAK,IAAI;UAChC,gBAAgB;;;;;UAChB,mBAAmB;uBAEnB,MAAM,WAAW,mBAAmB,CAAC;;;wBASrC,QAAQ,OAAO,CAAC;aAChB,OAAO;;;;;;;;2BASP,MAAM,IAAI;qCACS,gBAAgB,qBACvB,UAAU,YACnB,cAAc,cACZ,MAAM,KACjB,QAAQ;sBACF,gBAAgB;iBAChB,MAAM,QAAQ;oBACd,MAAM,MAAM;gBACZ,MAAM,mBAAmB;eACzB,MAAM,kBAAkB;cACxB,MAAM,MAAM;oBACZ,MAAM,MAAM,EAAE;qBAC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ACtB,cAAc,qDAEd,MAAM,KACJ,QAAQ,qBAAqB,CAAC;sCAKhC,MAAM,KACJ,yCAAyC;8BAK3C,cAAc,gBACd,OAAO,KACL,OAAO;;UAKN,MAAM,IAAI;;kBAIX,OAAO,MAAM,CAAC;;;;;;mCAShB,KAAK,KACH,SAAS;qBAIT,MAAM,YAAY,CAAC;8BAKrB,QAAQ,KACN,OAAO;;;;;+BAQP,IAAI;;iBAKH,WAAW;gBACX,UAAU;uBACV,iBAAiB;;;0BAKP,OAAO,iBAAiB,UAAU,KAAK,IAAI;;;;;;4CASxD,KAAK,gBAAgB,CAAC,uBACtB,mBAAmB,uBACnB,mBAAmB,4CAEjB;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,kBAAkB,EAAE,kBAAkB,CAAA;CAAE;;;;;wCASzE,OAAO,gBACP,YAAY,KACV,IAAI;mCAKJ,QAAQ;0CAKR,YAAY;sCAKZ,mBAAmB;qCAKnB,kBAAkB;;eAKjB,sBAAsB;uBACtB,iBAAiB;cACjB,qBAAqB;qBACrB,4BAA4B;gBAC5B,wBAAwB;eACxB,uBAAuB;mCACb,OAAO,KAAK,IAAI;;+BAK3B,cAAc;+CAKhB,MAAM,EAAE"}
@@ -204,7 +204,7 @@
204
204
  /**
205
205
  * @typedef {object} ExecuteContractResult
206
206
  * @property {object} creatorFacet
207
- * @property {Promise<Invitation>} creatorInvitation
207
+ * @property {Promise<Invitation>} [creatorInvitation]
208
208
  * @property {object} publicFacet
209
209
  * @property {HandleOfferObj} handleOfferObj
210
210
  */