Skip to content

Commit

Permalink
Organizing some protocol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pgbrandao committed Oct 31, 2023
1 parent 18987eb commit 01ac32d
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 400 deletions.
82 changes: 7 additions & 75 deletions core/tests/protocols/aave.spec.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,20 @@
import { test } from "vitest";
import { generateTransaction } from "core/src/transaction/generate-transaction";
import { AssetStore } from "core/src/transaction/types";
import { loadConfig } from "core/src/config/load-config";
import { simulateRouterOperation } from "core/src/path/tx-simulator";
import { getProvider } from "core/src/utils/get-provider";
import { simulateSingleAssetToSingleAsset } from "./utils";

test("generateTransaction: USDC to aPolUSDC (aaveV3Deposit)", async () => {
const assetStore = new AssetStore();
const config = await loadConfig();
const provider = await getProvider({ chainId: 137 });

const routerOperation = await generateTransaction({
inputAllocation: [
{
assetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
amountStr: "1000000000",
},
],
outputAllocation: [
{
assetId: "371b83f1-3301-4c69-b3ad-8d199c6d1774",
fraction: 1.0,
},
],
assetStore,
simulateSingleAssetToSingleAsset({
chainId: 137,
walletAddress: config.networks[137].routerSimulatorAddress,
});

const result = await simulateRouterOperation({
chainId: 137,
routerOperation,
provider,
sellAsset: assetStore.getAssetById("e251ecf6-48c2-4538-afcd-fbb92424054d"),
inputAssetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
outputAssetId: "371b83f1-3301-4c69-b3ad-8d199c6d1774",
amountIn: "1000000000",
buyAsset: assetStore.getAssetById("371b83f1-3301-4c69-b3ad-8d199c6d1774"),
});

console.dir(
{
encodedTransactionData: routerOperation.getEncodedTransactionData(),
result,
},
{ depth: null, maxStringLength: null }
);
});

test.skip("generateTransaction: aPolUSDC (aaveV3Deposit) to USDC", async () => {
const assetStore = new AssetStore();
const config = await loadConfig();
const provider = await getProvider({ chainId: 137 });

const routerOperation = await generateTransaction({
inputAllocation: [
{
assetId: "371b83f1-3301-4c69-b3ad-8d199c6d1774",
amountStr: "1000000000",
},
],
outputAllocation: [
{
assetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
fraction: 1.0,
},
],
assetStore,
simulateSingleAssetToSingleAsset({
chainId: 137,
walletAddress: config.networks[137].routerSimulatorAddress,
});

const result = await simulateRouterOperation({
chainId: 137,
routerOperation,
provider,
sellAsset: assetStore.getAssetById("371b83f1-3301-4c69-b3ad-8d199c6d1774"),
inputAssetId: "371b83f1-3301-4c69-b3ad-8d199c6d1774",
outputAssetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
amountIn: "1000000000",
buyAsset: assetStore.getAssetById("e251ecf6-48c2-4538-afcd-fbb92424054d"),
});

console.dir(
{
encodedTransactionData: routerOperation.getEncodedTransactionData(),
result,
},
{ depth: null, maxStringLength: null }
);
});
82 changes: 7 additions & 75 deletions core/tests/protocols/beefy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,20 @@
import { test } from "vitest";
import { generateTransaction } from "core/src/transaction/generate-transaction";
import { AssetStore } from "core/src/transaction/types";
import { loadConfig } from "core/src/config/load-config";
import { simulateRouterOperation } from "core/src/path/tx-simulator";
import { getProvider } from "core/src/utils/get-provider";
import { simulateSingleAssetToSingleAsset } from "./utils";

test("generateTransaction: USDC to QUICK (beefyDeposit)", async () => {
const assetStore = new AssetStore();
const config = await loadConfig();
const provider = await getProvider({ chainId: 137 });

const routerOperation = await generateTransaction({
inputAllocation: [
{
assetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
amountStr: "1000000000",
},
],
outputAllocation: [
{
assetId: "37819023-9c6a-4848-8cf5-24a95350f001",
fraction: 1.0,
},
],
assetStore,
simulateSingleAssetToSingleAsset({
chainId: 137,
walletAddress: config.networks[137].routerSimulatorAddress,
});

const result = await simulateRouterOperation({
chainId: 137,
routerOperation,
provider,
sellAsset: assetStore.getAssetById("e251ecf6-48c2-4538-afcd-fbb92424054d"),
inputAssetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
outputAssetId: "37819023-9c6a-4848-8cf5-24a95350f001",
amountIn: "1000000000",
buyAsset: assetStore.getAssetById("37819023-9c6a-4848-8cf5-24a95350f001"),
});

console.dir(
{
encodedTransactionData: routerOperation.getEncodedTransactionData(),
result,
},
{ depth: null, maxStringLength: null }
);
});

test.skip("generateTransaction: beefy.finance (beefyDeposit) to USDC", async () => {
const assetStore = new AssetStore();
const config = await loadConfig();
const provider = await getProvider({ chainId: 137 });

const routerOperation = await generateTransaction({
inputAllocation: [
{
assetId: "fecfd33d-e6a7-476b-89cb-910a0058fa48",
amountStr: "1000000",
},
],
outputAllocation: [
{
assetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
fraction: 1.0,
},
],
assetStore,
simulateSingleAssetToSingleAsset({
chainId: 137,
walletAddress: config.networks[137].routerSimulatorAddress,
});

const result = await simulateRouterOperation({
chainId: 137,
routerOperation,
provider,
sellAsset: assetStore.getAssetById("fecfd33d-e6a7-476b-89cb-910a0058fa48"),
inputAssetId: "fecfd33d-e6a7-476b-89cb-910a0058fa48",
outputAssetId: "e251ecf6-48c2-4538-afcd-fbb92424054d",
amountIn: "1000000",
buyAsset: assetStore.getAssetById("e251ecf6-48c2-4538-afcd-fbb92424054d"),
});

console.dir(
{
encodedTransactionData: routerOperation.getEncodedTransactionData(),
result,
},
{ depth: null, maxStringLength: null }
);
});
Loading

0 comments on commit 01ac32d

Please sign in to comment.