From d7c713060f43b2cbc220cff330ef73d99bc44997 Mon Sep 17 00:00:00 2001 From: Dhruv Gupta Date: Mon, 22 Jul 2024 21:37:55 +0530 Subject: [PATCH] Update marketAgg setup --- scripts/abi/erc20.ts | 1122 ++++------------- scripts/abi/index.ts | 3 +- .../smokeTest1/auctionOpen.ts | 44 +- .../smokeTest1/auctionStart.ts | 34 +- .../smokeTest1/exerciseOptions.ts | 3 +- scripts/integrationTests/smokeTest1/index.ts | 2 + .../smokeTest1/optionSettle.ts | 12 +- scripts/integrationTests/smokeTesting.ts | 4 + scripts/katana.sh | 4 + scripts/main.ts | 17 +- scripts/utils/deployment/deployContracts.ts | 3 + scripts/utils/facades/TestRunner.ts | 66 +- scripts/utils/facades/erc20Facade.ts | 8 +- .../utils/facades/marketAggregatorFacade.ts | 67 + scripts/utils/facades/types.ts | 15 +- scripts/utils/facades/vaultFacade.ts | 83 +- scripts/utils/helpers/accelerators.ts | 13 +- scripts/utils/helpers/setup.ts | 26 +- 18 files changed, 531 insertions(+), 995 deletions(-) create mode 100644 scripts/utils/facades/marketAggregatorFacade.ts diff --git a/scripts/abi/erc20.ts b/scripts/abi/erc20.ts index a4d495b6..8037db11 100644 --- a/scripts/abi/erc20.ts +++ b/scripts/abi/erc20.ts @@ -1,1029 +1,341 @@ export const ABI = [ { - type: "impl", - name: "MintableToken", - interface_name: "src::mintable_token_interface::IMintableToken", + "type": "impl", + "name": "ERC20MixinImpl", + "interface_name": "openzeppelin::token::erc20::interface::ERC20ABI" }, { - type: "struct", - name: "core::integer::u256", - members: [ + "type": "struct", + "name": "core::integer::u256", + "members": [ { - name: "low", - type: "core::integer::u128", + "name": "low", + "type": "core::integer::u128" }, { - name: "high", - type: "core::integer::u128", - }, - ], - }, - { - type: "interface", - name: "src::mintable_token_interface::IMintableToken", - items: [ - { - type: "function", - name: "permissioned_mint", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "permissioned_burn", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "MintableTokenCamelImpl", - interface_name: "src::mintable_token_interface::IMintableTokenCamel", - }, - { - type: "interface", - name: "src::mintable_token_interface::IMintableTokenCamel", - items: [ - { - type: "function", - name: "permissionedMint", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "permissionedBurn", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "Replaceable", - interface_name: "src::replaceability_interface::IReplaceable", - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "struct", - name: "src::replaceability_interface::EICData", - members: [ - { - name: "eic_hash", - type: "core::starknet::class_hash::ClassHash", - }, - { - name: "eic_init_data", - type: "core::array::Span::", - }, - ], - }, - { - type: "enum", - name: "core::option::Option::", - variants: [ - { - name: "Some", - type: "src::replaceability_interface::EICData", - }, - { - name: "None", - type: "()", - }, - ], + "name": "high", + "type": "core::integer::u128" + } + ] }, { - type: "enum", - name: "core::bool", - variants: [ + "type": "enum", + "name": "core::bool", + "variants": [ { - name: "False", - type: "()", + "name": "False", + "type": "()" }, { - name: "True", - type: "()", - }, - ], + "name": "True", + "type": "()" + } + ] }, { - type: "struct", - name: "src::replaceability_interface::ImplementationData", - members: [ + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ { - name: "impl_hash", - type: "core::starknet::class_hash::ClassHash", + "name": "data", + "type": "core::array::Array::" }, { - name: "eic_data", - type: "core::option::Option::", + "name": "pending_word", + "type": "core::felt252" }, { - name: "final", - type: "core::bool", - }, - ], + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] }, { - type: "interface", - name: "src::replaceability_interface::IReplaceable", - items: [ + "type": "interface", + "name": "openzeppelin::token::erc20::interface::ERC20ABI", + "items": [ { - type: "function", - name: "get_upgrade_delay", - inputs: [], - outputs: [ + "type": "function", + "name": "total_supply", + "inputs": [], + "outputs": [ { - type: "core::integer::u64", - }, + "type": "core::integer::u256" + } ], - state_mutability: "view", + "state_mutability": "view" }, { - type: "function", - name: "get_impl_activation_time", - inputs: [ + "type": "function", + "name": "balance_of", + "inputs": [ { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", - }, + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } ], - outputs: [ + "outputs": [ { - type: "core::integer::u64", - }, + "type": "core::integer::u256" + } ], - state_mutability: "view", + "state_mutability": "view" }, { - type: "function", - name: "add_new_implementation", - inputs: [ + "type": "function", + "name": "allowance", + "inputs": [ { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress" }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "remove_implementation", - inputs: [ { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", - }, + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" + } ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "replace_to", - inputs: [ + "outputs": [ { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", - }, + "type": "core::integer::u256" + } ], - outputs: [], - state_mutability: "external", + "state_mutability": "view" }, - ], - }, - { - type: "impl", - name: "AccessControlImplExternal", - interface_name: "src::access_control_interface::IAccessControl", - }, - { - type: "interface", - name: "src::access_control_interface::IAccessControl", - items: [ { - type: "function", - name: "has_role", - inputs: [ + "type": "function", + "name": "transfer", + "inputs": [ { - name: "role", - type: "core::felt252", + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" }, { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, + "name": "amount", + "type": "core::integer::u256" + } ], - outputs: [ + "outputs": [ { - type: "core::bool", - }, + "type": "core::bool" + } ], - state_mutability: "view", + "state_mutability": "external" }, { - type: "function", - name: "get_role_admin", - inputs: [ + "type": "function", + "name": "transfer_from", + "inputs": [ { - name: "role", - type: "core::felt252", + "name": "sender", + "type": "core::starknet::contract_address::ContractAddress" }, - ], - outputs: [ { - type: "core::felt252", + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "impl", - name: "RolesImpl", - interface_name: "src::roles_interface::IMinimalRoles", - }, - { - type: "interface", - name: "src::roles_interface::IMinimalRoles", - items: [ - { - type: "function", - name: "is_governance_admin", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "is_upgrade_governor", - inputs: [ { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, + "name": "amount", + "type": "core::integer::u256" + } ], - outputs: [ + "outputs": [ { - type: "core::bool", - }, + "type": "core::bool" + } ], - state_mutability: "view", + "state_mutability": "external" }, { - type: "function", - name: "register_governance_admin", - inputs: [ + "type": "function", + "name": "approve", + "inputs": [ { - name: "account", - type: "core::starknet::contract_address::ContractAddress", + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "remove_governance_admin", - inputs: [ { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, + "name": "amount", + "type": "core::integer::u256" + } ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "register_upgrade_governor", - inputs: [ + "outputs": [ { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, + "type": "core::bool" + } ], - outputs: [], - state_mutability: "external", + "state_mutability": "external" }, { - type: "function", - name: "remove_upgrade_governor", - inputs: [ + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, + "type": "core::byte_array::ByteArray" + } ], - outputs: [], - state_mutability: "external", + "state_mutability": "view" }, { - type: "function", - name: "renounce", - inputs: [ - { - name: "role", - type: "core::felt252", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "ERC20Impl", - interface_name: "openzeppelin::token::erc20::interface::IERC20", - }, - { - type: "interface", - name: "openzeppelin::token::erc20::interface::IERC20", - items: [ - { - type: "function", - name: "name", - inputs: [], - outputs: [ - { - type: "core::felt252", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "symbol", - inputs: [], - outputs: [ - { - type: "core::felt252", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "decimals", - inputs: [], - outputs: [ - { - type: "core::integer::u8", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "total_supply", - inputs: [], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "balance_of", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "allowance", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "transfer", - inputs: [ - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "external", - }, - { - type: "function", - name: "transfer_from", - inputs: [ - { - name: "sender", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [ + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ { - type: "core::bool", - }, + "type": "core::byte_array::ByteArray" + } ], - state_mutability: "external", + "state_mutability": "view" }, { - type: "function", - name: "approve", - inputs: [ - { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "amount", - type: "core::integer::u256", - }, - ], - outputs: [ + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ { - type: "core::bool", - }, + "type": "core::integer::u8" + } ], - state_mutability: "external", + "state_mutability": "view" }, - ], - }, - { - type: "impl", - name: "ERC20CamelOnlyImpl", - interface_name: "openzeppelin::token::erc20::interface::IERC20CamelOnly", - }, - { - type: "interface", - name: "openzeppelin::token::erc20::interface::IERC20CamelOnly", - items: [ { - type: "function", - name: "totalSupply", - inputs: [], - outputs: [ + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ { - type: "core::integer::u256", - }, + "type": "core::integer::u256" + } ], - state_mutability: "view", + "state_mutability": "view" }, { - type: "function", - name: "balanceOf", - inputs: [ + "type": "function", + "name": "balanceOf", + "inputs": [ { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } ], - outputs: [ + "outputs": [ { - type: "core::integer::u256", - }, + "type": "core::integer::u256" + } ], - state_mutability: "view", + "state_mutability": "view" }, { - type: "function", - name: "transferFrom", - inputs: [ + "type": "function", + "name": "transferFrom", + "inputs": [ { - name: "sender", - type: "core::starknet::contract_address::ContractAddress", + "name": "sender", + "type": "core::starknet::contract_address::ContractAddress" }, { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" }, { - name: "amount", - type: "core::integer::u256", - }, + "name": "amount", + "type": "core::integer::u256" + } ], - outputs: [ + "outputs": [ { - type: "core::bool", - }, + "type": "core::bool" + } ], - state_mutability: "external", - }, - ], - }, - { - type: "constructor", - name: "constructor", - inputs: [ - { - name: "name", - type: "core::felt252", - }, - { - name: "symbol", - type: "core::felt252", - }, - { - name: "decimals", - type: "core::integer::u8", - }, - { - name: "initial_supply", - type: "core::integer::u256", - }, - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "permitted_minter", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "provisional_governance_admin", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "upgrade_delay", - type: "core::integer::u64", - }, - ], - }, - { - type: "function", - name: "increase_allowance", - inputs: [ - { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "added_value", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "external", + "state_mutability": "external" + } + ] }, { - type: "function", - name: "decrease_allowance", - inputs: [ + "type": "constructor", + "name": "constructor", + "inputs": [ { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", + "name": "initial_supply", + "type": "core::integer::u256" }, { - name: "subtracted_value", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "external", + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + } + ] }, { - type: "function", - name: "increaseAllowance", - inputs: [ + "type": "event", + "name": "openzeppelin::token::erc20::erc20::ERC20Component::Transfer", + "kind": "struct", + "members": [ { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", + "name": "from", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" }, { - name: "addedValue", - type: "core::integer::u256", + "name": "to", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" }, - ], - outputs: [ { - type: "core::bool", - }, - ], - state_mutability: "external", + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] }, { - type: "function", - name: "decreaseAllowance", - inputs: [ + "type": "event", + "name": "openzeppelin::token::erc20::erc20::ERC20Component::Approval", + "kind": "struct", + "members": [ { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" }, { - name: "subtractedValue", - type: "core::integer::u256", + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" }, - ], - outputs: [ { - type: "core::bool", - }, - ], - state_mutability: "external", + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] }, { - type: "event", - name: "openzeppelin::token::erc20_v070::erc20::ERC20::Transfer", - kind: "struct", - members: [ + "type": "event", + "name": "openzeppelin::token::erc20::erc20::ERC20Component::Event", + "kind": "enum", + "variants": [ { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", + "name": "Transfer", + "type": "openzeppelin::token::erc20::erc20::ERC20Component::Transfer", + "kind": "nested" }, { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "value", - type: "core::integer::u256", - kind: "data", - }, - ], + "name": "Approval", + "type": "openzeppelin::token::erc20::erc20::ERC20Component::Approval", + "kind": "nested" + } + ] }, { - type: "event", - name: "openzeppelin::token::erc20_v070::erc20::ERC20::Approval", - kind: "struct", - members: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, + "type": "event", + "name": "pitch_lake_starknet::library::eth::Eth::Event", + "kind": "enum", + "variants": [ { - name: "spender", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "value", - type: "core::integer::u256", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::replaceability_interface::ImplementationAdded", - kind: "struct", - members: [ - { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::replaceability_interface::ImplementationRemoved", - kind: "struct", - members: [ - { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::replaceability_interface::ImplementationReplaced", - kind: "struct", - members: [ - { - name: "implementation_data", - type: "src::replaceability_interface::ImplementationData", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::replaceability_interface::ImplementationFinalized", - kind: "struct", - members: [ - { - name: "impl_hash", - type: "core::starknet::class_hash::ClassHash", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::access_control_interface::RoleGranted", - kind: "struct", - members: [ - { - name: "role", - type: "core::felt252", - kind: "data", - }, - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "sender", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::access_control_interface::RoleRevoked", - kind: "struct", - members: [ - { - name: "role", - type: "core::felt252", - kind: "data", - }, - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "sender", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::access_control_interface::RoleAdminChanged", - kind: "struct", - members: [ - { - name: "role", - type: "core::felt252", - kind: "data", - }, - { - name: "previous_admin_role", - type: "core::felt252", - kind: "data", - }, - { - name: "new_admin_role", - type: "core::felt252", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::roles_interface::GovernanceAdminAdded", - kind: "struct", - members: [ - { - name: "added_account", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "added_by", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::roles_interface::GovernanceAdminRemoved", - kind: "struct", - members: [ - { - name: "removed_account", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "removed_by", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::roles_interface::UpgradeGovernorAdded", - kind: "struct", - members: [ - { - name: "added_account", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "added_by", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - ], - }, - { - type: "event", - name: "src::roles_interface::UpgradeGovernorRemoved", - kind: "struct", - members: [ - { - name: "removed_account", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - { - name: "removed_by", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc20_v070::erc20::ERC20::Event", - kind: "enum", - variants: [ - { - name: "Transfer", - type: "openzeppelin::token::erc20_v070::erc20::ERC20::Transfer", - kind: "nested", - }, - { - name: "Approval", - type: "openzeppelin::token::erc20_v070::erc20::ERC20::Approval", - kind: "nested", - }, - { - name: "ImplementationAdded", - type: "src::replaceability_interface::ImplementationAdded", - kind: "nested", - }, - { - name: "ImplementationRemoved", - type: "src::replaceability_interface::ImplementationRemoved", - kind: "nested", - }, - { - name: "ImplementationReplaced", - type: "src::replaceability_interface::ImplementationReplaced", - kind: "nested", - }, - { - name: "ImplementationFinalized", - type: "src::replaceability_interface::ImplementationFinalized", - kind: "nested", - }, - { - name: "RoleGranted", - type: "src::access_control_interface::RoleGranted", - kind: "nested", - }, - { - name: "RoleRevoked", - type: "src::access_control_interface::RoleRevoked", - kind: "nested", - }, - { - name: "RoleAdminChanged", - type: "src::access_control_interface::RoleAdminChanged", - kind: "nested", - }, - { - name: "GovernanceAdminAdded", - type: "src::roles_interface::GovernanceAdminAdded", - kind: "nested", - }, - { - name: "GovernanceAdminRemoved", - type: "src::roles_interface::GovernanceAdminRemoved", - kind: "nested", - }, - { - name: "UpgradeGovernorAdded", - type: "src::roles_interface::UpgradeGovernorAdded", - kind: "nested", - }, - { - name: "UpgradeGovernorRemoved", - type: "src::roles_interface::UpgradeGovernorRemoved", - kind: "nested", - }, - ], - }, + "name": "ERC20Event", + "type": "openzeppelin::token::erc20::erc20::ERC20Component::Event", + "kind": "flat" + } + ] + } ] as const; diff --git a/scripts/abi/index.ts b/scripts/abi/index.ts index cf4b54cc..680ff1cd 100644 --- a/scripts/abi/index.ts +++ b/scripts/abi/index.ts @@ -1,3 +1,4 @@ export { ABI as vaultABI} from "./vault" export { ABI as erc20ABI} from "./erc20" -export { ABI as optionRoundABI} from "./optionRound" \ No newline at end of file +export { ABI as optionRoundABI} from "./optionRound" +export {ABI as marketAggregatorABI} from "./marketAggregator" \ No newline at end of file diff --git a/scripts/integrationTests/smokeTest1/auctionOpen.ts b/scripts/integrationTests/smokeTest1/auctionOpen.ts index aeaccb8c..76f2df8b 100644 --- a/scripts/integrationTests/smokeTest1/auctionOpen.ts +++ b/scripts/integrationTests/smokeTest1/auctionOpen.ts @@ -17,7 +17,7 @@ export const smokeTest = async ({ //Approve A for depositing await eth.approval({ owner: liquidityProviderAccounts[0], - amount: 1000000, + amount: BigInt(100)*BigInt(depositAmount), spender: vault.vaultContract.address, }); @@ -71,11 +71,11 @@ export const smokeTest = async ({ const withdrawAllData: Array = [ { account: liquidityProviderAccounts[0], - amount: depositAmount / 2, + amount: BigInt(depositAmount) / BigInt(2), }, { account: liquidityProviderAccounts[1], - amount: depositAmount / 2, + amount: BigInt(depositAmount) / BigInt(2), }, ]; await vault.withdrawAll(withdrawAllData); @@ -91,7 +91,7 @@ export const smokeTest = async ({ try { await vault.withdraw({ account: liquidityProviderAccounts[1], - amount: depositAmount / 2 + 1, + amount: BigInt(depositAmount) / BigInt(2) + BigInt(1), }); throw Error("Should have reverted"); } catch (err: unknown) { @@ -102,10 +102,6 @@ export const smokeTest = async ({ const lpUnlockedBalancesAfterWithdraw2 = await vault.getLPUnlockedBalanceAll( liquidityProviderAccounts ); - console.log( - "lpUnlockedBalancesAfterWithdraw2:", - lpUnlockedBalancesAfterWithdraw2 - ); //Asserts //1) Check liquidity for A & B has decreased by depositAmount/2 //2) Check balance for A & B has increased by depositAmount/2 @@ -130,21 +126,21 @@ function checkpoint1({ lpUnlockedBalancesAfter: Array; ethBalancesBefore: Array; ethBalancesAfter: Array; - depositAmount: number; + depositAmount: number|bigint; }) { assert( - Number(lpUnlockedBalancesAfter[0]) === - Number(lpUnlockedBalancesBefore[0]) + depositAmount, + BigInt(lpUnlockedBalancesAfter[0]) === + BigInt(lpUnlockedBalancesBefore[0]) + BigInt(depositAmount), "liquidity A mismatch" ); assert( - Number(lpUnlockedBalancesAfter[1]) === - Number(lpUnlockedBalancesBefore[1]) + depositAmount, + BigInt(lpUnlockedBalancesAfter[1]) === + BigInt(lpUnlockedBalancesBefore[1]) + BigInt(depositAmount), "liquidity B mismatch" ); assert( - Number(ethBalancesBefore[0]) === - Number(ethBalancesAfter[0]) + 2 * depositAmount, + BigInt(ethBalancesBefore[0]) === + BigInt(ethBalancesAfter[0]) + BigInt(2) * BigInt(depositAmount), "Eth balance for a mismatch" ); } @@ -159,26 +155,26 @@ function checkpoint2({ lpUnlockedBalancesBefore: Array; ethBalancesAfter: Array; ethBalancesBefore: Array; - depositAmount: number; + depositAmount: number|bigint; }) { assert( - Number(lpUnlockedBalancesBefore[0]) == - Number(lpUnlockedBalancesAfter[0]) + depositAmount / 2, + BigInt(lpUnlockedBalancesBefore[0]) == + BigInt(lpUnlockedBalancesAfter[0]) + BigInt(depositAmount) / BigInt(2), "Mismatch A liquidity" ); assert( - Number(lpUnlockedBalancesBefore[1]) == - Number(lpUnlockedBalancesAfter[1]) + depositAmount / 2, + BigInt(lpUnlockedBalancesBefore[1]) == + BigInt(lpUnlockedBalancesAfter[1]) + BigInt(depositAmount) / BigInt(2), "Mismatch B liquidity" ); assert( - Number(ethBalancesBefore[0]) == - Number(ethBalancesAfter[0]) - depositAmount / 2, + BigInt(ethBalancesBefore[0]) == + BigInt(ethBalancesAfter[0]) - BigInt(depositAmount) / BigInt(2), "Mismatch A balance" ); assert( - Number(ethBalancesBefore[1]) == - Number(ethBalancesAfter[1]) - depositAmount / 2, + BigInt(ethBalancesBefore[1]) == + BigInt(ethBalancesAfter[1]) - BigInt(depositAmount) / BigInt(2), "Mismatch B balance" ); } diff --git a/scripts/integrationTests/smokeTest1/auctionStart.ts b/scripts/integrationTests/smokeTest1/auctionStart.ts index cf444f95..79d53405 100644 --- a/scripts/integrationTests/smokeTest1/auctionStart.ts +++ b/scripts/integrationTests/smokeTest1/auctionStart.ts @@ -27,10 +27,10 @@ export const smokeTest = async ({ const devAccount = getAccount("dev", provider); try { await vaultFacade.startAuction(devAccount); - throw Error("Should have reverted") + throw Error("Should have reverted"); } catch (err) { - const error = err as LibraryError - assert(error.message!=="Should have reverted",error.message) + const error = err as LibraryError; + assert(error.message !== "Should have reverted", error.message); //Failure expected when contracts are changed to revert } @@ -45,7 +45,7 @@ export const smokeTest = async ({ `Expected:Open\nReceived:${stateAfter.activeVariant()}` ); - await vaultFacade.startAuctionBystander(provider); + await vaultFacade.startAuctionBystander(provider, constants); const unlockedBalances = await vaultFacade.getLPUnlockedBalanceAll( liquidityProviderAccounts @@ -62,7 +62,7 @@ export const smokeTest = async ({ lockedBalances, totalLockedAmount, totalUnlockedAmount, - constants, + depositAmount: constants.depositAmount, }); //Approve OptionBidders @@ -128,13 +128,13 @@ async function checkpoint1({ unlockedBalances, totalLockedAmount, totalUnlockedAmount, - constants, + depositAmount, }: { lockedBalances: Array; unlockedBalances: Array; - totalLockedAmount: bigint | number | Uint256 | undefined; - totalUnlockedAmount: bigint | number | Uint256 | undefined; - constants: Constants; + totalLockedAmount: bigint | number; + totalUnlockedAmount: bigint | number; + depositAmount: number | bigint; }) { assert( Number(unlockedBalances[0]) === 0, @@ -145,24 +145,26 @@ async function checkpoint1({ `UnlockedBalanceB 0 expected, found ${unlockedBalances[1]}` ); assert( - Number(lockedBalances[0]) === constants.depositAmount / 2, - `LockedBalanceA ${constants.depositAmount / 2} expected, found ${ + BigInt(lockedBalances[0]) === BigInt(depositAmount) / BigInt(2), + `LockedBalanceA ${BigInt(depositAmount) / BigInt(2)} expected, found ${ lockedBalances[0] }` ); assert( - Number(lockedBalances[1]) === constants.depositAmount / 2, - `LockedBalanceB ${constants.depositAmount / 2} expected, found ${ + BigInt(lockedBalances[1]) === BigInt(depositAmount) / BigInt(2), + `LockedBalanceB ${BigInt(depositAmount) / BigInt(2)} expected, found ${ lockedBalances[1] }` ); assert( - Number(totalUnlockedAmount) === 0, + BigInt(totalUnlockedAmount) === BigInt(0), `Total unlocked 0 expected, found ${totalUnlockedAmount}` ); assert( - Number(totalLockedAmount) === constants.depositAmount, - `Total Locked amount ${constants.depositAmount} expected, found ${totalLockedAmount}` + BigInt(totalLockedAmount) === BigInt(depositAmount), + `Total Locked amount ${BigInt( + depositAmount + )} expected, found ${totalLockedAmount}` ); } diff --git a/scripts/integrationTests/smokeTest1/exerciseOptions.ts b/scripts/integrationTests/smokeTest1/exerciseOptions.ts index dc798cee..fb42b21b 100644 --- a/scripts/integrationTests/smokeTest1/exerciseOptions.ts +++ b/scripts/integrationTests/smokeTest1/exerciseOptions.ts @@ -14,7 +14,8 @@ export const smokeTest = async ({ }: TestRunner) => { const optionRoundFacade = await getOptionRoundFacade( provider, - vaultFacade.vaultContract + vaultFacade.vaultContract, + true ); const optionBidderAccounts = getOptionBidderAccounts(provider, 3); diff --git a/scripts/integrationTests/smokeTest1/index.ts b/scripts/integrationTests/smokeTest1/index.ts index 689d4429..740b5c8d 100644 --- a/scripts/integrationTests/smokeTest1/index.ts +++ b/scripts/integrationTests/smokeTest1/index.ts @@ -2,3 +2,5 @@ export { smokeTest as auctionOpenTests } from "./auctionOpen"; export { smokeTest as auctionStartTests } from "./auctionStart"; export { smokeTest as auctionEndTetsts } from "./auctionEnd"; export { smokeTest as refundTokenizeBids } from "./refundBid"; +export { smokeTest as optionSettle } from "./optionSettle"; +export { smokeTest as exerciseOptions } from "./exerciseOptions"; diff --git a/scripts/integrationTests/smokeTest1/optionSettle.ts b/scripts/integrationTests/smokeTest1/optionSettle.ts index fac67793..cdcfae52 100644 --- a/scripts/integrationTests/smokeTest1/optionSettle.ts +++ b/scripts/integrationTests/smokeTest1/optionSettle.ts @@ -6,7 +6,7 @@ import { getOptionBidderAccounts, } from "../../utils/helpers/accounts"; import { TestRunner } from "../../utils/facades/TestRunner"; -import { LibraryError } from "starknet"; +import { eth, LibraryError } from "starknet"; export const smokeTest = async ({ provider, @@ -24,7 +24,7 @@ export const smokeTest = async ({ const devAccount = getAccount("dev", provider); try { - await vaultFacade.settleAuction(devAccount); + await vaultFacade.settleOptionRound(devAccount); throw Error("Should have reverted"); } catch (err) { const error = err as LibraryError; @@ -45,7 +45,7 @@ export const smokeTest = async ({ ); - vaultFacade.withdraw({ + await vaultFacade.withdraw({ account: liquidityProviderAccounts[0], amount: BigInt(totalPremiums) / BigInt(4), }); @@ -67,7 +67,8 @@ export const smokeTest = async ({ totalPremiums, }); - await vaultFacade.settleAuctionBystander(provider); + await vaultFacade.settleOptionRoundBystander(provider); + const stateAfter: any = await optionRoundFacade.optionRoundContract.get_state(); @@ -78,7 +79,7 @@ export const smokeTest = async ({ const totalPayout = await optionRoundFacade.getTotalPayout(); const totalLocked = await vaultFacade.getTotalLocked(); assert( - stateAfter.activeVariant() === "Running", + stateAfter.activeVariant() === "Settled", `Expected:Running\nReceived:${stateAfter.activeVariant()}` ); @@ -105,6 +106,7 @@ async function checkpoint1({ totalUnlocked: number | bigint; totalPremiums: number | bigint; }) { + console.log("ethBalanceAfter:",ethBalanceAfter,"\nethBalanceBefore:",ethBalanceBefore,"\ntotalPremiums",totalPremiums,"lpUnlockedBalanceAfter:",lpUnlockedBalanceAfter); assert( BigInt(ethBalanceAfter) - BigInt(ethBalanceBefore) === BigInt(totalPremiums) / BigInt(4), diff --git a/scripts/integrationTests/smokeTesting.ts b/scripts/integrationTests/smokeTesting.ts index e3aa41eb..c1322946 100644 --- a/scripts/integrationTests/smokeTesting.ts +++ b/scripts/integrationTests/smokeTesting.ts @@ -2,6 +2,8 @@ import { auctionEndTetsts, auctionOpenTests, auctionStartTests, + exerciseOptions, + optionSettle, refundTokenizeBids, } from "./smokeTest1"; import { TestRunner } from "../utils/facades/TestRunner"; @@ -10,6 +12,8 @@ async function smokeTesting(testRunner: TestRunner) { await auctionStartTests(testRunner); await auctionEndTetsts(testRunner); await refundTokenizeBids(testRunner); + await optionSettle(testRunner); + await exerciseOptions(testRunner); } export { smokeTesting }; diff --git a/scripts/katana.sh b/scripts/katana.sh index 31b49470..e4bc2f5b 100755 --- a/scripts/katana.sh +++ b/scripts/katana.sh @@ -6,6 +6,10 @@ PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.ge echo "Starting katana on port $PORT" katana --chain-id SN_SEPOLIA --host 127.0.0.1 --port 5050 --accounts "25" --seed "1" -b 2000 --dev & +npx abi-wan-kanabi --input target/dev/pitch_lake_starknet_Eth.contract_class.json --output scripts/abi/erc20.ts +npx abi-wan-kanabi --input target/dev/pitch_lake_starknet_Vault.contract_class.json --output scripts/abi/vault.ts +npx abi-wan-kanabi --input target/dev/pitch_lake_starknet_OptionRound.contract_class.json --output scripts/abi/optionRound.ts +npx abi-wan-kanabi --input target/dev/pitch_lake_starknet_MarketAggregator.contract_class.json --output scripts/abi/MarketAggregator.ts # while ! nc -z localhost $PORT; do # sleep 0.1 # wait for 1/10 of the second before check again # done diff --git a/scripts/main.ts b/scripts/main.ts index 57de2eb8..77d14e05 100644 --- a/scripts/main.ts +++ b/scripts/main.ts @@ -2,22 +2,29 @@ import { getAccount, getProvider } from "./utils/helpers/common"; import { smokeTesting } from "./integrationTests/smokeTesting"; import { declareContracts } from "./utils/deployment/declareContracts"; import { deployContracts } from "./utils/deployment/deployContracts"; -import { erc20ABI } from "./abi"; -import { Contract } from "starknet"; import { TestRunner } from "./utils/facades/TestRunner"; +import { Constants } from "./utils/facades/types"; async function main(environment: string, port?: string) { const provider = getProvider(environment, port); const devAccount = getAccount(environment, provider); let hashes = await declareContracts(devAccount); - + const constants:Constants={ + depositAmount:BigInt(10000000000000), + reservePrice:BigInt(4000000000), + strikePrice:BigInt(8000000000), + settlementPrice:BigInt(16000000000), + capLevel:5000, + } let { ethAddress, vaultAddress } = await deployContracts( environment, devAccount, - hashes + hashes, + constants, ); - const testRunner = new TestRunner(provider, vaultAddress, ethAddress); + const testRunner = new TestRunner(provider, vaultAddress, ethAddress,constants); + await testRunner.ethFacade.supplyERC20( devAccount, diff --git a/scripts/utils/deployment/deployContracts.ts b/scripts/utils/deployment/deployContracts.ts index e3f66417..b44cd515 100644 --- a/scripts/utils/deployment/deployContracts.ts +++ b/scripts/utils/deployment/deployContracts.ts @@ -78,6 +78,9 @@ async function deployContracts( vaultHash: string; optionRoundHash: string; marketAggregatorHash: string; + }, + constants:{ + } ) { let ethAddress = await deployEthContract( diff --git a/scripts/utils/facades/TestRunner.ts b/scripts/utils/facades/TestRunner.ts index eb4b83b7..88a64512 100644 --- a/scripts/utils/facades/TestRunner.ts +++ b/scripts/utils/facades/TestRunner.ts @@ -1,20 +1,76 @@ -import { Provider } from "starknet"; +import { Account, Provider } from "starknet"; import { ERC20Facade } from "./erc20Facade"; import { VaultFacade } from "./vaultFacade"; import { Constants } from "./types"; +export type ResultSheet = { + accounts: Array; + params: Array; + method: Methods; + before: Map> + after:Map> +}; + + export class TestRunner { public provider: Provider; public ethFacade: ERC20Facade; public vaultFacade: VaultFacade; public constants: Constants; - constructor(provider: Provider, vaultAddress: string, ethAddress: string) { + constructor(provider: Provider, vaultAddress: string, ethAddress: string,constants:Constants) { this.vaultFacade = new VaultFacade(vaultAddress, provider); this.ethFacade = new ERC20Facade(ethAddress, provider); - this.constants = { - depositAmount: 1000, - }; + this.constants = constants; this.provider = provider; } + + async testResults(accounts:Array,params: Array, method: Methods) { + + + const before:Map> = new Map; + + const after:Map> = new Map; + const resultSheet:ResultSheet = {params,accounts,method,before,after}; + for( const param of params) + { + switch (param){ + case StoragePoints.lpLocked: + { + const res = await this.vaultFacade.getLPLockedBalanceAll(accounts); + resultSheet.before.set(StoragePoints.lpLocked,res); + break; + } + case StoragePoints.lpUnlocked: + { + const res = await this.vaultFacade.getLPUnlockedBalanceAll(accounts); + resultSheet.before.set(StoragePoints.lpUnlocked,res); + break; + } + case StoragePoints.totalLocked: + { + const res = await this.vaultFacade.getTotalLocked(); + resultSheet.before.set(StoragePoints.totalLocked,res); + break; + } + case StoragePoints.totalUnlocked: + { + const res = await this.vaultFacade.getTotalUnLocked(); + resultSheet.before.set(StoragePoints.totalUnlocked,res); + break; + } + } + } + } +} + +enum StoragePoints { + lpUnlocked, + lpLocked, + totalLocked, + totalUnlocked, +} + +enum Methods { + } diff --git a/scripts/utils/facades/erc20Facade.ts b/scripts/utils/facades/erc20Facade.ts index db0bcf50..b2b0ceff 100644 --- a/scripts/utils/facades/erc20Facade.ts +++ b/scripts/utils/facades/erc20Facade.ts @@ -104,11 +104,11 @@ export class ERC20Facade { await this.supply( devAccount, liquidityProviders[i].account, - BigInt("1000000000000000") + BigInt("100000000000000000") ); await this.approval({ owner: lp, - amount: BigInt("1000000000000000"), + amount: BigInt("100000000000000000"), spender: approveFor, }); console.log(`Liquidity Provider ${i} funded `); @@ -116,11 +116,11 @@ export class ERC20Facade { await this.supply( devAccount, optionBidders[i].account, - BigInt("1000000000000000") + BigInt("100000000000000000") ); await this.approval({ owner: ob, - amount: BigInt("1000000000000000"), + amount: BigInt("100000000000000000"), spender: approveFor, }); console.log(`Option Bidder ${i} funded `); diff --git a/scripts/utils/facades/marketAggregatorFacade.ts b/scripts/utils/facades/marketAggregatorFacade.ts new file mode 100644 index 00000000..243efdaa --- /dev/null +++ b/scripts/utils/facades/marketAggregatorFacade.ts @@ -0,0 +1,67 @@ +import { Account, Contract, Provider, TypedContractV2 } from "starknet"; +import { marketAggregatorABI } from "../../abi"; + +export class MarketAggregatorFacade { + marketAggregatorContract: TypedContractV2; + + constructor(marketAggregatorAddress: string, provider: Provider) { + this.marketAggregatorContract = new Contract( + marketAggregatorABI, + marketAggregatorAddress, + provider + ).typedv2(marketAggregatorABI); + } + + async setCapLevel( + account: Account, + from: number | bigint, + to: number | bigint, + capLevel: number | bigint + ) { + this.marketAggregatorContract.connect(account); + await this.marketAggregatorContract.set_cap_level_for_time_period( + from, + to, + capLevel + ); + } + async setReservePrice( + account: Account, + from: number | bigint, + to: number | bigint, + reservePrice: number | bigint + ) { + this.marketAggregatorContract.connect(account); + await this.marketAggregatorContract.set_reserve_price_for_time_period( + from, + to, + reservePrice + ); + } + async setStrikePrice( + account: Account, + from: number | bigint, + to: number | bigint, + strikePrice: number | bigint + ) { + this.marketAggregatorContract.connect(account); + await this.marketAggregatorContract.set_strike_price_for_time_period( + from, + to, + strikePrice + ); + } + async setTWAP( + account: Account, + from: number | bigint, + to: number | bigint, + reservePrice: number | bigint + ) { + this.marketAggregatorContract.connect(account); + await this.marketAggregatorContract.set_TWAP_for_time_period( + from, + to, + reservePrice + ); + } +} diff --git a/scripts/utils/facades/types.ts b/scripts/utils/facades/types.ts index 89d73b34..c9e47ee7 100644 --- a/scripts/utils/facades/types.ts +++ b/scripts/utils/facades/types.ts @@ -29,8 +29,8 @@ export type PlaceBidArgs = { export type UpdateBidArgs = { bidId: string; from: Account; - amount: number|bigint; - price: number|bigint; + amount: number; + price: number; }; export type RefundableBidsArgs = { @@ -54,6 +54,10 @@ export type RefundUnusedBidsArgs = { optionBidder: string; }; +export type ExerciseOptionArgs = { + from: Account; +}; + export type TokenizeOptionArgs = { from: Account; }; @@ -61,7 +65,12 @@ export type TokenizeOptionArgs = { //Smoke Test types export type Constants = { - depositAmount: number; + depositAmount: number|bigint; + reservePrice:number|bigint; + settlementPrice:number|bigint; + strikePrice:number|bigint; + capLevel:number|bigint; + }; export type Bid = { diff --git a/scripts/utils/facades/vaultFacade.ts b/scripts/utils/facades/vaultFacade.ts index f6ec8f97..8a4d32d1 100644 --- a/scripts/utils/facades/vaultFacade.ts +++ b/scripts/utils/facades/vaultFacade.ts @@ -5,21 +5,35 @@ import { Provider, TypedContractV2, } from "starknet"; -import { vaultABI } from "../../abi"; -import { DepositArgs, WithdrawArgs } from "./types"; +import { optionRoundABI, vaultABI } from "../../abi"; +import { Constants, DepositArgs, WithdrawArgs } from "./types"; import { accelerateToAuctioning, accelerateToRunning, accelerateToSettled, } from "../helpers/accelerators"; +import { getAccount, stringToHex } from "../helpers/common"; +import { MarketAggregatorFacade } from "./marketAggregatorFacade"; +import { getOptionRoundContract } from "../helpers/setup"; export class VaultFacade { vaultContract: TypedContractV2; + currentOptionRound?: TypedContractV2; - constructor(vaultAddress: string, provider: Provider) { + constructor( + vaultAddress: string, + provider: Provider, + optionRoundAddress?: string + ) { this.vaultContract = new Contract(vaultABI, vaultAddress, provider).typedv2( vaultABI ); + if (optionRoundAddress) + this.currentOptionRound = new Contract( + optionRoundABI, + optionRoundAddress, + provider + ).typedv2(optionRoundABI); } async getTotalLocked() { @@ -78,7 +92,7 @@ export class VaultFacade { } async withdraw({ account, amount }: WithdrawArgs) { this.vaultContract.connect(account); - await this.vaultContract.withdraw_liquidity(amount); + await this.vaultContract.withdraw_liquidity(amount); } async deposit({ from, beneficiary, amount }: DepositArgs) { @@ -113,10 +127,54 @@ export class VaultFacade { } //@note Only works for katana dev instance with a --dev flag - async startAuctionBystander(provider: Provider) { + async startAuctionBystander(provider: Provider, constants: Constants) { + const devAccount = getAccount("dev", provider); + //Set market aggregator reserve_price + const marketAggregatorString = + await this.vaultContract.get_market_aggregator(); + const marketAggregatorAddress = "0x" + stringToHex(marketAggregatorString); + const marketAggFacade = new MarketAggregatorFacade( + marketAggregatorAddress, + provider + ); + const optionRound = await getOptionRoundContract( + provider, + this.vaultContract + ); + const startDate = await optionRound.get_auction_start_date(); + const settleDate = await optionRound.get_option_settlement_date(); + await marketAggFacade.setReservePrice( + devAccount, + startDate, + settleDate, + constants.reservePrice + ); + await marketAggFacade.setCapLevel( + devAccount, + startDate, + settleDate, + constants.capLevel + ); + + await marketAggFacade.setStrikePrice( + devAccount, + startDate, + settleDate, + constants.strikePrice + ); + await marketAggFacade.setTWAP( + devAccount, + startDate, + settleDate, + constants.settlementPrice + ); + await this.vaultContract.update_round_params(); + await accelerateToAuctioning(provider, this.vaultContract); - } + this.vaultContract.connect(devAccount); + await this.vaultContract.start_auction(); + } async endAuction(account: Account) { this.vaultContract.connect(account); @@ -124,15 +182,20 @@ export class VaultFacade { } async endAuctionBystander(provider: Provider) { + const devAccount = getAccount("dev", provider); await accelerateToRunning(provider, this.vaultContract); + this.vaultContract.connect(devAccount); + await this.vaultContract.end_auction(); } - async settleAuction(account:Account){ + async settleOptionRound(account: Account) { this.vaultContract.connect(account); + await this.vaultContract.settle_option_round(); } - async settleAuctionBystander(provider:Provider){ - await accelerateToSettled(provider,this.vaultContract) + async settleOptionRoundBystander(provider: Provider) { + await accelerateToSettled(provider, this.vaultContract); + const devAccount = getAccount("dev", provider); + await this.settleOptionRound(devAccount); } } - diff --git a/scripts/utils/helpers/accelerators.ts b/scripts/utils/helpers/accelerators.ts index 6782fea1..b88cf60d 100644 --- a/scripts/utils/helpers/accelerators.ts +++ b/scripts/utils/helpers/accelerators.ts @@ -15,14 +15,12 @@ async function accelerateToAuctioning( const currentTime = await getNow(provider); const auctionStartDate = await optionRoundContract.get_auction_start_date(); + console.log("currentTime:",currentTime,"\nauctionStartDate:",auctionStartDate);; await timeskipNextBlock( Number(auctionStartDate) - Number(currentTime), provider.channel.nodeUrl ); - const devAccount = getAccount("dev", provider); - vaultContract.connect(devAccount); - await vaultContract.start_auction(); } async function accelerateToRunning( @@ -41,9 +39,6 @@ async function accelerateToRunning( Number(auctionEndDate) - Number(currentTime), provider.channel.nodeUrl ); - const devAccount = getAccount("dev", provider); - vaultContract.connect(devAccount); - await vaultContract.end_auction(); } async function accelerateToSettled( @@ -60,11 +55,9 @@ async function accelerateToSettled( await optionRoundContract.get_option_settlement_date(); await timeskipNextBlock( - Number(optionSettleDate) - Number(currentTime), + Number(optionSettleDate) - Number(currentTime)+1, provider.channel.nodeUrl ); - const devAccount = getAccount("dev", provider); - vaultContract.connect(devAccount); - await vaultContract.end_auction(); + } export { accelerateToAuctioning, accelerateToRunning, accelerateToSettled }; diff --git a/scripts/utils/helpers/setup.ts b/scripts/utils/helpers/setup.ts index 4123fc9d..7a360dee 100644 --- a/scripts/utils/helpers/setup.ts +++ b/scripts/utils/helpers/setup.ts @@ -1,13 +1,18 @@ -import { Contract, Provider, TypedContractV2 } from "starknet"; +import { CairoUint256, Contract, Provider, TypedContractV2 } from "starknet"; import { stringToHex } from "./common"; import { erc20ABI, optionRoundABI, vaultABI } from "../../abi"; import { OptionRoundFacade } from "../facades/optionRoundFacade"; export const getOptionRoundFacade = async ( provider: Provider, - vault: TypedContractV2 + vault: TypedContractV2, + prev?: boolean ) => { - const optionRoundContract = await getOptionRoundContract(provider, vault); + const optionRoundContract = await getOptionRoundContract( + provider, + vault, + prev + ); const optionRoundFacade = new OptionRoundFacade(optionRoundContract); return optionRoundFacade; }; @@ -27,11 +32,20 @@ export const getOptionRoundERC20Contract = async ( export const getOptionRoundContract = async ( provider: Provider, - vault: TypedContractV2 + vault: TypedContractV2, + prev?: boolean ) => { - const optionRoundId = await vault.current_option_round_id(); + let optionRoundId = await vault.current_option_round_id(); + let id; + if (typeof optionRoundId !== "number" && typeof optionRoundId !== "bigint") { + const temp = new CairoUint256(optionRoundId); + id = temp.toBigInt(); + } else id = BigInt(optionRoundId); + if (prev) { + id = id - BigInt(1); + } const optionRoundAddressDecimalString = await vault.get_option_round_address( - optionRoundId + id ); const optionRoundAddress = "0x" + stringToHex(optionRoundAddressDecimalString);