Jayant Krishnamurthy преди 2 години
родител
ревизия
673cdfce9f

+ 1 - 1
target_chains/ethereum/contracts/.env.prod.development

@@ -1,5 +1,5 @@
 # Migrations Metadata
-MIGRATIONS_DIR=./migrations/prod
+MIGRATIONS_DIR=./migrations/prod-receiver
 MIGRATIONS_NETWORK=development
 WORMHOLE_CHAIN_NAME=ethereum
 CLUSTER=testnet

+ 8 - 0
target_chains/ethereum/examples/oracle_swap/README.md

@@ -83,3 +83,11 @@ usd 0x98cDc14fe999435F3d4C2E65eC8863e0d70493Df
 swap contract 0xf3161b2B32761B46C084a7e1d8993C19703C09e7
 
 Once you've configured everything, simply run `npm run start`.
+
+## Local Eth network
+
+from `ethereum/contracts/contract` run
+
+`npx ganache-cli -e 10000 --deterministic --time="1970-01-02T00:00:00+00:00" --host=0.0.0.0`
+
+then run `./local-devnet.sh` in this directory to set up the contracts on the ganache node

+ 4 - 4
target_chains/ethereum/examples/oracle_swap/app/src/App.tsx

@@ -20,20 +20,20 @@ const CONFIG = {
   // Note that feeds have different ids on testnet / mainnet.
   baseToken: {
     name: "BRL",
-    erc20Address: "0x8e2a09b54fF35Cc4fe3e7dba68bF4173cC559C69",
+    erc20Address: "0x0290FB167208Af455bB137780163b7B7a9a10C16",
     pythPriceFeedId:
       "08f781a893bc9340140c5f89c8a96f438bcfae4d1474cc0f688e3a52892c7318",
     decimals: 18,
   },
   quoteToken: {
     name: "USD",
-    erc20Address: "0x98cDc14fe999435F3d4C2E65eC8863e0d70493Df",
+    erc20Address: "0x9b1f7F645351AF3631a656421eD2e40f2802E6c0",
     pythPriceFeedId:
       "1fc18861232290221461220bd4e2acd1dcdfbc89c84092c93c18bdc7756c1588",
     decimals: 18,
   },
-  swapContractAddress: "0xec86479a72469Fe5E4efc2B5b1c960Ed460e9081",
-  pythContractAddress: "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C",
+  swapContractAddress: "0x67B5656d60a809915323Bf2C40A8bEF15A152e3e",
+  pythContractAddress: "0xe982E462b094850F12AF94d21D470e21bE9D0E9C",
   priceServiceUrl: "https://xc-testnet.pyth.network",
   mintQty: 100,
 };

+ 1 - 4
target_chains/ethereum/examples/oracle_swap/app/src/OrderEntry.tsx

@@ -239,7 +239,7 @@ async function sendSwapTxNew(
   try {
     const res = await swapContract.methods
       .swapNoUpdate(isBuy, qtyWei)
-      .call({ value: tip, from: sender });
+      .send({ value: tip, from: sender });
   } catch (error) {
     console.log(error);
   }
@@ -258,7 +258,4 @@ async function sendSwapTxNew(
   const updateFee = await pythContract.methods
     .getUpdateFee(priceFeedUpdateData.length)
     .call();
-
-  pythContract;
-  alert(res);
 }

+ 33 - 0
target_chains/ethereum/examples/oracle_swap/local_devnet.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+
+RPC_URL=localhost:8545
+
+BASE_FEED_ID="0x08f781a893bc9340140c5f89c8a96f438bcfae4d1474cc0f688e3a52892c7318"
+QUOTE_FEED_ID="0x1fc18861232290221461220bd4e2acd1dcdfbc89c84092c93c18bdc7756c1588"
+PRIVATE_KEY="0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d"
+BASE_ERC20_ADDR="0x0290FB167208Af455bB137780163b7B7a9a10C16"
+QUOTE_ERC20_ADDR="0x9b1f7F645351AF3631a656421eD2e40f2802E6c0"
+
+YOUR_WALLET_ADDRESS="0x368397bDc956b4F23847bE244f350Bde4615F25E"
+
+cd ../../contracts && ./deploy.sh development
+
+cd ../examples/oracle_swap/contract/
+
+forge create ERC20Mock --rpc-url $RPC_URL --private-key $PRIVATE_KEY --constructor-args "Brazilean Real" "BRL" "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1" "0"
+forge create ERC20Mock --rpc-url $RPC_URL --private-key $PRIVATE_KEY --constructor-args "US Dollar" "USD" "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1" "0"
+
+forge create src/OracleSwap.sol:OracleSwap \
+  --private-key $PRIVATE_KEY \
+  --rpc-url $RPC_URL \
+  --constructor-args \
+  "0xe982E462b094850F12AF94d21D470e21bE9D0E9C" \
+  $BASE_FEED_ID \
+  $QUOTE_FEED_ID \
+  $BASE_ERC20_ADDR \
+  $QUOTE_ERC20_ADDR
+
+
+# swap contract address = 0x67B5656d60a809915323Bf2C40A8bEF15A152e3e
+
+cast send --private-key $PRIVATE_KEY $YOUR_WALLET_ADDRESS --value 10ether

+ 2 - 1
target_chains/ethereum/proxy/src/index.ts

@@ -2,12 +2,13 @@ import express from "express";
 import axios, { AxiosError } from "axios";
 import bodyParser from "body-parser";
 
-const UNDERLYING_URL = "https://goerli.optimism.io";
+const UNDERLYING_URL = "http://localhost:8545";
 
 const IGNORE_METHODS = [
   "eth_blockNumber",
   "eth_getBalance",
   "eth_getBlockByNumber",
+  "eth_getBlockByHash",
   "eth_feeHistory",
   "eth_call",
 ];