Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge FpmmLiquidity and FpmmTrade #77

Closed
altbee opened this issue Oct 26, 2020 · 6 comments
Closed

Merge FpmmLiquidity and FpmmTrade #77

altbee opened this issue Oct 26, 2020 · 6 comments

Comments

@altbee
Copy link

altbee commented Oct 26, 2020

Screen Shot 2020-10-26 at 8 04 31 AM
Screen Shot 2020-10-26 at 8 04 39 AM

I think we can merge all fields and add one more field to check if it's FpmmLiquidity or FpmmTrade.

@davidalbela
Copy link
Contributor

They come from different FPMM contract events.

@altbee
Copy link
Author

altbee commented Oct 26, 2020

@davidalbela

protofire/omen-exchange#1194
Mi-Lan needs to sort fpmmLiquidities and fpmmTrades items by creationTimestamp and implement pagination.
Using the following query,

For example, using the following query, he gets the first 3 liquidities and trades.
But he needs to only 3 items( merge 3 liquidities and trades and totally 6 items, sort by date and get the first 3)

Is there any solution to implement his needs using query, do you think?
It's not a good idea to fetch all liquidities/trades, merge them, sort them and implement pagination.

{
  fpmmLiquidities(
    where: {
      fpmm: "0x748a098efb58b8f61961cab15bcc92a3174c221a"
    }
    first:3
    orderBy: creationTimestamp
  ) {
    outcomeTokenAmounts
    type
  }
  fpmmTrades(
    where:{
      fpmm:"0x748a098efb58b8f61961cab15bcc92a3174c221a"
    }
    first:3
    orderBy: creationTimestamp
  ){
    type
    feeAmount
    outcomeTokensTraded
    collateralToken
  }
}

@davidalbela
Copy link
Contributor

davidalbela commented Oct 30, 2020

The entities are being used by the bots for different approaches.

What about create a common entity? Eg: FPMMTransaction with the following attributes:

id: ID!
fpmm: FixedProductMarketMaker!
user: Account!
transactionType: TransactionType!
collateralAmount: BigInt! 
collateralTokenAddress: Bytes!
collateralTokenAmount: BigInt!
creationTimestamp: BigInt!

Where collateralAmount field is the sharesMinted/sharesBurnt from a FPMMFundingAdded/FPMMFundingRemoved event and investmentAmount/returnAmount from a FPMMBuy /FPMMSell event.

There is also a FpmmParticipation entity being used for buy, sell, and transfer events.

gejeduck pushed a commit to gejeduck/omen-subgraph that referenced this issue Nov 3, 2020
@davidalbela
Copy link
Contributor

Could be possible to include the tx hash on it?

@Mi-Lan
Copy link
Contributor

Mi-Lan commented Nov 5, 2020

@davidalbela it seems that astro514 made those changes #80 for tx hash and also for main issue gejeduck@a66cab1

@pimato
Copy link
Contributor

pimato commented Nov 6, 2020

this issue was fixed by #81

@pimato pimato closed this as completed Nov 6, 2020
kadenzipfel added a commit that referenced this issue Nov 24, 2020
* Add `FPMMTrade` entity into the subgraph

* Fix TradeType enum and FPMMTrade creator type

* Add custom trade subgraph to package info

* Set `outcomeIndex` to type BigInt

* Rename FPMMTrade attributes to `amount` and `outcomeTokensTrade`

* Set FPMMTrade `creator` attribute to type string

* Rename FpmmTrade attributes to `collateralAmount` and `outcomeTokensTraded`

* Set package deployments to protofire

* Fix omen subgraphs name

* Add tradeNonce to Account

  * Increment the `tradeNonce` on every sell or buy event.

* Set package deployments to protofire

* Update Reality.eth adapter

* Add RealitioScalarAdapter to deployment

* Add ScalarQuestionLink entity

* Refine testing workflow, adding test-fresh-deploy task

* Enable standard uint questions from Realitio to be indexed

* WIP scalar market tests

* Preannounced scalar market links now enable scalar markets

* Scalar market link can be established after condition created

* Add more details about different question IDs when using scalar markets

* Fully switch to Yarn

* Use switch task runner from NPM to Yarn

* Fix set `account.tradeNonce` on recordTrade

* Set package deployments to protofire

* Deploy RealitioScalarAdapter on Rinkeby and Mainnet

* Fix Omen Verified Markets on Rinkeby

The previous version of the list used a buggy centralized arbitrator. This fixes the issue.

* Copy bounds to condition and FPMM entities

* Set rinkeby and mainnet deployments to protofire

* Fix repository endpoint on package.json

* Add USD amount in FPMMTrade entity

Add a new field `collateralAmountUSD` as BigDecimal type to calculate
the value of `collateralAmount` in USD value at the moment of the trade.

Resolves: #72

* Add FPMM Liquidity entity

Add a new `FPMMLiquidity` entity with the record of every
`FPMMFundingAdded` and `FPMMFundingRemoved` events from all
FixedProductMarketMakert contracts.

Add a new `fpmm.calculateLiquidityParameter` method to calculate with the
`nthRoot` the collateral liquidity parameter.

Resolves: #71

* Rename field `collateralTokenAmount`

* Assignments for `collateralUSDPrice` and `collateralAmountUSD` into if conditional block. Set to `zeroDec` on declaration.

* Add FPMM Liquidity entity

Add a new `FPMMLiquidity` entity with the record of every
`FPMMFundingAdded` and `FPMMFundingRemoved` events from all
FixedProductMarketMakert contracts.

Add a new `fpmm.calculateLiquidityParameter` method to calculate with the
`nthRoot` the collateral liquidity parameter.

Resolves: #71

* Rename field `collateralTokenAmount`

* Add `additionalLiquidityParameter` Liquidity field

Add `additionalLiquidityParameter` field with the
`calculateLiquidityParameter` value.
Replace `collateralTokenAmount` to max/min value from
`outcomeTokenAmounts` list.
Add new `utils/Math.ts` file with max and min methods for BigInt[].

* Fix call as `recordFPMMLiquidity` BigInt parameter to `fromI32(0)`

* Add Outcome token marginal price to Trade entity

Set the old and new values for the `OutcomeTokenMarginalPrices` of the
selected outcome on the `FPMMBuy` and `FPMMSell` events to store that
values on FPMMTrade entity.

* Use original ConditionalTokens deployed on Rinkeby (#76)

* Add cast to `Array<BigDecimal>` to new and old `outcomeTokenMarginalPrices`

* Add transaction Hash to Trade and Liquidity entities

* Merge FpmmLiquidity and FpmmTrade #77 (#81)

* Add CollateralAmountUSD, FpmmType and TransactionHash to FpmmTransaction

* Add Answer event logic

* Add the TokenList entity for DxTokenRegister contract

* fix: add ERC20Details abi to DXTokenRegistry

Co-authored-by: David Albela Pérez <3659067+davidalbela@users.noreply.github.com>
Co-authored-by: Mariano Aguero <mariano.aguero@altoros.com>
Co-authored-by: Alan Lu <alanlu1023@gmail.com>
Co-authored-by: Matheus Faria de Alencar <mtsalenc@gmail.com>
Co-authored-by: Astro <bramchen77@outlook.com>
Co-authored-by: Thomas Pulber <corkus@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants