Balmy
DCA
DCA
  • Introduction to the protocol
  • FAQ
  • Concepts
    • Positions
      • Actions
      • NFT/Permissions
      • Swap Intervals
    • Fees
    • Swaps
    • Token Integration
    • Yield Sources
  • Architecture
    • Core
      • Hub
      • Permission Manager
      • NFT Descriptor
    • Periphery
      • Companion
      • Libraries
  • Tech Guides
    • Interacting with the protocol
    • Smart Contract Registry
    • Swaps
      • Next Swap
      • Executing a Flash Swap
    • Position Management
      • Creating a Position
      • Modifying a Position
      • Withdrawing from a Position
      • Terminating a Position
    • Permission Management
    • Subgraphs
      • Playground
      • Fetch all pairs
      • Fetch all tokens
      • Fetch all active intervals
      • Fetch positions by address
    • Github
  • Mean explained by friends
    • By Perpetual Protocol
    • By Ceazor's Snack Sandwich
  • Other
    • Bug Reports
Powered by GitBook
On this page
  • Execution
  • Query
  • Response

Was this helpful?

  1. Tech Guides
  2. Subgraphs

Fetch positions by address

PreviousFetch all active intervals

Last updated 2 years ago

Was this helpful?

Execution

You can execute this query on our Optimism subgraph, .

Query

Get all positions from a user by wallet address. This query will return information like:

  • Name of the token used to buy

  • Name token to be bought

  • Total deposited into the position (expressed in from token with applied decimals)

  • Total withdrawn from the position (expressed in to token with applied decimals)

  • Current will hold the current state of the position.

    • Rate with which the position will swap

    • Remaining swaps of the position

  • Swap interval

    • Interval (expressed in seconds)

  • Status (ACTIVE, or TERMINATED)

  • Block at which the position was created

  • Timestamp of the block at which the position was created

{
  positions (where: { user: "{{ADDRESS_OF_USER}}" }) {
    user
    from {
      name
    }
    to {
      name
    }
    totalDeposited
    totalWithdrawn
    rate
    remainingSwaps
    swapInterval {
      interval
    }
    status
    createdAtBlock
    createdAtTimestamp
  }
}

Response

{
  data {
    positions: [
      {
        user: Bytes
        from {
          name: string
        }
        to {
          name: string
        }
        totalDeposits: BigInt
        totalWithdrawn: BigInt
        current {
          rate: BigInt
          remainingSwaps: BigInt
        }
        swapInterval {
          interval: BigInt
        }
        status: "ACTIVE" or "TERMINATED"
        createdAtBlock: BigInt
        createdAtTimestamp: BigInt
      }
    ]
  }
}
here