Skip to content

Commit

Permalink
allowUnlimitedContractSize: true
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Oct 15, 2024
1 parent bd87e3a commit 323d9e2
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 95 deletions.
50 changes: 25 additions & 25 deletions contracts/Chadex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -788,30 +788,30 @@ contract Chadex is ChadexBase, ReentrancyGuard {
// }
// }

// struct TokenInfoResult {
// string symbol;
// string name;
// uint8 decimals;
// Tokens totalSupply;
// }
// function getTokenInfo(Token[] memory tokens) public view returns (TokenInfoResult[] memory results) {
// results = new TokenInfoResult[](tokens.length);
// for (uint i; i < tokens.length; i++) {
// IERC20 t = IERC20(Token.unwrap(tokens[i]));
// results[i] = TokenInfoResult(t.symbol(), t.name(), t.decimals(), Tokens.wrap(int128(uint128(t.totalSupply()))));
// }
// }
struct TokenInfoResult {
string symbol;
string name;
uint8 decimals;
Tokens totalSupply;
}
function getTokenInfo(Token[] memory tokens) public view returns (TokenInfoResult[] memory results) {
results = new TokenInfoResult[](tokens.length);
for (uint i; i < tokens.length; i++) {
IERC20 t = IERC20(Token.unwrap(tokens[i]));
results[i] = TokenInfoResult(t.symbol(), t.name(), t.decimals(), Tokens.wrap(uint128(t.totalSupply())));
}
}

// struct TokenBalanceAndAllowanceResult {
// Tokens balance;
// Tokens allowance;
// }
// function getTokenBalanceAndAllowance(Account[] memory owners, Token[] memory tokens) public view returns (TokenBalanceAndAllowanceResult[] memory results) {
// require(owners.length == tokens.length);
// results = new TokenBalanceAndAllowanceResult[](owners.length);
// for (uint i; i < owners.length; i++) {
// IERC20 t = IERC20(Token.unwrap(tokens[i]));
// results[i] = TokenBalanceAndAllowanceResult(Tokens.wrap(uint128(t.allowance(Account.unwrap(owners[i]), address(this)))), Tokens.wrap(uint128(t.balanceOf(Account.unwrap(owners[i])))));
// }
// }
struct TokenBalanceAndAllowanceResult {
Tokens balance;
Tokens allowance;
}
function getTokenBalanceAndAllowance(Account[] memory owners, Token[] memory tokens) public view returns (TokenBalanceAndAllowanceResult[] memory results) {
require(owners.length == tokens.length);
results = new TokenBalanceAndAllowanceResult[](owners.length);
for (uint i; i < owners.length; i++) {
IERC20 t = IERC20(Token.unwrap(tokens[i]));
results[i] = TokenBalanceAndAllowanceResult(Tokens.wrap(uint128(t.allowance(Account.unwrap(owners[i]), address(this)))), Tokens.wrap(uint128(t.balanceOf(Account.unwrap(owners[i])))));
}
}
}
7 changes: 7 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ module.exports = {
},
},
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
allowUnlimitedContractSize: true,
// blockGasLimit: 30_000_000,
},
},
};
4 changes: 2 additions & 2 deletions test/00_test_0.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe("Chadex", function () {
const actionsA = [
{ action: Action.FillAnyAndAddOrder, buySell: BuySell.Buy, tokenz: [data.token0.target, data.weth.target], price: ethers.parseUnits(price1, 9).toString(), targetPrice: ethers.parseUnits(price1, 9).toString(), expiry: expiry, baseTokens: baseTokens1.toString(), skipCheck: false },
{ action: Action.FillAnyAndAddOrder, buySell: BuySell.Buy, tokenz: [data.token0.target, data.weth.target], price: ethers.parseUnits(price2, 9).toString(), targetPrice: ethers.parseUnits(price2, 9).toString(), expiry: expiry, baseTokens: baseTokens2.toString(), skipCheck: false },
{ action: Action.FillAnyAndAddOrder, buySell: BuySell.Buy, tokenz: [data.token0.target, data.weth.target], price: ethers.parseUnits(price3, 9).toString(), targetPrice: ethers.parseUnits(price3, 9).toString(), expiry: expiry, baseTokens: baseTokens3.toString(), skipCheck: false },
{ action: Action.FillAnyAndAddOrder, buySell: BuySell.Buy, tokenz: [data.token0.target, data.weth.target], price: ethers.parseUnits(price3, 9).toString(), targetPrice: ethers.parseUnits(price3, 9).toString(), expiry: expired, baseTokens: baseTokens3.toString(), skipCheck: false },
];
console.log(" Executing: " + JSON.stringify(actionsA, null, 2));

Expand All @@ -181,7 +181,7 @@ describe("Chadex", function () {

await data.printState("After Adding Orders");

if (false) {
if (true) {
const targetPrice1 = "0.6901";
const baseTokensB1 = ethers.parseUnits("10", data.decimals0);
const actionsB1 = [
Expand Down
Loading

0 comments on commit 323d9e2

Please sign in to comment.