-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ManualValueOracle and related (#549)
- Loading branch information
Showing
9 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@enzymefinance/sdk": patch | ||
--- | ||
|
||
Add ManualValueOracle and related |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@enzymefinance/environment": patch | ||
"@enzymefinance/sdk": patch | ||
--- | ||
|
||
Add ManualValueOracle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { IManualValueOracleFactory, IManualValueOracleLib } from "@enzymefinance/abis"; | ||
import { type Address, type Client, stringToHex } from "viem"; | ||
import { readContract } from "viem/actions"; | ||
import { Viem } from "../Utils.js"; | ||
|
||
//-------------------------------------------------------------------------------------------- | ||
// TRANSACTIONS | ||
//-------------------------------------------------------------------------------------------- | ||
|
||
export function deploy(args: { | ||
manualValueOracleFactory: Address; | ||
owner: Address; | ||
updater: Address; | ||
description: string; | ||
}) { | ||
return new Viem.PopulatedTransaction({ | ||
abi: IManualValueOracleFactory, | ||
functionName: "deploy", | ||
address: args.manualValueOracleFactory, | ||
args: [args.owner, args.updater, stringToHex(args.description, { size: 32 })], | ||
}); | ||
} | ||
|
||
export function setUpdater(args: { | ||
manualValueOracle: Address; | ||
updater: Address; | ||
}) { | ||
return new Viem.PopulatedTransaction({ | ||
abi: IManualValueOracleLib, | ||
functionName: "setUpdater", | ||
address: args.manualValueOracle, | ||
args: [args.updater], | ||
}); | ||
} | ||
|
||
export function setNominatedOwner(args: { | ||
manualValueOracle: Address; | ||
nominatedOwner: Address; | ||
}) { | ||
return new Viem.PopulatedTransaction({ | ||
abi: IManualValueOracleLib, | ||
functionName: "setNominatedOwner", | ||
address: args.manualValueOracle, | ||
args: [args.nominatedOwner], | ||
}); | ||
} | ||
|
||
export function updateValue(args: { | ||
manualValueOracle: Address; | ||
value: bigint; | ||
}) { | ||
return new Viem.PopulatedTransaction({ | ||
abi: IManualValueOracleLib, | ||
functionName: "updateValue", | ||
address: args.manualValueOracle, | ||
args: [args.value], | ||
}); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------- | ||
// READ FUNCTIONS | ||
//-------------------------------------------------------------------------------------------- | ||
|
||
export function getValueWithTimestamp( | ||
client: Client, | ||
args: Viem.ContractCallParameters<{ manualValueOracle: Address }>, | ||
) { | ||
return readContract(client, { | ||
...Viem.extractBlockParameters(args), | ||
abi: IManualValueOracleLib, | ||
address: args.manualValueOracle, | ||
functionName: "getValueWithTimestamp", | ||
}); | ||
} | ||
export function getLastUpdated(client: Client, args: Viem.ContractCallParameters<{ manualValueOracle: Address }>) { | ||
return readContract(client, { | ||
...Viem.extractBlockParameters(args), | ||
abi: IManualValueOracleLib, | ||
address: args.manualValueOracle, | ||
functionName: "getLastUpdated", | ||
}); | ||
} | ||
export function getUpdater(client: Client, args: Viem.ContractCallParameters<{ manualValueOracle: Address }>) { | ||
return readContract(client, { | ||
...Viem.extractBlockParameters(args), | ||
abi: IManualValueOracleLib, | ||
address: args.manualValueOracle, | ||
functionName: "getUpdater", | ||
}); | ||
} | ||
export function getValue(client: Client, args: Viem.ContractCallParameters<{ manualValueOracle: Address }>) { | ||
return readContract(client, { | ||
...Viem.extractBlockParameters(args), | ||
abi: IManualValueOracleLib, | ||
address: args.manualValueOracle, | ||
functionName: "getValue", | ||
}); | ||
} |