5 golang怎么解析solana的pool信息

使用golang解析pool信息,但是获取的信息为空,有没有好心人解答下

type PoolState struct {
    // Bump to identify PDA
    Bump      [1]uint8
    AmmConfig ag_solanago.PublicKey
    Owner     ag_solanago.PublicKey

    // Token pair of the pool, where token_mint_0 address < token_mint_1 address
    TokenMint0 ag_solanago.PublicKey
    TokenMint1 ag_solanago.PublicKey

    // Token pair vault
    TokenVault0 ag_solanago.PublicKey
    TokenVault1 ag_solanago.PublicKey

    // observation account key
    ObservationKey ag_solanago.PublicKey

    // mint0 and mint1 decimals
    MintDecimals0 uint8
    MintDecimals1 uint8

    // The minimum number of ticks between initialized ticks
    TickSpacing uint16

    // The currently in range liquidity available to the pool.
    Liquidity ag_binary.Uint128

    // The current price of the pool as a sqrt(token_1/token_0) Q64.64 value
    SqrtPriceX64 ag_binary.Uint128

    // The current tick of the pool, i.e. according to the last tick transition that was run.
    TickCurrent int32

    // the most-recently updated index of the observations array
    ObservationIndex          uint16
    ObservationUpdateDuration uint16

    // The fee growth as a Q64.64 number, i.e. fees of token_0 and token_1 collected per
    // unit of liquidity for the entire life of the pool.
    FeeGrowthGlobal0X64 ag_binary.Uint128
    FeeGrowthGlobal1X64 ag_binary.Uint128

    // The amounts of token_0 and token_1 that are owed to the protocol.
    ProtocolFeesToken0 uint64
    ProtocolFeesToken1 uint64

    // The amounts in and out of swap token_0 and token_1
    SwapInAmountToken0  ag_binary.Uint128
    SwapOutAmountToken1 ag_binary.Uint128
    SwapInAmountToken1  ag_binary.Uint128
    SwapOutAmountToken0 ag_binary.Uint128

    // Bitwise representation of the state of the pool
    // bit0, 1: disable open position and increase liquidity, 0: normal
    // bit1, 1: disable decrease liquidity, 0: normal
    // bit2, 1: disable collect fee, 0: normal
    // bit3, 1: disable collect reward, 0: normal
    // bit4, 1: disable swap, 0: normal
    Status uint8

    // Leave blank for future use
    Padding     [7]uint8
    RewardInfos [3]RewardInfo

    // Packed initialized tick array state
    TickArrayBitmap [16]uint64

    // except protocol_fee and fund_fee
    TotalFeesToken0 uint64

    // except protocol_fee and fund_fee
    TotalFeesClaimedToken0 uint64
    TotalFeesToken1        uint64
    TotalFeesClaimedToken1 uint64
    FundFeesToken0         uint64
    FundFeesToken1         uint64
    OpenTime               uint64
    Padding1               [25]uint64
    Padding2               [32]uint64
}

func (this *PairInfo) GetPoolState(ctx context.Context, poolAddress solana.PublicKey) {
    var pool amm_v3.PoolState
    //var polls interface{}
    account, err := SolanaRpcClient.GetAccountInfoWithOpts(context.TODO(),
        poolAddress,
        &rpc.GetAccountInfoOpts{
            Encoding:   solana.EncodingJSONParsed,
            Commitment: rpc.CommitmentFinalized,
        },
    )
    fmt.Println(err)
    dataPos := account.GetBinary()

    json.Unmarshal(dataPos, &pool)
    borshDec := bin.NewBorshDecoder(dataPos)
    borshDec.Decode(&pool)
    //log.Println(wpData)
    util.JsonLogInfo(pool)
}
请先 登录 后评论

2 个回答

Wade - Footprint Analytics CTO
  擅长:数据分析,GameFi,NFT
请先 登录 后评论
NPC.李括
请先 登录 后评论
  • 2 关注
  • 0 收藏,1560 浏览
  • 提出于 2024-05-19 17:51