@agoric/portfolio-api 0.1.1-dev-14afd8f.0.14afd8f → 0.1.1-dev-776528e.0.776528e
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/package.json +4 -4
- package/src/target-balances.d.ts.map +1 -1
- package/src/target-balances.js +13 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/portfolio-api",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-776528e.0.776528e",
|
|
4
4
|
"description": "API for Portfolio management",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"generate:ymax-machine": "npx tsx scripts/gen-ymax-machine.mts"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@agoric/internal": "0.3.3-dev-
|
|
50
|
-
"@agoric/orchestration": "0.1.1-dev-
|
|
49
|
+
"@agoric/internal": "0.3.3-dev-776528e.0.776528e",
|
|
50
|
+
"@agoric/orchestration": "0.1.1-dev-776528e.0.776528e",
|
|
51
51
|
"@endo/common": "^1.2.13",
|
|
52
52
|
"@endo/errors": "^1.2.13",
|
|
53
53
|
"@endo/patterns": "^1.7.0"
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": "^22.11"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "776528eb7ca6f31911f2ca21a9702e20fdca2595"
|
|
93
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-balances.d.ts","sourceRoot":"","sources":["target-balances.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAO5E,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAA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/target-balances.js
CHANGED
|
@@ -334,6 +334,12 @@ export const computeTargetBalances = (
|
|
|
334
334
|
);
|
|
335
335
|
let remainder = liquidTotal;
|
|
336
336
|
const pending = new Set (Object.values(draft));
|
|
337
|
+
const claim = (chainName , value ) => {
|
|
338
|
+
const chainPlace = `@${chainName}` ;
|
|
339
|
+
draft[chainPlace] ??= makeDraftRecord(chainPlace);
|
|
340
|
+
draft[chainPlace].resolvedDelta += value;
|
|
341
|
+
if (!pending.has(draft[chainPlace])) remainder -= value;
|
|
342
|
+
};
|
|
337
343
|
for (const draftRecord of pending) {
|
|
338
344
|
pending.delete(draftRecord);
|
|
339
345
|
const { place, current, delta, resolvedDelta } = draftRecord;
|
|
@@ -347,30 +353,26 @@ export const computeTargetBalances = (
|
|
|
347
353
|
|
|
348
354
|
// This sink cannot receive its inbound funds. If its chain is a net source
|
|
349
355
|
// or neutral, we leave them at the local hub. Otherwise, we reduce the net
|
|
350
|
-
// outflow from one or more donor-chain hubs.
|
|
356
|
+
// outflow from one or more donor-chain hubs before adjusting the local hub.
|
|
351
357
|
remainder -= current;
|
|
352
358
|
const local = getPlaceData(place, network).chain;
|
|
353
|
-
const
|
|
359
|
+
const localDonorEntry = donorChainsDesc.find(([n]) => n === local.name) ;
|
|
360
|
+
const localNetOut = localDonorEntry[1];
|
|
354
361
|
if (localNetOut >= 0n) {
|
|
355
|
-
|
|
356
|
-
draft[chainPlace] ??= makeDraftRecord(chainPlace);
|
|
357
|
-
draft[chainPlace].resolvedDelta += delta;
|
|
358
|
-
if (!pending.has(draft[chainPlace])) remainder -= delta;
|
|
362
|
+
claim(local.name, delta);
|
|
359
363
|
} else {
|
|
360
364
|
let excess = delta;
|
|
361
365
|
for (const donorEntry of donorChainsDesc) {
|
|
362
366
|
const [chainName, netOut] = donorEntry;
|
|
363
367
|
if (excess === 0n || netOut <= 0n) break;
|
|
364
|
-
const chainPlace = `@${chainName}` ;
|
|
365
|
-
draft[chainPlace] ??= makeDraftRecord(chainPlace);
|
|
366
368
|
const d = bigintMin(excess, netOut);
|
|
367
|
-
|
|
368
|
-
draft[chainPlace].resolvedDelta += d;
|
|
369
|
+
claim(chainName, d);
|
|
369
370
|
donorEntry[1] -= d;
|
|
370
371
|
excess -= d;
|
|
371
372
|
}
|
|
372
373
|
if (excess !== 0n) {
|
|
373
|
-
|
|
374
|
+
claim(local.name, excess);
|
|
375
|
+
localDonorEntry[1] -= excess;
|
|
374
376
|
}
|
|
375
377
|
sortEntriesDesc(donorChainsDesc);
|
|
376
378
|
}
|