Skip to content

Commit

Permalink
When bumping supply caps, bumps at least to min to avoid setting 0 (#637
Browse files Browse the repository at this point in the history
)

Noticed this due to a nonce issue in interest rate scens which were exercising utilization constraints, which were quietly failing to source collateral due to truncated supply caps.
  • Loading branch information
jflatow committed Dec 19, 2022
1 parent 2ef46ca commit 7435a05
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scenario/context/CometContext.ts
Expand Up @@ -32,7 +32,7 @@ import { sourceTokens } from '../../plugins/scenario/utils/TokenSourcer';
import { ProtocolConfiguration, deployComet, COMP_WHALES, WHALES } from '../../src/deploy';
import { AddressLike, getAddressFromNumber, resolveAddress } from './Address';
import { Requirements } from '../constraints/Requirements';
import { fastGovernanceExecute, mineBlocks, setNextBaseFeeToZero, setNextBlockTimestamp } from '../utils';
import { fastGovernanceExecute, max, mineBlocks, setNextBaseFeeToZero, setNextBlockTimestamp } from '../utils';

export type ActorMap = { [name: string]: CometActor };
export type AssetMap = { [name: string]: CometAsset };
Expand Down Expand Up @@ -151,13 +151,14 @@ export class CometContext {
const newTotalSupply = currentTotalSupply + supplyAmountPerAsset[asset];
if (newTotalSupply > assetInfo.supplyCap.toBigInt()) {
shouldUpgrade = true;
newSupplyCaps[asset] = newTotalSupply * 2n;
newSupplyCaps[asset] = max(newTotalSupply * 2n, assetInfo.scale.toBigInt());
}
}
}

// Set new supply caps in Configurator and do a deployAndUpgradeTo
if (shouldUpgrade) {
debug(`Bumping supply caps...`, comet.address, newSupplyCaps);
const gov = await this.world.impersonateAddress(await comet.governor(), 10n ** 18n);
const cometAdmin = (await this.getCometAdmin()).connect(gov);
const configurator = (await this.getConfigurator()).connect(gov);
Expand Down

0 comments on commit 7435a05

Please sign in to comment.