Skip to content

Commit

Permalink
Merge pull request #411 from arthurka-o/KIP-3-remove-G
Browse files Browse the repository at this point in the history
KIP-3: remove G
  • Loading branch information
marceljay committed Sep 26, 2023
2 parents 322f0e6 + de6bd29 commit cfc6167
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/generic-skip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Test contracts (Generic Skip)

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
branches: ['main', 'dev', 'KIP-3']
paths-ignore:
- "packages/contracts/**"

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ env:

on:
push:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
branches: ['main', 'dev', 'KIP-3']
paths-ignore:
# In future file changes, we can delete the following line
# and uncomment the one below.
Expand All @@ -18,6 +20,8 @@ on:
- 'papers/**'
- 'images/**'
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
branches: ['main', 'dev', 'KIP-3']
paths-ignore:
# In future file changes, we can delete the following line
# and uncomment the one below.
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ env:

on:
push:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
branches: ['main', 'dev', 'KIP-3']
paths:
# In future file changes, we can uncomment the following line
# - ".github/workflows/test-contracts.yml"
- "packages/contracts/**"
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
branches: ['main', 'dev', 'KIP-3']
paths:
# In future file changes, we can uncomment the following line
# - ".github/workflows/test-contracts.yml"
Expand Down Expand Up @@ -42,7 +46,7 @@ jobs:

coverage:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'coverage') }}

continue-on-error: true

steps:
Expand Down
3 changes: 1 addition & 2 deletions packages/contracts/contracts/Interfaces/IStabilityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ interface IStabilityPool is IDeposit {

event P_Updated(uint256 _P);
event S_Updated(uint256 _S, uint128 _epoch, uint128 _scale);
event G_Updated(uint256 _G, uint128 _epoch, uint128 _scale);
event EpochUpdated(uint128 _currentEpoch);
event ScaleUpdated(uint128 _currentScale);

Expand All @@ -58,7 +57,7 @@ interface IStabilityPool is IDeposit {
);
event KUMOPaidToFrontEnd(address indexed _frontEnd, uint256 _KUMO);

event DepositSnapshotUpdated(address indexed _depositor, uint256 _P, uint256 _S, uint256 _G);
event DepositSnapshotUpdated(address indexed _depositor, uint256 _P, uint256 _S);
event UserDepositChanged(address indexed _depositor, uint256 _newDeposit);

event AssetGainWithdrawn(address indexed _depositor, uint256 _Asset, uint256 _kusdLoss);
Expand Down
20 changes: 4 additions & 16 deletions packages/contracts/contracts/StabilityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ contract StabilityPool is KumoBase, CheckContract, IStabilityPool {
struct Snapshots {
uint256 S;
uint256 P;
uint256 G;
uint128 scale;
uint128 epoch;
}
Expand Down Expand Up @@ -198,15 +197,6 @@ contract StabilityPool is KumoBase, CheckContract, IStabilityPool {
*/
mapping(uint128 => mapping(uint128 => uint256)) public epochToScaleToSum;

/*
* Similarly, the sum 'G' is used to calculate KUMO gains. During it's lifetime, each deposit d_t earns a KUMO gain of
* ( d_t * [G - G_t] )/P_t, where G_t is the depositor's snapshot of G taken at time t when the deposit was made.
*
* KUMO reward events occur are triggered by depositor operations (new deposit, topup, withdrawal), and liquidations.
* In each case, the KUMO reward is issued (i.e. G is updated), before other state changes are made.
*/
mapping(uint128 => mapping(uint128 => uint256)) public epochToScaleToG;

// Error trackers for the error correction in the offset calculation
uint256 public lastETHError_Offset;
uint256 public lastKUSDLossError_Offset;
Expand Down Expand Up @@ -729,25 +719,23 @@ contract StabilityPool is KumoBase, CheckContract, IStabilityPool {

if (_newValue == 0) {
delete depositSnapshots[_depositor];
emit DepositSnapshotUpdated(_depositor, 0, 0, 0);
emit DepositSnapshotUpdated(_depositor, 0, 0);
return;
}
uint128 currentScaleCached = currentScale;
uint128 currentEpochCached = currentEpoch;
uint256 currentP = P;

// Get S and G for the current epoch and current scale
// Get S for the current epoch and current scale
uint256 currentS = epochToScaleToSum[currentEpochCached][currentScaleCached];
uint256 currentG = epochToScaleToG[currentEpochCached][currentScaleCached];

// Record new snapshots of the latest running product P, sum S, and sum G, for the depositor
// Record new snapshots of the latest running product P, and sum S, for the depositor
depositSnapshots[_depositor].P = currentP;
depositSnapshots[_depositor].S = currentS;
depositSnapshots[_depositor].G = currentG;
depositSnapshots[_depositor].scale = currentScaleCached;
depositSnapshots[_depositor].epoch = currentEpochCached;

emit DepositSnapshotUpdated(_depositor, currentP, currentS, currentG);
emit DepositSnapshotUpdated(_depositor, currentP, currentS);

// --- Staking part ---
stakingSnapshots[_depositor].F_ASSET_Snapshot = F_ASSET;
Expand Down

0 comments on commit cfc6167

Please sign in to comment.