Sha256: 3e7d96684b8e0cefdd7a14ade3ff0c9ebfa02425eb72b174e430bad841abe411

Contents?: true

Size: 918 Bytes

Versions: 3

Compression:

Stored size: 918 Bytes

Contents

module Stellar
  module LiquidityPool
    class BasePool
      attr_reader :asset_a, :asset_b, :fee

      # @param asset_a [Asset]
      # @param asset_b [Asset]
      def initialize(asset_a:, asset_b:)
        @asset_a = asset_a
        @asset_b = asset_b
        @fee = LIQUIDITY_POOL_FEE_V18
      end

      def id
        PoolID.to_xdr(to_pool_id, :hex)
      end

      def to_s
        "liquidity_pool:#{id}"
      end

      def inspect
        "#<#{self.class.name} #{self}>"
      end

      def to_pool_id
        Digest::SHA256.digest(pool_params.to_xdr)
      end

      def to_change_trust_asset
        ChangeTrustAsset.liquidity_pool(pool_params)
      end

      def to_trust_line_asset
        TrustLineAsset.liquidity_pool_id(to_pool_id)
      end

      def pool_type
        raise NotImplementedError
      end

      def pool_params
        raise NotImplementedError
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stellar-base-0.32.0 lib/stellar/liquidity_pool/base_pool.rb
stellar-base-0.31.0 lib/stellar/liquidity_pool/base_pool.rb
stellar-base-0.30.0 lib/stellar/liquidity_pool/base_pool.rb