Skip to content

Commit

Permalink
feat: update computeWeights
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Dec 11, 2023
1 parent 0609815 commit 0f9c8c2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions contracts/strategies/G3MStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,22 @@ contract G3MStrategy is IG3MStrategy {
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 (config.startWeightX < config.endWeightX) {
uint256 fw0 =
G3MStrategyLib.computeISFunction(config.startWeightX);
uint256 fw1 =
G3MStrategyLib.computeISFunction(config.endWeightX);
weightX = G3MStrategyLib.computeSFunction(t, fw1 - fw0, fw0);
weightY = WAD - weightX;
} else {
uint256 fw0 =
G3MStrategyLib.computeISFunction(WAD - config.startWeightX);
uint256 fw1 =
G3MStrategyLib.computeISFunction(WAD - config.endWeightX);
weightY = G3MStrategyLib.computeSFunction(t, fw1 - fw0, fw0);
weightX = WAD - weightY;
}
}
}
}

0 comments on commit 0f9c8c2

Please sign in to comment.