Class: WhopSDK::Resources::Swaps
- Inherits:
-
Object
- Object
- WhopSDK::Resources::Swaps
- Defined in:
- lib/whop_sdk/resources/swaps.rb,
sig/whop_sdk/resources/swaps.rbs
Overview
Swaps convert value between supported tokens, chains, or wallet destinations for an account. A swap quote describes the expected output, fees, and approval requirements before you create the swap.
Use the Swaps API to quote a conversion, create the swap, list recent swaps, and retrieve status until the transaction completes.
Instance Method Summary collapse
-
#create(account_id:, amount:, from_token:, to_token:, from_chain: nil, slippage_bps: nil, to_chain: nil, request_options: {}) ⇒ WhopSDK::Models::SwapCreateResponse
Some parameter documentations has been truncated, see Models::SwapCreateParams for more 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
Some parameter documentations has been truncated, see Models::SwapCreateQuoteParams for more details.
-
#initialize(client:) ⇒ Swaps
constructor
private
A new instance of Swaps.
-
#list(account_id:, request_options: {}) ⇒ WhopSDK::Models::SwapListResponse
Lists the account's swaps.
-
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::SwapRetrieveResponse
Returns the status of a specific swap, by the id returned from POST /swaps.
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.
138 139 140 |
# File 'lib/whop_sdk/resources/swaps.rb', line 138 def initialize(client:) @client = client end |
Instance Method Details
#create(account_id:, amount:, from_token:, to_token:, from_chain: nil, slippage_bps: nil, to_chain: nil, request_options: {}) ⇒ WhopSDK::Models::SwapCreateResponse
Some parameter documentations has been truncated, see Models::SwapCreateParams for more details.
Executes a swap from the account's wallet. Runs asynchronously; poll GET /swaps/id for status.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/whop_sdk/resources/swaps.rb', line 39 def create(params) parsed, = WhopSDK::SwapCreateParams.dump_request(params) @client.request( method: :post, path: "swaps", body: parsed, model: WhopSDK::Models::SwapCreateResponse, options: ) end |
#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
Some parameter documentations has been truncated, see Models::SwapCreateQuoteParams for more details.
Returns a stateless swap price preview. No funds move and nothing is persisted.
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/whop_sdk/resources/swaps.rb', line 124 def create_quote(params) parsed, = WhopSDK::SwapCreateQuoteParams.dump_request(params) @client.request( method: :post, path: "swaps/quote", body: parsed, model: WhopSDK::Models::SwapCreateQuoteResponse, options: ) end |
#list(account_id:, request_options: {}) ⇒ WhopSDK::Models::SwapListResponse
Lists the account's swaps. Currently returns the in-flight or most recent swap, so zero or one rows.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/whop_sdk/resources/swaps.rb', line 82 def list(params) parsed, = WhopSDK::SwapListParams.dump_request(params) query = WhopSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "swaps", query: query, model: WhopSDK::Models::SwapListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::SwapRetrieveResponse
Returns the status of a specific swap, by the id returned from POST /swaps.
61 62 63 64 65 66 67 68 |
# File 'lib/whop_sdk/resources/swaps.rb', line 61 def retrieve(id, params = {}) @client.request( method: :get, path: ["swaps/%1$s", id], model: WhopSDK::Models::SwapRetrieveResponse, options: params[:request_options] ) end |