Skip to content

Commit

Permalink
blast
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Jan 16, 2025
1 parent ca4e90b commit c4b6629
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/foundry/DeployGasdaddy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,28 @@ contract DeployGasdaddy is Script {

// SKIP BERACHAIN AS THERE's NO ETH/USD PRICE FEED THERE

// BLAST SEPOLIA
tokenPMConfigs[168587773] = TokenPMConfig(
address(0xf9A3bec11e342317DF97809201Bf394e29B6B585), // nativeAssetToUsdOracle
1e18, // nativeAssetDecimalsMultiplier
3600, // nativeAssetPriceExpiryDuration // 1 hour
address(0x4200000000000000000000000000000000000023), // wrappedNativeAddress
address(0x0000000000000000000000000000000000000000), // NO SWAP ROUTER ON BLAST SEPOLIA <= OWNER CAN SET IT WHEN (IF) IT IS DEPLOYED
new address[](0),
new IBiconomyTokenPaymaster.TokenInfo[](0)
);

// BLAST MAINNET
tokenPMConfigs[81457] = TokenPMConfig(
address(0xf9A3bec11e342317DF97809201Bf394e29B6B585), // nativeAssetToUsdOracle
1e18, // nativeAssetDecimalsMultiplier
3600, // nativeAssetPriceExpiryDuration // 1 hour
address(0x4300000000000000000000000000000000000004), // wrappedNativeAddress
address(0x0000000000000000000000000000000000000000), // NO SWAP ROUTER ON BLAST <= OWNER CAN SET IT WHEN (IF) IT IS DEPLOYED
new address[](0),
new IBiconomyTokenPaymaster.TokenInfo[](0)
);

// ANVIL
MockOracle mockNativeOracle;
if (block.chainid == 31337) {
Expand Down
68 changes: 68 additions & 0 deletions scripts/foundry/DeployPythFeedAdapter.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
import {IOracle} from "contracts/interfaces/oracles/IOracle.sol";

struct Price {
// Price
int64 price;
// Confidence interval around the price
uint64 conf;
// Price exponent
int32 expo;
// Unix timestamp describing when the price was published
uint publishTime;
}

interface IPythFeed {
function getPriceUnsafe(bytes32 id) external view returns (Price memory price);
}

contract PythFeedAdapter is IOracle {
IPythFeed public immutable pythFeed;
bytes32 public immutable priceId;

string public name;

int32 private constant EXPO = -8;

error InvalidPythFeedAddress();
error InvalidPythFeedPrecision();

constructor(address pythFeedAddress, string memory _name, bytes32 _priceId) {
if (pythFeedAddress == address(0)) revert InvalidPythFeedAddress();
pythFeed = IPythFeed(pythFeedAddress);
if (pythFeed.getPriceUnsafe(_priceId).expo != EXPO) revert InvalidPythFeedPrecision();
priceId = _priceId;
name = _name;
}

function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) {
Price memory price = pythFeed.getPriceUnsafe(priceId);
roundId = 0;
answer = price.price;
startedAt = price.publishTime;
updatedAt = price.publishTime;
answeredInRound = 0;
}

function decimals() external pure returns (uint8) {
return uint8(uint32(-EXPO));
}

function latestAnswer() external view returns (int256) {
Price memory price = pythFeed.getPriceUnsafe(priceId);
return price.price;
}
}

contract DeployPythFeedAdapter is Script {
function run() public {
console.log("Deploying PythFeedAdapter");
vm.startBroadcast();
PythFeedAdapter pythFeedAdapter = new PythFeedAdapter(0xA2aa501b19aff244D90cc15a4Cf739D2725B5729, "ETH/USD", 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace);
vm.stopBroadcast();
console.log("PythFeedAdapter deployed at", address(pythFeedAdapter));
}
}

0 comments on commit c4b6629

Please sign in to comment.