diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..b32ecbbf0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "utils/frontend/contracts.sol/lib/forge-std"] + path = utils/frontend/contracts.sol/lib/forge-std + url = https://github.com/foundry-rs/forge-std +[submodule "utils/frontend/contracts.sol/lib/openzeppelin-contracts"] + path = utils/frontend/contracts.sol/lib/openzeppelin-contracts + url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/cliTool/index.ts b/cliTool/index.ts index 776cdef3b..c002feef7 100644 --- a/cliTool/index.ts +++ b/cliTool/index.ts @@ -49,7 +49,7 @@ import { getPolkAddress, create10sequencers, closeL1Item, - sendUpdateToL1, + sendUpdateToL1, calculateBuyPrice } from "../utils/setupsOnTheGo"; import { findErrorMetadata, @@ -135,10 +135,14 @@ async function app(): Promise { "Close All L1 items", "1000 withdrawals", "sync updates", + "calculateBuyPrice", ], }) .then(async (answers: { option: string | string[] }) => { console.log("Answers::: " + JSON.stringify(answers, null, " ")); + if (answers.option.includes("calculateBuyPrice")){ + await calculateBuyPrice(); + } if (answers.option.includes("sync updates")) { await sendUpdateToL1(); } diff --git a/package.json b/package.json index b7430302f..9aa7b2896 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,8 @@ "ethers": "^5.4.7", "exec-sh": "^0.4.0", "express": "^4.18.2", - "gasp-sdk": "0.0.2-feature-rolldown-on-idle-hook.0", - "gasp-types": "0.0.2-feature-rolldown-on-idle-hook.0", + "gasp-sdk": "0.0.2-feature-stable-pool-mgx-1307.18", + "gasp-types": "0.0.2-feature-stable-pool-mgx-1307.24", "get-port-please": "^3.0.1", "guid-typescript": "^1.0.9", "jest-docblock": "^29.7.0", diff --git a/utils/frontend/contracts.sol/.gitignore b/utils/frontend/contracts.sol/.gitignore new file mode 100644 index 000000000..85198aaa5 --- /dev/null +++ b/utils/frontend/contracts.sol/.gitignore @@ -0,0 +1,14 @@ +# Compiler files +cache/ +out/ + +# Ignores development broadcast logs +!/broadcast +/broadcast/*/31337/ +/broadcast/**/dry-run/ + +# Docs +docs/ + +# Dotenv file +.env diff --git a/utils/frontend/contracts.sol/README.md b/utils/frontend/contracts.sol/README.md new file mode 100644 index 000000000..9b6bb6d41 --- /dev/null +++ b/utils/frontend/contracts.sol/README.md @@ -0,0 +1,77 @@ +## Foundry + +**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** + +Foundry consists of: + +- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). +- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. +- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. +- **Chisel**: Fast, utilitarian, and verbose solidity REPL. + +## Documentation + +https://book.getfoundry.sh/ + +## Usage + +### Build + +```shell +$ forge build +``` + +### Test + +```shell +$ forge test +``` + +### Format + +```shell +$ forge fmt +``` + +### Gas Snapshots + +```shell +$ forge snapshot +``` + +### Anvil + +```shell +$ anvil +``` + +### Deploy + +```shell +$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key +``` + +### Cast + +```shell +$ cast +``` + +### Help + +```shell +$ forge --help +$ anvil --help +$ cast --help +``` + + +# Howto + foundryup + + forge install OpenZeppelin/openzeppelin-contracts + + forge build + + export PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 ; forge script --rpc-url=https://evm-node-arb-frontend.gasp.xyz script/deploycontracts.sol --broadcast + diff --git a/utils/frontend/contracts.sol/foundry.toml b/utils/frontend/contracts.sol/foundry.toml new file mode 100644 index 000000000..d958fc307 --- /dev/null +++ b/utils/frontend/contracts.sol/foundry.toml @@ -0,0 +1,8 @@ +[profile.default] +src = "src" +out = "out" +libs = ["lib"] + +# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options +[remappings] +openzeppelin-contracts="lib/openzeppelin-contracts" \ No newline at end of file diff --git a/utils/frontend/contracts.sol/lib/forge-std b/utils/frontend/contracts.sol/lib/forge-std new file mode 160000 index 000000000..1eea5bae1 --- /dev/null +++ b/utils/frontend/contracts.sol/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 1eea5bae12ae557d589f9f0f0edae2faa47cb262 diff --git a/utils/frontend/contracts.sol/lib/openzeppelin-contracts b/utils/frontend/contracts.sol/lib/openzeppelin-contracts new file mode 160000 index 000000000..69c8def5f --- /dev/null +++ b/utils/frontend/contracts.sol/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit 69c8def5f222ff96f2b5beff05dfba996368aa79 diff --git a/utils/frontend/contracts.sol/script/deploycontracts.sol b/utils/frontend/contracts.sol/script/deploycontracts.sol new file mode 100644 index 000000000..e8ab5b041 --- /dev/null +++ b/utils/frontend/contracts.sol/script/deploycontracts.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import "forge-std/Script.sol"; +import {USDC} from "../src/USDC.sol"; + +contract DeployTokens is Script { + function run() external { + // Fetch the deployer's private key from environment variables + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + + // Start broadcast for transactions + vm.startBroadcast(deployerPrivateKey); + + // Deploy TestERC20 + USDC testERC20 = new USDC("Test Token10", "Token10"); + console.log("USDC deployed to:", address(testERC20)); + + vm.stopBroadcast(); + } +} \ No newline at end of file diff --git a/utils/frontend/contracts.sol/src/USDC.sol b/utils/frontend/contracts.sol/src/USDC.sol new file mode 100644 index 000000000..c35f4f2d5 --- /dev/null +++ b/utils/frontend/contracts.sol/src/USDC.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract USDC is ERC20 { + constructor( + string memory name, + string memory symbol + ) ERC20(name, symbol) { + // Mint initial tokens + _mint(msg.sender, 1_000_000_000 * 10**decimals()); + } + + function decimals() public pure override returns (uint8) { + return 18; + } + + function mint(address to, uint256 amount) external { + _mint(to, amount); + } +} diff --git a/utils/setupsOnTheGo.ts b/utils/setupsOnTheGo.ts index 28d994ff4..36acabfab 100644 --- a/utils/setupsOnTheGo.ts +++ b/utils/setupsOnTheGo.ts @@ -360,6 +360,7 @@ export async function setupPoolWithRewardsForDefaultUsers() { amount.divn(10), token2, amount.divn(10), + "Xyk", ), ), ); @@ -475,6 +476,15 @@ export async function setupTokenWithRewardsForDefaultUsers() { return { users, liqId, sudo, token2 }; } +export async function calculateBuyPrice() { + await setupUsers(); + await setupApi(); + const api = await getApi(); + //@ts-ignore + const value = await api.rpc.market.get_pools(3); + //@ts-ignore + testLog.getLog().info(JSON.stringify(value.toHuman())); +} export async function printAllTxsDoneByUser(userAddress: string) { await setupUsers(); await setupApi(); diff --git a/yarn.lock b/yarn.lock index fca38ada8..0db75bac5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9559,27 +9559,27 @@ ganache@7.9.1: bufferutil "4.0.5" utf-8-validate "5.0.7" -gasp-sdk@0.0.2-feature-rolldown-on-idle-hook.0: - version "0.0.2-feature-rolldown-on-idle-hook.0" - resolved "https://registry.yarnpkg.com/gasp-sdk/-/gasp-sdk-0.0.2-feature-rolldown-on-idle-hook.0.tgz#17693211576b6a679df72dbedae12abfeb23a2a6" - integrity sha512-h08qiBKXhDgrGWojgepdOAk+Lumaq/EEro1KAlFhf+MfR+fHzH1Mm8UVONUrN2Xp/xmaVUam/0HBoLcNo+Q03A== +gasp-sdk@0.0.2-feature-stable-pool-mgx-1307.18: + version "0.0.2-feature-stable-pool-mgx-1307.18" + resolved "https://registry.yarnpkg.com/gasp-sdk/-/gasp-sdk-0.0.2-feature-stable-pool-mgx-1307.18.tgz#7e576c7ca5255ac53d492ee4a7e8ff5801785285" + integrity sha512-7RHw82pBQ2FR1Cybg2bXDbupRBZz+EV7SYgcGAK8F568rhWX3maiYQH34L4OoGHAtWo/LCrnZtpZObbo/bez8g== dependencies: big.js "6.2.1" - gasp-type-definitions "0.0.2-feature-rolldown-on-idle-hook.0" + gasp-type-definitions "0.0.2-feature-stable-pool-mgx-1307.24" tslib "^2.3.0" tslog "4.8.2" viem "^2.17.4" wagmi "^2.10.10" -gasp-type-definitions@0.0.2-feature-rolldown-on-idle-hook.0: - version "0.0.2-feature-rolldown-on-idle-hook.0" - resolved "https://registry.yarnpkg.com/gasp-type-definitions/-/gasp-type-definitions-0.0.2-feature-rolldown-on-idle-hook.0.tgz#823400703966ac0042c3e2017877810e1fbb4269" - integrity sha512-unRXCS2OUbeSSzYSKWeVpTcyEoZq8/TB+Fb7JaNO+CQ+kVOghEjatHhUtfzxkkBjdpCnB8BprLmgZm9pVLU4Sw== +gasp-type-definitions@0.0.2-feature-stable-pool-mgx-1307.24: + version "0.0.2-feature-stable-pool-mgx-1307.24" + resolved "https://registry.yarnpkg.com/gasp-type-definitions/-/gasp-type-definitions-0.0.2-feature-stable-pool-mgx-1307.24.tgz#9b227cc62ae5625dd11e250db336133f6d86edb4" + integrity sha512-AFgQMA7CsIB2K8zFyVseHKEVXlrWhtMNikLfHF15dfxP23uApnd7mMR72WKv7qYBMuxCGFI05QdatGgGQigxDA== -gasp-types@0.0.2-feature-rolldown-on-idle-hook.0: - version "0.0.2-feature-rolldown-on-idle-hook.0" - resolved "https://registry.yarnpkg.com/gasp-types/-/gasp-types-0.0.2-feature-rolldown-on-idle-hook.0.tgz#6952414f82bb2bece10a8e26f104682cf8d04145" - integrity sha512-P0VFssv/HGfJuRu9biW2DRQv2fHjc0E0L3B6M8dS2741J24ZBPi3MlCkgXQeYVyNjXT7SAdt53qZeES7CUQLug== +gasp-types@0.0.2-feature-stable-pool-mgx-1307.24: + version "0.0.2-feature-stable-pool-mgx-1307.24" + resolved "https://registry.yarnpkg.com/gasp-types/-/gasp-types-0.0.2-feature-stable-pool-mgx-1307.24.tgz#6cbf4ff7dd71460b3525c8632f2c832bfb52f165" + integrity sha512-86iMzX4ZiyxwdNAriljIqQLYmvyO4beczY+QKrqYW6k309EEp9P39VZYzWmKPKhjpF+5n2x2n2iXmXnywjKK3g== gauge@^4.0.3: version "4.0.4"