Skip to content

Commit

Permalink
Explicitly calculating withdrawal shares pnl instead of preview (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
slundqui authored Oct 18, 2023
1 parent 7503bbf commit 6f147d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/chainsync/chainsync/analysis/calc_pnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ def calc_single_closeout(
elif tokentype == "WITHDRAWAL_SHARE":
fn_args = (amount, min_output, address, as_underlying)
try:
preview_result = smart_contract_preview_transaction(
contract, sender, "redeemWithdrawalShares", *fn_args, block_identifier=position["blockNumber"]
)
out_pnl = preview_result["proceeds"] / Decimal(1e18)
# For PNL, we assume all withdrawal shares are redeemable
# even if there are no withdrawal shares available to withdraw
# Hence, we don't use preview transaction here
out_pnl = Decimal(
amount * pool_info["sharePrice"].values[-1] * pool_info["lpSharePrice"].values[-1]
) / Decimal(1e18)
except Exception as exception: # pylint: disable=broad-except
logging.warning("Exception caught, ignoring: %s", exception)
else:
Expand Down

1 comment on commit 6f147d0

@vercel
Copy link

@vercel vercel bot commented on 6f147d0 Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.