Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sip 366 implementation #2145

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
2209136
wip sip366
leomassazza May 8, 2024
45dfd41
wip 366
leomassazza May 9, 2024
cebc9c4
wip 366 start fixing tests
leomassazza May 9, 2024
f41d109
fix, wrong params for pair
leomassazza May 9, 2024
e3ab470
wip: add per collateral accounting
leomassazza May 13, 2024
18de031
Test MarketManagerModule
leomassazza May 13, 2024
de561f0
Fix LiquidationModule test
leomassazza May 13, 2024
1f49264
wip: fix tests
leomassazza May 13, 2024
5a28067
checkpoint: fixing vault module test (wip)
leomassazza May 13, 2024
13a5120
checkpoint: use delta for intent declarations
leomassazza May 13, 2024
b2cb01c
checkpoint: added some events
leomassazza May 13, 2024
7280c58
Link to liquidation
leomassazza May 13, 2024
64030e3
checkpoint: more tests fixed and bugs smashed
leomassazza May 14, 2024
3f68d81
Fix tests
leomassazza May 15, 2024
c60b1c4
fix other project tests
leomassazza May 16, 2024
6ae5345
fix another tests on bfp
leomassazza May 16, 2024
8289f11
Only owner can delete all intents
leomassazza May 17, 2024
c6b5332
Make window time flexible with configuration changes
leomassazza May 20, 2024
55cf924
wip: timing tests
leomassazza May 20, 2024
383d27e
test edge cases
leomassazza May 20, 2024
18a4308
Reduce AccountDelegationIntents footprint
leomassazza May 21, 2024
a47d06c
Cleanup and comments
leomassazza May 21, 2024
12db077
update storage.dump
leomassazza May 22, 2024
1027f7f
add skipped test - multiple markets with diff timing
leomassazza May 22, 2024
3a4ac69
deps fix
leomassazza May 22, 2024
ed9d256
undo deps fix
leomassazza May 22, 2024
fc9cf62
Merge branch 'SIP-366-implementation' of https://github.com/Synthetix…
leomassazza May 22, 2024
f0531e2
fix deps
leomassazza May 22, 2024
d03d3ca
typos + remove account owner check on delete expired intents
leomassazza May 22, 2024
0cf5549
PR review fixes (partial)
leomassazza May 27, 2024
6c54a5d
fix: ensure intentId to process is still valid for the account (not r…
leomassazza May 27, 2024
3c9f5be
fix pair using wrong key
leomassazza May 27, 2024
50b6b61
fix tests
leomassazza May 27, 2024
f62dad5
propagate storage change
leomassazza May 27, 2024
901f542
rename function (wip)
leomassazza May 27, 2024
30953ee
add two new views
leomassazza May 28, 2024
05cd81f
some fixes
leomassazza May 30, 2024
2e5ddcd
add views test + small fix
leomassazza Jun 4, 2024
9e836d5
PR Fixes -> SIP 366 (#2171)
leomassazza Jun 26, 2024
cb02ac7
Merge branch 'main' into SIP-366-implementation
leomassazza Jun 26, 2024
4061dec
fix bfp tests
leomassazza Jun 26, 2024
f9ba8da
more fixes on bfp (roll back changes)
leomassazza Jun 26, 2024
cc0bd12
add missing empty line
leomassazza Jun 27, 2024
62de774
add more info to view
leomassazza Jun 27, 2024
9a44955
fix wrong sign + a small refactor
leomassazza Jun 27, 2024
6272a49
fix test
leomassazza Jun 27, 2024
ac3ad55
rename FFs
leomassazza Jul 1, 2024
c11d354
fix tests
leomassazza Jul 1, 2024
c4fa5d3
Merge branch 'main' into SIP-366-implementation
leomassazza Jul 2, 2024
0a2d08e
push storage dump
leomassazza Jul 3, 2024
b190bfc
Merge branch 'main' into SIP-366-implementation
leomassazza Jul 15, 2024
dde2c7d
Merge branch 'main' into SIP-366-implementation
leomassazza Jul 18, 2024
4ff64db
Reduce delegationIntent footprint
leomassazza Jul 19, 2024
cd8a7f9
fix missing references to intent.id
leomassazza Jul 19, 2024
eb05eba
Merge branch 'main' into SIP-366-implementation
leomassazza Jul 27, 2024
1f46654
Merge branch 'main' into SIP-366-implementation
leomassazza Aug 13, 2024
f960f81
fix test
leomassazza Aug 13, 2024
712921c
Merge branch 'main' into SIP-366-implementation
leomassazza Aug 27, 2024
dcb9ea4
Merge branch 'main' into SIP-366-implementation
leomassazza Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into SIP-366-implementation
  • Loading branch information
leomassazza authored Aug 13, 2024
commit 1f466540994c6107d6b7de7ba1d6eb6562d47289
5 changes: 4 additions & 1 deletion markets/perps-market/test/integration/Insolvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ethers } from 'ethers';
import { fastForwardTo, getTime } from '@synthetixio/core-utils/utils/hardhat/rpc';
import assertBn from '@synthetixio/core-utils/utils/assertions/assert-bignumber';
import { delegateCollateral } from '@synthetixio/main/test/common';
import assertRevert from '@synthetixio/core-utils/utils/assertions/assert-revert';

const _SECONDS_IN_DAY = 24 * 60 * 60;

Expand All @@ -18,7 +19,7 @@ const interestRateParams = {
highUtilGradient: wei(0.01),
};

describe('Position - interest rates', () => {
describe('Insolvent test', () => {
const { systems, perpsMarkets, superMarketId, provider, owner, trader1, keeper, staker } =
bootstrapMarkets({
interestRateParams: {
Expand Down Expand Up @@ -100,6 +101,8 @@ describe('Position - interest rates', () => {
wei(currentCollateralAmount).mul(wei(0.1)).toBN(),
ethers.utils.parseEther('1')
);
// this ends up being total delegated collateral value
delegatedCollateralValue = wei(200_000);
});

it('reverts if attempting to open position when market insolved', async () => {
Expand Down
17 changes: 5 additions & 12 deletions protocol/synthetix/contracts/modules/core/VaultModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,6 @@ contract VaultModule is IVaultModule {
// Identify the vault that corresponds to this collateral type and pool id.
Vault.Data storage vault = Pool.loadExisting(poolId).vaults[collateralType];

// Use account interaction to update its rewards.
uint256 totalSharesD18 = vault.currentEpoch().accountsDebtDistribution.totalSharesD18;
uint256 actorSharesD18 = vault.currentEpoch().accountsDebtDistribution.getActorShares(
accountId.toBytes32()
);

uint256 currentCollateralAmount = vault.currentAccountCollateral(accountId);

uint256 newCollateralAmountD18 = (currentCollateralAmount.toInt() +
Expand Down Expand Up @@ -639,6 +633,11 @@ contract VaultModule is IVaultModule {
);
}

// distribute any outstanding rewards distributor value to vaults prior to updating positions
Pool.load(poolId).updateRewardsToVaults(
Vault.PositionSelector(accountId, poolId, collateralType)
);

// Update the account's position for the given pool and collateral type,
// Note: This will trigger an update in the entire debt distribution chain.
uint256 collateralPrice = _updatePosition(
Expand Down Expand Up @@ -692,12 +691,6 @@ contract VaultModule is IVaultModule {
leverage,
ERC2771Context._msgSender() // this is the executor address, not the account owner or authorized (the one that posted the intent)
);

vault.updateRewards(
Vault.PositionSelector(accountId, poolId, collateralType),
totalSharesD18,
actorSharesD18
);
}

/**
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.