Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 0 additions & 1 deletion examples/create_perp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def main():
print("Creating new perpetual market...")

params = CreatePerpParams(
starting_price=1.0,
beacon=beacon,
)

Expand Down
252 changes: 109 additions & 143 deletions src/perpcity_sdk/abis/perp_manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,19 @@
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "contract IFees",
"name": "feesModule",
"type": "address"
}
],
"name": "FeesModuleRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
"indexed": true,
"internalType": "uint8",
"name": "moduleType",
"type": "uint8"
},
{
"indexed": false,
"internalType": "contract ILockupPeriod",
"name": "lockupPeriodModule",
"indexed": true,
"internalType": "address",
"name": "module",
"type": "address"
}
],
"name": "LockupPeriodModuleRegistered",
"name": "ModuleRegistered",
"type": "event"
},
{
Expand Down Expand Up @@ -297,19 +290,6 @@
"name": "MarginAdjusted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "contract IMarginRatios",
"name": "marginRatiosModule",
"type": "address"
}
],
"name": "MarginRatiosModuleRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -483,13 +463,13 @@
{
"indexed": false,
"internalType": "int256",
"name": "perpDelta",
"name": "exitPerpDelta",
"type": "int256"
},
{
"indexed": false,
"internalType": "int256",
"name": "usdDelta",
"name": "exitUsdDelta",
"type": "int256"
},
{
Expand All @@ -503,6 +483,42 @@
"internalType": "int24",
"name": "tickUpper",
"type": "int24"
},
{
"indexed": false,
"internalType": "int256",
"name": "netUsdDelta",
"type": "int256"
},
{
"indexed": false,
"internalType": "int256",
"name": "funding",
"type": "int256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "utilizationFee",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "adl",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "liquidationFee",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int256",
"name": "netMargin",
"type": "int256"
}
],
"name": "PositionClosed",
Expand Down Expand Up @@ -575,19 +591,6 @@
"name": "PositionOpened",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "contract ISqrtPriceImpactLimit",
"name": "sqrtPriceImpactLimitModule",
"type": "address"
}
],
"name": "SqrtPriceImpactLimitModuleRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -714,12 +717,12 @@
},
{
"internalType": "int256",
"name": "perpDelta",
"name": "usdDelta",
"type": "int256"
},
{
"internalType": "uint128",
"name": "usdLimit",
"name": "perpLimit",
"type": "uint128"
}
],
Expand Down Expand Up @@ -966,11 +969,6 @@
"internalType": "contract ISqrtPriceImpactLimit",
"name": "sqrtPriceImpactLimit",
"type": "address"
},
{
"internalType": "uint160",
"name": "startingSqrtPriceX96",
"type": "uint160"
}
],
"internalType": "struct IPerpManager.CreatePerpParams",
Expand Down Expand Up @@ -1091,69 +1089,17 @@
{
"inputs": [
{
"internalType": "contract IFees",
"name": "",
"type": "address"
}
],
"name": "isFeesRegistered",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ILockupPeriod",
"name": "",
"type": "address"
}
],
"name": "isLockupPeriodRegistered",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IMarginRatios",
"name": "",
"type": "address"
}
],
"name": "isMarginRatiosRegistered",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
"internalType": "uint8",
"name": "moduleType",
"type": "uint8"
},
{
"internalType": "contract ISqrtPriceImpactLimit",
"name": "",
"internalType": "address",
"name": "module",
"type": "address"
}
],
"name": "isSqrtPriceImpactLimitRegistered",
"name": "isModuleRegistered",
"outputs": [
{
"internalType": "bool",
Expand Down Expand Up @@ -1505,14 +1451,19 @@
"type": "int256"
},
{
"internalType": "uint256",
"internalType": "int256",
"name": "netMargin",
"type": "uint256"
"type": "int256"
},
{
"internalType": "bool",
"name": "wasLiquidated",
"type": "bool"
},
{
"internalType": "uint256",
"name": "notional",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
Expand Down Expand Up @@ -1653,51 +1604,66 @@
{
"inputs": [
{
"internalType": "contract IFees",
"name": "feesModule",
"type": "address"
}
],
"name": "registerFeesModule",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
"internalType": "PoolId",
"name": "perpId",
"type": "bytes32"
},
{
"internalType": "contract ILockupPeriod",
"name": "lockupPeriodModule",
"type": "address"
"internalType": "bool",
"name": "zeroForOne",
"type": "bool"
},
{
"internalType": "bool",
"name": "isExactIn",
"type": "bool"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint160",
"name": "sqrtPriceLimitX96",
"type": "uint160"
}
],
"name": "registerLockupPeriodModule",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
"name": "quoteSwap",
"outputs": [
{
"internalType": "contract IMarginRatios",
"name": "marginRatiosModule",
"type": "address"
"internalType": "bytes",
"name": "unexpectedReason",
"type": "bytes"
},
{
"internalType": "int256",
"name": "perpDelta",
"type": "int256"
},
{
"internalType": "int256",
"name": "usdDelta",
"type": "int256"
}
],
"name": "registerMarginRatiosModule",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISqrtPriceImpactLimit",
"name": "sqrtPriceImpactLimitModule",
"internalType": "uint8",
"name": "moduleType",
"type": "uint8"
},
{
"internalType": "address",
"name": "module",
"type": "address"
}
],
"name": "registerSqrtPriceImpactLimitModule",
"name": "registerModule",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down Expand Up @@ -1971,4 +1937,4 @@
"stateMutability": "view",
"type": "function"
}
]
]
2 changes: 1 addition & 1 deletion src/perpcity_sdk/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _fetch_position_live_details(self, perp_id: str, position_id: int) -> LiveDe
def _fetch() -> LiveDetails:
result = self._perp_manager.functions.quoteClosePosition(position_id).call()

unexpected_reason, pnl, funding, net_margin, was_liquidated = result
unexpected_reason, pnl, funding, net_margin, was_liquidated, _notional = result

if unexpected_reason != b"" and unexpected_reason != "0x":
raise PerpCityError(
Expand Down
Loading
Loading