Skip to content

Commit

Permalink
feat: update computeWeights function
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Dec 8, 2023
1 parent 3863d0e commit 38151aa
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions contracts/strategies/G3MStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,19 @@ contract G3MStrategy is IG3MStrategy {
{
Config memory config = configs[poolId];

uint256 duration =
configs[poolId].endUpdate - configs[poolId].startUpdate;
uint256 timeElapsed = block.timestamp - configs[poolId].startUpdate;
uint256 t = timeElapsed * WAD / duration;
uint256 fw0 = G3MStrategyLib.computeISFunction(config.startWeightX);
uint256 fw1 = G3MStrategyLib.computeISFunction(config.endWeightX);

weightX = G3MStrategyLib.computeSFunction(t, fw1 - fw0, fw0);
weightY = WAD - weightX;
if (block.timestamp >= config.endUpdate) {
weightX = config.endWeightX;
weightY = WAD - config.endWeightX;
} else {
uint256 duration =
configs[poolId].endUpdate - configs[poolId].startUpdate;
uint256 timeElapsed = block.timestamp - configs[poolId].startUpdate;
uint256 t = timeElapsed * WAD / duration;
uint256 fw0 = G3MStrategyLib.computeISFunction(config.startWeightX);
uint256 fw1 = G3MStrategyLib.computeISFunction(config.endWeightX);

weightX = G3MStrategyLib.computeSFunction(t, fw1 - fw0, fw0);
weightY = WAD - weightX;
}
}
}

0 comments on commit 38151aa

Please sign in to comment.