-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
aptos_sdk | ||
python-dotenv | ||
pathlib | ||
yaml | ||
pyyaml | ||
toml | ||
requests | ||
eth-brownie | ||
ccxt==1.72.64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from brownie import network | ||
import ccxt | ||
|
||
from scripts.serde_aptos import get_serde_facet | ||
from scripts.struct import omniswap_aptos_path, hex_str_to_vector_u8 | ||
from scripts.utils import aptos_brownie | ||
|
||
|
||
def set_so_gas(): | ||
package = aptos_brownie.AptosPackage( | ||
project_path=omniswap_aptos_path, | ||
network="aptos-mainnet" | ||
) | ||
|
||
serde = get_serde_facet(package, network.show_active()) | ||
|
||
nets = ["mainnet", "bsc-main", "avax-main", "polygon-main"] | ||
|
||
for net in nets: | ||
base_gas = hex_str_to_vector_u8(str(serde.normalizeU256( | ||
package.network_config["wormhole"]["gas"][net]["base_gas"]))) | ||
gas_per_bytes = hex_str_to_vector_u8(str(serde.normalizeU256( | ||
package.network_config["wormhole"]["gas"][net]["per_byte_gas"]))) | ||
print(f"Set wormhole gas for:{net}") | ||
package["wormhole_facet::set_wormhole_gas"]( | ||
package.network_config["wormhole"]["gas"][net]["dst_chainid"], | ||
base_gas, | ||
gas_per_bytes | ||
) | ||
|
||
|
||
def set_so_price(): | ||
api = ccxt.binance() | ||
symbols = ["ETH/USDT", "BNB/USDT", "MATIC/USDT", "AVAX/USDT", "APT/USDT"] | ||
prices = {} | ||
|
||
for symbol in symbols: | ||
result = api.fetch_ohlcv(symbol=symbol, | ||
timeframe="1m", | ||
limit=1) | ||
price = result[-1][4] | ||
print(f"Symbol:{symbol}, price:{price}") | ||
prices[symbol] = price | ||
|
||
ratio_decimal = 1e8 | ||
multiply = 1.1 | ||
package = aptos_brownie.AptosPackage( | ||
project_path=omniswap_aptos_path, | ||
network="aptos-mainnet" | ||
) | ||
|
||
nets = ["mainnet", "bsc-main", "avax-main", "polygon-main"] | ||
|
||
if "mainnet" in nets: | ||
ratio = int(prices["ETH/USDT"] / prices["APT/USDT"] * ratio_decimal * multiply) | ||
print(f"Set price ratio for mainnet:{ratio}") | ||
package["so_fee_wormhole::set_price_ratio"](2, ratio) | ||
if "bsc-main" in nets: | ||
ratio = int(prices["BNB/USDT"] / prices["APT/USDT"] * ratio_decimal * multiply) | ||
print(f"Set price ratio for bsc-main:{ratio}") | ||
package["so_fee_wormhole::set_price_ratio"](4, ratio) | ||
if "polygon-main" in nets: | ||
ratio = int(prices["MATIC/USDT"] / prices["APT/USDT"] * ratio_decimal * multiply) | ||
print(f"Set price ratio for polygon-main:{ratio}") | ||
package["so_fee_wormhole::set_price_ratio"](5, ratio) | ||
if "avax-main" in nets: | ||
ratio = int(prices["AVAX/USDT"] / prices["APT/USDT"] * ratio_decimal * multiply) | ||
print(f"Set price ratio for avax-main:{ratio}") | ||
package["so_fee_wormhole::set_price_ratio"](6, ratio) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
eth-brownie | ||
aptos_sdk | ||
python-dotenv | ||
pathlib | ||
pyyaml | ||
toml | ||
requests | ||
eth-brownie | ||
ccxt==1.72.64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from brownie import network, Contract, SoDiamond, WormholeFacet, LibSoFeeWormholeV1 | ||
import ccxt | ||
|
||
from scripts.helpful_scripts import get_wormhole_info, get_account | ||
from scripts.utils import aptos_brownie | ||
|
||
|
||
def set_so_gas(): | ||
proxy_wormhole = Contract.from_abi( | ||
"WormholeFacet", SoDiamond[-1].address, WormholeFacet.abi) | ||
|
||
nets = ["mainnet", "bsc-main", "avax-main", "polygon-main"] | ||
|
||
gas = get_wormhole_info()["gas"] | ||
for net in nets: | ||
if net == network.show_active(): | ||
continue | ||
print(f"network:{network.show_active()}, " | ||
f"set dst net {net} wormhole gas: " | ||
f"base_gas:{gas[net]['base_gas']}," | ||
f"per_byte_gas:{gas[net]['per_byte_gas']}") | ||
proxy_wormhole.setWormholeGas( | ||
gas[net]["dst_chainid"], | ||
gas[net]["base_gas"], | ||
gas[net]["per_byte_gas"], | ||
{'from': get_account()} | ||
) | ||
|
||
|
||
def set_so_price(): | ||
api = ccxt.binance() | ||
symbols = ["ETH/USDT", "BNB/USDT", "MATIC/USDT", "AVAX/USDT", "APT/USDT"] | ||
prices = {} | ||
|
||
for symbol in symbols: | ||
result = api.fetch_ohlcv(symbol=symbol, | ||
timeframe="1m", | ||
limit=1) | ||
price = result[-1][4] | ||
print(f"Symbol:{symbol}, price:{price}") | ||
prices[symbol] = price | ||
|
||
decimal = 1e27 | ||
multiply = 1.1 | ||
if network.show_active() == "avax-main": | ||
# bnb | ||
dst_wormhole_id = 2 | ||
ratio = int(prices["BNB/USDT"] / prices["AVAX/USDT"] * decimal * multiply) | ||
print(f"Set price ratio for bnb-main:{ratio}") | ||
LibSoFeeWormholeV1[-1].setPriceRatio(dst_wormhole_id, | ||
ratio, {"from": get_account()}) | ||
# aptos | ||
dst_wormhole_id = 22 | ||
ratio = int(prices["APT/USDT"] / prices["AVAX/USDT"] * decimal * multiply) | ||
print(f"Set price ratio for aptos-mainnet:{ratio}") | ||
LibSoFeeWormholeV1[-1].setPriceRatio(dst_wormhole_id, | ||
ratio, {"from": get_account()}) | ||
|
||
if network.show_active() == "mainnet": | ||
# aptos | ||
dst_wormhole_id = 22 | ||
ratio = int(prices["APT/USDT"] / prices["ETH/USDT"] * decimal * multiply) | ||
print(f"Set price ratio for aptos-mainnet:{ratio}") | ||
LibSoFeeWormholeV1[-1].setPriceRatio(dst_wormhole_id, | ||
ratio, {"from": get_account()}) | ||
|
||
if network.show_active() == "polygon-main": | ||
# aptos | ||
dst_wormhole_id = 22 | ||
ratio = int(prices["APT/USDT"] / prices["MATIC/USDT"] * decimal * multiply) | ||
print(f"Set price ratio for aptos-mainnet:{ratio}") | ||
LibSoFeeWormholeV1[-1].setPriceRatio(dst_wormhole_id, | ||
ratio, {"from": get_account()}) | ||
|
||
if network.show_active() == "bsc-main": | ||
# aptos | ||
dst_wormhole_id = 22 | ||
ratio = int(prices["APT/USDT"] / prices["BNB/USDT"] * decimal * multiply) | ||
print(f"Set price ratio for aptos-mainnet:{ratio}") | ||
LibSoFeeWormholeV1[-1].setPriceRatio(dst_wormhole_id, | ||
ratio, {"from": get_account()}) |