diff --git a/.yarn/cache/@usecannon-builder-npm-2.10.5-328aa49fab-3c2beffbc8.zip b/.yarn/cache/@usecannon-builder-npm-2.10.6-alpha.4-1fb7cd37e5-13b8f6fbb1.zip similarity index 65% rename from .yarn/cache/@usecannon-builder-npm-2.10.5-328aa49fab-3c2beffbc8.zip rename to .yarn/cache/@usecannon-builder-npm-2.10.6-alpha.4-1fb7cd37e5-13b8f6fbb1.zip index dd8b15c489..694d1f211e 100644 Binary files a/.yarn/cache/@usecannon-builder-npm-2.10.5-328aa49fab-3c2beffbc8.zip and b/.yarn/cache/@usecannon-builder-npm-2.10.6-alpha.4-1fb7cd37e5-13b8f6fbb1.zip differ diff --git a/.yarn/cache/@usecannon-cli-npm-2.10.5-e806316ed6-ff66d9cd27.zip b/.yarn/cache/@usecannon-cli-npm-2.10.6-alpha.4-ed362ab55e-8516f6b8b9.zip similarity index 84% rename from .yarn/cache/@usecannon-cli-npm-2.10.5-e806316ed6-ff66d9cd27.zip rename to .yarn/cache/@usecannon-cli-npm-2.10.6-alpha.4-ed362ab55e-8516f6b8b9.zip index bab1212a70..5d5e07320b 100644 Binary files a/.yarn/cache/@usecannon-cli-npm-2.10.5-e806316ed6-ff66d9cd27.zip and b/.yarn/cache/@usecannon-cli-npm-2.10.6-alpha.4-ed362ab55e-8516f6b8b9.zip differ diff --git a/.yarn/cache/hardhat-cannon-npm-2.10.5-6f354a5f41-22686b4085.zip b/.yarn/cache/hardhat-cannon-npm-2.10.6-alpha.4-ae25790292-41fd845e0b.zip similarity index 88% rename from .yarn/cache/hardhat-cannon-npm-2.10.5-6f354a5f41-22686b4085.zip rename to .yarn/cache/hardhat-cannon-npm-2.10.6-alpha.4-ae25790292-41fd845e0b.zip index 8e4a329b74..dc014c3a91 100644 Binary files a/.yarn/cache/hardhat-cannon-npm-2.10.5-6f354a5f41-22686b4085.zip and b/.yarn/cache/hardhat-cannon-npm-2.10.6-alpha.4-ae25790292-41fd845e0b.zip differ diff --git a/auxiliary/buyback-snx/cannonfile.test.toml b/auxiliary/buyback-snx/cannonfile.test.toml index d20ffc492d..cc9b7592e6 100644 --- a/auxiliary/buyback-snx/cannonfile.test.toml +++ b/auxiliary/buyback-snx/cannonfile.test.toml @@ -8,79 +8,43 @@ defaultValue = "10000000000000000" defaultValue = "500000000000000000" [provision.snx] -source = "mintable-token" -targetPreset = "permissionless-mint" +source = "mintable-token:1.6@permissionless-mint" options.symbol = "SNX" options.name = "Mintable SNX" -options.salt = "0xdeadbeef" +options.salt = "snx" [provision.usd] -source = "mintable-token" -targetPreset = "permissionless-mint" +source = "mintable-token:1.6@permissionless-mint" options.symbol = "USD" options.name = "Mintable USD" -options.salt = "testing" +options.salt = "usd" [setting.staleness_tolerance] defaultValue = "60" -[setting.pyth_snx_feed_id] -defaultValue = "0x39d020f60982ed892abbcd4a06a276a9f9b7bfbce003204c110b6e488f502da3" - [provision.oracle_manager] -source = "oracle-manager:3.3.3-dev.249e185f" - -[import.pyth] -source = "pyth" +source = "oracle-manager:3.3.5" +sourcePreset = "main" -[provision.pyth_erc7412_wrapper] -source = "pyth-erc7412-wrapper:3.3.3-dev.249e185f" -options.pythAddress = "<%= imports.pyth.contracts.Pyth.address %>" - -# This registers a staleness node that looks to Pyth for a fresh enough price, or otherwise reverts with an ERC-7412 compatible error -# Latest Pyth Price -[invoke.registerPythSnxOracleNode] +# Latest Price +[invoke.registerConstantNode] target = ["oracle_manager.Proxy"] func = "registerNode" args = [ - 5, # 5 = pyth aggregator type - "<%= defaultAbiCoder.encode(['address', 'bytes32', 'bool'], [imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address, settings.pyth_snx_feed_id, false]) %>", - [] + 8, # constant node type + "<%= defaultAbiCoder.encode(['int256'], [parseEther('10')]) %>", + [], ] extra.snx_pyth_oracle_id.event = "NodeRegistered" extra.snx_pyth_oracle_id.arg = 0 -# Pyth Off-chain Lookup -[invoke.registerLookupSnxOracleNode] -target = ["oracle_manager.Proxy"] -func = "registerNode" -args = [ - 9, # 9 = PythOffchainLookupNode - "<%= defaultAbiCoder.encode(['address', 'bytes32', 'uint256'], [imports.pyth_erc7412_wrapper.contracts.PythERC7412Wrapper.address, settings.pyth_snx_feed_id, settings.staleness_tolerance]) %>", - [] -] -extra.snx_lookup_oracle_id.event = "NodeRegistered" -extra.snx_lookup_oracle_id.arg = 0 - -# Staleness Node -[invoke.registerSnxOracleNode] -target = ["oracle_manager.Proxy"] -func = "registerNode" -args = [ - 7, # 7 = staleness circuit breaker - "<%= defaultAbiCoder.encode(['uint256'], [settings.staleness_tolerance]) %>", - ["<%= extras.snx_pyth_oracle_id %>", "<%= extras.snx_lookup_oracle_id %>"] -] -extra.snx_oracle_id.event = "NodeRegistered" -extra.snx_oracle_id.arg = 0 - [contract.buyback_snx] artifact = "contracts/BuybackSnx.sol:BuybackSnx" args = [ "<%= settings.premium %>", "<%= settings.snx_fee_share %>", "<%= imports.oracle_manager.contracts.Proxy.address %>", - "<%= extras.snx_oracle_id %>", + "<%= extras.snx_pyth_oracle_id %>", "<%= imports.snx.contracts.MintableToken.address %>", "<%= imports.usd.contracts.MintableToken.address %>" ] diff --git a/auxiliary/buyback-snx/test/integration/BuybackSnx.test.ts b/auxiliary/buyback-snx/test/integration/BuybackSnx.test.ts index 0fb933f810..6b6afe7fcc 100644 --- a/auxiliary/buyback-snx/test/integration/BuybackSnx.test.ts +++ b/auxiliary/buyback-snx/test/integration/BuybackSnx.test.ts @@ -3,66 +3,28 @@ import assert from 'assert/strict'; import assertBn from '@synthetixio/core-utils/utils/assertions/assert-bignumber'; import { ethers } from 'ethers'; -import hre from 'hardhat'; import { bn, bootstrapBuyback } from './bootstrap'; import { findSingleEvent } from '@synthetixio/core-utils/utils/ethers/events'; -const parseUnits = ethers.utils.parseUnits; - describe('BuybackSnx', function () { const { getContract, user, owner } = bootstrapBuyback(); - let Pyth: ethers.Contract; - let PythERC7412Wrapper: ethers.Contract; let BuybackSnx: ethers.Contract; let SnxToken: ethers.Contract; let UsdToken: ethers.Contract; - let priceFeedId: string; - + const snxPrice = bn(10); const snxAmount = bn(100); const usdAmount = bn(5000); const premiumValue = bn(0.01); const snxFeeShareRatio = bn(0.5); - const decimals = 8; - const price = parseUnits('10', decimals).toString(); - const emaPrice = parseUnits('2', decimals).toString(); - before('prepare environment', async () => { - const blockNumber = await hre.ethers.provider.getBlockNumber(); - const timestamp = (await hre.ethers.provider.getBlock(blockNumber)).timestamp; - + BuybackSnx = getContract('buyback_snx'); SnxToken = getContract('snx.MintableToken'); UsdToken = getContract('usd.MintableToken'); console.log('snx token address', SnxToken.address); console.log('usd token address', UsdToken.address); - - Pyth = getContract('pyth.Pyth'); - PythERC7412Wrapper = getContract('pyth_erc7412_wrapper.PythERC7412Wrapper'); - BuybackSnx = getContract('buyback_snx'); - - priceFeedId = '0x39d020f60982ed892abbcd4a06a276a9f9b7bfbce003204c110b6e488f502da3'; - console.log('priceFeedId', priceFeedId.toString()); - - const resp = await Pyth.createPriceFeedUpdateData( - priceFeedId, - price, - 1, - -decimals, - emaPrice, - 1, - timestamp - 1, - 0 - ); - console.log('Pyth.createPriceFeedUpdateData response', resp); - console.log('timestamp -1 ', timestamp - 1); - - const fee = await Pyth['getUpdateFee(bytes[])']([resp]); - await Pyth.updatePriceFeeds([resp], { value: fee }); - - const priceUnsafe = await Pyth.getPriceUnsafe(priceFeedId); - console.log('Pyth.getPriceUnsafe(snxNodeId)', priceUnsafe.toString()); }); before('set up token balances', async () => { @@ -85,7 +47,7 @@ describe('BuybackSnx', function () { }); }); - describe.skip('buyback', function () { + describe('buyback', function () { let userAddress: string; let userSnxBalanceBefore: any; let userUsdBalanceBefore: any; @@ -109,9 +71,6 @@ describe('BuybackSnx', function () { }); it('buys snx for usd', async () => { - const snxPrice = await PythERC7412Wrapper.getLatestPrice(priceFeedId, 60); - console.log('PythERC7412Wrapper.getLatestPrice(snxNodeId, 60)', snxPrice.toString()); - const premium = await BuybackSnx.getPremium(); console.log('premium', premium.toString()); diff --git a/auxiliary/buyback-snx/test/integration/bootstrap.ts b/auxiliary/buyback-snx/test/integration/bootstrap.ts index bd32a34eba..a62824b444 100644 --- a/auxiliary/buyback-snx/test/integration/bootstrap.ts +++ b/auxiliary/buyback-snx/test/integration/bootstrap.ts @@ -6,8 +6,6 @@ import { BuybackSnx } from '../generated/typechain'; interface Contracts { buyback_snx: BuybackSnx; - 'pyth.Pyth': ethers.Contract; - 'pyth_erc7412_wrapper.PythERC7412Wrapper': ethers.Contract; 'snx.MintableToken': ethers.Contract; 'usd.MintableToken': ethers.Contract; } diff --git a/markets/perps-market/package.json b/markets/perps-market/package.json index d653122061..38f00fa73f 100644 --- a/markets/perps-market/package.json +++ b/markets/perps-market/package.json @@ -33,7 +33,7 @@ "@synthetixio/router": "^3.3.0", "@synthetixio/spot-market": "workspace:*", "@synthetixio/wei": "^2.74.4", - "@usecannon/cli": "2.10.5", + "@usecannon/cli": "2.10.6-alpha.4", "ethers": "^5.7.2", "hardhat": "^2.19.0", "solidity-docgen": "^0.6.0-beta.36", diff --git a/markets/perps-market/subgraph/package.json b/markets/perps-market/subgraph/package.json index 3153cd71c4..d393fc922e 100644 --- a/markets/perps-market/subgraph/package.json +++ b/markets/perps-market/subgraph/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@graphprotocol/graph-cli": "^0.61.0", "@graphprotocol/graph-ts": "^0.31.0", - "@usecannon/cli": "2.10.5", + "@usecannon/cli": "2.10.6-alpha.4", "ethers": "^5.7.2", "matchstick-as": "^0.6.0", "prettier": "^3.0.3" diff --git a/markets/spot-market/package.json b/markets/spot-market/package.json index 8b446c2732..5b42144b53 100644 --- a/markets/spot-market/package.json +++ b/markets/spot-market/package.json @@ -34,7 +34,7 @@ "@synthetixio/router": "^3.3.0", "@synthetixio/wei": "^2.74.4", "@types/node-fetch": "^2.6.9", - "@usecannon/cli": "2.10.5", + "@usecannon/cli": "2.10.6-alpha.4", "ethers": "^5.7.2", "hardhat": "^2.19.0", "node-fetch": "^2.7.0", diff --git a/markets/spot-market/subgraph/package.json b/markets/spot-market/subgraph/package.json index f5d18e89e9..6bf67865ad 100644 --- a/markets/spot-market/subgraph/package.json +++ b/markets/spot-market/subgraph/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@graphprotocol/graph-cli": "^0.61.0", "@graphprotocol/graph-ts": "^0.31.0", - "@usecannon/cli": "2.10.5", + "@usecannon/cli": "2.10.6-alpha.4", "ethers": "^5.7.2", "matchstick-as": "^0.6.0", "prettier": "^3.0.3" diff --git a/package.json b/package.json index 592f1666b9..3463fd9df9 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@types/node": "^18.18.9", "@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/parser": "^6.10.0", - "@usecannon/cli": "2.10.5", + "@usecannon/cli": "2.10.6-alpha.4", "eslint": "^8.53.0", "eslint-plugin-no-only-tests": "^3.1.0", "lint-staged": "^15.0.2", diff --git a/protocol/synthetix/subgraph/package.json b/protocol/synthetix/subgraph/package.json index e23fcf186c..5aad318298 100644 --- a/protocol/synthetix/subgraph/package.json +++ b/protocol/synthetix/subgraph/package.json @@ -26,7 +26,7 @@ "devDependencies": { "@graphprotocol/graph-cli": "^0.61.0", "@graphprotocol/graph-ts": "^0.31.0", - "@usecannon/cli": "2.10.5", + "@usecannon/cli": "2.10.6-alpha.4", "ethers": "^5.7.2", "matchstick-as": "^0.6.0", "prettier": "^3.0.3" diff --git a/utils/common-config/package.json b/utils/common-config/package.json index c00a2b4339..901dd43195 100644 --- a/utils/common-config/package.json +++ b/utils/common-config/package.json @@ -17,7 +17,7 @@ "@typechain/hardhat": "^9.1.0", "dotenv": "^16.3.1", "hardhat": "^2.19.0", - "hardhat-cannon": "2.10.5", + "hardhat-cannon": "2.10.6-alpha.4", "hardhat-contract-sizer": "^2.10.0", "hardhat-gas-reporter": "^1.0.9", "hardhat-ignore-warnings": "^0.2.9", diff --git a/utils/core-utils/package.json b/utils/core-utils/package.json index e10005f8bf..263268a21d 100644 --- a/utils/core-utils/package.json +++ b/utils/core-utils/package.json @@ -39,7 +39,7 @@ "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/prompts": "^2.4.8", - "@usecannon/builder": "2.10.5", + "@usecannon/builder": "2.10.6-alpha.4", "ethers": "^5.7.2", "hardhat": "^2.19.0", "mocha": "^10.2.0", diff --git a/utils/docgen/package.json b/utils/docgen/package.json index 14270edbee..9626d50520 100644 --- a/utils/docgen/package.json +++ b/utils/docgen/package.json @@ -12,7 +12,7 @@ "docgen:contracts": "./docgen-contracts.sh" }, "devDependencies": { - "@usecannon/builder": "2.10.5", + "@usecannon/builder": "2.10.6-alpha.4", "handlebars": "^4.7.8", "prettier": "^3.0.3", "solidity-ast": "^0.4.52", diff --git a/utils/sample-project/package.json b/utils/sample-project/package.json index 45fe4664f7..84d62ebd6a 100644 --- a/utils/sample-project/package.json +++ b/utils/sample-project/package.json @@ -20,7 +20,7 @@ "@synthetixio/router": "^3.3.0", "ethers": "^5.7.2", "hardhat": "^2.19.0", - "hardhat-cannon": "2.10.5", + "hardhat-cannon": "2.10.6-alpha.4", "solidity-coverage": "^0.8.5" } } diff --git a/yarn.lock b/yarn.lock index 3321a6793e..2c252713a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2841,7 +2841,7 @@ __metadata: "@typechain/hardhat": "npm:^9.1.0" dotenv: "npm:^16.3.1" hardhat: "npm:^2.19.0" - hardhat-cannon: "npm:2.10.5" + hardhat-cannon: "npm:2.10.6-alpha.4" hardhat-contract-sizer: "npm:^2.10.0" hardhat-gas-reporter: "npm:^1.0.9" hardhat-ignore-warnings: "npm:^0.2.9" @@ -2881,7 +2881,7 @@ __metadata: dependencies: "@graphprotocol/graph-cli": "npm:^0.61.0" "@graphprotocol/graph-ts": "npm:^0.31.0" - "@usecannon/cli": "npm:2.10.5" + "@usecannon/cli": "npm:2.10.6-alpha.4" ethers: "npm:^5.7.2" matchstick-as: "npm:^0.6.0" prettier: "npm:^3.0.3" @@ -2895,7 +2895,7 @@ __metadata: "@ethersproject/abi": "npm:^5.7.0" "@istanbuljs/nyc-config-typescript": "npm:^1.0.2" "@types/prompts": "npm:^2.4.8" - "@usecannon/builder": "npm:2.10.5" + "@usecannon/builder": "npm:2.10.6-alpha.4" chalk: "npm:^4.1.2" ethereumjs-util: "npm:^7.1.5" ethers: "npm:^5.7.2" @@ -2942,7 +2942,7 @@ __metadata: version: 0.0.0-use.local resolution: "@synthetixio/docgen@workspace:utils/docgen" dependencies: - "@usecannon/builder": "npm:2.10.5" + "@usecannon/builder": "npm:2.10.6-alpha.4" handlebars: "npm:^4.7.8" prettier: "npm:^3.0.3" solidity-ast: "npm:^0.4.52" @@ -3056,7 +3056,7 @@ __metadata: dependencies: "@graphprotocol/graph-cli": "npm:^0.61.0" "@graphprotocol/graph-ts": "npm:^0.31.0" - "@usecannon/cli": "npm:2.10.5" + "@usecannon/cli": "npm:2.10.6-alpha.4" ethers: "npm:^5.7.2" matchstick-as: "npm:^0.6.0" prettier: "npm:^3.0.3" @@ -3077,7 +3077,7 @@ __metadata: "@synthetixio/router": "npm:^3.3.0" "@synthetixio/spot-market": "workspace:*" "@synthetixio/wei": "npm:^2.74.4" - "@usecannon/cli": "npm:2.10.5" + "@usecannon/cli": "npm:2.10.6-alpha.4" ethers: "npm:^5.7.2" hardhat: "npm:^2.19.0" solidity-docgen: "npm:^0.6.0-beta.36" @@ -3129,7 +3129,7 @@ __metadata: "@synthetixio/router": "npm:^3.3.0" ethers: "npm:^5.7.2" hardhat: "npm:^2.19.0" - hardhat-cannon: "npm:2.10.5" + hardhat-cannon: "npm:2.10.6-alpha.4" solidity-coverage: "npm:^0.8.5" languageName: unknown linkType: soft @@ -3155,7 +3155,7 @@ __metadata: dependencies: "@graphprotocol/graph-cli": "npm:^0.61.0" "@graphprotocol/graph-ts": "npm:^0.31.0" - "@usecannon/cli": "npm:2.10.5" + "@usecannon/cli": "npm:2.10.6-alpha.4" ethers: "npm:^5.7.2" matchstick-as: "npm:^0.6.0" prettier: "npm:^3.0.3" @@ -3176,7 +3176,7 @@ __metadata: "@synthetixio/router": "npm:^3.3.0" "@synthetixio/wei": "npm:^2.74.4" "@types/node-fetch": "npm:^2.6.9" - "@usecannon/cli": "npm:2.10.5" + "@usecannon/cli": "npm:2.10.6-alpha.4" ethers: "npm:^5.7.2" hardhat: "npm:^2.19.0" node-fetch: "npm:^2.7.0" @@ -3800,9 +3800,9 @@ __metadata: languageName: node linkType: hard -"@usecannon/builder@npm:2.10.5, @usecannon/builder@npm:^2.10.5": - version: 2.10.5 - resolution: "@usecannon/builder@npm:2.10.5" +"@usecannon/builder@npm:2.10.6-alpha.4, @usecannon/builder@npm:^2.10.6-alpha.4": + version: 2.10.6-alpha.4 + resolution: "@usecannon/builder@npm:2.10.6-alpha.4" dependencies: "@synthetixio/router": "npm:^3.3.0" axios: "npm:^1.6.2" @@ -3817,17 +3817,17 @@ __metadata: zod: "npm:^3.22.4" peerDependencies: ethers: ">=5.6.0 < 6.0.0" - checksum: 3c2beffbc877183c293322bd7ef9847bc329ae0e420f87e5a20bc110d9a3952635ec5ac017eb036117c24506876e9301536fbaeb34019240511786a005fb99b2 + checksum: 13b8f6fbb1e1a7db662f2497e9469174578215aeb3fac29c1ab59e2b43474000c22d5d2ddf13864b219647a6f02e5f90324c3a076e135ed7b161fdde0d5122cb languageName: node linkType: hard -"@usecannon/cli@npm:2.10.5, @usecannon/cli@npm:^2.10.5": - version: 2.10.5 - resolution: "@usecannon/cli@npm:2.10.5" +"@usecannon/cli@npm:2.10.6-alpha.4, @usecannon/cli@npm:^2.10.6-alpha.4": + version: 2.10.6-alpha.4 + resolution: "@usecannon/cli@npm:2.10.6-alpha.4" dependencies: "@iarna/toml": "npm:^3.0.0" "@synthetixio/wei": "npm:^2.74.1" - "@usecannon/builder": "npm:^2.10.5" + "@usecannon/builder": "npm:^2.10.6-alpha.4" chalk: "npm:^4.1.2" commander: "npm:^9.5.0" debug: "npm:^4.3.4" @@ -3844,7 +3844,7 @@ __metadata: untildify: "npm:^4.0.0" bin: cannon: bin/cannon.js - checksum: ff66d9cd27566d48265d8b2ebf34203f64c17dc167eff597611b8715140eae4a143590ce7bb275abf3d3fe0ba983b3ff807358b70ade52dee645a22e79eb090c + checksum: 8516f6b8b95e1ab5d86b5d49a21ab3d33d664df939cb850ca685656415f2b9766b8fc1083943aeef30ac4b58fb6839d87a5d2a9a4b2ab643a6a2467da5ad86d1 languageName: node linkType: hard @@ -8613,13 +8613,13 @@ __metadata: languageName: node linkType: hard -"hardhat-cannon@npm:2.10.5": - version: 2.10.5 - resolution: "hardhat-cannon@npm:2.10.5" +"hardhat-cannon@npm:2.10.6-alpha.4": + version: 2.10.6-alpha.4 + resolution: "hardhat-cannon@npm:2.10.6-alpha.4" dependencies: "@iarna/toml": "npm:^3.0.0" - "@usecannon/builder": "npm:^2.10.5" - "@usecannon/cli": "npm:^2.10.5" + "@usecannon/builder": "npm:^2.10.6-alpha.4" + "@usecannon/cli": "npm:^2.10.6-alpha.4" chalk: "npm:^4.1.2" debug: "npm:^4.3.3" ethers: "npm:^5.7.1" @@ -8628,7 +8628,7 @@ __metadata: "@nomiclabs/hardhat-ethers": ">=2.0.0" "@nomiclabs/hardhat-etherscan": ">=3.0.0" hardhat: ">=2.0.0" - checksum: 22686b4085395f2f6777968acc74d2a4c0d131e85a029aecdf9055bf436305d7cccd700425556c57f50248e06656a5b00c0f26f7fcff0d0ea595804fbb9572d8 + checksum: 41fd845e0b3691572dc1787d21faa15427dcd8a5efb1584d80b89e9107bbd5e175d189f0bf7cceff50a46096f5ad2b11da003dfded1fbd10193079d2fa232899 languageName: node linkType: hard @@ -15515,7 +15515,7 @@ __metadata: "@types/node": "npm:^18.18.9" "@typescript-eslint/eslint-plugin": "npm:^6.10.0" "@typescript-eslint/parser": "npm:^6.10.0" - "@usecannon/cli": "npm:2.10.5" + "@usecannon/cli": "npm:2.10.6-alpha.4" eslint: "npm:^8.53.0" eslint-plugin-no-only-tests: "npm:^3.1.0" lint-staged: "npm:^15.0.2"