Skip to content

SIP-2059: Legacy Spot Synth Migration #2227

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

Merged
merged 23 commits into from
Apr 5, 2024
Merged

SIP-2059: Legacy Spot Synth Migration #2227

merged 23 commits into from
Apr 5, 2024

Conversation

barrasso
Copy link
Member

@barrasso barrasso commented Mar 26, 2024

Introduces a new contract, DynamicSynthRedeemer, which quotes synth redemption prices based on real-time chainlink price data * a discount rate (as opposed to the SynthRedeemer, which does so by removing the synth from the issuer and redeems at a fixed rate).

https://sips.synthetix.io/sips/sip-2059/

@barrasso barrasso marked this pull request as ready for review March 29, 2024 13:03
@barrasso barrasso requested a review from kaleb-keny March 29, 2024 13:03
}

function _redeem(address synthProxy, uint amountOfSynth) internal {
bytes32 currencyKey = ISynth(IProxy(synthProxy).target()).currencyKey();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worthwhile adding a allowForRedemption map, set by governance, in order to protect against situations of things being allowed for redemption, while that not being the intention.... Like SNX

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is one way to do it. Another way would be to simply require the currencyKey to not be sUSD. This way all synths except for sUSD can be redeemed.

Also, since SNX is not an ISynth, this function will revert for any non-synth tokens.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also add a setActive flag to enable/disable dynamic redemptions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 🙏🏼

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed here 5b0ec99

function target() external view returns (address);
}

contract DynamicSynthRedeemer is Owned, IDynamicSynthRedeemer, MixinResolver {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will disabling exchanges / atomic exchanges on all synths be done in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need a code change for that. It can be done with an owner action: SystemStatus.suspendSynthsExchange[]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for killing atomic exchanges I assume?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do synths that are pending fee reclamation go into play here? Should we run a script that eliminates all settles all pending fee reclamations before executing this or should we tackle this in a PR, to kill pending fee reclamations?

Copy link
Member Author

@barrasso barrasso Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for killing atomic exchanges I assume?

Yessir. exchangeAtomically also requires exchangeActive to be true

Copy link
Member Author

@barrasso barrasso Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do synths that are pending fee reclamation go into play here? Should we run a script that eliminates all settles all pending fee reclamations before executing this or should we tackle this in a PR, to kill pending fee reclamations?

This can be done as part of the release:

  • 1 - suspend exchanges
  • 2- settle() all pending fee reclamations (set waiting period to 0 if needed)
  • 3 - deploy dynamic redeemer
  • 4 - set redemptionActive = true

@@ -144,7 +151,8 @@ contract BaseDebtCache is Owned, MixinSystemSettings, IDebtCache {
address synthAddress = address(synths[i]);
require(synthAddress != address(0), "Synth does not exist");
uint supply = IERC20(synthAddress).totalSupply();
values[i] = supply.multiplyDecimalRound(rates[i]);
uint value = supply.multiplyDecimalRound(rates[i]);
values[i] = value.multiplyDecimalRound(dynamicSynthRedeemer().getDiscountRate());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe sUSD needs to always have a discountRate of 1. The discountRate is only applied on synths that are open for dynamic redemption... I think another reason why we may need allowedForRedemption list. In addition, the old redemption tokens redeemer, are hopefully not affected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of maintaining a list, we can also add an exception here for sUSD only.

Copy link
Member

@kaleb-keny kaleb-keny Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing 🙏🏼 and for old tokens like sLINK, i am assuming they are not captured here (rather the sUSD in redeemer is used), because we removed from the exchangeRates and being considered as synths, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing 🙏🏼 and for old tokens like sLINK, i am assuming they are not captured here (rather the sUSD in redeemer is used), because we removed from the exchangeRates and being considered as synths, right?

Correct. Old synths like sLINK have been removed from the Issuer and are no longer considered to be synths in the system. They are only available for redemption through the legacy SynthRedeemer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe sUSD needs to always have a discountRate of 1

Addressed here 0e4eff7

@barrasso barrasso merged commit 654c384 into develop Apr 5, 2024
11 of 19 checks passed
@barrasso barrasso deleted the sip-2059 branch April 5, 2024 14:49
barrasso added a commit that referenced this pull request Apr 16, 2024
* SIP-2059: Legacy Spot Synth Migration (#2227)

* sepolia-ethereum deployment artifacts

* update verify

* sepolia-ovm deployment artifacts

* fix: check valid synth (#2231)

* add check for valid synth target

* remove unnecessary address casts

* impl feedback and update tests

* replace proxy param with currency key

* add burnAndIssueSynthsWithoutDebtCache func
barrasso added a commit that referenced this pull request Aug 26, 2024
* SIP-2059: Legacy Spot Synth Migration (#2227)

* implements 2096 (#2225)

Co-authored-by: Leonardo Massazza <lmassazza@gmail.com>

* sccp-2100 (#2235)

* update sccp 2099 (#2230)

Co-authored-by: Leonardo Massazza <lmassazza@gmail.com>

* implements sccp 2104 (#2239)

* sccp-2106 (#2241)

Co-authored-by: Leonardo Massazza <lmassazza@gmail.com>

* Upgrade hardhat-cannon version ^2.12.4 (#2240)

* add funding.json (#2244)

* sccp-2116 (#2243)

Co-authored-by: meb <4982406+barrasso@users.noreply.github.com>

* implements sccp-2108 (#2242)

Co-authored-by: meb <4982406+barrasso@users.noreply.github.com>

* fix: resolve merge conflict

* sccp-2125 (#2245)

* chore: fix lint issuer (#2247)

* legacymarket: prevent self liquidation on v2x once LM is enabled (#2246)

* legacymarket: prevent self liquidation on v2x once LM is enabled

* add test case

---------

Co-authored-by: meb <4982406+barrasso@users.noreply.github.com>

* l1 deployment artifacts

* l2 deployment artifacts

---------

Co-authored-by: kaleb <62237347+kaleb-keny@users.noreply.github.com>
Co-authored-by: Leonardo Massazza <lmassazza@gmail.com>
Co-authored-by: Noah Litvin <335975+noahlitvin@users.noreply.github.com>
Co-authored-by: dbeal <git@danb.email>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants