diff --git a/abis/InstaAutomation.json b/abis/InstaAutomation.json index 2cd141e..8fed5c2 100644 --- a/abis/InstaAutomation.json +++ b/abis/InstaAutomation.json @@ -42,35 +42,17 @@ { "indexed": true, "internalType": "address", - "name": "user", + "name": "oldOnwer", "type": "address" }, { "indexed": true, - "internalType": "uint32", - "name": "id", - "type": "uint32" - }, - { - "indexed": true, - "internalType": "uint32", - "name": "nonce", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "bool", - "name": "isSafe", - "type": "bool" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "metadata", - "type": "bytes" + "internalType": "address", + "name": "newOnwer", + "type": "address" } ], - "name": "LogExecutedAutomation", + "name": "LogChangedOwner", "type": "event" }, { @@ -94,24 +76,6 @@ "name": "nonce", "type": "uint32" }, - { - "indexed": false, - "internalType": "uint128", - "name": "finalHf", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "initialHf", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "uint16", - "name": "automationFee", - "type": "uint16" - }, { "components": [ { @@ -172,21 +136,37 @@ "type": "tuple" }, { - "components": [ - { - "internalType": "string[]", - "name": "_targets", - "type": "string[]" - }, - { "internalType": "bytes[]", "name": "_datas", "type": "bytes[]" } - ], "indexed": false, - "internalType": "struct Structs.Spell", - "name": "spells", - "type": "tuple" + "internalType": "bool", + "name": "isSafe", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "automationFee", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "metadata", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "finalHf", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "initialHf", + "type": "uint128" } ], - "name": "LogExecutedAutomationParams", + "name": "LogExecutedAutomation", "type": "event" }, { @@ -195,7 +175,7 @@ { "indexed": true, "internalType": "address", - "name": "recipient_", + "name": "recipient", "type": "address" }, { @@ -270,6 +250,31 @@ "name": "LogSubmittedAutomation", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "actionId", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "metadata", + "type": "bytes" + } + ], + "name": "LogSystemCall", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -440,27 +445,10 @@ }, { "inputs": [ - { - "internalType": "contract AccountInterface", - "name": "dsa", - "type": "address" - }, - { - "components": [ - { - "internalType": "string[]", - "name": "_targets", - "type": "string[]" - }, - { "internalType": "bytes[]", "name": "_datas", "type": "bytes[]" } - ], - "internalType": "struct Structs.Spell", - "name": "spells", - "type": "tuple" - } + { "internalType": "address", "name": "newOwner_", "type": "address" } ], - "name": "cast", - "outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], + "name": "changeOwner", + "outputs": [], "stateMutability": "nonpayable", "type": "function" }, @@ -591,9 +579,19 @@ }, { "inputs": [ - { "internalType": "address", "name": "user_", "type": "address" }, - { "internalType": "uint32", "name": "id_", "type": "uint32" }, - { "internalType": "uint8", "name": "errorCode_", "type": "uint8" } + { "internalType": "string", "name": "actionId_", "type": "string" }, + { "internalType": "bytes", "name": "metadata_", "type": "bytes" } + ], + "name": "systemCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "users_", "type": "address[]" }, + { "internalType": "uint32[]", "name": "ids_", "type": "uint32[]" }, + { "internalType": "uint8[]", "name": "errorCodes_", "type": "uint8[]" } ], "name": "systemCancel", "outputs": [], @@ -644,22 +642,5 @@ "outputs": [], "stateMutability": "nonpayable", "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" } ] diff --git a/generated/InstaAutomation/InstaAutomation.ts b/generated/InstaAutomation/InstaAutomation.ts index 60baa51..05c9240 100644 --- a/generated/InstaAutomation/InstaAutomation.ts +++ b/generated/InstaAutomation/InstaAutomation.ts @@ -36,6 +36,28 @@ export class LogCancelledAutomation__Params { } } +export class LogChangedOwner extends ethereum.Event { + get params(): LogChangedOwner__Params { + return new LogChangedOwner__Params(this); + } +} + +export class LogChangedOwner__Params { + _event: LogChangedOwner; + + constructor(event: LogChangedOwner) { + this._event = event; + } + + get oldOnwer(): Address { + return this._event.parameters[0].value.toAddress(); + } + + get newOnwer(): Address { + return this._event.parameters[1].value.toAddress(); + } +} + export class LogExecutedAutomation extends ethereum.Event { get params(): LogExecutedAutomation__Params { return new LogExecutedAutomation__Params(this); @@ -61,66 +83,34 @@ export class LogExecutedAutomation__Params { return this._event.parameters[2].value.toBigInt(); } + get params(): LogExecutedAutomationParamsStruct { + return changetype( + this._event.parameters[3].value.toTuple() + ); + } + get isSafe(): boolean { - return this._event.parameters[3].value.toBoolean(); - } - - get metadata(): Bytes { - return this._event.parameters[4].value.toBytes(); - } -} - -export class LogExecutedAutomationParams extends ethereum.Event { - get params(): LogExecutedAutomationParams__Params { - return new LogExecutedAutomationParams__Params(this); - } -} - -export class LogExecutedAutomationParams__Params { - _event: LogExecutedAutomationParams; - - constructor(event: LogExecutedAutomationParams) { - this._event = event; - } - - get user(): Address { - return this._event.parameters[0].value.toAddress(); - } - - get id(): BigInt { - return this._event.parameters[1].value.toBigInt(); - } - - get nonce(): BigInt { - return this._event.parameters[2].value.toBigInt(); - } - - get finalHf(): BigInt { - return this._event.parameters[3].value.toBigInt(); - } - - get initialHf(): BigInt { - return this._event.parameters[4].value.toBigInt(); + return this._event.parameters[4].value.toBoolean(); } get automationFee(): i32 { return this._event.parameters[5].value.toI32(); } - get params(): LogExecutedAutomationParamsParamsStruct { - return changetype( - this._event.parameters[6].value.toTuple() - ); + get metadata(): Bytes { + return this._event.parameters[6].value.toBytes(); } - get spells(): LogExecutedAutomationParamsSpellsStruct { - return changetype( - this._event.parameters[7].value.toTuple() - ); + get finalHf(): BigInt { + return this._event.parameters[7].value.toBigInt(); + } + + get initialHf(): BigInt { + return this._event.parameters[8].value.toBigInt(); } } -export class LogExecutedAutomationParamsParamsStruct extends ethereum.Tuple { +export class LogExecutedAutomationParamsStruct extends ethereum.Tuple { get collateralToken(): Address { return this[0].toAddress(); } @@ -141,10 +131,8 @@ export class LogExecutedAutomationParamsParamsStruct extends ethereum.Tuple { return this[4].toBigInt(); } - get swap(): LogExecutedAutomationParamsParamsSwapStruct { - return changetype( - this[5].toTuple() - ); + get swap(): LogExecutedAutomationParamsSwapStruct { + return changetype(this[5].toTuple()); } get route(): BigInt { @@ -156,7 +144,7 @@ export class LogExecutedAutomationParamsParamsStruct extends ethereum.Tuple { } } -export class LogExecutedAutomationParamsParamsSwapStruct extends ethereum.Tuple { +export class LogExecutedAutomationParamsSwapStruct extends ethereum.Tuple { get buyToken(): Address { return this[0].toAddress(); } @@ -178,16 +166,6 @@ export class LogExecutedAutomationParamsParamsSwapStruct extends ethereum.Tuple } } -export class LogExecutedAutomationParamsSpellsStruct extends ethereum.Tuple { - get _targets(): Array { - return this[0].toStringArray(); - } - - get _datas(): Array { - return this[1].toBytesArray(); - } -} - export class LogFeeTransferred extends ethereum.Event { get params(): LogFeeTransferred__Params { return new LogFeeTransferred__Params(this); @@ -201,7 +179,7 @@ export class LogFeeTransferred__Params { this._event = event; } - get recipient_(): Address { + get recipient(): Address { return this._event.parameters[0].value.toAddress(); } @@ -270,6 +248,32 @@ export class LogSubmittedAutomation__Params { } } +export class LogSystemCall extends ethereum.Event { + get params(): LogSystemCall__Params { + return new LogSystemCall__Params(this); + } +} + +export class LogSystemCall__Params { + _event: LogSystemCall; + + constructor(event: LogSystemCall) { + this._event = event; + } + + get sender(): Address { + return this._event.parameters[0].value.toAddress(); + } + + get actionId(): string { + return this._event.parameters[1].value.toString(); + } + + get metadata(): Bytes { + return this._event.parameters[2].value.toBytes(); + } +} + export class LogSystemCancelledAutomation extends ethereum.Event { get params(): LogSystemCancelledAutomation__Params { return new LogSystemCancelledAutomation__Params(this); @@ -421,16 +425,6 @@ export class InstaAutomation___userAutomationConfigsResult { } } -export class InstaAutomation__castInputSpellsStruct extends ethereum.Tuple { - get _targets(): Array { - return this[0].toStringArray(); - } - - get _datas(): Array { - return this[1].toBytesArray(); - } -} - export class InstaAutomation extends ethereum.SmartContract { static bind(address: Address): InstaAutomation { return new InstaAutomation("InstaAutomation", address); @@ -621,31 +615,6 @@ export class InstaAutomation extends ethereum.SmartContract { return ethereum.CallResult.fromValue(value[0].toBigInt()); } - cast(dsa: Address, spells: InstaAutomation__castInputSpellsStruct): boolean { - let result = super.call("cast", "cast(address,(string[],bytes[])):(bool)", [ - ethereum.Value.fromAddress(dsa), - ethereum.Value.fromTuple(spells) - ]); - - return result[0].toBoolean(); - } - - try_cast( - dsa: Address, - spells: InstaAutomation__castInputSpellsStruct - ): ethereum.CallResult { - let result = super.tryCall( - "cast", - "cast(address,(string[],bytes[])):(bool)", - [ethereum.Value.fromAddress(dsa), ethereum.Value.fromTuple(spells)] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBoolean()); - } - getHealthFactor(user: Address): BigInt { let result = super.call( "getHealthFactor", @@ -668,21 +637,6 @@ export class InstaAutomation extends ethereum.SmartContract { let value = result.value; return ethereum.CallResult.fromValue(value[0].toBigInt()); } - - version(): BigInt { - let result = super.call("version", "version():(uint256)", []); - - return result[0].toBigInt(); - } - - try_version(): ethereum.CallResult { - let result = super.tryCall("version", "version():(uint256)", []); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBigInt()); - } } export class ConstructorCall extends ethereum.Call { @@ -745,54 +699,34 @@ export class CancelAutomationRequestCall__Outputs { } } -export class CastCall extends ethereum.Call { - get inputs(): CastCall__Inputs { - return new CastCall__Inputs(this); +export class ChangeOwnerCall extends ethereum.Call { + get inputs(): ChangeOwnerCall__Inputs { + return new ChangeOwnerCall__Inputs(this); } - get outputs(): CastCall__Outputs { - return new CastCall__Outputs(this); + get outputs(): ChangeOwnerCall__Outputs { + return new ChangeOwnerCall__Outputs(this); } } -export class CastCall__Inputs { - _call: CastCall; +export class ChangeOwnerCall__Inputs { + _call: ChangeOwnerCall; - constructor(call: CastCall) { + constructor(call: ChangeOwnerCall) { this._call = call; } - get dsa(): Address { + get newOwner_(): Address { return this._call.inputValues[0].value.toAddress(); } - - get spells(): CastCallSpellsStruct { - return changetype( - this._call.inputValues[1].value.toTuple() - ); - } } -export class CastCall__Outputs { - _call: CastCall; +export class ChangeOwnerCall__Outputs { + _call: ChangeOwnerCall; - constructor(call: CastCall) { + constructor(call: ChangeOwnerCall) { this._call = call; } - - get success(): boolean { - return this._call.outputValues[0].value.toBoolean(); - } -} - -export class CastCallSpellsStruct extends ethereum.Tuple { - get _targets(): Array { - return this[0].toStringArray(); - } - - get _datas(): Array { - return this[1].toBytesArray(); - } } export class ExecuteAutomationCall extends ethereum.Call { @@ -1009,6 +943,40 @@ export class SubmitAutomationRequestCall__Outputs { } } +export class SystemCallCall extends ethereum.Call { + get inputs(): SystemCallCall__Inputs { + return new SystemCallCall__Inputs(this); + } + + get outputs(): SystemCallCall__Outputs { + return new SystemCallCall__Outputs(this); + } +} + +export class SystemCallCall__Inputs { + _call: SystemCallCall; + + constructor(call: SystemCallCall) { + this._call = call; + } + + get actionId_(): string { + return this._call.inputValues[0].value.toString(); + } + + get metadata_(): Bytes { + return this._call.inputValues[1].value.toBytes(); + } +} + +export class SystemCallCall__Outputs { + _call: SystemCallCall; + + constructor(call: SystemCallCall) { + this._call = call; + } +} + export class SystemCancelCall extends ethereum.Call { get inputs(): SystemCancelCall__Inputs { return new SystemCancelCall__Inputs(this); @@ -1026,16 +994,16 @@ export class SystemCancelCall__Inputs { this._call = call; } - get user_(): Address { - return this._call.inputValues[0].value.toAddress(); + get users_(): Array
{ + return this._call.inputValues[0].value.toAddressArray(); } - get id_(): BigInt { - return this._call.inputValues[1].value.toBigInt(); + get ids_(): Array { + return this._call.inputValues[1].value.toBigIntArray(); } - get errorCode_(): i32 { - return this._call.inputValues[2].value.toI32(); + get errorCodes_(): Array { + return this._call.inputValues[2].value.toI32Array(); } } diff --git a/generated/schema.ts b/generated/schema.ts index 57543d2..2de81e5 100644 --- a/generated/schema.ts +++ b/generated/schema.ts @@ -242,6 +242,83 @@ export class Spell extends Entity { } } +export class TransactionData extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save TransactionData entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type TransactionData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("TransactionData", id.toString(), this); + } + } + + static load(id: string): TransactionData | null { + return changetype(store.get("TransactionData", id)); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get blockNumber(): BigInt { + let value = this.get("blockNumber"); + return value!.toBigInt(); + } + + set blockNumber(value: BigInt) { + this.set("blockNumber", Value.fromBigInt(value)); + } + + get timeStamp(): BigInt { + let value = this.get("timeStamp"); + return value!.toBigInt(); + } + + set timeStamp(value: BigInt) { + this.set("timeStamp", Value.fromBigInt(value)); + } + + get logIndex(): BigInt { + let value = this.get("logIndex"); + return value!.toBigInt(); + } + + set logIndex(value: BigInt) { + this.set("logIndex", Value.fromBigInt(value)); + } + + get transactionHash(): Bytes { + let value = this.get("transactionHash"); + return value!.toBytes(); + } + + set transactionHash(value: Bytes) { + this.set("transactionHash", Value.fromBytes(value)); + } + + get transactionLogIndex(): BigInt { + let value = this.get("transactionLogIndex"); + return value!.toBigInt(); + } + + set transactionLogIndex(value: BigInt) { + this.set("transactionLogIndex", Value.fromBigInt(value)); + } +} + export class Account extends Entity { constructor(id: string) { super(); @@ -273,6 +350,15 @@ export class Account extends Entity { this.set("id", Value.fromString(value)); } + get user(): Bytes { + let value = this.get("user"); + return value!.toBytes(); + } + + set user(value: Bytes) { + this.set("user", Value.fromBytes(value)); + } + get submitAutomation(): Array { let value = this.get("submitAutomation"); return value!.toStringArray(); @@ -291,15 +377,6 @@ export class Account extends Entity { this.set("executeAutomation", Value.fromStringArray(value)); } - get executeMetaData(): Array { - let value = this.get("executeMetaData"); - return value!.toStringArray(); - } - - set executeMetaData(value: Array) { - this.set("executeMetaData", Value.fromStringArray(value)); - } - get cancelData(): Array { let value = this.get("cancelData"); return value!.toStringArray(); @@ -403,6 +480,15 @@ export class SubmitData extends Entity { set account(value: string) { this.set("account", Value.fromString(value)); } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } } export class ExecuteData extends Entity { @@ -499,83 +585,6 @@ export class ExecuteData extends Entity { this.set("params", Value.fromString(value)); } - get spells(): string { - let value = this.get("spells"); - return value!.toString(); - } - - set spells(value: string) { - this.set("spells", Value.fromString(value)); - } - - get account(): string { - let value = this.get("account"); - return value!.toString(); - } - - set account(value: string) { - this.set("account", Value.fromString(value)); - } -} - -export class ExecuteMetaData extends Entity { - constructor(id: string) { - super(); - this.set("id", Value.fromString(id)); - } - - save(): void { - let id = this.get("id"); - assert(id != null, "Cannot save ExecuteMetaData entity without an ID"); - if (id) { - assert( - id.kind == ValueKind.STRING, - `Entities of type ExecuteMetaData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` - ); - store.set("ExecuteMetaData", id.toString(), this); - } - } - - static load(id: string): ExecuteMetaData | null { - return changetype(store.get("ExecuteMetaData", id)); - } - - get id(): string { - let value = this.get("id"); - return value!.toString(); - } - - set id(value: string) { - this.set("id", Value.fromString(value)); - } - - get user(): Bytes { - let value = this.get("user"); - return value!.toBytes(); - } - - set user(value: Bytes) { - this.set("user", Value.fromBytes(value)); - } - - get userId(): BigInt { - let value = this.get("userId"); - return value!.toBigInt(); - } - - set userId(value: BigInt) { - this.set("userId", Value.fromBigInt(value)); - } - - get nonce(): BigInt { - let value = this.get("nonce"); - return value!.toBigInt(); - } - - set nonce(value: BigInt) { - this.set("nonce", Value.fromBigInt(value)); - } - get isSafe(): boolean { let value = this.get("isSafe"); return value!.toBoolean(); @@ -585,13 +594,13 @@ export class ExecuteMetaData extends Entity { this.set("isSafe", Value.fromBoolean(value)); } - get metadata(): Bytes { - let value = this.get("metadata"); + get metaData(): Bytes { + let value = this.get("metaData"); return value!.toBytes(); } - set metadata(value: Bytes) { - this.set("metadata", Value.fromBytes(value)); + set metaData(value: Bytes) { + this.set("metaData", Value.fromBytes(value)); } get account(): string { @@ -602,6 +611,15 @@ export class ExecuteMetaData extends Entity { set account(value: string) { this.set("account", Value.fromString(value)); } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } } export class CancelData extends Entity { @@ -670,6 +688,15 @@ export class CancelData extends Entity { set account(value: string) { this.set("account", Value.fromString(value)); } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } } export class SystemCancelData extends Entity { @@ -749,6 +776,403 @@ export class SystemCancelData extends Entity { set account(value: string) { this.set("account", Value.fromString(value)); } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } +} + +export class ChangedOwner extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save ChangedOwner entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type ChangedOwner must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("ChangedOwner", id.toString(), this); + } + } + + static load(id: string): ChangedOwner | null { + return changetype(store.get("ChangedOwner", id)); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get oldOwner(): Bytes { + let value = this.get("oldOwner"); + return value!.toBytes(); + } + + set oldOwner(value: Bytes) { + this.set("oldOwner", Value.fromBytes(value)); + } + + get newOwner(): Bytes { + let value = this.get("newOwner"); + return value!.toBytes(); + } + + set newOwner(value: Bytes) { + this.set("newOwner", Value.fromBytes(value)); + } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } +} + +export class FeeTransferData extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save FeeTransferData entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type FeeTransferData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("FeeTransferData", id.toString(), this); + } + } + + static load(id: string): FeeTransferData | null { + return changetype(store.get("FeeTransferData", id)); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get recipient(): Bytes { + let value = this.get("recipient"); + return value!.toBytes(); + } + + set recipient(value: Bytes) { + this.set("recipient", Value.fromBytes(value)); + } + + get tokens(): Array { + let value = this.get("tokens"); + return value!.toBytesArray(); + } + + set tokens(value: Array) { + this.set("tokens", Value.fromBytesArray(value)); + } + + get amount(): Array { + let value = this.get("amount"); + return value!.toBigIntArray(); + } + + set amount(value: Array) { + this.set("amount", Value.fromBigIntArray(value)); + } + + get from(): Bytes { + let value = this.get("from"); + return value!.toBytes(); + } + + set from(value: Bytes) { + this.set("from", Value.fromBytes(value)); + } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } +} + +export class SystemCallData extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save SystemCallData entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type SystemCallData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("SystemCallData", id.toString(), this); + } + } + + static load(id: string): SystemCallData | null { + return changetype(store.get("SystemCallData", id)); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get sender(): Bytes { + let value = this.get("sender"); + return value!.toBytes(); + } + + set sender(value: Bytes) { + this.set("sender", Value.fromBytes(value)); + } + + get actionId(): string { + let value = this.get("actionId"); + return value!.toString(); + } + + set actionId(value: string) { + this.set("actionId", Value.fromString(value)); + } + + get metaData(): Bytes { + let value = this.get("metaData"); + return value!.toBytes(); + } + + set metaData(value: Bytes) { + this.set("metaData", Value.fromBytes(value)); + } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } +} + +export class UpdateAutomationFeeData extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert( + id != null, + "Cannot save UpdateAutomationFeeData entity without an ID" + ); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type UpdateAutomationFeeData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("UpdateAutomationFeeData", id.toString(), this); + } + } + + static load(id: string): UpdateAutomationFeeData | null { + return changetype( + store.get("UpdateAutomationFeeData", id) + ); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get oldAutomationFee(): i32 { + let value = this.get("oldAutomationFee"); + return value!.toI32(); + } + + set oldAutomationFee(value: i32) { + this.set("oldAutomationFee", Value.fromI32(value)); + } + + get newAutomationFee(): i32 { + let value = this.get("newAutomationFee"); + return value!.toI32(); + } + + set newAutomationFee(value: i32) { + this.set("newAutomationFee", Value.fromI32(value)); + } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } +} + +export class UpdateBufferHfData extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save UpdateBufferHfData entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type UpdateBufferHfData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("UpdateBufferHfData", id.toString(), this); + } + } + + static load(id: string): UpdateBufferHfData | null { + return changetype( + store.get("UpdateBufferHfData", id) + ); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get oldBuffer(): BigInt { + let value = this.get("oldBuffer"); + return value!.toBigInt(); + } + + set oldBuffer(value: BigInt) { + this.set("oldBuffer", Value.fromBigInt(value)); + } + + get newBuffer(): BigInt { + let value = this.get("newBuffer"); + return value!.toBigInt(); + } + + set newBuffer(value: BigInt) { + this.set("newBuffer", Value.fromBigInt(value)); + } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } +} + +export class UpdateMinHfData extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save UpdateMinHfData entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type UpdateMinHfData must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}` + ); + store.set("UpdateMinHfData", id.toString(), this); + } + } + + static load(id: string): UpdateMinHfData | null { + return changetype(store.get("UpdateMinHfData", id)); + } + + get id(): string { + let value = this.get("id"); + return value!.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get oldMinHf(): BigInt { + let value = this.get("oldMinHf"); + return value!.toBigInt(); + } + + set oldMinHf(value: BigInt) { + this.set("oldMinHf", Value.fromBigInt(value)); + } + + get newMinHf(): BigInt { + let value = this.get("newMinHf"); + return value!.toBigInt(); + } + + set newMinHf(value: BigInt) { + this.set("newMinHf", Value.fromBigInt(value)); + } + + get transactionDetail(): string { + let value = this.get("transactionDetail"); + return value!.toString(); + } + + set transactionDetail(value: string) { + this.set("transactionDetail", Value.fromString(value)); + } } export class Executor extends Entity { diff --git a/schema.graphql b/schema.graphql index ed0260c..5524cd6 100644 --- a/schema.graphql +++ b/schema.graphql @@ -25,11 +25,20 @@ type Spell @entity { _datas: [Bytes!]! } +type TransactionData @entity { + id: ID! + blockNumber: BigInt! + timeStamp: BigInt! + logIndex: BigInt! + transactionHash: Bytes! + transactionLogIndex: BigInt! +} + type Account @entity { id: ID! + user: Bytes! submitAutomation: [SubmitData!]! @derivedFrom (field: "account") executeAutomation: [ExecuteData!]! @derivedFrom (field: "account") - executeMetaData: [ExecuteMetaData!]! @derivedFrom (field: "account") cancelData: [CancelData!]! @derivedFrom (field: "account") systemCancelData: [SystemCancelData!]! @derivedFrom (field: "account") } @@ -42,6 +51,7 @@ type SubmitData @entity { thresholdHF: BigInt! currentHf: BigInt! account: Account! + transactionDetail: TransactionData! } type ExecuteData @entity { @@ -53,18 +63,10 @@ type ExecuteData @entity { initialHf: BigInt! automationFee: Int! params: ExecutionParams! - spells: Spell! - account: Account! -} - -type ExecuteMetaData @entity { - id: ID! - user: Bytes! - userId: BigInt! - nonce: BigInt! isSafe: Boolean! - metadata: Bytes! + metaData: Bytes! account: Account! + transactionDetail: TransactionData! } type CancelData @entity { @@ -73,6 +75,7 @@ type CancelData @entity { userId: BigInt! nonce: BigInt! account: Account! + transactionDetail: TransactionData! } type SystemCancelData @entity { @@ -82,6 +85,52 @@ type SystemCancelData @entity { nonce: BigInt! errorCode: Int! account: Account! + transactionDetail: TransactionData! +} + +type ChangedOwner @entity { + id: ID! + oldOwner: Bytes! + newOwner: Bytes! + transactionDetail: TransactionData! +} + +type FeeTransferData @entity { + id: ID! + recipient: Bytes! + tokens: [Bytes!]! + amount: [BigInt!]! + from: Bytes! + transactionDetail: TransactionData! +} + +type SystemCallData @entity { + id: ID! + sender: Bytes! + actionId: String! + metaData: Bytes! + transactionDetail: TransactionData! +} + +type UpdateAutomationFeeData @entity { + id: ID! + oldAutomationFee: Int! + newAutomationFee: Int! + transactionDetail: TransactionData! +} + +type UpdateBufferHfData @entity { + id: ID! + oldBuffer: BigInt! + newBuffer: BigInt! + transactionDetail: TransactionData! +} + +type UpdateMinHfData @entity { + id: ID! + oldMinHf: BigInt! + newMinHf: BigInt! + transactionDetail: TransactionData! } type Executor @entity { diff --git a/src/insta-automation.ts b/src/insta-automation.ts index f46d82d..ae70de5 100644 --- a/src/insta-automation.ts +++ b/src/insta-automation.ts @@ -1,16 +1,26 @@ -import { Address, BigInt, Bytes, dataSource, log } from "@graphprotocol/graph-ts"; +import { + Address, + BigInt, + Bytes, + dataSource, + log, +} from "@graphprotocol/graph-ts"; import { InstaAutomation, LogCancelledAutomation, + LogChangedOwner, LogExecutedAutomation, - LogExecutedAutomationParams, + LogFeeTransferred, LogFlippedExecutors, LogSubmittedAutomation, + LogSystemCall, LogSystemCancelledAutomation, -} from "../generated/InstaIndex/InstaAutomation"; + LogUpdatedAutomationFee, + LogUpdatedBufferHf, + LogUpdatedMinHf, +} from "../generated/InstaAutomation/InstaAutomation"; import { ExecuteData, - ExecuteMetaData, ExecutionParams, Spell, Swap, @@ -18,22 +28,28 @@ import { SubmitData, CancelData, SystemCancelData, - Executor + Executor, } from "../generated/schema"; import { createOrLoadCancelData, + createOrLoadChangedOwner, createOrLoadDsa, createOrLoadExecute, - createOrLoadExecuteMetaData, createOrLoadExecutionParams, - createOrLoadSpell, + createOrLoadFeeTransferData, createOrLoadSubmit, createOrLoadSwap, + createOrLoadSystemCallData, createOrLoadSystemCancelData, + createOrLoadTransaction, + createOrUpdateAutomationFeeData, + createOrUpdateBufferHfData, + createOrUpdateMinHfData, } from "./insta-index"; export function handleLogSubmitAutomation(event: LogSubmittedAutomation): void { - let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); + let dsaId = + event.params.user.toHexString() + "#" + event.params.id.toString(); let eventId = event.transaction.hash.toHexString() + event.logIndex.toString(); @@ -44,6 +60,7 @@ export function handleLogSubmitAutomation(event: LogSubmittedAutomation): void { log.info("ID: {}", [dsaId]); let dsa = createOrLoadDsa(dsaId); + dsa.user = event.params.user; let submitData = createOrLoadSubmit(eventId); submitData.user = event.params.user; submitData.userId = event.params.id; @@ -51,13 +68,22 @@ export function handleLogSubmitAutomation(event: LogSubmittedAutomation): void { submitData.thresholdHF = event.params.thresholdHF; submitData.currentHf = event.params.currentHf; submitData.account = dsaId; + let transaction = createOrLoadTransaction(eventId); + transaction.blockNumber = event.block.number; + transaction.timeStamp = event.block.timestamp; + transaction.logIndex = event.logIndex; + transaction.transactionHash = event.transaction.hash; + transaction.transactionLogIndex = event.transactionLogIndex; + submitData.transactionDetail = transaction.id; + transaction.save(); submitData.save(); dsa.save(); } export function handleLogCancelAutomation(event: LogCancelledAutomation): void { - let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); + let dsaId = + event.params.user.toHexString() + "#" + event.params.id.toString(); let eventId = event.transaction.hash.toHexString() + event.logIndex.toString(); @@ -68,13 +94,22 @@ export function handleLogCancelAutomation(event: LogCancelledAutomation): void { log.info("ID: {}", [dsaId]); let dsa = createOrLoadDsa(dsaId); + dsa.user = event.params.user; let cancelData = createOrLoadCancelData(eventId); cancelData.user = event.params.user; cancelData.userId = event.params.id; cancelData.nonce = event.params.nonce; cancelData.account = dsaId; - + let transaction = createOrLoadTransaction(eventId); + transaction.blockNumber = event.block.number; + transaction.timeStamp = event.block.timestamp; + transaction.logIndex = event.logIndex; + transaction.transactionHash = event.transaction.hash; + transaction.transactionLogIndex = event.transactionLogIndex; + cancelData.transactionDetail = transaction.id; + + transaction.save(); cancelData.save(); dsa.save(); } @@ -82,7 +117,8 @@ export function handleLogCancelAutomation(event: LogCancelledAutomation): void { export function handleSystemCancelledAutomation( event: LogSystemCancelledAutomation ): void { - let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); + let dsaId = + event.params.user.toHexString() + "#" + event.params.id.toString(); let eventId = event.transaction.hash.toHexString() + event.logIndex.toString(); @@ -93,6 +129,7 @@ export function handleSystemCancelledAutomation( log.info("ID: {}", [dsaId]); let dsa = createOrLoadDsa(dsaId); + dsa.user = event.params.user; let cancelData = createOrLoadSystemCancelData(eventId); cancelData.user = event.params.user; @@ -100,43 +137,24 @@ export function handleSystemCancelledAutomation( cancelData.nonce = event.params.nonce; cancelData.errorCode = event.params.errorCode; cancelData.account = dsaId; - + let transaction = createOrLoadTransaction(eventId); + transaction.blockNumber = event.block.number; + transaction.timeStamp = event.block.timestamp; + transaction.logIndex = event.logIndex; + transaction.transactionHash = event.transaction.hash; + transaction.transactionLogIndex = event.transactionLogIndex; + cancelData.transactionDetail = transaction.id; + + transaction.save(); cancelData.save(); dsa.save(); } -export function handleLogExecuteAutomationMetadata( +export function handleLogExecuteAutomation( event: LogExecutedAutomation ): void { - let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); - let eventId = - event.transaction.hash.toHexString() + event.logIndex.toString(); - - log.info("transaction hash: {} and from: {} ", [ - event.transaction.hash.toHexString(), - event.transaction.from.toHexString(), - ]); - log.info("ID: {}", [dsaId]); - - let dsa = createOrLoadDsa(dsaId); - let executeData = createOrLoadExecuteMetaData(eventId); - - executeData.user = event.params.user; - executeData.userId = event.params.id; - executeData.nonce = event.params.nonce; - executeData.isSafe = event.params.isSafe; - executeData.metadata = event.params.metadata; - executeData.account = dsaId; - - executeData.save(); - dsa.save(); -} - -export function handleLogExecuteAutomation( - event: LogExecutedAutomationParams -): void { - - let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); + let dsaId = + event.params.user.toHexString() + "#" + event.params.id.toString(); let eventId = event.transaction.hash.toHexString() + event.logIndex.toString(); @@ -147,6 +165,7 @@ export function handleLogExecuteAutomation( log.info("ID: {}", [dsaId]); let dsa = createOrLoadDsa(dsaId); + dsa.user = event.params.user; let executeData = createOrLoadExecute(eventId); let params = createOrLoadExecutionParams(eventId); @@ -156,50 +175,183 @@ export function handleLogExecuteAutomation( executeData.finalHf = event.params.finalHf; executeData.initialHf = event.params.initialHf; executeData.automationFee = event.params.automationFee; - params.collateralToken = event.params.params.collateralToken; - params.debtToken = event.params.params.debtToken; - params.collateralAmount = event.params.params.collateralAmount; - params.debtAmount = event.params.params.debtAmount; - params.collateralAmountWithTotalFee = event.params.params.collateralAmountWithTotalFee; + params.collateralToken = event.params.params.collateralToken; + params.debtToken = event.params.params.debtToken; + params.collateralAmount = event.params.params.collateralAmount; + params.debtAmount = event.params.params.debtAmount; + params.collateralAmountWithTotalFee = + event.params.params.collateralAmountWithTotalFee; + executeData.isSafe = event.params.isSafe; + executeData.metaData = event.params.metadata; let swaps = createOrLoadSwap(eventId); swaps.buyToken = event.params.params.swap.buyToken; swaps.sellToken = event.params.params.swap.sellToken; swaps.sellAmt = event.params.params.swap.sellAmt; swaps.unitAmt = event.params.params.swap.unitAmt; swaps.callData = event.params.params.swap.callData; - let spells = createOrLoadSpell(eventId); - spells._datas = event.params.spells._datas; - spells._targets = event.params.spells._targets; - params.swap = swaps.id; + params.swap = swaps.id; executeData.params = params.id; - executeData.spells = spells.id; executeData.account = dsaId; - + let transaction = createOrLoadTransaction(eventId); + transaction.blockNumber = event.block.number; + transaction.timeStamp = event.block.timestamp; + transaction.logIndex = event.logIndex; + transaction.transactionHash = event.transaction.hash; + transaction.transactionLogIndex = event.transactionLogIndex; + executeData.transactionDetail = transaction.id; + + transaction.save(); params.save(); swaps.save(); - spells.save(); executeData.save(); dsa.save(); } +export function handleLogChangedOwner(event: LogChangedOwner): void { + let eventId = + event.transaction.hash.toHexString() + event.logIndex.toString(); + + let changeOwnerData = createOrLoadChangedOwner(eventId); + changeOwnerData.oldOwner = event.params.oldOnwer; + changeOwnerData.newOwner = event.params.newOnwer; + let transaction = createOrLoadTransaction(eventId); + transaction.blockNumber = event.block.number; + transaction.timeStamp = event.block.timestamp; + transaction.logIndex = event.logIndex; + transaction.transactionHash = event.transaction.hash; + transaction.transactionLogIndex = event.transactionLogIndex; + changeOwnerData.transactionDetail = transaction.id; + + transaction.save(); + changeOwnerData.save(); +} + +export function handleLogFeeTransferred(event: LogFeeTransferred): void { + let eventId = + event.transaction.hash.toHexString() + event.logIndex.toString(); + + let data = createOrLoadFeeTransferData(eventId); + data.recipient = event.params.recipient; + let tokens = event.params.tokens; + let amounts = event.params.amount; + data.from = event.transaction.from; + let dataTokens = data.tokens; + let dataAmounts = data.amount; + + for(let i = 0; i