Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Funding Support #215

Merged
merged 6 commits into from
Nov 27, 2024
Merged

feat: Add Funding Support #215

merged 6 commits into from
Nov 27, 2024

Conversation

alex-stone
Copy link
Contributor

@alex-stone alex-stone commented Nov 8, 2024

What changed? Why?

This adds support for funding wallets for a given Crypto Asset and amount, using your Coinbase accounts as the source of funds to buy the asset.

Note:: This is an Alpha feature and you must reach out on the CDP SDK Discord to opt in.

This enables quoting a fund operation

Creating a fund quote and then executing it:

wallet = Coinbase::Wallet.create(network: Coinbase::Network::BASE_MAINNET)

# Generate a quote
quote = wallet.quote_fund(12, :usdc)

# Inspect quote.buy_fee (fiat) and quote.transfer_fee (crypto)
puts quote

# Execute the fund operation
op = quote.execute!

# Wait for the fund operation to complete. This could take a while since this involves off-chain + on-chain interactions.
op.wait!

Fund a wallet

wallet = Coinbase::Wallet.create(network: Coinbase::Network::BASE_MAINNET)

# Generate a fund operation
op = wallet.fund(12, :usdc)

# Wait for the fund operation to complete. This could take a while since this involves off-chain + on-chain interactions.
op.wait!

Qualified Impact

@cb-heimdall
Copy link

cb-heimdall commented Nov 8, 2024

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@alex-stone alex-stone changed the base branch from master to v0.11.0 November 13, 2024 18:42
@alex-stone alex-stone force-pushed the stone/funding branch 2 times, most recently from a867854 to a189a0d Compare November 18, 2024 21:36
# @param wallet_id [String] The Wallet ID of the sending Wallet
# @param amount [BigDecimal] The amount of the Asset to send
# @param network [Coinbase::Network, Symbol] The Network or Network ID of the Asset
# @param asset_id [Symbol] The Asset ID of the Asset to send

This comment was marked as resolved.

@alex-stone alex-stone force-pushed the stone/funding branch 4 times, most recently from ba63456 to 830d259 Compare November 22, 2024 20:00
This adds a CryptoAmount types that provides a wrapper for the
underlying CryptoAmount object and can provide helpers for converting
from atomic to whole amounts.

This provides a FiatAmount type as well to wrap our fiat amount +
currency pairings in a consistent manner.
This adds support for generating a quote of a wallet fund operation.

This will be able to be used to execute a fund operation soon.
This adds support for funding wallets using `wallet.fund` or
`address.fund`.

This will be extended to support leveraging a fund quote in a
subsequent commit.
This makes it so that after you generate a fund quote and verify
the amounts and fees make sense to you, you can execute that quote.

Note: If it has been a while the quote may expire and we will return
an error indicating that to you.
This fixes the rendering for Balance, CryptoAmount, and FiatAmount, to
print out the BigDecimals as a float.

They were erroneously printing the `amount` as an integer, which removes
the precision unnecessarily.
@alex-stone alex-stone changed the title feat: Add Funding Support 🚧 feat: Add Funding Support Nov 27, 2024
@alex-stone alex-stone merged commit e92329f into v0.11.0 Nov 27, 2024
10 checks passed
@alex-stone alex-stone deleted the stone/funding branch November 27, 2024 19:27
@alex-stone alex-stone mentioned this pull request Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants