From 1b7877391f86eedc3b14b3717845f8a0e48efe66 Mon Sep 17 00:00:00 2001 From: gs8nrv <55771972+GuillaumeNervoXS@users.noreply.github.com> Date: Fri, 19 Apr 2024 18:20:15 +0200 Subject: [PATCH] fix tests --- .../angle-staked-stable-e2e.test.ts | 138 +++++------- .../angle-staked-stable-integration.test.ts | 204 ++++++++++++++---- .../angle-staked-stable-pool.ts | 12 +- .../angle-staked-stable.ts | 192 +++++++++++------ src/dex/angle-staked-stable/config.ts | 24 +-- src/dex/angle-staked-stable/types.ts | 2 + tests/constants-e2e.ts | 4 +- tests/utils-e2e.ts | 2 +- 8 files changed, 367 insertions(+), 211 deletions(-) diff --git a/src/dex/angle-staked-stable/angle-staked-stable-e2e.test.ts b/src/dex/angle-staked-stable/angle-staked-stable-e2e.test.ts index d36fb3b4a..b3fa320bd 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable-e2e.test.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable-e2e.test.ts @@ -82,89 +82,63 @@ function testForNetwork( } describe('AngleStakedStable E2E', () => { + // same addresses accross all chains + const tokens = Tokens[Network.MAINNET]; const dexKey = 'AngleStakedStable'; - describe('Mainnet', () => { - const network = Network.MAINNET; - - const tokenASymbol: string = 'EURA'; - const tokenBSymbol: string = 'stEUR'; - - const tokenAAmount: string = '1000000000000000000'; - const tokenBAmount: string = '1000000000000000000'; - const nativeTokenAmount = '1000000000000000000'; - - testForNetwork( - network, - dexKey, - tokenASymbol, - tokenBSymbol, - tokenAAmount, - tokenBAmount, - nativeTokenAmount, - ); - }); - - describe('Arbitrum', () => { - const network = Network.ARBITRUM; - - const tokenASymbol: string = 'EURA'; - const tokenBSymbol: string = 'stEUR'; - - const tokenAAmount: string = '1000000000000000000'; - const tokenBAmount: string = '1000000000000000000'; - const nativeTokenAmount = '1000000000000000000'; - - testForNetwork( - network, - dexKey, - tokenASymbol, - tokenBSymbol, - tokenAAmount, - tokenBAmount, - nativeTokenAmount, - ); - }); - - describe('Polygon', () => { - const network = Network.POLYGON; - - const tokenASymbol: string = 'EURA'; - const tokenBSymbol: string = 'stEUR'; - - const tokenAAmount: string = '1000000000000000000'; - const tokenBAmount: string = '1000000000000000000'; - const nativeTokenAmount = '1000000000000000000'; - - testForNetwork( - network, - dexKey, - tokenASymbol, - tokenBSymbol, - tokenAAmount, - tokenBAmount, - nativeTokenAmount, - ); - }); - - describe('Optimism', () => { - const network = Network.OPTIMISM; - - const tokenASymbol: string = 'EURA'; - const tokenBSymbol: string = 'stEUR'; - - const tokenAAmount: string = '1000000000000000000'; - const tokenBAmount: string = '1000000000000000000'; - const nativeTokenAmount = '1000000000000000000'; + const networksEUR = [ + Network.MAINNET, + Network.ARBITRUM, + Network.POLYGON, + Network.OPTIMISM, + ]; + + const networksUSD = [ + Network.MAINNET, + Network.ARBITRUM, + Network.POLYGON, + Network.OPTIMISM, + Network.BASE, + Network.BSC, + ]; + + // biome-ignore lint/complexity/noForEach: + networksEUR.forEach(network => + describe(`${network} - EUR`, () => { + const tokenASymbol: string = 'EURA'; + const tokenBSymbol: string = 'stEUR'; + const tokenAAmount: string = '990000000000000000'; + const tokenBAmount: string = '990000000000000000'; + const nativeTokenAmount = '990000000000000000'; + testForNetwork( + network, + dexKey, + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + nativeTokenAmount, + ); + }), + ); - testForNetwork( - network, - dexKey, - tokenASymbol, - tokenBSymbol, - tokenAAmount, - tokenBAmount, - nativeTokenAmount, - ); - }); + // biome-ignore lint/complexity/noForEach: + networksUSD.forEach(network => + describe(`${network} - USD`, () => { + const tokenASymbol: string = 'USDA'; + const tokenBSymbol: string = 'stUSD'; + const tokenAAmount: string = '990000000000000000'; + const tokenBAmount: string = '990000000000000000'; + const nativeTokenAmount = '990000000000000000'; + testForNetwork( + network, + dexKey, + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + nativeTokenAmount, + ); + }), + ); }); diff --git a/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts b/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts index b8b170f14..4d4aa7ee7 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts @@ -57,11 +57,10 @@ async function checkOnChainPricing( angleStakedStable: AngleStakedStable, funcName: string, blockNumber: number, + exchangeAddress: string, prices: bigint[], amounts: bigint[], ) { - const exchangeAddress = '0x004626a008b1acdc4c74ab51644093b155e59a23'; - // Normally you can get it from angleStakedStable.Iface or from eventPool. // It depends on your implementation const readerIface = AngleStakedStableEventPool.angleStakedStableIface; @@ -137,11 +136,17 @@ async function testPricingOnNetwork( checkPoolPrices(poolPrices!, amounts, side, dexKey); } + const exchange = + srcTokenSymbol === 'stEUR' || srcTokenSymbol === 'stUSD' + ? networkTokens[srcTokenSymbol].address + : networkTokens[destTokenSymbol].address; + // Check if onchain pricing equals to calculated ones await checkOnChainPricing( angleStakedStable, funcNameToCheck, blockNumber, + exchange, poolPrices![0].prices, amounts, ); @@ -159,42 +164,49 @@ describe('AngleStakedStable', () => { const tokens = Tokens[network]; // Don't forget to update relevant tokens in constant-e2e.ts - const srcTokenSymbolEnter = 'EURA'; - const destTokenSymbolEnter = 'stEUR'; + const srcTokenSymbolEUREnter = 'EURA'; + const destTokenSymbolEUREnter = 'stEUR'; + const srcTokenSymbolUSDEnter = 'USDA'; + const destTokenSymbolUSDEnter = 'stUSD'; const funcNameSellEnter = 'previewDeposit'; const funcNameBuyEnter = 'previewMint'; - const srcTokenSymbolExit = 'stEUR'; - const destTokenSymbolExit = 'EURA'; + const srcTokenSymbolEURExit = 'stEUR'; + const destTokenSymbolEURExit = 'EURA'; + const destTokenSymbolUSDExit = 'USDA'; + const srcTokenSymbolUSDExit = 'stUSD'; const funcNameSellExit = 'previewRedeem'; const funcNameBuyExit = 'previewWithdraw'; + const exchangeSTEUR = `${dexKey}_${tokens.stEUR.address.toLowerCase()}`; + const exchangeSTUSD = `${dexKey}_${tokens.stUSD.address.toLowerCase()}`; + const amountsForSell = [ 0n, - 1n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 2n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 3n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 4n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 5n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 6n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 7n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 8n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 9n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], - 10n * BI_POWS[tokens[srcTokenSymbolEnter].decimals], + 1n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 2n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 3n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 4n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 5n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 6n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 7n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 8n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 9n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], + 10n * BI_POWS[tokens[srcTokenSymbolEUREnter].decimals], ]; const amountsForBuy = [ 0n, - 1n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 2n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 3n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 4n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 5n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 6n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 7n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 8n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 9n * BI_POWS[tokens[destTokenSymbolEnter].decimals], - 10n * BI_POWS[tokens[destTokenSymbolEnter].decimals], + 1n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 2n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 3n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 4n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 5n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 6n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 7n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 8n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 9n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], + 10n * BI_POWS[tokens[destTokenSymbolEUREnter].decimals], ]; beforeAll(async () => { @@ -211,8 +223,8 @@ describe('AngleStakedStable', () => { network, dexKey, blockNumber, - srcTokenSymbolEnter, - destTokenSymbolEnter, + srcTokenSymbolEUREnter, + destTokenSymbolEUREnter, SwapSide.SELL, amountsForSell, funcNameSellEnter, @@ -225,8 +237,8 @@ describe('AngleStakedStable', () => { network, dexKey, blockNumber, - srcTokenSymbolEnter, - destTokenSymbolEnter, + srcTokenSymbolEUREnter, + destTokenSymbolEUREnter, SwapSide.BUY, amountsForBuy, funcNameBuyEnter, @@ -239,8 +251,8 @@ describe('AngleStakedStable', () => { network, dexKey, blockNumber, - srcTokenSymbolExit, - destTokenSymbolExit, + srcTokenSymbolEURExit, + destTokenSymbolEURExit, SwapSide.SELL, amountsForSell, funcNameSellExit, @@ -253,8 +265,64 @@ describe('AngleStakedStable', () => { network, dexKey, blockNumber, - srcTokenSymbolExit, - destTokenSymbolExit, + srcTokenSymbolEURExit, + destTokenSymbolEURExit, + SwapSide.BUY, + amountsForBuy, + funcNameBuyExit, + ); + }); + + it('getPoolIdentifiers and getPricesVolume SELL - USDA', async () => { + await testPricingOnNetwork( + angleStakedStable, + network, + dexKey, + blockNumber, + srcTokenSymbolUSDEnter, + destTokenSymbolUSDEnter, + SwapSide.SELL, + amountsForSell, + funcNameSellEnter, + ); + }); + + it('getPoolIdentifiers and getPricesVolume BUY - stUSD', async () => { + await testPricingOnNetwork( + angleStakedStable, + network, + dexKey, + blockNumber, + srcTokenSymbolUSDEnter, + destTokenSymbolUSDEnter, + SwapSide.BUY, + amountsForBuy, + funcNameBuyEnter, + ); + }); + + it('getPoolIdentifiers and getPricesVolume SELL - stUSD', async () => { + await testPricingOnNetwork( + angleStakedStable, + network, + dexKey, + blockNumber, + srcTokenSymbolUSDExit, + destTokenSymbolUSDExit, + SwapSide.SELL, + amountsForSell, + funcNameSellExit, + ); + }); + + it('getPoolIdentifiers and getPricesVolume BUY - USDA', async () => { + await testPricingOnNetwork( + angleStakedStable, + network, + dexKey, + blockNumber, + srcTokenSymbolUSDExit, + destTokenSymbolUSDExit, SwapSide.BUY, amountsForBuy, funcNameBuyExit, @@ -273,16 +341,16 @@ describe('AngleStakedStable', () => { await newAngleStakedStable.updatePoolState(); } const poolLiquidity = await newAngleStakedStable.getTopPoolsForToken( - tokens[srcTokenSymbolEnter].address, + tokens[srcTokenSymbolEUREnter].address, 10, ); - console.log(`${srcTokenSymbolEnter} Top Pools:`, poolLiquidity); + console.log(`${srcTokenSymbolEUREnter} Top Pools:`, poolLiquidity); if (!newAngleStakedStable.hasConstantPriceLargeAmounts) { checkPoolsLiquidity( poolLiquidity, - Tokens[network][srcTokenSymbolEnter].address, - dexKey, + Tokens[network][srcTokenSymbolEUREnter].address, + exchangeSTEUR, ); } }); @@ -299,16 +367,68 @@ describe('AngleStakedStable', () => { await newAngleStakedStable.updatePoolState(); } const poolLiquidity = await newAngleStakedStable.getTopPoolsForToken( - tokens[srcTokenSymbolExit].address, + tokens[srcTokenSymbolEURExit].address, + 10, + ); + console.log(`${srcTokenSymbolEURExit} Top Pools:`, poolLiquidity); + + if (!newAngleStakedStable.hasConstantPriceLargeAmounts) { + checkPoolsLiquidity( + poolLiquidity, + Tokens[network][srcTokenSymbolEURExit].address, + exchangeSTEUR, + ); + } + }); + + it('getTopPoolsForToken - USDA', async () => { + // We have to check without calling initializePricing, because + // pool-tracker is not calling that function + const newAngleStakedStable = new AngleStakedStable( + network, + dexKey, + dexHelper, + ); + if (newAngleStakedStable.updatePoolState) { + await newAngleStakedStable.updatePoolState(); + } + const poolLiquidity = await newAngleStakedStable.getTopPoolsForToken( + tokens[srcTokenSymbolUSDEnter].address, + 10, + ); + console.log(`${srcTokenSymbolUSDEnter} Top Pools:`, poolLiquidity); + + if (!newAngleStakedStable.hasConstantPriceLargeAmounts) { + checkPoolsLiquidity( + poolLiquidity, + Tokens[network][srcTokenSymbolUSDEnter].address, + exchangeSTUSD, + ); + } + }); + + it('getTopPoolsForToken - stUSD', async () => { + // We have to check without calling initializePricing, because + // pool-tracker is not calling that function + const newAngleStakedStable = new AngleStakedStable( + network, + dexKey, + dexHelper, + ); + if (newAngleStakedStable.updatePoolState) { + await newAngleStakedStable.updatePoolState(); + } + const poolLiquidity = await newAngleStakedStable.getTopPoolsForToken( + tokens[srcTokenSymbolUSDExit].address, 10, ); - console.log(`${srcTokenSymbolExit} Top Pools:`, poolLiquidity); + console.log(`${srcTokenSymbolUSDExit} Top Pools:`, poolLiquidity); if (!newAngleStakedStable.hasConstantPriceLargeAmounts) { checkPoolsLiquidity( poolLiquidity, - Tokens[network][srcTokenSymbolExit].address, - dexKey, + Tokens[network][srcTokenSymbolUSDExit].address, + exchangeSTUSD, ); } }); diff --git a/src/dex/angle-staked-stable/angle-staked-stable-pool.ts b/src/dex/angle-staked-stable/angle-staked-stable-pool.ts index 0180e9ea1..bae13a934 100644 --- a/src/dex/angle-staked-stable/angle-staked-stable-pool.ts +++ b/src/dex/angle-staked-stable/angle-staked-stable-pool.ts @@ -35,14 +35,14 @@ export class AngleStakedStableEventPool extends StatefulEventSubscriber AngleStakedStableEventPool.angleStakedStableIface.parseLog(log); - this.addressesSubscribed = [config.stEUR]; + this.addressesSubscribed = [stakeToken]; // Add handlers this.handlers.Accrued = this.handleAccrued.bind(this); @@ -98,28 +98,28 @@ export class AngleStakedStableEventPool extends StatefulEventSubscriber { - if (!this._knownAddress(srcToken, destToken)) return []; - return [this.dexKey]; + const knownInfo = this._knownAddress(srcToken, destToken); + if (!knownInfo.known) return []; + return [`${this.dexKey}_${knownInfo.stakeToken!.toLowerCase()}`]; } // Returns pool prices for amounts. @@ -107,60 +119,60 @@ export class AngleStakedStable ): Promise> { const srcTokenAddress = srcToken.address.toLowerCase(); const destTokenAddress = destToken.address.toLowerCase(); - if (!this._knownAddress(srcToken, destToken)) return null; + const knownInfo = this._knownAddress(srcToken, destToken); + if (!knownInfo.known) return null; - const state = this.eventPools?.getState(blockNumber); + const agToken = knownInfo.agToken!; + const stakeToken = knownInfo.stakeToken!; + const eventPool = this.eventPools[stakeToken]; + const exchange = `${this.dexKey}`; + // const exchange = `${this.dexKey}_${stakeToken.toLowerCase()}`; + const state = eventPool?.getState(blockNumber); if (this.eventPools === null || state === undefined || state === null) return null; - if (srcTokenAddress === this.config.EURA && side === SwapSide.SELL) + if (srcTokenAddress === agToken && side === SwapSide.SELL) return [ { prices: amounts.map(amount => - this.eventPools!.getRateDeposit(amount, state), + eventPool.getRateDeposit(amount, state), ), - unit: this.eventPools.getRateDeposit(1n * BigInt(10 ** 18), state), + unit: eventPool.getRateDeposit(1n * BigInt(10 ** 18), state), gasCost: AngleStakedGasCost, - exchange: this.dexKey, - data: { exchange: `${this.config.stEUR}` }, - poolAddresses: [`${this.config.stEUR}_${this.config.EURA}`], + exchange: exchange, + data: { exchange: `${stakeToken}` }, + poolAddresses: [`${stakeToken}`], }, ]; - if (destTokenAddress === this.config.EURA && side === SwapSide.SELL) + if (destTokenAddress === agToken && side === SwapSide.SELL) return [ { - prices: amounts.map(share => - this.eventPools!.getRateRedeem(share, state), - ), - unit: this.eventPools.getRateRedeem(1n * BigInt(10 ** 18), state), + prices: amounts.map(share => eventPool.getRateRedeem(share, state)), + unit: eventPool.getRateRedeem(1n * BigInt(10 ** 18), state), gasCost: AngleStakedGasCost, - exchange: this.dexKey, - data: { exchange: `${this.config.stEUR}` }, - poolAddresses: [`${this.config.stEUR}_${this.config.EURA}`], + exchange: exchange, + data: { exchange: `${stakeToken}` }, + poolAddresses: [`${stakeToken}_${agToken}`], }, ]; - if (srcTokenAddress === this.config.EURA && side === SwapSide.BUY) + if (srcTokenAddress === agToken && side === SwapSide.BUY) return [ { - prices: amounts.map(share => - this.eventPools!.getRateMint(share, state), - ), - unit: this.eventPools.getRateMint(1n * BigInt(10 ** 18), state), + prices: amounts.map(share => eventPool.getRateMint(share, state)), + unit: eventPool.getRateMint(1n * BigInt(10 ** 18), state), gasCost: AngleStakedGasCost, - exchange: this.dexKey, - data: { exchange: `${this.config.stEUR}` }, - poolAddresses: [`${this.config.stEUR}_${this.config.EURA}`], + exchange: exchange, + data: { exchange: `${stakeToken}` }, + poolAddresses: [`${stakeToken}_${agToken}`], }, ]; return [ { - prices: amounts.map(amount => - this.eventPools!.getRateWithdraw(amount, state), - ), - unit: this.eventPools.getRateWithdraw(1n * BigInt(10 ** 18), state), + prices: amounts.map(amount => eventPool.getRateWithdraw(amount, state)), + unit: eventPool.getRateWithdraw(1n * BigInt(10 ** 18), state), gasCost: AngleStakedGasCost, - exchange: this.dexKey, - data: { exchange: `${this.config.stEUR}` }, - poolAddresses: [`${this.config.stEUR}_${this.config.EURA}`], + exchange: exchange, + data: { exchange: `${stakeToken}` }, + poolAddresses: [`${stakeToken}_${agToken}`], }, ]; } @@ -211,7 +223,8 @@ export class AngleStakedStable // Encode here the transaction arguments const swapData = - srcToken.toLowerCase() === this.config.EURA + srcToken.toLowerCase() === this.config.EURA || + srcToken.toLowerCase() === this.config.USDA ? AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData( side === SwapSide.SELL ? 'deposit' : 'mint', [ @@ -252,6 +265,13 @@ export class AngleStakedStable 'paused', ), }, + { + target: this.config.stUSD, + callData: + AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData( + 'paused', + ), + }, ]; const returnData = ( await this.dexHelper.multiContract.methods @@ -259,11 +279,16 @@ export class AngleStakedStable .call() ).returnData; - this.isPaused = + this.isPaused[this.config.stEUR] = AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult( 'paused', returnData[0], )[0] as boolean; + this.isPaused[this.config.stUSD] = + AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult( + 'paused', + returnData[1], + )[0] as boolean; } // Returns list of top pools based on liquidity. Max @@ -273,21 +298,45 @@ export class AngleStakedStable limit: number, ): Promise { if ( - this.isPaused || - (tokenAddress.toLowerCase() !== this.config.EURA && - tokenAddress.toLowerCase() !== this.config.stEUR) + (this.isPaused[this.config.stEUR] || + (tokenAddress.toLowerCase() !== this.config.EURA && + tokenAddress.toLowerCase() !== this.config.stEUR)) && + (this.isPaused[this.config.stUSD] || + (tokenAddress.toLowerCase() !== this.config.USDA && + tokenAddress.toLowerCase() !== this.config.stUSD)) ) return []; + + if ( + !( + this.isPaused[this.config.stEUR] || + (tokenAddress.toLowerCase() !== this.config.EURA && + tokenAddress.toLowerCase() !== this.config.stEUR) + ) + ) + return [ + { + exchange: `${this.dexKey}_${this.config.stEUR!.toLowerCase()}`, + address: this.config.stEUR, + connectorTokens: [ + tokenAddress.toLowerCase() === this.config.EURA + ? ({ address: this.config.stEUR, decimals: 18 } as Token) + : ({ address: this.config.EURA, decimals: 18 } as Token), + ], + // liquidity is infinite as to have been able to mint stEUR, you must have deposited EURA + liquidityUSD: 1e12, + }, + ]; return [ { - exchange: this.dexKey, - address: this.config.stEUR, + exchange: `${this.dexKey}_${this.config.stUSD!.toLowerCase()}`, + address: this.config.stUSD, connectorTokens: [ - tokenAddress.toLowerCase() === this.config.EURA - ? ({ address: this.config.stEUR, decimals: 18 } as Token) - : ({ address: this.config.EURA, decimals: 18 } as Token), + tokenAddress.toLowerCase() === this.config.USDA + ? ({ address: this.config.stUSD, decimals: 18 } as Token) + : ({ address: this.config.USDA, decimals: 18 } as Token), ], - // liquidity is infinite as to have been able to mint stEUR, you must have deposited EURA + // liquidity is infinite as to have been able to mint stUSD, you must have deposited USDA liquidityUSD: 1e12, }, ]; @@ -297,25 +346,36 @@ export class AngleStakedStable // you need to release for graceful shutdown. For example, it may be any interval timer releaseResources(): AsyncOrSync {} - _knownAddress(srcToken: Token, destToken: Token): boolean { + _knownAddress( + srcToken: Token, + destToken: Token, + ): { known: boolean; agToken: string | null; stakeToken: string | null } { const srcTokenAddress = srcToken.address.toLowerCase(); const destTokenAddress = destToken.address.toLowerCase(); if ( - !( - ( - (srcTokenAddress === this.config.EURA && - destTokenAddress === this.config.stEUR) || - (srcTokenAddress === this.config.stEUR && - destTokenAddress === this.config.EURA) - ) - // (srcTokenAddress === this.config.USDA && - // destTokenAddress === this.config.stUSD) || - // (srcTokenAddress === this.config.stUSD && - // destTokenAddress === this.config.USDA) - ) + (srcTokenAddress === this.config.EURA && + destTokenAddress === this.config.stEUR) || + (srcTokenAddress === this.config.stEUR && + destTokenAddress === this.config.EURA) + ) { + return { + known: true, + agToken: this.config.EURA, + stakeToken: this.config.stEUR, + }; + } + if ( + (srcTokenAddress === this.config.USDA && + destTokenAddress === this.config.stUSD) || + (srcTokenAddress === this.config.stUSD && + destTokenAddress === this.config.USDA) ) { - return false; + return { + known: true, + agToken: this.config.USDA, + stakeToken: this.config.stUSD, + }; } - return true; + return { known: false, agToken: null, stakeToken: null }; } } diff --git a/src/dex/angle-staked-stable/config.ts b/src/dex/angle-staked-stable/config.ts index 1415c1af8..1ed556ddf 100644 --- a/src/dex/angle-staked-stable/config.ts +++ b/src/dex/angle-staked-stable/config.ts @@ -7,38 +7,38 @@ export const AngleStakedStableConfig: DexConfigMap = { [Network.ARBITRUM]: { EURA: '0xfa5ed56a203466cbbc2430a43c66b9d8723528e7', stEUR: '0x004626A008B1aCdC4c74ab51644093b155e59A23', - // USDA: "0x0000206329b97DB379d5E1Bf586BbDB969C63274", - // stUSD: "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776", + USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274', + stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776', }, [Network.MAINNET]: { EURA: '0x1a7e4e63778B4f12a199C062f3eFdD288afCBce8', stEUR: '0x004626A008B1aCdC4c74ab51644093b155e59A23', - // USDA: "0x0000206329b97DB379d5E1Bf586BbDB969C63274", - // stUSD: "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776", + USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274', + stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776', }, [Network.OPTIMISM]: { EURA: '0x9485aca5bbbe1667ad97c7fe7c4531a624c8b1ed', stEUR: '0x004626A008B1aCdC4c74ab51644093b155e59A23', - // USDA: "0x0000206329b97DB379d5E1Bf586BbDB969C63274", - // stUSD: "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776", + USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274', + stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776', }, [Network.POLYGON]: { EURA: '0xe0b52e49357fd4daf2c15e02058dce6bc0057db4', stEUR: '0x004626A008B1aCdC4c74ab51644093b155e59A23', - // USDA: "0x0000206329b97DB379d5E1Bf586BbDB969C63274", - // stUSD: "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776", + USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274', + stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776', }, [Network.BASE]: { EURA: '0xA61BeB4A3d02decb01039e378237032B351125B4', stEUR: '0x004626A008B1aCdC4c74ab51644093b155e59A23', - // USDA: "0x0000206329b97DB379d5E1Bf586BbDB969C63274", - // stUSD: "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776", + USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274', + stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776', }, [Network.BSC]: { EURA: '0x12f31B73D812C6Bb0d735a218c086d44D5fe5f89', stEUR: '0x004626A008B1aCdC4c74ab51644093b155e59A23', - // USDA: "0x0000206329b97DB379d5E1Bf586BbDB969C63274", - // stUSD: "0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776", + USDA: '0x0000206329b97DB379d5E1Bf586BbDB969C63274', + stUSD: '0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776', }, }, }; diff --git a/src/dex/angle-staked-stable/types.ts b/src/dex/angle-staked-stable/types.ts index 880676ad8..34fbcdf39 100644 --- a/src/dex/angle-staked-stable/types.ts +++ b/src/dex/angle-staked-stable/types.ts @@ -13,4 +13,6 @@ export type AngleStakedStableData = { exchange: Address }; export type DexParams = { EURA: Address; stEUR: Address; + USDA: Address; + stUSD: Address; }; diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 6a8a13d51..022bdf4be 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1323,9 +1323,9 @@ export const Holders: { RDNT: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6', SDEX: '0xb0470cf15b22a6a32c49a7c20e3821b944a76058', wstETH: '0x916792f7734089470de27297903bed8a4630b26d', - EURA: '0xf89051707a91D6b63ca7B090B15D1Eb964d12494', + EURA: '0x6dd7b830896b56812aa667bdd14b71c8b3252f8e', stEUR: '0xE588611e7A2392507879E3be80531654b85C16aA', - USDA: '0xa9ddd91249dfdd450e81e1c56ab60e1a62651701', + USDA: '0x4e2c46063b4aadcb24adf784172db6f043a77d95', stUSD: '0xa9ddd91249dfdd450e81e1c56ab60e1a62651701', }, [Network.OPTIMISM]: { diff --git a/tests/utils-e2e.ts b/tests/utils-e2e.ts index 82e0b8e00..7958d2822 100644 --- a/tests/utils-e2e.ts +++ b/tests/utils-e2e.ts @@ -382,7 +382,7 @@ export async function testE2E( expect(parseFloat(priceRoute.destAmount)).toBeGreaterThan(0); // Calculate slippage. Default is 1% - const _slippage = slippage || 100; + const _slippage = slippage === undefined ? 100 : slippage; const minMaxAmount = (swapSide === SwapSide.SELL ? BigInt(priceRoute.destAmount) * (10000n - BigInt(_slippage))