Class: Privy::Resources::Wallets::Swap
- Inherits:
-
Object
- Object
- Privy::Resources::Wallets::Swap
- Defined in:
- lib/privy/resources/wallets/swap.rb
Overview
Operations for swapping tokens within wallets
Instance Method Summary collapse
-
#execute(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, privy_idempotency_key: nil, request_options: {}) ⇒ Privy::Models::SwapActionResponse
Some parameter documentations has been truncated, see Models::Wallets::SwapExecuteParams for more details.
-
#initialize(client:) ⇒ Swap
constructor
private
A new instance of Swap.
-
#quote(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, request_options: {}) ⇒ Privy::Models::SwapQuoteResponse
Some parameter documentations has been truncated, see Models::Wallets::SwapQuoteParams for more details.
Constructor Details
#initialize(client:) ⇒ Swap
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 Swap.
99 100 101 |
# File 'lib/privy/resources/wallets/swap.rb', line 99 def initialize(client:) @client = client end |
Instance Method Details
#execute(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, privy_idempotency_key: nil, request_options: {}) ⇒ Privy::Models::SwapActionResponse
Some parameter documentations has been truncated, see Models::Wallets::SwapExecuteParams for more details.
Execute a token swap within a wallet.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/privy/resources/wallets/swap.rb', line 38 def execute(wallet_id, params) parsed, = Privy::Wallets::SwapExecuteParams.dump_request(params) header_params = { privy_authorization_signature: "privy-authorization-signature", privy_idempotency_key: "privy-idempotency-key" } @client.request( method: :post, path: ["v1/wallets/%1$s/swap", wallet_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Privy::SwapActionResponse, options: ) end |
#quote(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, request_options: {}) ⇒ Privy::Models::SwapQuoteResponse
Some parameter documentations has been truncated, see Models::Wallets::SwapQuoteParams for more details.
Get a price quote for swapping tokens within a wallet.
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/privy/resources/wallets/swap.rb', line 83 def quote(wallet_id, params) parsed, = Privy::Wallets::SwapQuoteParams.dump_request(params) header_params = {privy_authorization_signature: "privy-authorization-signature"} @client.request( method: :post, path: ["v1/wallets/%1$s/swap/quote", wallet_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Privy::SwapQuoteResponse, options: ) end |