Skip to content

Commit

Permalink
Correctly handling ETH in getMarketSize(...) function of Euler clie…
Browse files Browse the repository at this point in the history
…nt (#245)

* fix: correctly handling ETH in getMarketSize

* chore: version bump
  • Loading branch information
benesjan authored Sep 28, 2022
1 parent 3226a7b commit 0fa1401
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aztec/bridge-clients",
"version": "0.1.60",
"version": "0.1.61",
"description": "This repo contains the solidity files and typescript helper class for all of the Aztec Connect Bridge Contracts",
"repository": "git@github.com:AztecProtocol/aztec-connect-bridges.git",
"license": "Apache-2.0",
Expand Down
7 changes: 7 additions & 0 deletions src/client/euler/euler-bridge-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ describe("Euler bridge data", () => {
expect(assetValue.assetId).toBe(daiAsset.id);
expect(assetValue.value).toBeGreaterThan(0);
});

it("should correctly fetch market size for ETH", async () => {
const eulerBridgeData = EulerBridgeData.create({} as any);
const assetValue = (await eulerBridgeData.getMarketSize(ethAsset, emptyAsset, emptyAsset, emptyAsset, 0))[0];
expect(assetValue.assetId).toBe(ethAsset.id);
expect(assetValue.value).toBeGreaterThan(0);
});
});
11 changes: 9 additions & 2 deletions src/client/euler/euler-bridge-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { EthereumProvider } from "@aztec/barretenberg/blockchain";
import { Web3Provider } from "@ethersproject/providers";
import "isomorphic-fetch";
import { createWeb3Provider } from "../aztec/provider";
import { AztecAsset } from "../bridge-data";
import { AztecAsset, AztecAssetType } from "../bridge-data";

import { ERC4626BridgeData } from "../erc4626/erc4626-bridge-data";

export class EulerBridgeData extends ERC4626BridgeData {
private readonly subgraphWethId = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";

protected constructor(ethersProvider: Web3Provider) {
super(ethersProvider);
}
Expand Down Expand Up @@ -60,6 +62,11 @@ export class EulerBridgeData extends ERC4626BridgeData {
outputAssetB: AztecAsset,
auxData: number,
): Promise<AssetValue[]> {
const subgraphAssetId =
inputAssetA.assetType === AztecAssetType.ETH
? this.subgraphWethId
: inputAssetA.erc20Address.toString().toLowerCase();

const result = await (
await fetch("https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet", {
method: "POST",
Expand All @@ -75,7 +82,7 @@ export class EulerBridgeData extends ERC4626BridgeData {
}
`,
variables: {
id: inputAssetA.erc20Address.toString().toLowerCase(),
id: subgraphAssetId,
},
}),
})
Expand Down

0 comments on commit 0fa1401

Please sign in to comment.