Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKozAllB committed Jul 5, 2024
2 parents cb4a841 + b35e2a5 commit 691f69f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe("SDK", () => {
wormholeMessengerProgramId: "wormholeMessengerProgramId",
solanaLookUpTable: "solanaLookUpTable",
sorobanNetworkPassphrase: "sorobanNetworkPassphrase",
jupiterUrl: "",
cctpParams: {
cctpDomains: {},
cctpTransmitterProgramId: "",
Expand Down
1 change: 1 addition & 0 deletions src/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const mainnet: AllbridgeCoreSdkOptions = {
coreApiUrl: "https://core.api.allbridgecoreapi.net",
coreApiQueryParams: {},
coreApiHeaders: {},
jupiterUrl: "https://quote-api.jup.ag/v6",
wormholeMessengerProgramId: "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth",
solanaLookUpTable: "2JcBAEVnAwVo4u8d61iqgHPrzZuugur7cVTjWubsVLHj",
sorobanNetworkPassphrase: "Public Global Stellar Network ; September 2015",
Expand Down
1 change: 1 addition & 0 deletions src/configs/testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const testnet: AllbridgeCoreSdkOptions = {
coreApiUrl: "https://core-dev.a11bd.net",
coreApiQueryParams: {},
coreApiHeaders: {},
jupiterUrl: "",
wormholeMessengerProgramId: "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5",
solanaLookUpTable: "C3jAxHRTZjM2Bs7EqPir4nvrT8zKtpcW7RvGR9R2qKtN",
sorobanNetworkPassphrase: "Test SDF Network ; September 2015",
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface AllbridgeCoreSdkOptions {
* A set of headers to be added to all requests to the Core API.
*/
coreApiHeaders?: Record<string, string>;
/**
* Jupiter v6 Swap Api
*/
jupiterUrl: string;
wormholeMessengerProgramId: string;
solanaLookUpTable: string;
sorobanNetworkPassphrase: string;
Expand Down
1 change: 1 addition & 0 deletions src/services/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export function getChainBridgeService(
wormholeMessengerProgramId: params.wormholeMessengerProgramId,
solanaLookUpTable: params.solanaLookUpTable,
cctpParams: params.cctpParams,
jupiterUrl: params.jupiterUrl,
},
api
);
Expand Down
3 changes: 2 additions & 1 deletion src/services/bridge/sol/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface SolanaBridgeParams {
wormholeMessengerProgramId: string;
solanaLookUpTable: string;
cctpParams: CctpParams;
jupiterUrl: string;
}

export interface CctpParams {
Expand All @@ -79,7 +80,7 @@ export class SolanaBridgeService extends ChainBridgeService {

constructor(public solanaRpcUrl: string, public params: SolanaBridgeParams, public api: AllbridgeCoreClient) {
super();
this.jupiterService = new JupiterService(solanaRpcUrl);
this.jupiterService = new JupiterService(solanaRpcUrl, params.jupiterUrl);
}

async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {
Expand Down
8 changes: 5 additions & 3 deletions src/services/bridge/sol/jupiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import { fetchAddressLookupTableAccountsFromTx } from "../../../utils/sol/utils"

export class JupiterService {
connection: Connection;
jupiterUrl: string;

constructor(solanaRpcUrl: string) {
constructor(solanaRpcUrl: string, jupiterUrl: string) {
this.connection = new Connection(solanaRpcUrl);
this.jupiterUrl = jupiterUrl.replace(/\/$/, ""); // trim last "/" if exist
}

async getJupiterSwapTx(
Expand All @@ -18,7 +20,7 @@ export class JupiterService {
): Promise<{ tx: VersionedTransaction }> {
let quoteResponse: any;
try {
quoteResponse = await axios.get(`https://quote-api.jup.ag/v6/quote?inputMint=${stableTokenAddress}
quoteResponse = await axios.get(`${this.jupiterUrl}/quote?inputMint=${stableTokenAddress}
&outputMint=${NATIVE_MINT.toString()}
&amount=${amount}
&slippageBps=100
Expand All @@ -33,7 +35,7 @@ export class JupiterService {
let transactionResponse: any;
try {
transactionResponse = await axios.post(
"https://quote-api.jup.ag/v6/swap",
`${this.jupiterUrl}/swap`,
JSON.stringify({
quoteResponse: quoteResponse.data,
userPublicKey: userAddress,
Expand Down

0 comments on commit 691f69f

Please sign in to comment.