@morpho-org/morpho-sdk 6.3.0 → 6.3.1
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.
|
@@ -372,8 +372,9 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
372
372
|
* or allocator capacity are skipped before projecting source interest. The
|
|
373
373
|
* adapter's minimum share minting requirement, supply-share limits, and target
|
|
374
374
|
* absolute or zero relative caps are checked against a one-asset deposit.
|
|
375
|
-
* Shared cap IDs that a source withdrawal can reduce remain eligible
|
|
376
|
-
*
|
|
375
|
+
* Shared cap IDs that a source withdrawal can reduce remain eligible. Each
|
|
376
|
+
* accepted leg counts at least its requested `assets` against the target cap
|
|
377
|
+
* IDs, so a leg sized to a cap leaves no rounding headroom.
|
|
377
378
|
*
|
|
378
379
|
* Shared-cap discovery is conservative. Operation planning searches at most
|
|
379
380
|
* 1,024 base units above its targeted amount for the nearest executable fit.
|
|
@@ -573,8 +573,9 @@ class VaultV2BlueReallocationData {
|
|
|
573
573
|
* or allocator capacity are skipped before projecting source interest. The
|
|
574
574
|
* adapter's minimum share minting requirement, supply-share limits, and target
|
|
575
575
|
* absolute or zero relative caps are checked against a one-asset deposit.
|
|
576
|
-
* Shared cap IDs that a source withdrawal can reduce remain eligible
|
|
577
|
-
*
|
|
576
|
+
* Shared cap IDs that a source withdrawal can reduce remain eligible. Each
|
|
577
|
+
* accepted leg counts at least its requested `assets` against the target cap
|
|
578
|
+
* IDs, so a leg sized to a cap leaves no rounding headroom.
|
|
578
579
|
*
|
|
579
580
|
* Shared-cap discovery is conservative. Operation planning searches at most
|
|
580
581
|
* 1,024 base units above its targeted amount for the nearest executable fit.
|
|
@@ -862,7 +863,7 @@ class VaultV2BlueReallocationData {
|
|
|
862
863
|
untracked +
|
|
863
864
|
targetPair.reserve());
|
|
864
865
|
const minimumAllocation = minimumSupply.market.toSupplyAssets(adapterShares + minimumSupply.shares);
|
|
865
|
-
const minimumAllocationChange = minimumAllocation - adapterMarketCapAllocation.allocation;
|
|
866
|
+
const minimumAllocationChange = blue_sdk_1.MathLib.max(minimumAllocation - adapterMarketCapAllocation.allocation, minimumSupply.assets);
|
|
866
867
|
const blockedTargetIds = targetAllocations
|
|
867
868
|
.filter(({ allocation, absoluteCap, relativeCap, id }) => {
|
|
868
869
|
const nextAllocation = allocation +
|
|
@@ -1367,21 +1368,15 @@ class VaultV2BlueReallocationData {
|
|
|
1367
1368
|
if (!targetAdapter.markets.some(({ id }) => id === targetMarket.id))
|
|
1368
1369
|
targetAdapter.markets.push(supply.market);
|
|
1369
1370
|
data.setMarkets([supply.market], probe ? [targetAdapter] : undefined);
|
|
1370
|
-
const
|
|
1371
|
+
const simulatedChange = supply.market.toSupplyAssets(targetSupplyShares) - oldTargetAllocation;
|
|
1372
|
+
// The adapter's rounded expected-assets delta can differ by one wei at inclusion,
|
|
1373
|
+
// so cap tracking assumes each accepted leg adds at least its requested assets.
|
|
1374
|
+
const targetChange = blue_sdk_1.MathLib.max(simulatedChange, reallocation.assets);
|
|
1371
1375
|
for (const id of targetIds) {
|
|
1372
1376
|
const allocation = data.getAllocation(reallocation.vault, id);
|
|
1373
|
-
const nextAllocation = allocation.allocation + targetChange;
|
|
1374
|
-
if (nextAllocation < 0n) {
|
|
1375
|
-
throw new index_js_1.ReallocationAllocationUnderflowError({
|
|
1376
|
-
vault: reallocation.vault,
|
|
1377
|
-
id,
|
|
1378
|
-
allocation: allocation.allocation,
|
|
1379
|
-
change: targetChange,
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
1377
|
data.mutableAllocations[allocationsKey][id] = {
|
|
1383
1378
|
...allocation,
|
|
1384
|
-
allocation:
|
|
1379
|
+
allocation: allocation.allocation + targetChange,
|
|
1385
1380
|
};
|
|
1386
1381
|
}
|
|
1387
1382
|
vault.assetBalance -= reallocation.assets;
|
|
@@ -372,8 +372,9 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
372
372
|
* or allocator capacity are skipped before projecting source interest. The
|
|
373
373
|
* adapter's minimum share minting requirement, supply-share limits, and target
|
|
374
374
|
* absolute or zero relative caps are checked against a one-asset deposit.
|
|
375
|
-
* Shared cap IDs that a source withdrawal can reduce remain eligible
|
|
376
|
-
*
|
|
375
|
+
* Shared cap IDs that a source withdrawal can reduce remain eligible. Each
|
|
376
|
+
* accepted leg counts at least its requested `assets` against the target cap
|
|
377
|
+
* IDs, so a leg sized to a cap leaves no rounding headroom.
|
|
377
378
|
*
|
|
378
379
|
* Shared-cap discovery is conservative. Operation planning searches at most
|
|
379
380
|
* 1,024 base units above its targeted amount for the nearest executable fit.
|
|
@@ -570,8 +570,9 @@ export class VaultV2BlueReallocationData {
|
|
|
570
570
|
* or allocator capacity are skipped before projecting source interest. The
|
|
571
571
|
* adapter's minimum share minting requirement, supply-share limits, and target
|
|
572
572
|
* absolute or zero relative caps are checked against a one-asset deposit.
|
|
573
|
-
* Shared cap IDs that a source withdrawal can reduce remain eligible
|
|
574
|
-
*
|
|
573
|
+
* Shared cap IDs that a source withdrawal can reduce remain eligible. Each
|
|
574
|
+
* accepted leg counts at least its requested `assets` against the target cap
|
|
575
|
+
* IDs, so a leg sized to a cap leaves no rounding headroom.
|
|
575
576
|
*
|
|
576
577
|
* Shared-cap discovery is conservative. Operation planning searches at most
|
|
577
578
|
* 1,024 base units above its targeted amount for the nearest executable fit.
|
|
@@ -859,7 +860,7 @@ export class VaultV2BlueReallocationData {
|
|
|
859
860
|
untracked +
|
|
860
861
|
targetPair.reserve());
|
|
861
862
|
const minimumAllocation = minimumSupply.market.toSupplyAssets(adapterShares + minimumSupply.shares);
|
|
862
|
-
const minimumAllocationChange = minimumAllocation - adapterMarketCapAllocation.allocation;
|
|
863
|
+
const minimumAllocationChange = MathLib.max(minimumAllocation - adapterMarketCapAllocation.allocation, minimumSupply.assets);
|
|
863
864
|
const blockedTargetIds = targetAllocations
|
|
864
865
|
.filter(({ allocation, absoluteCap, relativeCap, id }) => {
|
|
865
866
|
const nextAllocation = allocation +
|
|
@@ -1364,21 +1365,15 @@ export class VaultV2BlueReallocationData {
|
|
|
1364
1365
|
if (!targetAdapter.markets.some(({ id }) => id === targetMarket.id))
|
|
1365
1366
|
targetAdapter.markets.push(supply.market);
|
|
1366
1367
|
data.setMarkets([supply.market], probe ? [targetAdapter] : undefined);
|
|
1367
|
-
const
|
|
1368
|
+
const simulatedChange = supply.market.toSupplyAssets(targetSupplyShares) - oldTargetAllocation;
|
|
1369
|
+
// The adapter's rounded expected-assets delta can differ by one wei at inclusion,
|
|
1370
|
+
// so cap tracking assumes each accepted leg adds at least its requested assets.
|
|
1371
|
+
const targetChange = MathLib.max(simulatedChange, reallocation.assets);
|
|
1368
1372
|
for (const id of targetIds) {
|
|
1369
1373
|
const allocation = data.getAllocation(reallocation.vault, id);
|
|
1370
|
-
const nextAllocation = allocation.allocation + targetChange;
|
|
1371
|
-
if (nextAllocation < 0n) {
|
|
1372
|
-
throw new ReallocationAllocationUnderflowError({
|
|
1373
|
-
vault: reallocation.vault,
|
|
1374
|
-
id,
|
|
1375
|
-
allocation: allocation.allocation,
|
|
1376
|
-
change: targetChange,
|
|
1377
|
-
});
|
|
1378
|
-
}
|
|
1379
1374
|
data.mutableAllocations[allocationsKey][id] = {
|
|
1380
1375
|
...allocation,
|
|
1381
|
-
allocation:
|
|
1376
|
+
allocation: allocation.allocation + targetChange,
|
|
1382
1377
|
};
|
|
1383
1378
|
}
|
|
1384
1379
|
vault.assetBalance -= reallocation.assets;
|