Skip to content

Commit 0fa1401

Browse files
authored
Correctly handling ETH in getMarketSize(...) function of Euler client (#245)
* fix: correctly handling ETH in getMarketSize * chore: version bump
1 parent 3226a7b commit 0fa1401

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aztec/bridge-clients",
3-
"version": "0.1.60",
3+
"version": "0.1.61",
44
"description": "This repo contains the solidity files and typescript helper class for all of the Aztec Connect Bridge Contracts",
55
"repository": "[email protected]:AztecProtocol/aztec-connect-bridges.git",
66
"license": "Apache-2.0",

src/client/euler/euler-bridge-data.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,11 @@ describe("Euler bridge data", () => {
6060
expect(assetValue.assetId).toBe(daiAsset.id);
6161
expect(assetValue.value).toBeGreaterThan(0);
6262
});
63+
64+
it("should correctly fetch market size for ETH", async () => {
65+
const eulerBridgeData = EulerBridgeData.create({} as any);
66+
const assetValue = (await eulerBridgeData.getMarketSize(ethAsset, emptyAsset, emptyAsset, emptyAsset, 0))[0];
67+
expect(assetValue.assetId).toBe(ethAsset.id);
68+
expect(assetValue.value).toBeGreaterThan(0);
69+
});
6370
});

src/client/euler/euler-bridge-data.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { EthereumProvider } from "@aztec/barretenberg/blockchain";
33
import { Web3Provider } from "@ethersproject/providers";
44
import "isomorphic-fetch";
55
import { createWeb3Provider } from "../aztec/provider";
6-
import { AztecAsset } from "../bridge-data";
6+
import { AztecAsset, AztecAssetType } from "../bridge-data";
77

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

1010
export class EulerBridgeData extends ERC4626BridgeData {
11+
private readonly subgraphWethId = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
12+
1113
protected constructor(ethersProvider: Web3Provider) {
1214
super(ethersProvider);
1315
}
@@ -60,6 +62,11 @@ export class EulerBridgeData extends ERC4626BridgeData {
6062
outputAssetB: AztecAsset,
6163
auxData: number,
6264
): Promise<AssetValue[]> {
65+
const subgraphAssetId =
66+
inputAssetA.assetType === AztecAssetType.ETH
67+
? this.subgraphWethId
68+
: inputAssetA.erc20Address.toString().toLowerCase();
69+
6370
const result = await (
6471
await fetch("https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet", {
6572
method: "POST",
@@ -75,7 +82,7 @@ export class EulerBridgeData extends ERC4626BridgeData {
7582
}
7683
`,
7784
variables: {
78-
id: inputAssetA.erc20Address.toString().toLowerCase(),
85+
id: subgraphAssetId,
7986
},
8087
}),
8188
})

0 commit comments

Comments
 (0)