Class: Privy::Resources::Wallets::Swap
- Inherits:
-
Object
- Object
- Privy::Resources::Wallets::Swap
- Defined in:
- lib/privy/resources/wallets/swap.rb,
sig/privy/resources/wallets/swap.rbs
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, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::Wallets::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, privy_request_expiry: 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.
108 109 110 |
# File 'lib/privy/resources/wallets/swap.rb', line 108 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, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::Wallets::SwapActionResponse
Some parameter documentations has been truncated, see Models::Wallets::SwapExecuteParams for more details.
Execute a token swap within a wallet.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/privy/resources/wallets/swap.rb', line 40 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", privy_request_expiry: "privy-request-expiry" } @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::Wallets::SwapActionResponse, options: ) end |
#quote(wallet_id, base_amount:, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_authorization_signature: nil, privy_request_expiry: 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.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/privy/resources/wallets/swap.rb', line 88 def quote(wallet_id, params) parsed, = Privy::Wallets::SwapQuoteParams.dump_request(params) header_params = { privy_authorization_signature: "privy-authorization-signature", privy_request_expiry: "privy-request-expiry" } @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 |