Class: WhopSDK::Resources::Swaps

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/swaps.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Swaps

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Swaps.

Parameters:



47
48
49
# File 'lib/whop_sdk/resources/swaps.rb', line 47

def initialize(client:)
  @client = client
end

Instance Method Details

#create_quote(amount:, from_token:, to_token:, from_address: nil, from_chain: nil, metadata: nil, slippage_bps: nil, to_address: nil, to_chain: nil, request_options: {}) ⇒ WhopSDK::Models::SwapCreateQuoteResponse

Returns a stateless swap price preview. No funds move and nothing is persisted.

Parameters:

  • amount (String)

    Input token amount.

  • from_token (String)

    Source token contract address.

  • to_token (String)

    Destination token contract address.

  • from_address (String, nil)
  • from_chain (String, Integer, nil)
  • metadata (Hash{Symbol=>Object})
  • slippage_bps (Integer, nil)
  • to_address (String, nil)
  • to_chain (String, Integer, nil)
  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
# File 'lib/whop_sdk/resources/swaps.rb', line 33

def create_quote(params)
  parsed, options = WhopSDK::SwapCreateQuoteParams.dump_request(params)
  @client.request(
    method: :post,
    path: "swaps/quote",
    body: parsed,
    model: WhopSDK::Models::SwapCreateQuoteResponse,
    options: options
  )
end