Skip to content

Commit

Permalink
feat(#major); uni v3; add uniswap v3 optimism swap only (#2351)
Browse files Browse the repository at this point in the history
  • Loading branch information
melotik authored Sep 1, 2023
1 parent 8a7f872 commit 7a45790
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
22 changes: 22 additions & 0 deletions deployment/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -4204,6 +4204,28 @@
"query-id": "uniswap-v3-swap-base"
}
}
},
"uniswap-v3-swap-optimism": {
"network": "optimism",
"status": "dev",
"versions": {
"schema": "4.0.1",
"subgraph": "1.0.0",
"methodology": "1.0.0"
},
"files": {
"template": "uniswap.v3.swap.template.yaml"
},
"options": {
"prepare:yaml": true,
"prepare:constants": true
},
"services": {
"hosted-service": {
"slug": "uniswap-v3-swap-optimism",
"query-id": "uniswap-v3-swap-optimism"
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Deploy } from "./deploy";
import { PancakeV3BSCConfigurations } from "../../protocols/pancakeswap-v3-swap/config/deployments/pancakeswap-v3-swap-bsc/configurations";
import { PancakeV3EthereumConfigurations } from "../../protocols/pancakeswap-v3-swap/config/deployments/pancakeswap-v3-swap-ethereum/configurations";
import { UniswapV3BaseConfigurations } from "../../protocols/uniswap-v3-swap/config/deployments/uniswap-v3-swap-base/configurations";
import { UniswapV3OptimismConfigurations } from "../../protocols/uniswap-v3-swap/config/deployments/uniswap-v3-swap-optimism/configurations";
import { SushiswapV3BaseConfigurations } from "../../protocols/sushiswap-v3-swap/config/deployments/sushiswap-v3-swap-base/configurations";

export function getNetworkConfigurations(deploy: i32): Configurations {
Expand All @@ -19,6 +20,9 @@ export function getNetworkConfigurations(deploy: i32): Configurations {
case Deploy.UNISWAP_V3_BASE: {
return new UniswapV3BaseConfigurations();
}
case Deploy.UNISWAP_V3_OPTIMISM: {
return new UniswapV3OptimismConfigurations();
}
case Deploy.SUSHISWAP_V3_BASE: {
return new SushiswapV3BaseConfigurations();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export namespace Deploy {
export const PANCAKE_V3_ETHEREUM = 1;
export const UNISWAP_V3_BASE = 2;
export const SUSHISWAP_V3_BASE = 3;
export const UNISWAP_V3_OPTIMISM = 4;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"network": "optimism",
"factoryAddress": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"factoryAddressStartBlock": 0,
"nonFungiblePositionManagerAddress": "0xC36442b4a4522E871399CD717aBDD847Ab11FE88",
"nonFungiblePositionManagerAddressStartBlock": 0,
"deployment": "UNISWAP_V3_OPTIMISM",
"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import {
Address,
BigDecimal,
BigInt,
Bytes,
log,
} from "@graphprotocol/graph-ts";
import { Factory } from "../../../../../generated/Factory/Factory";
import {
BIGDECIMAL_ONE,
BIGDECIMAL_ZERO,
FeeSwitch,
Network,
RewardIntervalType,
} from "../../../../../src/common/constants";
import { Configurations } from "../../../../../configurations/configurations/interface";
import { PROTOCOL_NAME, PROTOCOL_SLUG } from "../../../src/common/constants";
import { stringToBytesList } from "../../../../../src/common/utils";

export class UniswapV3OptimismConfigurations implements Configurations {
getNetwork(): string {
return Network.OPTIMISM;
}
getProtocolName(): string {
return PROTOCOL_NAME;
}
getProtocolSlug(): string {
return PROTOCOL_SLUG;
}
getFactoryAddress(): Bytes {
return Bytes.fromHexString("0x1f98431c8ad98523631ae4a59f267346ea31f984");
}
getFactoryContract(): Factory {
return Factory.bind(
Address.fromString("0x1f98431c8ad98523631ae4a59f267346ea31f984")
);
}
getProtocolFeeOnOff(): string {
return FeeSwitch.OFF;
}
getInitialProtocolFeeProportion(fee: i64): BigDecimal {
log.warning("getProtocolFeeRatio is not implemented: {}", [fee.toString()]);
return BIGDECIMAL_ZERO;
}
getProtocolFeeProportion(protocolFee: BigInt): BigDecimal {
return BIGDECIMAL_ONE.div(protocolFee.toBigDecimal());
}
getRewardIntervalType(): string {
return RewardIntervalType.NONE;
}
getReferenceToken(): Bytes {
return Bytes.fromHexString("0x4200000000000000000000000000000000000006");
}
getRewardToken(): Bytes {
return Bytes.fromHexString("");
}
getWhitelistTokens(): Bytes[] {
return stringToBytesList([
"0x7f5c764cbc14f9669b88837ca1490cca17c31607", // usdc
"0x94b008aa00579c1307b0ef2c499ad98a8ce58e58", // tusd
"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", // dai
"0x68f180fcce6836688e9084f035309e29bf0a2095", // wbtc
"0x9e1028f5f1d5ede59748ffcee5532509976840e0", // perp
"0x50c5725949a6f0c72e6c4a641f24049a917db0cb", // lyra
"0x61baadcf22d2565b0f471b291c475db5555e0b76", // aelin
]);
}
getStableCoins(): Bytes[] {
return stringToBytesList([
"0x7f5c764cbc14f9669b88837ca1490cca17c31607", // usdc
"0x94b008aa00579c1307b0ef2c499ad98a8ce58e58", // tusd
"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", // dai
]);
}
getStableOraclePools(): Bytes[] {
return stringToBytesList([
"0x03af20bdaaffb4cc0a521796a223f7d85e2aac31", // weth/dai
"0xb589969d38ce76d3d7aa319de7133bc9755fd840", // weth/usdc - 0.30
"0x85149247691df622eaf1a8bd0cafd40bc45154a9", // weth/usdc - 0.05
]);
}
getUntrackedPairs(): Bytes[] {
return stringToBytesList([]);
}
getUntrackedTokens(): Bytes[] {
return stringToBytesList(["0xb5df6b8f7ebec28858b267fc2ddc59cc8aca7a8d"]);
}
getMinimumLiquidityThreshold(): BigDecimal {
return BigDecimal.fromString("100000");
}
getBrokenERC20Tokens(): Bytes[] {
return stringToBytesList(["0x000000000000be0ab658f92dddac29d6df19a3be"]);
}
}

0 comments on commit 7a45790

Please sign in to comment.