Skip to content

Idle #3

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

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/swapService/config/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
StrategyBalmySDK,
StrategyCombinedUniswap,
StrategyERC4626Wrapper,
StrategyIdleCDOTranche,
StrategyMidas,
StrategyRepayWrapper,
} from "../strategies"
Expand All @@ -15,6 +16,8 @@ const PT_WSTUSR1740182579 = "0xd0097149aa4cc0d0e1fc99b8bd73fc17dc32c1e9"
const PT_WSTUSR_27MAR2025_MAINNET = "0xA8c8861b5ccF8CCe0ade6811CD2A7A7d3222B0B8"
const USD0PLUSPLUS_MAINNET = "0x35d8949372d46b7a3d5a56006ae77b215fc69bc0"
const YNETHX_MAINNET = "0x657d9aba1dbb59e53f9f3ecaa878447dcfc96dcb"
const IDLEAATRANCHEFASANARA_MAINNET =
"0x45054c6753b4Bce40C5d54418DabC20b070F85bE"

const mainnetRoutingConfig: ChainRoutingConfig = [
// WRAPPERS
Expand All @@ -30,6 +33,10 @@ const mainnetRoutingConfig: ChainRoutingConfig = [
strategy: StrategyMidas.name(),
match: {}, // supports function will match mTokens
},
{
strategy: StrategyIdleCDOTranche.name(),
match: { tokensInOrOut: [IDLEAATRANCHEFASANARA_MAINNET] },
},
{
strategy: StrategyERC4626Wrapper.name(),
match: {
Expand Down
3 changes: 3 additions & 0 deletions src/swapService/strategies/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StrategyBalmySDK } from "./strategyBalmySDK"
import { StrategyCombinedUniswap } from "./strategyCombinedUniswap"
import { StrategyERC4626Wrapper } from "./strategyERC4626Wrapper"
import { StrategyIdleCDOTranche } from "./strategyIdleCDOTranche"
import { StrategyMidas } from "./strategyMidas"
import { StrategyRepayWrapper } from "./strategyRepayWrapper"

Expand All @@ -10,6 +11,7 @@ export {
StrategyRepayWrapper,
StrategyBalmySDK,
StrategyERC4626Wrapper,
StrategyIdleCDOTranche,
}

export const strategies = {
Expand All @@ -18,4 +20,5 @@ export const strategies = {
[StrategyRepayWrapper.name()]: StrategyRepayWrapper,
[StrategyBalmySDK.name()]: StrategyBalmySDK,
[StrategyERC4626Wrapper.name()]: StrategyERC4626Wrapper,
[StrategyIdleCDOTranche.name()]: StrategyIdleCDOTranche,
}
1 change: 1 addition & 0 deletions src/swapService/strategies/strategyBalmySDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export class StrategyBalmySDK {
? getAddress(sdkQuote.source.allowanceTarget)
: undefined

console.log("allowanceTarget: ", allowanceTarget)
return {
swapParams,
amountIn: sdkQuote.sellAmount.amount,
Expand Down
22 changes: 15 additions & 7 deletions src/swapService/strategies/strategyERC4626Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,11 @@ export class StrategyERC4626Wrapper {
)

const vaultData = this.getSupportedVault(swapParams.tokenIn.addressInfo)

const tokenIn = findToken(swapParams.chainId, vaultData.asset)
if (!tokenIn) throw new Error("Inner token not found")
const innerSwapParams = {
...swapParams,
tokenIn: findToken(swapParams.chainId, vaultData.asset),
tokenIn,
amount: redeemAmountOut,
}

Expand Down Expand Up @@ -325,10 +326,11 @@ export class StrategyERC4626Wrapper {
swapParams: SwapParams,
): Promise<SwapApiResponse> {
const vaultData = this.getSupportedVault(swapParams.tokenOut.addressInfo)

const tokenOut = findToken(swapParams.chainId, vaultData.asset)
if (!tokenOut) throw new Error("Inner token not found")
const innerSwapParams = {
...swapParams,
tokenOut: findToken(swapParams.chainId, vaultData.asset),
tokenOut,
receiver: swapParams.from,
}

Expand Down Expand Up @@ -436,9 +438,11 @@ export class StrategyERC4626Wrapper {
): Promise<SwapApiResponse> {
// TODO expects dust out - add to dust list
const vaultData = this.getSupportedVault(swapParams.tokenIn.addressInfo)
const tokenIn = findToken(swapParams.chainId, vaultData.asset)
if (!tokenIn) throw new Error("Inner token not found")
const innerSwapParams = {
...swapParams,
tokenIn: findToken(swapParams.chainId, vaultData.asset),
tokenIn,
vaultIn: vaultData.assetDustEVault,
onlyFixedInputExactOut: true, // eliminate dust in the intermediate asset (vault underlying)
}
Expand Down Expand Up @@ -548,9 +552,11 @@ export class StrategyERC4626Wrapper {
const vaultData = this.getSupportedVault(swapParams.tokenOut.addressInfo)

const mintAmount = adjustForInterest(swapParams.amount)
const tokenIn = findToken(swapParams.chainId, vaultData.asset)
if (!tokenIn) throw new Error("Inner token in not found")
const mintSwapParams = {
...swapParams,
tokenIn: findToken(swapParams.chainId, vaultData.asset),
tokenIn,
vaultIn: vaultData.assetDustEVault,
}

Expand All @@ -565,10 +571,12 @@ export class StrategyERC4626Wrapper {
swapParams.from,
)

const tokenOut = findToken(swapParams.chainId, vaultData.asset)
if (!tokenOut) throw new Error("Inner token not found")
const innerSwapParams = {
...swapParams,
amount: mintAmountIn,
tokenOut: findToken(swapParams.chainId, vaultData.asset),
tokenOut,
receiver: swapParams.from,
onlyFixedInputExactOut: true, // this option will overswap, which should cover growing exchange rate
}
Expand Down
Loading