Skip to content

Commit

Permalink
Merge pull request #100 from eco-stake/disable-dydx-restake
Browse files Browse the repository at this point in the history
Disable REStake for dYdX and hide operators until REStake is supported
  • Loading branch information
tombeynon authored Jun 12, 2024
2 parents 3b67ce3 + ef28be6 commit 736dd39
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 12 deletions.
11 changes: 10 additions & 1 deletion src/components/Delegations.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ class Delegations extends React.Component {
return this.props.network.authzSupport
}

restakeSupport() {
return this.authzSupport() && this.props.network.restakeSupport
}

operatorGrants() {
if (!this.state.operatorGrants) return {}
return this.props.operators.reduce((sum, operator) => {
Expand All @@ -328,7 +332,7 @@ class Delegations extends React.Component {
}

restakePossible() {
return this.props.address && this.state.walletAuthzSupport && this.authzSupport();
return this.props.address && this.state.walletAuthzSupport && this.restakeSupport();
}

totalRewards(validators) {
Expand Down Expand Up @@ -412,6 +416,11 @@ class Delegations extends React.Component {

const alerts = (
<>
{this.props.network.restakeAlert && (
<AlertMessage variant="info" dismissible={false}>
{this.props.network.restakeAlert}
</AlertMessage>
)}
{!this.authzSupport() && (
<AlertMessage variant="info" dismissible={false}>
{this.props.network.prettyName} doesn't support Authz just yet. You can stake and compound manually, REStake will update automatically when support is added.
Expand Down
6 changes: 3 additions & 3 deletions src/components/NetworkChecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function NetworkChecks(props) {
failTitle: "No REStake operators",
failDescription: "There are no operators for this network yet. You can stake and compound manually in the meantime."
}
if(!network.authzSupport && network.operatorCount > 0){
if(!network.restakeSupport && network.operatorCount > 0){
operatorCheck.failTitle = operatorCheck.title,
operatorCheck.failDescription = "Authz is disabled but there are operators ready when support is added."
operatorCheck.failDescription = `${network.authzSupport ? 'REStake' : 'Authz'} is disabled but there are operators ready when support is added.`
}

const testedCheck = {
Expand Down Expand Up @@ -89,7 +89,7 @@ function NetworkChecks(props) {
}),
renderCheck({
...operatorCheck,
state: network.authzSupport && network.operatorCount > 0,
state: network.restakeSupport && network.operatorCount > 0,
identifier: 'operators'
}),
renderCheck({
Expand Down
2 changes: 1 addition & 1 deletion src/components/NetworkSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function NetworkSelect(props) {
<span className="ms-1">{network.label} {!network.online && <small>(Offline)</small>}</span>
</div>
<div className="text-end pt-1 d-none d-sm-block">
{network.operatorCount > 0 &&
{network.restakeSupport && network.operatorCount > 0 &&
<small>{network.operatorCount} Operator{network.operatorCount > 1 ? 's' : ''}</small>
}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/REStakeStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function REStakeStatus(props) {
)
}else{
content = <XCircle className={joinString(`opacity-50`, className)} />
tooltip = 'This validator is not a REStake operator'
tooltip = !network.restakeSupport ? "REStake is not supported at this time" : "This validator is not a REStake operator"
}

return (
Expand All @@ -93,4 +93,4 @@ function REStakeStatus(props) {
)
}

export default REStakeStatus
export default REStakeStatus
2 changes: 1 addition & 1 deletion src/components/ValidatorProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function ValidatorProfile(props) {
</tbody>
</Table>
) :
<TooltipIcon icon={<XCircle className="opacity-50" />} identifier={validator.operator_address} tooltip="This validator is not a REStake operator" />
<TooltipIcon icon={<XCircle className="opacity-50" />} identifier={validator.operator_address} tooltip={!network.restakeSupport ? "REStake is not supported at this time" : "This validator is not a REStake operator"}/>
}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ValidatorStake.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function ValidatorStake(props) {
<TooltipIcon
icon={<XCircle className="opacity-50" />}
identifier={validator.operator_address}
tooltip="This validator is not a REStake operator"
tooltip={!network.restakeSupport ? "REStake is not supported at this time" : "This validator is not a REStake operator"}
/>
)}
</td>
Expand Down
7 changes: 6 additions & 1 deletion src/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,12 @@
},
{
"name": "dydx",
"ownerAddress": "dydxvaloper15wphegl8esn7r2rgj9j3xf870v78lxg8yfjn95"
"ownerAddress": "dydxvaloper15wphegl8esn7r2rgj9j3xf870v78lxg8yfjn95",
"aminoPreventTypes": [
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"
],
"restakeEnabled": false,
"restakeAlert": "dYdX rewards are paid in USDC which cannot be automatically swapped to DYDX at this time. Auto-compounding is disabled for now."
},
{
"name": "celestia",
Expand Down
2 changes: 2 additions & 0 deletions src/utils/Chain.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Chain = (data) => {
gov: sdk46OrLater ? 'v1' : 'v1beta1',
...data.apiVersions || {}
}
const restakeSupport = authzSupport && (data.restakeEnabled ?? true)

return {
...data,
Expand All @@ -35,6 +36,7 @@ const Chain = (data) => {
authzAminoLiftedValues,
authzAminoExecPreventTypes,
apiVersions,
restakeSupport,
denom: data.denom || baseAsset?.base?.denom,
display: data.display || baseAsset?.display?.denom,
symbol: data.symbol || baseAsset?.symbol,
Expand Down
11 changes: 9 additions & 2 deletions src/utils/Network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ class Network {
this.validators = (await this.directory.getValidators(this.name)).map(data => {
return Validator(this, data)
})
this.operators = (this.data.operators || this.validators.filter(el => el.restake && this.allowOperator(el.operator_address))).map(data => {
const operators = (this.data.operators || this.validators.filter(el => el.restake && this.allowOperator(el.operator_address))).map(data => {
return Operator(this, data)
})
this.operatorCount = this.operators.length
this.operatorCount = operators.length
if(this.restakeSupport){
this.operators = operators
}else{
this.operators = []
}
}

async setChain(data){
Expand All @@ -94,6 +99,8 @@ class Network {
this.authzAminoLiftedValues = this.chain.authzAminoLiftedValues
this.authzAminoExecPreventTypes = this.chain.authzAminoExecPreventTypes
this.aminoPreventTypes = this.chain.aminoPreventTypes
this.restakeSupport = this.chain.restakeSupport
this.restakeAlert = data.restakeAlert
this.txTimeout = this.data.txTimeout || 60_000
this.keywords = this.buildKeywords()

Expand Down

0 comments on commit 736dd39

Please sign in to comment.