Skip to content

Commit

Permalink
add USDA + fix max oracle value + add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeNervoXS committed Apr 22, 2024
1 parent 7726a6d commit cef9d71
Show file tree
Hide file tree
Showing 11 changed files with 3,155 additions and 370 deletions.
2,506 changes: 2,506 additions & 0 deletions src/abi/angle-transmuter/MorphoVault.json

Large diffs are not rendered by default.

114 changes: 51 additions & 63 deletions src/dex/angle-transmuter/angle-transmuter-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
import { Network, ContractMethod, SwapSide } from '../../constants';
import { StaticJsonRpcProvider } from '@ethersproject/providers';
import { generateConfig } from '../../config';
import { Collateral } from './angle-transmuter-integration.test';
import { BI_POWS } from '../../bigint-constants';

function testForNetwork(
network: Network,
Expand All @@ -20,6 +22,7 @@ function testForNetwork(
tokenAAmount: string,
tokenBAmount: string,
nativeTokenAmount: string,
isKYC: boolean,
) {
const provider = new StaticJsonRpcProvider(
generateConfig(network).privateHttpProvider,
Expand Down Expand Up @@ -52,19 +55,21 @@ function testForNetwork(
provider,
);
});
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
await testE2E(
tokens[tokenBSymbol],
tokens[tokenASymbol],
holders[tokenBSymbol],
side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
if (!isKYC) {
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
await testE2E(
tokens[tokenBSymbol],
tokens[tokenASymbol],
holders[tokenBSymbol],
side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
}
});
});
}),
Expand All @@ -78,59 +83,42 @@ describe('AngleTransmuter E2E', () => {
describe('Mainnet', () => {
const network = Network.MAINNET;

describe('EUROC', () => {
const tokenASymbol: string = 'EUROC';
const tokenBSymbol: string = 'EURA';
const tokens = Tokens[network];
const stables = [tokens.EURA, tokens.USDA];

const tokenAAmount: string = '1000000';
const tokenBAmount: string = '1000000000000000000';
const nativeTokenAmount = '1000000000000000000';
const collaterals: Collateral = {
USDA: [tokens.USDC, tokens.steakUSDC, tokens.bIB01],
EURA: [tokens.EUROC, tokens.bC3M, tokens.bERNX],
};

testForNetwork(
network,
dexKey,
tokenASymbol,
tokenBSymbol,
tokenAAmount,
tokenBAmount,
nativeTokenAmount,
);
});
describe('BC3M', () => {
const tokenASymbol: string = 'bC3M';
const tokenBSymbol: string = 'EURA';
const isKYC: { [token: string]: boolean } = {};
isKYC[tokens.bIB01.symbol!] = true;
isKYC[tokens.bC3M.symbol!] = true;
isKYC[tokens.bERNX.symbol!] = true;

const tokenAAmount: string = '100000000000000000';
const tokenBAmount: string = '1000000000000000000';
const nativeTokenAmount = '1000000000000000000';
stables.forEach(stable =>
collaterals[stable.symbol! as keyof Collateral].forEach(collateral =>
describe(`${stable.symbol}/${collateral.symbol}`, () => {
const stableAmount: string = (
1n * BI_POWS[stable.decimals]
).toString();
const collateralAmount: string = (
1n * BI_POWS[collateral.decimals]
).toString();
const nativeTokenAmount = '1000000000000000000';

testForNetwork(
network,
dexKey,
tokenASymbol,
tokenBSymbol,
tokenAAmount,
tokenBAmount,
nativeTokenAmount,
);
});
describe('BERNX', () => {
const tokenASymbol: string = 'bERNX';
const tokenBSymbol: string = 'EURA';

const tokenAAmount: string = '500000000000000000';
const tokenBAmount: string = '1000000000000000000';
const nativeTokenAmount = '1000000000000000000';

testForNetwork(
network,
dexKey,
tokenASymbol,
tokenBSymbol,
tokenAAmount,
tokenBAmount,
nativeTokenAmount,
);
});
testForNetwork(
network,
dexKey,
collateral.symbol!,
stable.symbol!,
collateralAmount,
stableAmount,
nativeTokenAmount,
isKYC[collateral.symbol!],
);
}),
),
);
});
});
60 changes: 28 additions & 32 deletions src/dex/angle-transmuter/angle-transmuter-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,45 +34,41 @@ describe('AngleTransmuter EventPool Mainnet', () => {
const eventsToTest: Record<Address, EventMappings> = {
//Transmuter Events
'0x00253582b2a3FE112feEC532221d9708c64cEFAb': {
// FeesSet: [19567142],
FeesSet: [],
RedemptionCurveParamsSet: [],
// OracleSet: [19567142],
// Swap: [
// 19582703, 19583592, 19584048, 19589408, 19602964, 19607526, 19611131, 19614332, 19616567, 19623965, 19625332,
// 19631246, 19631653, 19633515, 19638468, 19648373, 19653214, 19656178, 19657413, 19667310, 19667763,
// ],
OracleSet: [],
Swap: [
19582703, 19583592, 19584048, 19589408, 19602964, 19607526, 19611131,
19614332, 19616567, 19623965, 19625332, 19631246, 19631653, 19633515,
19638468, 19648373, 19653214, 19656178, 19657413, 19667310, 19667763,
],
Redeemed: [],
ReservesAdjusted: [],
// CollateralAdded: [19567142],
CollateralAdded: [],
CollateralRevoked: [],
// CollateralWhitelistStatusUpdated: [19567142],
CollateralWhitelistStatusUpdated: [],
WhitelistStatusToggled: [],
},
// Pyth Events
// "0x4305FB66699C3B2702D4d05CF36551390A4c69C6": {
// PriceFeedUpdate: [
// 19611413, 19611413, 19611413, 19611413, 19611413, 19611413, 19611413, 19611413, 19611413, 19611413, 19611413,
// 19611413, 19618548, 19618548, 19618548, 19618548, 19618548, 19618548, 19618548, 19618548, 19618548, 19618548,
// 19618548, 19618548, 19625698, 19625698, 19625698, 19625698, 19625698, 19625698, 19625698, 19625698, 19625698,
// 19625698, 19625698, 19625698, 19625698, 19625698, 19625698, 19632847, 19632847, 19632847, 19632847, 19632847,
// 19632847, 19632847, 19632847, 19632847, 19632847, 19632847, 19632847, 19632847, 19632847, 19632847, 19633586,
// 19633586, 19639991, 19639991, 19639991, 19639991, 19639991, 19639991, 19639991, 19639991, 19639991, 19639991,
// 19639991, 19639991, 19647112, 19647112, 19647112, 19647112, 19647112, 19647112, 19647112, 19647112, 19647112,
// 19647112, 19647112, 19647112, 19649850, 19649850, 19654237, 19654237, 19654237, 19654237, 19654237, 19654237,
// 19654237, 19654237, 19654237, 19654237, 19654237, 19654237,
// ],
// },
//Backed Events
// "0x83Ec02059F686E747392A22ddfED7833bA0d7cE3": {
// AnswerUpdated: [
// 19574099, 19574442, 19581598, 19588736, 19610148, 19617280, 19624427, 19638723, 19667243, 19674385,
// ],
// },
// "0x475855DAe09af1e3f2d380d766b9E630926ad3CE": {
// AnswerUpdated: [
// 19574095, 19574443, 19581596, 19588737, 19610145, 19617284, 19624426, 19631578, 19638720, 19667241, 19674386,
// ],
// },
'0x4305FB66699C3B2702D4d05CF36551390A4c69C6': {
PriceFeedUpdate: [
19611413, 19618548, 19625698, 19632847, 19633586, 19639991, 19647112,
19649850, 19649850, 19654237,
],
},
// Backed Events
'0x83Ec02059F686E747392A22ddfED7833bA0d7cE3': {
AnswerUpdated: [
19574099, 19574442, 19581598, 19588736, 19610148, 19617280, 19624427,
19638723, 19667243, 19674385,
],
},
'0x475855DAe09af1e3f2d380d766b9E630926ad3CE': {
AnswerUpdated: [
19574095, 19574443, 19581596, 19588737, 19610145, 19617284, 19624426,
19631578, 19638720, 19667241, 19674386,
],
},
//Redstone Events
'0x6E27A25999B3C665E44D903B2139F5a4Be2B6C26': {
AnswerUpdated: [],
Expand Down
Loading

0 comments on commit cef9d71

Please sign in to comment.