Skip to content

Commit 0882803

Browse files
committed
add pendle cool off
1 parent b24d57e commit 0882803

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/swapService/strategies/balmySDK/pendleQuoteSource.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import {
1515
failed,
1616
} from "@balmy/sdk/dist/services/quotes/quote-sources/utils"
1717
import qs from "qs"
18-
import { type Address, getAddress, isAddressEqual } from "viem"
18+
import { type Address, Hex, getAddress, isAddressEqual } from "viem"
19+
20+
const soldOutCoolOff: Record<string, number> = {}
21+
22+
const SOLD_OUT_COOL_OFF_TIME = 5 * 60 * 1000
1923

2024
// https://api-v2.pendle.finance/core/docs#/Chains/ChainsController_getSupportedChainIds
2125
export const PENDLE_METADATA: QuoteSourceMetadata<PendleSupport> = {
@@ -157,6 +161,19 @@ export class CustomPendleQuoteSource
157161

158162
url = `${getUrl()}/sdk/${chainId}/redeem?${queryString}`
159163
} else {
164+
if (
165+
Date.now() - soldOutCoolOff[`${buyToken}${chainId}`] <
166+
SOLD_OUT_COOL_OFF_TIME
167+
) {
168+
console.log("SOLD OUT")
169+
failed(
170+
PENDLE_METADATA,
171+
chainId,
172+
sellToken,
173+
buyToken,
174+
"Sold out cool off",
175+
)
176+
}
160177
// swap
161178
const queryParams = {
162179
receiver: recipient || takeFrom,
@@ -187,7 +204,12 @@ export class CustomPendleQuoteSource
187204
const msg =
188205
(await response.text()) || `Failed with status ${response.status}`
189206

190-
if (response.status === 400) console.log("[PENDLE ERROR]", msg, url)
207+
if (response.status === 400) {
208+
console.log("[PENDLE ERROR]", msg, url)
209+
if (msg.includes("SY limit exceeded")) {
210+
soldOutCoolOff[`${buyToken}${chainId}`] = Date.now()
211+
}
212+
}
191213

192214
failed(PENDLE_METADATA, chainId, sellToken, buyToken, msg)
193215
}

0 commit comments

Comments
 (0)