VBP4 - Increase staleness tolarence on oracle inputs

During a protocol upgrade data source inputs can end up marked as stale potentially reducing some of the protections the new mark price methodology.

We propose that the staleness tolerance for oracle inputs on the BTC and ETH markets are set to 7d from current 1m.

1 Like

Thanks for bringing this to light. I will prepare a proposal and update my post here.

Full proposal json:

{
  "batchProposalSubmission": {
    "rationale": {
      "description": "Update BTC and ETH markets to set the sourceStalenessTolerance to 7 days for the mark price calculation.",
      "title": "Update sourceStalenessTolerance for BTC and ETH Perps."
    },
    "terms": {
      "closingTimestamp": "1709575200",
      "changes": [
        {
          "enactmentTimestamp": "1709575200",
          "updateMarket": {
            "marketId": "4e9081e20e9e81f3e747d42cb0c9b8826454df01899e6027a22e771e19cc79fc",
            "changes": {
              "instrument": {
                "code": "BTC/USDT",
                "name": "Bitcoin / Tether USD (Perpetual)",
                "perpetual": {
                  "quoteName": "USDT",
                  "marginFundingFactor": "0.9",
                  "interestRate": "0.1095",
                  "clampLowerBound": "-0.0005",
                  "clampUpperBound": "0.0005",
                  "fundingRateLowerBound": "-0.001",
                  "fundingRateUpperBound": "0.001",
                  "dataSourceSpecForSettlementSchedule": {
                    "internal": {
                      "timeTrigger": {
                        "conditions": [
                          {
                            "operator": "OPERATOR_GREATER_THAN",
                            "value": "0"
                          }
                        ],
                        "triggers": [
                          {
                            "every": "28800"
                          }
                        ]
                      }
                    }
                  },
                  "dataSourceSpecForSettlementData": {
                    "external": {
                      "ethOracle": {
                        "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                        "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                        "method": "getPrice",
                        "args": [
                          "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"
                        ],
                        "trigger": {
                          "timeTrigger": {
                            "every": "60"
                          }
                        },
                        "requiredConfirmations": "3",
                        "filters": [
                          {
                            "key": {
                              "name": "btc.price",
                              "type": "TYPE_INTEGER",
                              "numberDecimalPlaces": "18"
                            },
                            "conditions": [
                              {
                                "operator": "OPERATOR_GREATER_THAN",
                                "value": "0"
                              }
                            ]
                          }
                        ],
                        "normalisers": [
                          {
                            "name": "btc.price",
                            "expression": "$[0]"
                          }
                        ],
                        "sourceChainId": "100"
                      }
                    }
                  },
                  "dataSourceSpecBinding": {
                    "settlementDataProperty": "btc.price",
                    "settlementScheduleProperty": "vegaprotocol.builtin.timetrigger"
                  },
                  "fundingRateScalingFactor": "1",
                  "internalCompositePriceConfiguration": {
                    "decayWeight": "1.0",
                    "decayPower": "1",
                    "cashAmount": "50000000",
                    "sourceWeights": [
                      "0.0",
                      "0.999",
                      "0.001",
                      "0.0"
                    ],
                    "sourceStalenessTolerance": [
                      "1m",
                      "1m",
                      "10m",
                      "10m"
                    ],
                    "compositePriceType": "COMPOSITE_PRICE_TYPE_WEIGHTED",
                    "dataSourcesSpec": [
                      {
                        "external": {
                          "ethOracle": {
                            "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                            "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                            "method": "getPrice",
                            "args": [
                              "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"
                            ],
                            "trigger": {
                              "timeTrigger": {
                                "every": "60"
                              }
                            },
                            "requiredConfirmations": "3",
                            "filters": [
                              {
                                "key": {
                                  "name": "btc.price",
                                  "type": "TYPE_INTEGER",
                                  "numberDecimalPlaces": "18"
                                },
                                "conditions": [
                                  {
                                    "operator": "OPERATOR_GREATER_THAN",
                                    "value": "0"
                                  }
                                ]
                              }
                            ],
                            "normalisers": [
                              {
                                "name": "btc.price",
                                "expression": "$[0]"
                              }
                            ],
                            "sourceChainId": "100"
                          }
                        }
                      }
                    ],
                    "dataSourcesSpecBinding": [
                      {
                        "priceSourceProperty": "btc.price"
                      }
                    ]
                  }
                }
              },
              "metadata": [
                "base:BTC",
                "quote:USDT",
                "oracle:pyth",
                "oracleChain:gnosis",
                "class:fx/crypto",
                "perpetual",
                "sector:defi",
                "enactment:2023-12-01T18:00:00Z"
              ],
              "priceMonitoringParameters": {
                "triggers": [
                  {
                    "horizon": "21600",
                    "probability": "0.9999999",
                    "auctionExtension": "86400"
                  },
                  {
                    "horizon": "4320",
                    "probability": "0.9999999",
                    "auctionExtension": "3600"
                  },
                  {
                    "horizon": "1440",
                    "probability": "0.9999999",
                    "auctionExtension": "1800"
                  },
                  {
                    "horizon": "360",
                    "probability": "0.9999999",
                    "auctionExtension": "300"
                  }
                ]
              },
              "liquidityMonitoringParameters": {
                "targetStakeParameters": {
                  "timeWindow": "3600",
                  "scalingFactor": 0.05
                },
                "triggeringRatio": "0.9",
                "auctionExtension": "1"
              },
              "logNormal": {
                "riskAversionParameter": 1e-06,
                "tau": 3.995e-06,
                "params": {
                  "mu": 0,
                  "r": 0,
                  "sigma": 1
                }
              },
              "linearSlippageFactor": "0.001",
              "quadraticSlippageFactor": "0",
              "liquiditySlaParameters": {
                "priceRange": "0.03",
                "commitmentMinTimeFraction": "0.75",
                "performanceHysteresisEpochs": "1",
                "slaCompetitionFactor": "0.8"
              },
              "liquidityFeeSettings": {
                "method": "METHOD_MARGINAL_COST"
              },
              "liquidationStrategy": {
                "disposalTimeStep": "1",
                "disposalFraction": "1",
                "fullDisposalSize": "1000000",
                "maxFractionConsumed": "0.1"
              },
              "markPriceConfiguration": {
                "decayWeight": "1.0",
                "decayPower": "1",
                "cashAmount": "50000000",
                "sourceWeights": [],
                "sourceStalenessTolerance": [
                  "1m",
                  "1m",
                  "10080m",
                  "10080m",
                  "1m"
                ],
                "compositePriceType": "COMPOSITE_PRICE_TYPE_MEDIAN",
                "dataSourcesSpec": [
                  {
                    "external": {
                      "ethOracle": {
                        "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                        "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                        "method": "getPrice",
                        "args": [
                          "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"
                        ],
                        "trigger": {
                          "timeTrigger": {
                            "every": "60"
                          }
                        },
                        "requiredConfirmations": "3",
                        "filters": [
                          {
                            "key": {
                              "name": "btc.price",
                              "type": "TYPE_INTEGER",
                              "numberDecimalPlaces": "18"
                            },
                            "conditions": [
                              {
                                "operator": "OPERATOR_GREATER_THAN",
                                "value": "0"
                              }
                            ]
                          }
                        ],
                        "normalisers": [
                          {
                            "name": "btc.price",
                            "expression": "$[0]"
                          }
                        ],
                        "sourceChainId": "100"
                      }
                    }
                  },
                  {
                    "external": {
                      "ethOracle": {
                        "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                        "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                        "method": "getPrice",
                        "args": [
                          "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43"
                        ],
                        "trigger": {
                          "timeTrigger": {
                            "every": "60"
                          }
                        },
                        "requiredConfirmations": "3",
                        "filters": [
                          {
                            "key": {
                              "name": "btc.price",
                              "type": "TYPE_INTEGER",
                              "numberDecimalPlaces": "18"
                            },
                            "conditions": [
                              {
                                "operator": "OPERATOR_GREATER_THAN",
                                "value": "0"
                              }
                            ]
                          }
                        ],
                        "normalisers": [
                          {
                            "name": "btc.price",
                            "expression": "$[0]"
                          }
                        ],
                        "sourceChainId": "100"
                      }
                    }
                  }
                ],
                "dataSourcesSpecBinding": [
                  {
                    "priceSourceProperty": "btc.price"
                  },
                  {
                    "priceSourceProperty": "btc.price"
                  }
                ]
              }
            }
          }
        },
        {
          "enactmentTimestamp": "1709575200",
          "updateMarket": {
            "marketId": "e63a37edae8b74599d976f5dedbf3316af82579447f7a08ae0495a021fd44d13",
            "changes": {
              "instrument": {
                "code": "ETH/USDT",
                "name": "Ether / Tether USD (Perpetual)",
                "perpetual": {
                  "quoteName": "USDT",
                  "marginFundingFactor": "0.9",
                  "interestRate": "0.1095",
                  "clampLowerBound": "-0.0005",
                  "clampUpperBound": "0.0005",
                  "fundingRateLowerBound": "-0.001",
                  "fundingRateUpperBound": "0.001",
                  "dataSourceSpecForSettlementSchedule": {
                    "internal": {
                      "timeTrigger": {
                        "conditions": [
                          {
                            "operator": "OPERATOR_GREATER_THAN",
                            "value": "0"
                          }
                        ],
                        "triggers": [
                          {
                            "every": "28800"
                          }
                        ]
                      }
                    }
                  },
                  "dataSourceSpecForSettlementData": {
                    "external": {
                      "ethOracle": {
                        "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                        "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                        "method": "getPrice",
                        "args": [
                          "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
                        ],
                        "trigger": {
                          "timeTrigger": {
                            "every": "60"
                          }
                        },
                        "requiredConfirmations": "3",
                        "filters": [
                          {
                            "key": {
                              "name": "eth.price",
                              "type": "TYPE_INTEGER",
                              "numberDecimalPlaces": "18"
                            },
                            "conditions": [
                              {
                                "operator": "OPERATOR_GREATER_THAN",
                                "value": "0"
                              }
                            ]
                          }
                        ],
                        "normalisers": [
                          {
                            "name": "eth.price",
                            "expression": "$[0]"
                          }
                        ],
                        "sourceChainId": "100"
                      }
                    }
                  },
                  "dataSourceSpecBinding": {
                    "settlementDataProperty": "eth.price",
                    "settlementScheduleProperty": "vegaprotocol.builtin.timetrigger"
                  },
                  "fundingRateScalingFactor": "1",
                  "internalCompositePriceConfiguration": {
                    "decayWeight": "1.0",
                    "decayPower": "1",
                    "cashAmount": "50000000",
                    "sourceWeights": [
                      "0.0",
                      "0.999",
                      "0.001",
                      "0.0"
                    ],
                    "sourceStalenessTolerance": [
                      "1m",
                      "1m",
                      "10m",
                      "10m"
                    ],
                    "compositePriceType": "COMPOSITE_PRICE_TYPE_WEIGHTED",
                    "dataSourcesSpec": [
                      {
                        "external": {
                          "ethOracle": {
                            "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                            "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                            "method": "getPrice",
                            "args": [
                              "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
                            ],
                            "trigger": {
                              "timeTrigger": {
                                "every": "60"
                              }
                            },
                            "requiredConfirmations": "3",
                            "filters": [
                              {
                                "key": {
                                  "name": "eth.price",
                                  "type": "TYPE_INTEGER",
                                  "numberDecimalPlaces": "18"
                                },
                                "conditions": [
                                  {
                                    "operator": "OPERATOR_GREATER_THAN",
                                    "value": "0"
                                  }
                                ]
                              }
                            ],
                            "normalisers": [
                              {
                                "name": "eth.price",
                                "expression": "$[0]"
                              }
                            ],
                            "sourceChainId": "100"
                          }
                        }
                      }
                    ],
                    "dataSourcesSpecBinding": [
                      {
                        "priceSourceProperty": "eth.price"
                      }
                    ]
                  }
                }
              },
              "metadata": [
                "base:ETH",
                "quote:USDT",
                "oracle:pyth",
                "oracleChain:gnosis",
                "class:fx/crypto",
                "perpetual",
                "sector:defi",
                "enactment:2023-11-19T02:00:00Z"
              ],
              "priceMonitoringParameters": {
                "triggers": [
                  {
                    "horizon": "21600",
                    "probability": "0.9999999",
                    "auctionExtension": "86400"
                  },
                  {
                    "horizon": "4320",
                    "probability": "0.9999999",
                    "auctionExtension": "3600"
                  },
                  {
                    "horizon": "1440",
                    "probability": "0.9999999",
                    "auctionExtension": "1800"
                  },
                  {
                    "horizon": "360",
                    "probability": "0.9999999",
                    "auctionExtension": "300"
                  }
                ]
              },
              "liquidityMonitoringParameters": {
                "targetStakeParameters": {
                  "timeWindow": "3600",
                  "scalingFactor": 0.05
                },
                "triggeringRatio": "0.9",
                "auctionExtension": "1"
              },
              "logNormal": {
                "riskAversionParameter": 1e-06,
                "tau": 3.995e-06,
                "params": {
                  "mu": 0,
                  "r": 0,
                  "sigma": 1
                }
              },
              "linearSlippageFactor": "0.001",
              "liquiditySlaParameters": {
                "priceRange": "0.03",
                "commitmentMinTimeFraction": "0.75",
                "performanceHysteresisEpochs": "1",
                "slaCompetitionFactor": "0.8"
              },
              "liquidityFeeSettings": {
                "method": "METHOD_MARGINAL_COST"
              },
              "liquidationStrategy": {
                "disposalTimeStep": "1",
                "disposalFraction": "1",
                "fullDisposalSize": "1000000",
                "maxFractionConsumed": "0.1"
              },
              "markPriceConfiguration": {
                "decayWeight": "1.0",
                "decayPower": "1",
                "cashAmount": "50000000",
                "sourceWeights": [],
                "sourceStalenessTolerance": [
                  "1m",
                  "1m",
                  "10080m",
                  "10080m",
                  "1m"
                ],
                "compositePriceType": "COMPOSITE_PRICE_TYPE_MEDIAN",
                "dataSourcesSpec": [
                  {
                    "external": {
                      "ethOracle": {
                        "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                        "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                        "method": "getPrice",
                        "args": [
                          "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
                        ],
                        "trigger": {
                          "timeTrigger": {
                            "every": "60"
                          }
                        },
                        "requiredConfirmations": "3",
                        "filters": [
                          {
                            "key": {
                              "name": "eth.price",
                              "type": "TYPE_INTEGER",
                              "numberDecimalPlaces": "18"
                            },
                            "conditions": [
                              {
                                "operator": "OPERATOR_GREATER_THAN",
                                "value": "0"
                              }
                            ]
                          }
                        ],
                        "normalisers": [
                          {
                            "name": "eth.price",
                            "expression": "$[0]"
                          }
                        ],
                        "sourceChainId": "100"
                      }
                    }
                  },
                  {
                    "external": {
                      "ethOracle": {
                        "address": "0x719abd606155442c21b7d561426d42bd0e40a776",
                        "abi": "[{\"inputs\": [{\"internalType\": \"bytes32\", \"name\": \"id\", \"type\": \"bytes32\"}], \"name\": \"getPrice\", \"outputs\": [{\"internalType\": \"int256\", \"name\": \"\", \"type\": \"int256\" }], \"stateMutability\": \"view\", \"type\": \"function\"}]",
                        "method": "getPrice",
                        "args": [
                          "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
                        ],
                        "trigger": {
                          "timeTrigger": {
                            "every": "60"
                          }
                        },
                        "requiredConfirmations": "3",
                        "filters": [
                          {
                            "key": {
                              "name": "eth.price",
                              "type": "TYPE_INTEGER",
                              "numberDecimalPlaces": "18"
                            },
                            "conditions": [
                              {
                                "operator": "OPERATOR_GREATER_THAN",
                                "value": "0"
                              }
                            ]
                          }
                        ],
                        "normalisers": [
                          {
                            "name": "eth.price",
                            "expression": "$[0]"
                          }
                        ],
                        "sourceChainId": "100"
                      }
                    }
                  }
                ],
                "dataSourcesSpecBinding": [
                  {
                    "priceSourceProperty": "eth.price"
                  },
                  {
                    "priceSourceProperty": "eth.price"
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

2 Likes

Looks great, thanks for preparing the proposals.