subgraphs icon indicating copy to clipboard operation
subgraphs copied to clipboard

Arakkis Finance Optimism: Possible misprice on lp tokens (find new oracle pricing)

Open bye43 opened this issue 2 years ago • 4 comments

@tnkrxyz Was investigating some protocols and noticed that Arrakis Finance OP has a really high withdraw values, which after further exploration makes sense for liquidity mining, but some of the amountUSD values seem slightly off from what I am seeing on optimism scan. For example in the first transaction in this query, we are recording a withdrawal amount of 800k, but when you dive into the optimism scan and eigentx chart looks like the whole transaction started with 610K. Feels like it could potentially be a mispricing somewhere on our end? Not exactly sure if this is wrong, but wanted to get some other eyes on it.

bye43 avatar Jun 22 '23 19:06 bye43

@bye43 , my deployment hasn't synced to the tx you noted, but this is what I found so far: the difference is most likely due to inaccurate/stale prices from oracle. For example, for this tx, the amounts of WETH in the withdraw in the subgraph log match optimism scan exactly at 638485634774337944364, but the USD amounts differ: $1,642,437.28 (subgraph) vs $1,190,507.05 (opscan), or a price difference of $2572.395051/WETH (subgraph) vs $1873.55/WETH (opscan):

  {
    "timestamp": "2023-06-28T05:41:22.693889999Z",
    "text": "[createWithdraw]tx 0x478e91cff51c688c5b60a20168ae7b568715fc0b29990d8897409283535bbaf8-10 vault 0x665d8d87ac09bdbc1222b8b9e72ddcb82f76b54a tokens (0x420000000000000000000000
0000000000000006, 0x61baadcf22d2565b0f471b291c475db5555e0b76): amounts=(638485634774337944364, 33085605264095341106) prices=(2572.395051, 49497.116769) amountsUSD=(1642437.2870281004298
83466942564, 1637642.067129968181872567606514), amountUSD=3280079.354158068611756034549078, data_source: ArrakisVault, component: UserMapping"
  },

I will check the tx you noted once the subgraph syncs there.

tnkrxyz avatar Jun 24 '23 23:06 tnkrxyz

@bye43, here is the info for the withdraw tx you noted:

  {
    "timestamp": "2023-06-29T06:33:40.835477039Z",
    "text": "[createWithdraw]tx 0xd389dd19f96f13bedebf317e8d11f6c4020d8929ef57661b82e33b1d774169b7-17 vault 0x9f831ba50004c265396515b7dd29a63523cb7826 tokens (0x1f32b1c2345538c0c6f582fc
b022739c4a194ebb, 0x7f5c764cbc14f9669b88837ca1490cca17c31607): amounts=(88426028677744490260, 610570102841) prices=(2360.478402, 0.99996128) amountsUSD=(208727.73086844848733322936452,
610546.46156661799648), amountUSD=819274.19243506648381322936452, data_source: ArrakisVault, component: UserMapping"
  },

The $611,180.67 on optimism scan is the value of USDC in the withdraw. There is also 88.42 wstETH, which according to the oracle we use is priced at $2360.478402, and thus the total amountUSD of the withdraw is $611,180.67 + 88.426028677744490260 * 2360.478402 = 819274.19243506648381322936452. Everything looks OK to me, except for difference in prices.

tnkrxyz avatar Jul 02 '23 04:07 tnkrxyz

Ya that makes sense. Is there any easy fix for us in terms of pricing (i.e. using a diff price oracle)? That $2360 value seems significantly higher than what it should be Image

bye43 avatar Jul 03 '23 19:07 bye43

cc: @tnkrxyz

bye43 avatar Jul 03 '23 19:07 bye43