BlockPo / BlockPo-to-Tradelayer

Incubation Repo for the TradeLayer protocol, 0.2.0
http://www.tradelayer.org
Other
8 stars 8 forks source link

Open interest RPC #238

Closed Galuf1 closed 4 years ago

Galuf1 commented 4 years ago

We need to build an open interest RPC, logic has to be derived from settlement tracking of contracts, where we can count how many new contracts are open with a buyer and a seller, and when we are closing contracts (closing at both sides), adding that amount should set a live amount of contracts.

patrickdugan commented 4 years ago

Aren't we already tracking net contract positions on any given block in the tallmap? It seems like this is similar to RPCs that get total # of tokens and that take the absolute value of the positives or negatives.

Galuf1 commented 4 years ago

I don't know how you feel about it but there is 2 choices, taking absolute values or all positions, which would require iterating through the database every block to check how many positions have the key of the contract name, updated with how many they closed. Or counting what's in the containers from the contract, which rebuild from settlement to settlement. The latter one is being done, we need to put it in a RPC only, it shouldn't take much time.

The # of tokens if i'm not mistaken is not the same for contracts, we don't keep a record of new tokens since in the case of contracts every new token requires 1 token on each side.

patrickdugan commented 4 years ago

Good point, ideally we could track OI between blocks but OI between settlements is acceptable if it's easier.

On Thu, May 7, 2020 at 12:37 PM Galuf1 notifications@github.com wrote:

I don't know how you feel about it but there is 2 choices, taking absolute values or all positions, which would require iterating through the database every block to check how many positions have the key of the contract name, updated with how many they closed. Or counting what's in the containers from the contract, which rebuild from settlement to settlement. The latter one is being done, we need to put it in a RPC only, it shouldn't take much time.

The # of tokens if i'm not mistaken is not the same for contracts, we don't keep a record of new tokens since in the case of contracts every new token requires 1 token on each side.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BlockPo/BlockPo-to-Tradelayer/issues/238#issuecomment-625364692, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS2CBOODQIFK77ZHI6DMULRQLPUPANCNFSM4MNNCTZQ .

Galuf1 commented 4 years ago

We should be able to track it live after every block following the containers, i'll get the variable, i think i found it last time.