Skip to content

Commit 7702e9d

Browse files
committed
note, fix *CacheExp
1 parent 4c4a3a0 commit 7702e9d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ export class JupiterService extends Service {
140140
}
141141

142142
//const quoteData = await this.getQuoteWithRetry(`https://public.jupiterapi.com/quote?inputMint=${inputMint}&outputMint=${outputMint}&amount=${intAmount}&slippageBps=${slippageBps}&platformFeeBps=200`)
143+
// &onlyDirectRoutes=true
144+
// This ensures Jupiter only uses live and fully-initialized pools.
143145
const quoteData = await quoteEnqueue(`https://public.jupiterapi.com/quote?inputMint=${inputMint}&outputMint=${outputMint}&amount=${intAmount}&slippageBps=${slippageBps}&platformFeeBps=200`)
144146

145147
/*
@@ -233,6 +235,7 @@ export class JupiterService extends Service {
233235
if (swapResponse.status === 429) {
234236
// , response.headers has no rate limit headers
235237
console.log('swap 429d')
238+
// probably should retry in a bit
236239
}
237240
const error = await swapResponse.text();
238241
throw new Error(`Failed to get swap transaction: ${error}`);
@@ -627,7 +630,7 @@ export class JupiterService extends Service {
627630

628631
// hack these in here
629632
async function getCacheExp(runtime, key) {
630-
const wrapper = runtime.getCache<WalletPortfolio>(key);
633+
const wrapper = await runtime.getCache<any>(key);
631634
// if exp is in the past
632635
if (wrapper.exp < Date.now()) {
633636
// no data
@@ -637,7 +640,7 @@ async function getCacheExp(runtime, key) {
637640
}
638641
async function setCacheExp(runtime, key, val, ttlInSecs) {
639642
const exp = Date.now() + ttlInSecs * 1_000
640-
return runtime.setCache<WalletPortfolio>(key, {
643+
return runtime.setCache<any>(key, {
641644
exp,
642645
data: val,
643646
});

0 commit comments

Comments
 (0)