-
Notifications
You must be signed in to change notification settings - Fork 2
Bump Orca / Stonfi deps #55
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
Open
0xh3rman
wants to merge
5
commits into
main
Choose a base branch
from
bump-orca
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bdee56b
Update Solana, Orca, Ston-fi, and TON dependencies
0xh3rman 4634993
Update pnpm-lock.yaml
0xh3rman 3aa2ab3
Refactor createQuoteRequest override handling
0xh3rman 90c17d4
Add version info endpoint and build step
0xh3rman a80268e
Add missing version generation script
0xh3rman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import { Chain, QuoteRequest } from "@gemwallet/types"; | ||
|
|
||
| import { StonfiProvider } from "./index"; | ||
| import { createQuoteRequest, TON_ASSET, USDT_TON_ASSET } from "./testkit"; | ||
|
|
||
| const runIntegration = process.env.STONFI_INTEGRATION_TEST === "1"; | ||
| const describeIntegration = runIntegration ? describe : describe.skip; | ||
|
|
||
| const TON_RPC_ENDPOINT = | ||
| process.env.TON_URL || "https://toncenter.com"; | ||
|
|
||
| // A valid TON wallet address for testing (TON Foundation address) | ||
| const WALLET_ADDRESS = "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"; | ||
|
|
||
| const REQUEST_TEMPLATE: QuoteRequest = createQuoteRequest({ | ||
| from_address: WALLET_ADDRESS, | ||
| to_address: WALLET_ADDRESS, | ||
| from_asset: TON_ASSET, | ||
| to_asset: USDT_TON_ASSET, | ||
| from_value: "1000000000", // 1 TON | ||
| referral_bps: 50, | ||
| slippage_bps: 100, | ||
| }); | ||
|
|
||
| const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); | ||
|
|
||
| describeIntegration("Stonfi live integration", () => { | ||
| jest.setTimeout(60_000); | ||
| const provider = new StonfiProvider(TON_RPC_ENDPOINT); | ||
|
|
||
| // Add delay between tests to avoid rate limiting from public RPC | ||
| afterEach(async () => { | ||
| await delay(2000); | ||
| }); | ||
|
|
||
| it("fetches a live quote for TON -> USDT", async () => { | ||
| const quote = await provider.get_quote(REQUEST_TEMPLATE); | ||
|
|
||
| expect(BigInt(quote.output_value) > 0).toBe(true); | ||
| expect(quote.output_min_value).toBeDefined(); | ||
|
|
||
| console.log("TON -> USDT quote", quote); | ||
| }); | ||
|
|
||
| it("fetches a live quote and builds quote data for TON -> USDT", async () => { | ||
| const quote = await provider.get_quote(REQUEST_TEMPLATE); | ||
|
|
||
| expect(BigInt(quote.output_value) > 0).toBe(true); | ||
|
|
||
| const quoteData = await provider.get_quote_data(quote); | ||
|
|
||
| expect(typeof quoteData.data).toBe("string"); | ||
| expect(quoteData.data.length).toBeGreaterThan(0); | ||
| expect(quoteData.to).toBeDefined(); | ||
| expect(quoteData.value).toBeDefined(); | ||
|
|
||
| console.log("TON -> USDT quoteData", quoteData); | ||
| }); | ||
|
|
||
| it("fetches a live quote and builds quote data for USDT -> TON", async () => { | ||
| const reverseRequest = createQuoteRequest({ | ||
| from_address: WALLET_ADDRESS, | ||
| to_address: WALLET_ADDRESS, | ||
| from_asset: USDT_TON_ASSET, | ||
| to_asset: TON_ASSET, | ||
| from_value: "1000000", // 1 USDT | ||
| referral_bps: 50, | ||
| slippage_bps: 100, | ||
| }); | ||
|
|
||
| const quote = await provider.get_quote(reverseRequest); | ||
|
|
||
| expect(BigInt(quote.output_value) > 0).toBe(true); | ||
|
|
||
| console.log("USDT -> TON quote", quote); | ||
|
|
||
| const quoteData = await provider.get_quote_data(quote); | ||
|
|
||
| expect(typeof quoteData.data).toBe("string"); | ||
| expect(quoteData.data.length).toBeGreaterThan(0); | ||
|
|
||
| console.log("USDT -> TON quoteData", quoteData); | ||
| }); | ||
|
|
||
| it("fetches a live quote for jetton to jetton swap", async () => { | ||
| const NOT_COIN = { | ||
| id: `${Chain.Ton}_EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT`, | ||
| symbol: "NOT", | ||
| decimals: 9, | ||
| }; | ||
|
|
||
| const jettonToJettonRequest = createQuoteRequest({ | ||
| from_address: WALLET_ADDRESS, | ||
| to_address: WALLET_ADDRESS, | ||
| from_asset: USDT_TON_ASSET, | ||
| to_asset: NOT_COIN, | ||
| from_value: "1000000", // 1 USDT | ||
| referral_bps: 50, | ||
| slippage_bps: 100, | ||
| }); | ||
|
|
||
| const quote = await provider.get_quote(jettonToJettonRequest); | ||
|
|
||
| expect(BigInt(quote.output_value) > 0).toBe(true); | ||
|
|
||
| console.log("USDT -> NOT quote", quote); | ||
|
|
||
| const quoteData = await provider.get_quote_data(quote); | ||
|
|
||
| expect(typeof quoteData.data).toBe("string"); | ||
| expect(quoteData.data.length).toBeGreaterThan(0); | ||
|
|
||
| console.log("USDT -> NOT quoteData", quoteData); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { Chain, Quote, QuoteRequest } from "@gemwallet/types"; | ||
|
|
||
| export const TON_ASSET = { | ||
| id: Chain.Ton, | ||
| symbol: "TON", | ||
| decimals: 9, | ||
| }; | ||
|
|
||
| export const USDT_TON_ASSET = { | ||
| id: `${Chain.Ton}_EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs`, | ||
| symbol: "USDT", | ||
| decimals: 6, | ||
| }; | ||
|
|
||
| export function createQuoteRequest(overrides: Partial<QuoteRequest> = {}): QuoteRequest { | ||
| const base: QuoteRequest = { | ||
| from_address: "UQDummyFromAddress1111111111111111111111111111", | ||
| to_address: "UQDummyToAddress11111111111111111111111111111", | ||
| from_asset: TON_ASSET, | ||
| to_asset: USDT_TON_ASSET, | ||
| from_value: "1000000000", // 1 TON | ||
| referral_bps: 0, | ||
| slippage_bps: 100, | ||
| }; | ||
|
|
||
| const { from_asset, to_asset, ...restOverrides } = overrides; | ||
|
|
||
| return { | ||
| ...base, | ||
| ...restOverrides, | ||
| from_asset: { | ||
| ...base.from_asset, | ||
| ...(from_asset ?? {}), | ||
| }, | ||
| to_asset: { | ||
| ...base.to_asset, | ||
| ...(to_asset ?? {}), | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| export function buildQuoteFixture( | ||
| requestOverrides: Partial<QuoteRequest> = {}, | ||
| quoteOverrides: Partial<Omit<Quote, "quote">> = {}, | ||
| ): Quote { | ||
| return { | ||
| quote: createQuoteRequest(requestOverrides), | ||
| output_value: "0", | ||
| output_min_value: "0", | ||
| eta_in_seconds: 3, | ||
| route_data: {}, | ||
| ...quoteOverrides, | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.