bancorprotocol / carbon-backend

MIT License
1 stars 5 forks source link

API should provide a way to get volume of a particular user between particular duration with trading pair wise #36

Open zavelevsky opened 1 month ago

zavelevsky commented 1 month ago

request by FusionX

ashachaf commented 1 month ago

to be a bit more specific with the request

  1. endpoint (in the lines of): /generated_volume
  2. input filters/values:
    • startDate
    • endDate
    • list of wallets (to allow anything between 1 to all wallets. optional value. if empty, fetch ALL wallets)
  3. expected outcome (in words):
    • 2 levels of information.
    • level 1: raw data -- group by strategy owner -- show every trade action (sell or buy) that used any of the strategies this wallet owns (this is what we currently display on the activity api)
    • level 2: total -- group by strategy owner -- show total token change from the above raw data -- important to note: we should use abs values when calculating the volume summary.
      example:
      the sum volume of the below two sell actions is:
      token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 = abs(6.718263)+abs(1.11268) = 7.830943
      token 0xdAC17F958D2ee523a2206206994597C13D831ec7 = abs(-6.717591)+abs(-1.112568) = 7.830159
      [
      {
      "action": "sell",
      "strategy": {
      "id": "1020847100762815390390123822295304634371",
      "owner": "0x5f7a009664B771E889751f4FD721aDc439033ECD",
      "base": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "quote": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
      "buy": {
      "budget": "41.197296",
      "min": "0.9998999999999989",
      "max": "0.9998999999999989",
      "marginal": "0.9998999999999989"
      },
      "sell": {
      "budget": "59.14971",
      "min": "1.0001000000000049",
      "max": "1.0001000000000049",
      "marginal": "1.0001000000000049"
      }
      },
      "blockNumber": 20510509,
      "txHash": "0x4e3174379471c2584c6576409060f70f1d6008eb5f801936cf45c7f232af5b3c",
      "timestamp": 1723441271,
      "changes": {
      "buy": {
      "budget": "6.718263",
      "min": "0",
      "max": "0",
      "marginal": "0"
      },
      "sell": {
      "budget": "-6.717591",
      "min": "0",
      "max": "0",
      "marginal": "0"
      }
      }
      },
      {
      "action": "sell",
      "strategy": {
      "id": "1020847100762815390390123822295304634371",
      "owner": "0x5f7a009664B771E889751f4FD721aDc439033ECD",
      "base": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "quote": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
      "buy": {
      "budget": "34.479033",
      "min": "0.9998999999999989",
      "max": "0.9998999999999989",
      "marginal": "0.9998999999999989"
      },
      "sell": {
      "budget": "65.867301",
      "min": "1.0001000000000049",
      "max": "1.0001000000000049",
      "marginal": "1.0001000000000049"
      }
      },
      "blockNumber": 20510038,
      "txHash": "0xdf32da14dddf938fa2646a263ca2948c5ca03befe103c24d0b2199941c46cac4",
      "timestamp": 1723435595,
      "changes": {
      "buy": {
      "budget": "1.11268",
      "min": "0",
      "max": "0",
      "marginal": "0"
      },
      "sell": {
      "budget": "-1.112568",
      "min": "0",
      "max": "0",
      "marginal": "0"
      }
      }
      }
      ]