From 0147679043505f9b95e07b1097e5bec483b00602 Mon Sep 17 00:00:00 2001 From: Peiman Date: Tue, 11 Jul 2023 14:39:45 +0330 Subject: [PATCH] feat: update perps market graph --- .../subgraph/abis/PerpsMarketProxy.json | 517 ++++++++++-------- .../generated/PerpsMarket/PerpsMarketProxy.ts | 272 ++++----- .../perps-market/subgraph/generated/schema.ts | 64 ++- markets/perps-market/subgraph/networks.json | 4 +- markets/perps-market/subgraph/schema.graphql | 10 +- markets/perps-market/subgraph/src/market.ts | 12 +- .../perps-market/subgraph/subgraph.base.yaml | 14 +- 7 files changed, 490 insertions(+), 403 deletions(-) diff --git a/markets/perps-market/subgraph/abis/PerpsMarketProxy.json b/markets/perps-market/subgraph/abis/PerpsMarketProxy.json index cd7aee84ac..23024a28b8 100644 --- a/markets/perps-market/subgraph/abis/PerpsMarketProxy.json +++ b/markets/perps-market/subgraph/abis/PerpsMarketProxy.json @@ -1,5 +1,4 @@ { - "address": "0x54D71285871C5a0914F5B53740b70bA3eDb51Fbb", "abi": [ { "inputs": [ @@ -819,13 +818,13 @@ "type": "uint128" }, { - "indexed": false, + "indexed": true, "internalType": "address", "name": "oldOwner", "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" @@ -844,7 +843,7 @@ "type": "uint128" }, { - "indexed": false, + "indexed": true, "internalType": "address", "name": "newNominatedOwner", "type": "address" @@ -1281,13 +1280,13 @@ "type": "uint128" }, { - "indexed": true, + "indexed": false, "internalType": "int256", "name": "amountDelta", "type": "int256" }, { - "indexed": false, + "indexed": true, "internalType": "address", "name": "sender", "type": "address" @@ -1302,56 +1301,14 @@ "internalType": "uint128", "name": "accountId", "type": "uint128" - }, - { - "internalType": "uint128", - "name": "marketId", - "type": "uint128" } ], - "name": "getAsyncOrderClaim", + "name": "getAvailableMargin", "outputs": [ { - "components": [ - { - "internalType": "uint128", - "name": "accountId", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "marketId", - "type": "uint128" - }, - { - "internalType": "int128", - "name": "sizeDelta", - "type": "int128" - }, - { - "internalType": "uint128", - "name": "settlementStrategyId", - "type": "uint128" - }, - { - "internalType": "uint256", - "name": "settlementTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "acceptablePrice", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "trackingCode", - "type": "bytes32" - } - ], - "internalType": "struct AsyncOrder.Data", + "internalType": "int256", "name": "", - "type": "tuple" + "type": "int256" } ], "stateMutability": "view", @@ -1363,14 +1320,19 @@ "internalType": "uint128", "name": "accountId", "type": "uint128" + }, + { + "internalType": "uint128", + "name": "synthMarketId", + "type": "uint128" } ], - "name": "getAvailableMargin", + "name": "getCollateralAmount", "outputs": [ { - "internalType": "int256", + "internalType": "uint256", "name": "", - "type": "int256" + "type": "uint256" } ], "stateMutability": "view", @@ -1697,17 +1659,6 @@ "name": "InsufficientMargin", "type": "error" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "leftover", - "type": "uint256" - } - ], - "name": "InsufficientMarginError", - "type": "error" - }, { "inputs": [ { @@ -1722,32 +1673,22 @@ { "inputs": [ { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "string[]", - "name": "urls", - "type": "string[]" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes" + "internalType": "uint128", + "name": "marketId", + "type": "uint128" }, { - "internalType": "bytes4", - "name": "callbackFunction", - "type": "bytes4" + "internalType": "uint256", + "name": "maxMarketSize", + "type": "uint256" }, { - "internalType": "bytes", - "name": "extraData", - "type": "bytes" + "internalType": "int256", + "name": "newSideSize", + "type": "int256" } ], - "name": "OffchainLookup", + "name": "MaxOpenInterestReached", "type": "error" }, { @@ -1776,59 +1717,6 @@ "name": "OverflowInt256ToInt128", "type": "error" }, - { - "inputs": [], - "name": "OverflowUint256ToUint64", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "deviation", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "tolerance", - "type": "uint256" - } - ], - "name": "PriceDeviationToleranceExceeded", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "enum SettlementStrategy.Type", - "name": "strategyType", - "type": "uint8" - } - ], - "name": "SettlementStrategyNotFound", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "settlementTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "settlementExpiration", - "type": "uint256" - } - ], - "name": "SettlementWindowExpired", - "type": "error" - }, { "inputs": [ { @@ -1902,7 +1790,7 @@ "type": "uint128" }, { - "indexed": true, + "indexed": false, "internalType": "enum SettlementStrategy.Type", "name": "orderType", "type": "uint8" @@ -1932,7 +1820,7 @@ "type": "uint256" }, { - "indexed": false, + "indexed": true, "internalType": "bytes32", "name": "trackingCode", "type": "bytes32" @@ -1947,80 +1835,6 @@ "name": "OrderCommitted", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint128", - "name": "marketId", - "type": "uint128" - }, - { - "indexed": true, - "internalType": "uint128", - "name": "accountId", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "fillPrice", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "int256", - "name": "accountPnlRealized", - "type": "int256" - }, - { - "indexed": false, - "internalType": "int128", - "name": "newSize", - "type": "int128" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "collectedFees", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "settelementReward", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "trackingCode", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "settler", - "type": "address" - } - ], - "name": "OrderSettled", - "type": "event" - }, - { - "inputs": [], - "name": "PRECISION", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -2193,6 +2007,218 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "leftover", + "type": "uint256" + } + ], + "name": "InsufficientMarginError", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "string[]", + "name": "urls", + "type": "string[]" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "callbackFunction", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "OffchainLookup", + "type": "error" + }, + { + "inputs": [], + "name": "OverflowUint256ToUint64", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "deviation", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tolerance", + "type": "uint256" + } + ], + "name": "PriceDeviationToleranceExceeded", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "enum SettlementStrategy.Type", + "name": "strategyType", + "type": "uint8" + } + ], + "name": "SettlementStrategyNotFound", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "settlementTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "settlementExpiration", + "type": "uint256" + } + ], + "name": "SettlementWindowExpired", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint128", + "name": "marketId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "int256", + "name": "skew", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "size", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "sizeDelta", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "currentFundingRate", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "currentFundingVelocity", + "type": "int256" + } + ], + "name": "MarketUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "marketId", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "accountId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fillPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int128", + "name": "sizeDelta", + "type": "int128" + }, + { + "indexed": false, + "internalType": "int128", + "name": "newSize", + "type": "int128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collectedFees", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "settlementReward", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "trackingCode", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "settler", + "type": "address" + } + ], + "name": "OrderSettled", + "type": "event" + }, + { + "inputs": [], + "name": "PRECISION", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -2565,7 +2591,7 @@ "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "uint128", "name": "marketId", "type": "uint128" @@ -2590,7 +2616,7 @@ "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "uint128", "name": "marketId", "type": "uint128" @@ -2598,13 +2624,13 @@ { "indexed": false, "internalType": "uint256", - "name": "initialMarginFraction", + "name": "initialMarginRatioD18", "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "maintenanceMarginFraction", + "name": "maintenanceMarginRatioD18", "type": "uint256" }, { @@ -2624,6 +2650,12 @@ "internalType": "uint256", "name": "maxSecondsInLiquidationWindow", "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minimumPositionMargin", + "type": "uint256" } ], "name": "LiquidationParametersSet", @@ -2633,7 +2665,7 @@ "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "uint128", "name": "marketId", "type": "uint128" @@ -2641,18 +2673,18 @@ { "indexed": false, "internalType": "uint256", - "name": "lockedOiPercent", + "name": "lockedOiRatioD18", "type": "uint256" } ], - "name": "LockedOiPercentSet", + "name": "LockedOiRatioD18Set", "type": "event" }, { "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "uint128", "name": "marketId", "type": "uint128" @@ -2660,18 +2692,18 @@ { "indexed": false, "internalType": "uint256", - "name": "maxMarketValue", + "name": "maxMarketSize", "type": "uint256" } ], - "name": "MaxMarketValueSet", + "name": "MaxMarketSizeSet", "type": "event" }, { "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "uint128", "name": "marketId", "type": "uint128" @@ -2773,7 +2805,7 @@ "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "uint128", "name": "marketId", "type": "uint128" @@ -2906,12 +2938,12 @@ "outputs": [ { "internalType": "uint256", - "name": "initialMarginFraction", + "name": "initialMarginRatioD18", "type": "uint256" }, { "internalType": "uint256", - "name": "maintenanceMarginFraction", + "name": "maintenanceMarginRatioD18", "type": "uint256" }, { @@ -2941,7 +2973,7 @@ "type": "uint128" } ], - "name": "getLockedOiPercent", + "name": "getLockedOiRatioD18", "outputs": [ { "internalType": "uint256", @@ -2960,11 +2992,11 @@ "type": "uint128" } ], - "name": "getMaxMarketValue", + "name": "getMaxMarketSize", "outputs": [ { "internalType": "uint256", - "name": "maxMarketValue", + "name": "maxMarketSize", "type": "uint256" } ], @@ -3103,12 +3135,12 @@ }, { "internalType": "uint256", - "name": "initialMarginFraction", + "name": "initialMarginRatioD18", "type": "uint256" }, { "internalType": "uint256", - "name": "maintenanceMarginFraction", + "name": "maintenanceMarginRatioD18", "type": "uint256" }, { @@ -3125,6 +3157,11 @@ "internalType": "uint256", "name": "maxSecondsInLiquidationWindow", "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumPositionMargin", + "type": "uint256" } ], "name": "setLiquidationParameters", @@ -3141,11 +3178,11 @@ }, { "internalType": "uint256", - "name": "lockedOiPercent", + "name": "lockedOiRatioD18", "type": "uint256" } ], - "name": "setLockedOiPercent", + "name": "setLockedOiRatio", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -3159,11 +3196,11 @@ }, { "internalType": "uint256", - "name": "maxMarketValue", + "name": "maxMarketSize", "type": "uint256" } ], - "name": "setMaxMarketValue", + "name": "setMaxMarketSize", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -3364,9 +3401,5 @@ "stateMutability": "nonpayable", "type": "function" } - ], - "deployTxnHash": "", - "sourceName": "", - "contractName": "", - "deployedOn": "invoke.upgrade_proxy" + ] } diff --git a/markets/perps-market/subgraph/generated/PerpsMarket/PerpsMarketProxy.ts b/markets/perps-market/subgraph/generated/PerpsMarket/PerpsMarketProxy.ts index 8eee9c19f2..f998670a3f 100644 --- a/markets/perps-market/subgraph/generated/PerpsMarket/PerpsMarketProxy.ts +++ b/markets/perps-market/subgraph/generated/PerpsMarket/PerpsMarketProxy.ts @@ -394,6 +394,44 @@ export class OrderCommitted__Params { } } +export class MarketUpdated extends ethereum.Event { + get params(): MarketUpdated__Params { + return new MarketUpdated__Params(this); + } +} + +export class MarketUpdated__Params { + _event: MarketUpdated; + + constructor(event: MarketUpdated) { + this._event = event; + } + + get marketId(): BigInt { + return this._event.parameters[0].value.toBigInt(); + } + + get skew(): BigInt { + return this._event.parameters[1].value.toBigInt(); + } + + get size(): BigInt { + return this._event.parameters[2].value.toBigInt(); + } + + get sizeDelta(): BigInt { + return this._event.parameters[3].value.toBigInt(); + } + + get currentFundingRate(): BigInt { + return this._event.parameters[4].value.toBigInt(); + } + + get currentFundingVelocity(): BigInt { + return this._event.parameters[5].value.toBigInt(); + } +} + export class OrderSettled extends ethereum.Event { get params(): OrderSettled__Params { return new OrderSettled__Params(this); @@ -419,7 +457,7 @@ export class OrderSettled__Params { return this._event.parameters[2].value.toBigInt(); } - get accountPnlRealized(): BigInt { + get sizeDelta(): BigInt { return this._event.parameters[3].value.toBigInt(); } @@ -431,7 +469,7 @@ export class OrderSettled__Params { return this._event.parameters[5].value.toBigInt(); } - get settelementReward(): BigInt { + get settlementReward(): BigInt { return this._event.parameters[6].value.toBigInt(); } @@ -597,11 +635,11 @@ export class LiquidationParametersSet__Params { return this._event.parameters[0].value.toBigInt(); } - get initialMarginFraction(): BigInt { + get initialMarginRatioD18(): BigInt { return this._event.parameters[1].value.toBigInt(); } - get maintenanceMarginFraction(): BigInt { + get maintenanceMarginRatioD18(): BigInt { return this._event.parameters[2].value.toBigInt(); } @@ -616,18 +654,22 @@ export class LiquidationParametersSet__Params { get maxSecondsInLiquidationWindow(): BigInt { return this._event.parameters[5].value.toBigInt(); } + + get minimumPositionMargin(): BigInt { + return this._event.parameters[6].value.toBigInt(); + } } -export class LockedOiPercentSet extends ethereum.Event { - get params(): LockedOiPercentSet__Params { - return new LockedOiPercentSet__Params(this); +export class LockedOiRatioD18Set extends ethereum.Event { + get params(): LockedOiRatioD18Set__Params { + return new LockedOiRatioD18Set__Params(this); } } -export class LockedOiPercentSet__Params { - _event: LockedOiPercentSet; +export class LockedOiRatioD18Set__Params { + _event: LockedOiRatioD18Set; - constructor(event: LockedOiPercentSet) { + constructor(event: LockedOiRatioD18Set) { this._event = event; } @@ -635,21 +677,21 @@ export class LockedOiPercentSet__Params { return this._event.parameters[0].value.toBigInt(); } - get lockedOiPercent(): BigInt { + get lockedOiRatioD18(): BigInt { return this._event.parameters[1].value.toBigInt(); } } -export class MaxMarketValueSet extends ethereum.Event { - get params(): MaxMarketValueSet__Params { - return new MaxMarketValueSet__Params(this); +export class MaxMarketSizeSet extends ethereum.Event { + get params(): MaxMarketSizeSet__Params { + return new MaxMarketSizeSet__Params(this); } } -export class MaxMarketValueSet__Params { - _event: MaxMarketValueSet; +export class MaxMarketSizeSet__Params { + _event: MaxMarketSizeSet; - constructor(event: MaxMarketValueSet) { + constructor(event: MaxMarketSizeSet) { this._event = event; } @@ -657,7 +699,7 @@ export class MaxMarketValueSet__Params { return this._event.parameters[0].value.toBigInt(); } - get maxMarketValue(): BigInt { + get maxMarketSize(): BigInt { return this._event.parameters[1].value.toBigInt(); } } @@ -881,36 +923,6 @@ export class PerpsMarketProxy__getAssociatedSystemResult { } } -export class PerpsMarketProxy__getAsyncOrderClaimResultValue0Struct extends ethereum.Tuple { - get accountId(): BigInt { - return this[0].toBigInt(); - } - - get marketId(): BigInt { - return this[1].toBigInt(); - } - - get sizeDelta(): BigInt { - return this[2].toBigInt(); - } - - get settlementStrategyId(): BigInt { - return this[3].toBigInt(); - } - - get settlementTime(): BigInt { - return this[4].toBigInt(); - } - - get acceptablePrice(): BigInt { - return this[5].toBigInt(); - } - - get trackingCode(): Bytes { - return this[6].toBytes(); - } -} - export class PerpsMarketProxy__getOpenPositionResult { value0: BigInt; value1: BigInt; @@ -1172,11 +1184,11 @@ export class PerpsMarketProxy__getLiquidationParametersResult { return map; } - getInitialMarginFraction(): BigInt { + getInitialMarginRatioD18(): BigInt { return this.value0; } - getMaintenanceMarginFraction(): BigInt { + getMaintenanceMarginRatioD18(): BigInt { return this.value1; } @@ -1661,49 +1673,47 @@ export class PerpsMarketProxy extends ethereum.SmartContract { return ethereum.CallResult.fromValue(value[0].toString()); } - getAsyncOrderClaim( - accountId: BigInt, - marketId: BigInt - ): PerpsMarketProxy__getAsyncOrderClaimResultValue0Struct { - let result = super.call( - 'getAsyncOrderClaim', - 'getAsyncOrderClaim(uint128,uint128):((uint128,uint128,int128,uint128,uint256,uint256,bytes32))', - [ethereum.Value.fromUnsignedBigInt(accountId), ethereum.Value.fromUnsignedBigInt(marketId)] - ); + getAvailableMargin(accountId: BigInt): BigInt { + let result = super.call('getAvailableMargin', 'getAvailableMargin(uint128):(int256)', [ + ethereum.Value.fromUnsignedBigInt(accountId), + ]); - return changetype(result[0].toTuple()); + return result[0].toBigInt(); } - try_getAsyncOrderClaim( - accountId: BigInt, - marketId: BigInt - ): ethereum.CallResult { - let result = super.tryCall( - 'getAsyncOrderClaim', - 'getAsyncOrderClaim(uint128,uint128):((uint128,uint128,int128,uint128,uint256,uint256,bytes32))', - [ethereum.Value.fromUnsignedBigInt(accountId), ethereum.Value.fromUnsignedBigInt(marketId)] - ); + try_getAvailableMargin(accountId: BigInt): ethereum.CallResult { + let result = super.tryCall('getAvailableMargin', 'getAvailableMargin(uint128):(int256)', [ + ethereum.Value.fromUnsignedBigInt(accountId), + ]); if (result.reverted) { return new ethereum.CallResult(); } let value = result.value; - return ethereum.CallResult.fromValue( - changetype(value[0].toTuple()) - ); + return ethereum.CallResult.fromValue(value[0].toBigInt()); } - getAvailableMargin(accountId: BigInt): BigInt { - let result = super.call('getAvailableMargin', 'getAvailableMargin(uint128):(int256)', [ - ethereum.Value.fromUnsignedBigInt(accountId), - ]); + getCollateralAmount(accountId: BigInt, synthMarketId: BigInt): BigInt { + let result = super.call( + 'getCollateralAmount', + 'getCollateralAmount(uint128,uint128):(uint256)', + [ + ethereum.Value.fromUnsignedBigInt(accountId), + ethereum.Value.fromUnsignedBigInt(synthMarketId), + ] + ); return result[0].toBigInt(); } - try_getAvailableMargin(accountId: BigInt): ethereum.CallResult { - let result = super.tryCall('getAvailableMargin', 'getAvailableMargin(uint128):(int256)', [ - ethereum.Value.fromUnsignedBigInt(accountId), - ]); + try_getCollateralAmount(accountId: BigInt, synthMarketId: BigInt): ethereum.CallResult { + let result = super.tryCall( + 'getCollateralAmount', + 'getCollateralAmount(uint128,uint128):(uint256)', + [ + ethereum.Value.fromUnsignedBigInt(accountId), + ethereum.Value.fromUnsignedBigInt(synthMarketId), + ] + ); if (result.reverted) { return new ethereum.CallResult(); } @@ -1955,21 +1965,6 @@ export class PerpsMarketProxy extends ethereum.SmartContract { return ethereum.CallResult.fromValue(value[0].toBigInt()); } - PRECISION(): BigInt { - let result = super.call('PRECISION', 'PRECISION():(int256)', []); - - return result[0].toBigInt(); - } - - try_PRECISION(): ethereum.CallResult { - let result = super.tryCall('PRECISION', 'PRECISION():(int256)', []); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBigInt()); - } - commitOrder( commitment: PerpsMarketProxy__commitOrderInputCommitmentStruct ): PerpsMarketProxy__commitOrderResult { @@ -2037,6 +2032,21 @@ export class PerpsMarketProxy extends ethereum.SmartContract { ); } + PRECISION(): BigInt { + let result = super.call('PRECISION', 'PRECISION():(int256)', []); + + return result[0].toBigInt(); + } + + try_PRECISION(): ethereum.CallResult { + let result = super.tryCall('PRECISION', 'PRECISION():(int256)', []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + getDeniers(feature: Bytes): Array
{ let result = super.call('getDeniers', 'getDeniers(bytes32):(address[])', [ ethereum.Value.fromFixedBytes(feature), @@ -2236,16 +2246,16 @@ export class PerpsMarketProxy extends ethereum.SmartContract { ); } - getLockedOiPercent(marketId: BigInt): BigInt { - let result = super.call('getLockedOiPercent', 'getLockedOiPercent(uint128):(uint256)', [ + getLockedOiRatioD18(marketId: BigInt): BigInt { + let result = super.call('getLockedOiRatioD18', 'getLockedOiRatioD18(uint128):(uint256)', [ ethereum.Value.fromUnsignedBigInt(marketId), ]); return result[0].toBigInt(); } - try_getLockedOiPercent(marketId: BigInt): ethereum.CallResult { - let result = super.tryCall('getLockedOiPercent', 'getLockedOiPercent(uint128):(uint256)', [ + try_getLockedOiRatioD18(marketId: BigInt): ethereum.CallResult { + let result = super.tryCall('getLockedOiRatioD18', 'getLockedOiRatioD18(uint128):(uint256)', [ ethereum.Value.fromUnsignedBigInt(marketId), ]); if (result.reverted) { @@ -2255,16 +2265,16 @@ export class PerpsMarketProxy extends ethereum.SmartContract { return ethereum.CallResult.fromValue(value[0].toBigInt()); } - getMaxMarketValue(marketId: BigInt): BigInt { - let result = super.call('getMaxMarketValue', 'getMaxMarketValue(uint128):(uint256)', [ + getMaxMarketSize(marketId: BigInt): BigInt { + let result = super.call('getMaxMarketSize', 'getMaxMarketSize(uint128):(uint256)', [ ethereum.Value.fromUnsignedBigInt(marketId), ]); return result[0].toBigInt(); } - try_getMaxMarketValue(marketId: BigInt): ethereum.CallResult { - let result = super.tryCall('getMaxMarketValue', 'getMaxMarketValue(uint128):(uint256)', [ + try_getMaxMarketSize(marketId: BigInt): ethereum.CallResult { + let result = super.tryCall('getMaxMarketSize', 'getMaxMarketSize(uint128):(uint256)', [ ethereum.Value.fromUnsignedBigInt(marketId), ]); if (result.reverted) { @@ -3645,11 +3655,11 @@ export class SetLiquidationParametersCall__Inputs { return this._call.inputValues[0].value.toBigInt(); } - get initialMarginFraction(): BigInt { + get initialMarginRatioD18(): BigInt { return this._call.inputValues[1].value.toBigInt(); } - get maintenanceMarginFraction(): BigInt { + get maintenanceMarginRatioD18(): BigInt { return this._call.inputValues[2].value.toBigInt(); } @@ -3664,6 +3674,10 @@ export class SetLiquidationParametersCall__Inputs { get maxSecondsInLiquidationWindow(): BigInt { return this._call.inputValues[5].value.toBigInt(); } + + get minimumPositionMargin(): BigInt { + return this._call.inputValues[6].value.toBigInt(); + } } export class SetLiquidationParametersCall__Outputs { @@ -3674,20 +3688,20 @@ export class SetLiquidationParametersCall__Outputs { } } -export class SetLockedOiPercentCall extends ethereum.Call { - get inputs(): SetLockedOiPercentCall__Inputs { - return new SetLockedOiPercentCall__Inputs(this); +export class SetLockedOiRatioCall extends ethereum.Call { + get inputs(): SetLockedOiRatioCall__Inputs { + return new SetLockedOiRatioCall__Inputs(this); } - get outputs(): SetLockedOiPercentCall__Outputs { - return new SetLockedOiPercentCall__Outputs(this); + get outputs(): SetLockedOiRatioCall__Outputs { + return new SetLockedOiRatioCall__Outputs(this); } } -export class SetLockedOiPercentCall__Inputs { - _call: SetLockedOiPercentCall; +export class SetLockedOiRatioCall__Inputs { + _call: SetLockedOiRatioCall; - constructor(call: SetLockedOiPercentCall) { + constructor(call: SetLockedOiRatioCall) { this._call = call; } @@ -3695,33 +3709,33 @@ export class SetLockedOiPercentCall__Inputs { return this._call.inputValues[0].value.toBigInt(); } - get lockedOiPercent(): BigInt { + get lockedOiRatioD18(): BigInt { return this._call.inputValues[1].value.toBigInt(); } } -export class SetLockedOiPercentCall__Outputs { - _call: SetLockedOiPercentCall; +export class SetLockedOiRatioCall__Outputs { + _call: SetLockedOiRatioCall; - constructor(call: SetLockedOiPercentCall) { + constructor(call: SetLockedOiRatioCall) { this._call = call; } } -export class SetMaxMarketValueCall extends ethereum.Call { - get inputs(): SetMaxMarketValueCall__Inputs { - return new SetMaxMarketValueCall__Inputs(this); +export class SetMaxMarketSizeCall extends ethereum.Call { + get inputs(): SetMaxMarketSizeCall__Inputs { + return new SetMaxMarketSizeCall__Inputs(this); } - get outputs(): SetMaxMarketValueCall__Outputs { - return new SetMaxMarketValueCall__Outputs(this); + get outputs(): SetMaxMarketSizeCall__Outputs { + return new SetMaxMarketSizeCall__Outputs(this); } } -export class SetMaxMarketValueCall__Inputs { - _call: SetMaxMarketValueCall; +export class SetMaxMarketSizeCall__Inputs { + _call: SetMaxMarketSizeCall; - constructor(call: SetMaxMarketValueCall) { + constructor(call: SetMaxMarketSizeCall) { this._call = call; } @@ -3729,15 +3743,15 @@ export class SetMaxMarketValueCall__Inputs { return this._call.inputValues[0].value.toBigInt(); } - get maxMarketValue(): BigInt { + get maxMarketSize(): BigInt { return this._call.inputValues[1].value.toBigInt(); } } -export class SetMaxMarketValueCall__Outputs { - _call: SetMaxMarketValueCall; +export class SetMaxMarketSizeCall__Outputs { + _call: SetMaxMarketSizeCall; - constructor(call: SetMaxMarketValueCall) { + constructor(call: SetMaxMarketSizeCall) { this._call = call; } } diff --git a/markets/perps-market/subgraph/generated/schema.ts b/markets/perps-market/subgraph/generated/schema.ts index 8e06938f52..362e49b9f2 100644 --- a/markets/perps-market/subgraph/generated/schema.ts +++ b/markets/perps-market/subgraph/generated/schema.ts @@ -248,8 +248,8 @@ export class Market extends Entity { } } - get initialMarginFraction(): BigInt | null { - let value = this.get('initialMarginFraction'); + get initialMarginRatioD18(): BigInt | null { + let value = this.get('initialMarginRatioD18'); if (!value || value.kind == ValueKind.NULL) { return null; } else { @@ -257,16 +257,16 @@ export class Market extends Entity { } } - set initialMarginFraction(value: BigInt | null) { + set initialMarginRatioD18(value: BigInt | null) { if (!value) { - this.unset('initialMarginFraction'); + this.unset('initialMarginRatioD18'); } else { - this.set('initialMarginFraction', Value.fromBigInt(value)); + this.set('initialMarginRatioD18', Value.fromBigInt(value)); } } - get maintenanceMarginFraction(): BigInt | null { - let value = this.get('maintenanceMarginFraction'); + get maintenanceMarginRatioD18(): BigInt | null { + let value = this.get('maintenanceMarginRatioD18'); if (!value || value.kind == ValueKind.NULL) { return null; } else { @@ -274,11 +274,11 @@ export class Market extends Entity { } } - set maintenanceMarginFraction(value: BigInt | null) { + set maintenanceMarginRatioD18(value: BigInt | null) { if (!value) { - this.unset('maintenanceMarginFraction'); + this.unset('maintenanceMarginRatioD18'); } else { - this.set('maintenanceMarginFraction', Value.fromBigInt(value)); + this.set('maintenanceMarginRatioD18', Value.fromBigInt(value)); } } @@ -316,8 +316,8 @@ export class Market extends Entity { } } - get lockedOiPercent(): BigInt | null { - let value = this.get('lockedOiPercent'); + get maxSecondsInLiquidationWindow(): BigInt | null { + let value = this.get('maxSecondsInLiquidationWindow'); if (!value || value.kind == ValueKind.NULL) { return null; } else { @@ -325,11 +325,45 @@ export class Market extends Entity { } } - set lockedOiPercent(value: BigInt | null) { + set maxSecondsInLiquidationWindow(value: BigInt | null) { if (!value) { - this.unset('lockedOiPercent'); + this.unset('maxSecondsInLiquidationWindow'); } else { - this.set('lockedOiPercent', Value.fromBigInt(value)); + this.set('maxSecondsInLiquidationWindow', Value.fromBigInt(value)); + } + } + + get minimumPositionMargin(): BigInt | null { + let value = this.get('minimumPositionMargin'); + if (!value || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigInt(); + } + } + + set minimumPositionMargin(value: BigInt | null) { + if (!value) { + this.unset('minimumPositionMargin'); + } else { + this.set('minimumPositionMargin', Value.fromBigInt(value)); + } + } + + get lockedOiRatioD18(): BigInt | null { + let value = this.get('lockedOiRatioD18'); + if (!value || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigInt(); + } + } + + set lockedOiRatioD18(value: BigInt | null) { + if (!value) { + this.unset('lockedOiRatioD18'); + } else { + this.set('lockedOiRatioD18', Value.fromBigInt(value)); } } diff --git a/markets/perps-market/subgraph/networks.json b/markets/perps-market/subgraph/networks.json index e6ee6e379d..2c43ef24a8 100644 --- a/markets/perps-market/subgraph/networks.json +++ b/markets/perps-market/subgraph/networks.json @@ -1,8 +1,8 @@ { "optimism-goerli": { "PerpsMarket": { - "address": "0x54D71285871C5a0914F5B53740b70bA3eDb51Fbb", - "startBlock": 9727531 + "address": "0xd78D47739Ed468a602beb11C34a2A20759bcEf4F", + "startBlock": 11669270 } } } diff --git a/markets/perps-market/subgraph/schema.graphql b/markets/perps-market/subgraph/schema.graphql index 50a7fabeb8..41bb89932a 100644 --- a/markets/perps-market/subgraph/schema.graphql +++ b/markets/perps-market/subgraph/schema.graphql @@ -14,11 +14,15 @@ type Market @entity { owner: String maxFundingVelocity: BigInt skewScale: BigInt - initialMarginFraction: BigInt - maintenanceMarginFraction: BigInt + + initialMarginRatioD18: BigInt + maintenanceMarginRatioD18: BigInt liquidationRewardRatioD18: BigInt maxLiquidationLimitAccumulationMultiplier: BigInt - lockedOiPercent: BigInt + maxSecondsInLiquidationWindow: BigInt + minimumPositionMargin: BigInt + + lockedOiRatioD18: BigInt makerFee: BigInt takerFee: BigInt } diff --git a/markets/perps-market/subgraph/src/market.ts b/markets/perps-market/subgraph/src/market.ts index dda4335f30..b6f59bfbda 100644 --- a/markets/perps-market/subgraph/src/market.ts +++ b/markets/perps-market/subgraph/src/market.ts @@ -4,8 +4,8 @@ import { MarketRegistered, FundingParametersSet, LiquidationParametersSet, - LockedOiPercentSet, OrderFeesSet, + LockedOiRatioD18Set, } from '../generated/PerpsMarket/PerpsMarketProxy'; import { Market } from '../generated/schema'; @@ -52,12 +52,12 @@ export function handleFundingParametersSet(event: FundingParametersSet): void { } } -export function handleLockedOiPercentSet(event: LockedOiPercentSet): void { +export function handleLockedOiRatioD18Set(event: LockedOiRatioD18Set): void { const id = event.params.marketId.toString(); const market = Market.load(id); if (market) { - market.lockedOiPercent = event.params.lockedOiPercent; + market.lockedOiRatioD18 = event.params.lockedOiRatioD18; market.save(); } } @@ -67,11 +67,13 @@ export function handleLiquidationParametersSet(event: LiquidationParametersSet): const market = Market.load(id); if (market) { - market.initialMarginFraction = event.params.initialMarginFraction; + market.initialMarginRatioD18 = event.params.initialMarginRatioD18; + market.maintenanceMarginRatioD18 = event.params.maintenanceMarginRatioD18; market.liquidationRewardRatioD18 = event.params.liquidationRewardRatioD18; - market.maintenanceMarginFraction = event.params.maintenanceMarginFraction; market.maxLiquidationLimitAccumulationMultiplier = event.params.maxLiquidationLimitAccumulationMultiplier; + market.maxSecondsInLiquidationWindow = event.params.maxSecondsInLiquidationWindow; + market.minimumPositionMargin = event.params.minimumPositionMargin; market.save(); } } diff --git a/markets/perps-market/subgraph/subgraph.base.yaml b/markets/perps-market/subgraph/subgraph.base.yaml index b007bc266c..7ff7b0c555 100644 --- a/markets/perps-market/subgraph/subgraph.base.yaml +++ b/markets/perps-market/subgraph/subgraph.base.yaml @@ -25,19 +25,19 @@ dataSources: handler: handleMarketRegistered - event: MarketPriceDataUpdated(indexed uint128,bytes32) handler: handleMarketPriceDataUpdated - - event: FundingParametersSet(uint128,uint256,uint256) + - event: FundingParametersSet(indexed uint128,uint256,uint256) handler: handleFundingParametersSet - - event: LiquidationParametersSet(uint128,uint256,uint256,uint256,uint256,uint256) + - event: LiquidationParametersSet(indexed uint128,uint256,uint256,uint256,uint256,uint256,uint256) handler: handleLiquidationParametersSet - - event: LockedOiPercentSet(uint128,uint256) - handler: handleLockedOiPercentSet - - event: OrderFeesSet(uint128,uint256,uint256) + - event: LockedOiRatioD18Set(indexed uint128,uint256) + handler: handleLockedOiRatioD18Set + - event: OrderFeesSet(indexed uint128,uint256,uint256) handler: handleOrderFeesSet - event: SettlementStrategyAdded(indexed uint128,(uint8,uint256,uint256,uint256,address,bytes32,string,uint256,uint256,bool),indexed uint256) handler: handleSettlementStrategyAdded - - event: SettlementStrategyEnabled(uint128,uint256,bool) + - event: SettlementStrategyEnabled(indexed uint128,uint256,bool) handler: handleSettlementStrategyEnabled - - event: OrderCommitted(indexed uint128,indexed uint128,indexed uint8,int128,uint256,uint256,uint256,bytes32,address) + - event: OrderCommitted(indexed uint128,indexed uint128,uint8,int128,uint256,uint256,uint256,indexed bytes32,address) handler: handleOrderCommitted file: ./src/core.ts