Skip to content

Commit

Permalink
Merge pull request #34 from rysk-finance/fix/sc-positions
Browse files Browse the repository at this point in the history
Fix/sc positions
  • Loading branch information
ugolino authored Jan 17, 2024
2 parents 597561d + b31d776 commit 17593a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rysk-subgraph",
"version": "1.4.1",
"version": "1.4.2",
"license": "UNLICENSED",
"scripts": {
"prepare": "scripts/generate_addresses.sh && mustache config.json subgraph.template.yaml > subgraph.yaml",
Expand Down
2 changes: 1 addition & 1 deletion src/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export function handleShortOtokenMinted(event: ShortOtokenMinted): void {
action.amount = amount
action.save()

if (event.transaction.to!.toHex() != OPTION_EXCHANGE) {
if (event.params.to.toHex() != OPTION_EXCHANGE) {
// ignore if not from option exchange as it will not have a position
return
}
Expand Down
13 changes: 5 additions & 8 deletions src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ShortPosition,
Stat,
} from '../generated/schema'
import { CHAINLINK_AGGREGATOR_ETH_USD, CONTROLLER } from './addresses'
import { CHAINLINK_AGGREGATOR_ETH_USD, CONTROLLER, OPTION_EXCHANGE } from './addresses'
import { BIGINT_ONE, BIGINT_ZERO, BIG_DECIMAL_ZERO, DEFAULT_VAULT_ID, ZERO_ADDRESS } from './constants'

export const SHORT_OTOKEN_BURNED = '0xdd96b18f26fd9950581b9fd821fa907fc318845fc4d220b825a7b19bfdd174e8'
Expand Down Expand Up @@ -490,12 +490,11 @@ export function addOptionsBoughtAction(event: OptionsBought): void {
for (let i = 0; i < txLogs.length; ++i) {
// if event is to Controller, avoid reading all events
if (txLogs[i].address.toHexString() == CONTROLLER) {
// if topic is ShortOtokenBurned and account owner is tx sender (trader)
// if topic is ShortOtokenBurned and account owner is not the options exchange to exclude options exchange trades
if (
txLogs[i].topics[0].toHexString() == SHORT_OTOKEN_BURNED &&
txLogs[i].topics[2].toHexString().slice(26) == from.toHexString().slice(2)
txLogs[i].topics[2].toHexString().slice(26) != OPTION_EXCHANGE
) {
// if topic is shortOTokenBurned and account owner is tx sender (trader)
updateOptionShortPosition(true, buyer, otoken, amount, id, premium, vaultId, fee)
return
}
Expand Down Expand Up @@ -549,13 +548,11 @@ export function addOptionsSoldAction(event: OptionsSold): void {
for (let i = 0; i < txLogs.length; ++i) {
// if event is to Controller, avoid reading all events
if (txLogs[i].address.toHexString() == CONTROLLER) {
// if topic is ShortOtokenMinted and account owner is tx sender (trader)
// if topic is ShortOtokenMinted and account owner is not the options exchange to exclude options exchange trades
if (
txLogs[i].topics[0].toHexString() == SHORT_OTOKEN_MINTED &&
txLogs[i].topics[2].toHexString().slice(26) == event.transaction.from.toHexString().slice(2)
txLogs[i].topics[2].toHexString().slice(26) != OPTION_EXCHANGE
) {
// if topic is shortOtokenMinted and account owner is tx sender (trader)

updateOptionShortPosition(false, seller, otoken, amount, id, premium, vaultId, fee)
return
}
Expand Down

0 comments on commit 17593a8

Please sign in to comment.