Merge pull request #1 from Richa-iitr/all-events

Updated events
This commit is contained in:
Richa 2022-08-06 10:43:23 +05:30 committed by GitHub
commit d746f5b2b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1100 additions and 458 deletions

View File

@ -42,35 +42,17 @@
{ {
"indexed": true, "indexed": true,
"internalType": "address", "internalType": "address",
"name": "user", "name": "oldOnwer",
"type": "address" "type": "address"
}, },
{ {
"indexed": true, "indexed": true,
"internalType": "uint32", "internalType": "address",
"name": "id", "name": "newOnwer",
"type": "uint32" "type": "address"
},
{
"indexed": true,
"internalType": "uint32",
"name": "nonce",
"type": "uint32"
},
{
"indexed": false,
"internalType": "bool",
"name": "isSafe",
"type": "bool"
},
{
"indexed": false,
"internalType": "bytes",
"name": "metadata",
"type": "bytes"
} }
], ],
"name": "LogExecutedAutomation", "name": "LogChangedOwner",
"type": "event" "type": "event"
}, },
{ {
@ -94,24 +76,6 @@
"name": "nonce", "name": "nonce",
"type": "uint32" "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": [ "components": [
{ {
@ -172,21 +136,37 @@
"type": "tuple" "type": "tuple"
}, },
{ {
"components": [
{
"internalType": "string[]",
"name": "_targets",
"type": "string[]"
},
{ "internalType": "bytes[]", "name": "_datas", "type": "bytes[]" }
],
"indexed": false, "indexed": false,
"internalType": "struct Structs.Spell", "internalType": "bool",
"name": "spells", "name": "isSafe",
"type": "tuple" "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" "type": "event"
}, },
{ {
@ -195,7 +175,7 @@
{ {
"indexed": true, "indexed": true,
"internalType": "address", "internalType": "address",
"name": "recipient_", "name": "recipient",
"type": "address" "type": "address"
}, },
{ {
@ -270,6 +250,31 @@
"name": "LogSubmittedAutomation", "name": "LogSubmittedAutomation",
"type": "event" "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, "anonymous": false,
"inputs": [ "inputs": [
@ -440,27 +445,10 @@
}, },
{ {
"inputs": [ "inputs": [
{ { "internalType": "address", "name": "newOwner_", "type": "address" }
"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"
}
], ],
"name": "cast", "name": "changeOwner",
"outputs": [{ "internalType": "bool", "name": "success", "type": "bool" }], "outputs": [],
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
@ -591,9 +579,19 @@
}, },
{ {
"inputs": [ "inputs": [
{ "internalType": "address", "name": "user_", "type": "address" }, { "internalType": "string", "name": "actionId_", "type": "string" },
{ "internalType": "uint32", "name": "id_", "type": "uint32" }, { "internalType": "bytes", "name": "metadata_", "type": "bytes" }
{ "internalType": "uint8", "name": "errorCode_", "type": "uint8" } ],
"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", "name": "systemCancel",
"outputs": [], "outputs": [],
@ -644,22 +642,5 @@
"outputs": [], "outputs": [],
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
} }
] ]

View File

@ -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 { export class LogExecutedAutomation extends ethereum.Event {
get params(): LogExecutedAutomation__Params { get params(): LogExecutedAutomation__Params {
return new LogExecutedAutomation__Params(this); return new LogExecutedAutomation__Params(this);
@ -61,66 +83,34 @@ export class LogExecutedAutomation__Params {
return this._event.parameters[2].value.toBigInt(); return this._event.parameters[2].value.toBigInt();
} }
get params(): LogExecutedAutomationParamsStruct {
return changetype<LogExecutedAutomationParamsStruct>(
this._event.parameters[3].value.toTuple()
);
}
get isSafe(): boolean { get isSafe(): boolean {
return this._event.parameters[3].value.toBoolean(); return this._event.parameters[4].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();
} }
get automationFee(): i32 { get automationFee(): i32 {
return this._event.parameters[5].value.toI32(); return this._event.parameters[5].value.toI32();
} }
get params(): LogExecutedAutomationParamsParamsStruct { get metadata(): Bytes {
return changetype<LogExecutedAutomationParamsParamsStruct>( return this._event.parameters[6].value.toBytes();
this._event.parameters[6].value.toTuple()
);
} }
get spells(): LogExecutedAutomationParamsSpellsStruct { get finalHf(): BigInt {
return changetype<LogExecutedAutomationParamsSpellsStruct>( return this._event.parameters[7].value.toBigInt();
this._event.parameters[7].value.toTuple() }
);
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 { get collateralToken(): Address {
return this[0].toAddress(); return this[0].toAddress();
} }
@ -141,10 +131,8 @@ export class LogExecutedAutomationParamsParamsStruct extends ethereum.Tuple {
return this[4].toBigInt(); return this[4].toBigInt();
} }
get swap(): LogExecutedAutomationParamsParamsSwapStruct { get swap(): LogExecutedAutomationParamsSwapStruct {
return changetype<LogExecutedAutomationParamsParamsSwapStruct>( return changetype<LogExecutedAutomationParamsSwapStruct>(this[5].toTuple());
this[5].toTuple()
);
} }
get route(): BigInt { 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 { get buyToken(): Address {
return this[0].toAddress(); return this[0].toAddress();
} }
@ -178,16 +166,6 @@ export class LogExecutedAutomationParamsParamsSwapStruct extends ethereum.Tuple
} }
} }
export class LogExecutedAutomationParamsSpellsStruct extends ethereum.Tuple {
get _targets(): Array<string> {
return this[0].toStringArray();
}
get _datas(): Array<Bytes> {
return this[1].toBytesArray();
}
}
export class LogFeeTransferred extends ethereum.Event { export class LogFeeTransferred extends ethereum.Event {
get params(): LogFeeTransferred__Params { get params(): LogFeeTransferred__Params {
return new LogFeeTransferred__Params(this); return new LogFeeTransferred__Params(this);
@ -201,7 +179,7 @@ export class LogFeeTransferred__Params {
this._event = event; this._event = event;
} }
get recipient_(): Address { get recipient(): Address {
return this._event.parameters[0].value.toAddress(); 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 { export class LogSystemCancelledAutomation extends ethereum.Event {
get params(): LogSystemCancelledAutomation__Params { get params(): LogSystemCancelledAutomation__Params {
return new LogSystemCancelledAutomation__Params(this); return new LogSystemCancelledAutomation__Params(this);
@ -421,16 +425,6 @@ export class InstaAutomation___userAutomationConfigsResult {
} }
} }
export class InstaAutomation__castInputSpellsStruct extends ethereum.Tuple {
get _targets(): Array<string> {
return this[0].toStringArray();
}
get _datas(): Array<Bytes> {
return this[1].toBytesArray();
}
}
export class InstaAutomation extends ethereum.SmartContract { export class InstaAutomation extends ethereum.SmartContract {
static bind(address: Address): InstaAutomation { static bind(address: Address): InstaAutomation {
return new InstaAutomation("InstaAutomation", address); return new InstaAutomation("InstaAutomation", address);
@ -621,31 +615,6 @@ export class InstaAutomation extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toBigInt()); 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<boolean> {
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 { getHealthFactor(user: Address): BigInt {
let result = super.call( let result = super.call(
"getHealthFactor", "getHealthFactor",
@ -668,21 +637,6 @@ export class InstaAutomation extends ethereum.SmartContract {
let value = result.value; let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBigInt()); return ethereum.CallResult.fromValue(value[0].toBigInt());
} }
version(): BigInt {
let result = super.call("version", "version():(uint256)", []);
return result[0].toBigInt();
}
try_version(): ethereum.CallResult<BigInt> {
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 { export class ConstructorCall extends ethereum.Call {
@ -745,54 +699,34 @@ export class CancelAutomationRequestCall__Outputs {
} }
} }
export class CastCall extends ethereum.Call { export class ChangeOwnerCall extends ethereum.Call {
get inputs(): CastCall__Inputs { get inputs(): ChangeOwnerCall__Inputs {
return new CastCall__Inputs(this); return new ChangeOwnerCall__Inputs(this);
} }
get outputs(): CastCall__Outputs { get outputs(): ChangeOwnerCall__Outputs {
return new CastCall__Outputs(this); return new ChangeOwnerCall__Outputs(this);
} }
} }
export class CastCall__Inputs { export class ChangeOwnerCall__Inputs {
_call: CastCall; _call: ChangeOwnerCall;
constructor(call: CastCall) { constructor(call: ChangeOwnerCall) {
this._call = call; this._call = call;
} }
get dsa(): Address { get newOwner_(): Address {
return this._call.inputValues[0].value.toAddress(); return this._call.inputValues[0].value.toAddress();
} }
get spells(): CastCallSpellsStruct {
return changetype<CastCallSpellsStruct>(
this._call.inputValues[1].value.toTuple()
);
}
} }
export class CastCall__Outputs { export class ChangeOwnerCall__Outputs {
_call: CastCall; _call: ChangeOwnerCall;
constructor(call: CastCall) { constructor(call: ChangeOwnerCall) {
this._call = call; this._call = call;
} }
get success(): boolean {
return this._call.outputValues[0].value.toBoolean();
}
}
export class CastCallSpellsStruct extends ethereum.Tuple {
get _targets(): Array<string> {
return this[0].toStringArray();
}
get _datas(): Array<Bytes> {
return this[1].toBytesArray();
}
} }
export class ExecuteAutomationCall extends ethereum.Call { 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 { export class SystemCancelCall extends ethereum.Call {
get inputs(): SystemCancelCall__Inputs { get inputs(): SystemCancelCall__Inputs {
return new SystemCancelCall__Inputs(this); return new SystemCancelCall__Inputs(this);
@ -1026,16 +994,16 @@ export class SystemCancelCall__Inputs {
this._call = call; this._call = call;
} }
get user_(): Address { get users_(): Array<Address> {
return this._call.inputValues[0].value.toAddress(); return this._call.inputValues[0].value.toAddressArray();
} }
get id_(): BigInt { get ids_(): Array<BigInt> {
return this._call.inputValues[1].value.toBigInt(); return this._call.inputValues[1].value.toBigIntArray();
} }
get errorCode_(): i32 { get errorCodes_(): Array<i32> {
return this._call.inputValues[2].value.toI32(); return this._call.inputValues[2].value.toI32Array();
} }
} }

View File

@ -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<TransactionData | null>(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 { export class Account extends Entity {
constructor(id: string) { constructor(id: string) {
super(); super();
@ -273,6 +350,15 @@ export class Account extends Entity {
this.set("id", Value.fromString(value)); 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<string> { get submitAutomation(): Array<string> {
let value = this.get("submitAutomation"); let value = this.get("submitAutomation");
return value!.toStringArray(); return value!.toStringArray();
@ -291,15 +377,6 @@ export class Account extends Entity {
this.set("executeAutomation", Value.fromStringArray(value)); this.set("executeAutomation", Value.fromStringArray(value));
} }
get executeMetaData(): Array<string> {
let value = this.get("executeMetaData");
return value!.toStringArray();
}
set executeMetaData(value: Array<string>) {
this.set("executeMetaData", Value.fromStringArray(value));
}
get cancelData(): Array<string> { get cancelData(): Array<string> {
let value = this.get("cancelData"); let value = this.get("cancelData");
return value!.toStringArray(); return value!.toStringArray();
@ -403,6 +480,15 @@ export class SubmitData extends Entity {
set account(value: string) { set account(value: string) {
this.set("account", Value.fromString(value)); 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 { export class ExecuteData extends Entity {
@ -499,83 +585,6 @@ export class ExecuteData extends Entity {
this.set("params", Value.fromString(value)); 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<ExecuteMetaData | null>(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 { get isSafe(): boolean {
let value = this.get("isSafe"); let value = this.get("isSafe");
return value!.toBoolean(); return value!.toBoolean();
@ -585,13 +594,13 @@ export class ExecuteMetaData extends Entity {
this.set("isSafe", Value.fromBoolean(value)); this.set("isSafe", Value.fromBoolean(value));
} }
get metadata(): Bytes { get metaData(): Bytes {
let value = this.get("metadata"); let value = this.get("metaData");
return value!.toBytes(); return value!.toBytes();
} }
set metadata(value: Bytes) { set metaData(value: Bytes) {
this.set("metadata", Value.fromBytes(value)); this.set("metaData", Value.fromBytes(value));
} }
get account(): string { get account(): string {
@ -602,6 +611,15 @@ export class ExecuteMetaData extends Entity {
set account(value: string) { set account(value: string) {
this.set("account", Value.fromString(value)); 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 { export class CancelData extends Entity {
@ -670,6 +688,15 @@ export class CancelData extends Entity {
set account(value: string) { set account(value: string) {
this.set("account", Value.fromString(value)); 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 { export class SystemCancelData extends Entity {
@ -749,6 +776,403 @@ export class SystemCancelData extends Entity {
set account(value: string) { set account(value: string) {
this.set("account", Value.fromString(value)); 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<ChangedOwner | null>(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<FeeTransferData | null>(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<Bytes> {
let value = this.get("tokens");
return value!.toBytesArray();
}
set tokens(value: Array<Bytes>) {
this.set("tokens", Value.fromBytesArray(value));
}
get amount(): Array<BigInt> {
let value = this.get("amount");
return value!.toBigIntArray();
}
set amount(value: Array<BigInt>) {
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<SystemCallData | null>(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<UpdateAutomationFeeData | null>(
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<UpdateBufferHfData | null>(
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<UpdateMinHfData | null>(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 { export class Executor extends Entity {

View File

@ -25,11 +25,20 @@ type Spell @entity {
_datas: [Bytes!]! _datas: [Bytes!]!
} }
type TransactionData @entity {
id: ID!
blockNumber: BigInt!
timeStamp: BigInt!
logIndex: BigInt!
transactionHash: Bytes!
transactionLogIndex: BigInt!
}
type Account @entity { type Account @entity {
id: ID! id: ID!
user: Bytes!
submitAutomation: [SubmitData!]! @derivedFrom (field: "account") submitAutomation: [SubmitData!]! @derivedFrom (field: "account")
executeAutomation: [ExecuteData!]! @derivedFrom (field: "account") executeAutomation: [ExecuteData!]! @derivedFrom (field: "account")
executeMetaData: [ExecuteMetaData!]! @derivedFrom (field: "account")
cancelData: [CancelData!]! @derivedFrom (field: "account") cancelData: [CancelData!]! @derivedFrom (field: "account")
systemCancelData: [SystemCancelData!]! @derivedFrom (field: "account") systemCancelData: [SystemCancelData!]! @derivedFrom (field: "account")
} }
@ -42,6 +51,7 @@ type SubmitData @entity {
thresholdHF: BigInt! thresholdHF: BigInt!
currentHf: BigInt! currentHf: BigInt!
account: Account! account: Account!
transactionDetail: TransactionData!
} }
type ExecuteData @entity { type ExecuteData @entity {
@ -53,18 +63,10 @@ type ExecuteData @entity {
initialHf: BigInt! initialHf: BigInt!
automationFee: Int! automationFee: Int!
params: ExecutionParams! params: ExecutionParams!
spells: Spell!
account: Account!
}
type ExecuteMetaData @entity {
id: ID!
user: Bytes!
userId: BigInt!
nonce: BigInt!
isSafe: Boolean! isSafe: Boolean!
metadata: Bytes! metaData: Bytes!
account: Account! account: Account!
transactionDetail: TransactionData!
} }
type CancelData @entity { type CancelData @entity {
@ -73,6 +75,7 @@ type CancelData @entity {
userId: BigInt! userId: BigInt!
nonce: BigInt! nonce: BigInt!
account: Account! account: Account!
transactionDetail: TransactionData!
} }
type SystemCancelData @entity { type SystemCancelData @entity {
@ -82,6 +85,52 @@ type SystemCancelData @entity {
nonce: BigInt! nonce: BigInt!
errorCode: Int! errorCode: Int!
account: Account! 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 { type Executor @entity {

View File

@ -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 { import {
InstaAutomation, InstaAutomation,
LogCancelledAutomation, LogCancelledAutomation,
LogChangedOwner,
LogExecutedAutomation, LogExecutedAutomation,
LogExecutedAutomationParams, LogFeeTransferred,
LogFlippedExecutors, LogFlippedExecutors,
LogSubmittedAutomation, LogSubmittedAutomation,
LogSystemCall,
LogSystemCancelledAutomation, LogSystemCancelledAutomation,
} from "../generated/InstaIndex/InstaAutomation"; LogUpdatedAutomationFee,
LogUpdatedBufferHf,
LogUpdatedMinHf,
} from "../generated/InstaAutomation/InstaAutomation";
import { import {
ExecuteData, ExecuteData,
ExecuteMetaData,
ExecutionParams, ExecutionParams,
Spell, Spell,
Swap, Swap,
@ -18,22 +28,28 @@ import {
SubmitData, SubmitData,
CancelData, CancelData,
SystemCancelData, SystemCancelData,
Executor Executor,
} from "../generated/schema"; } from "../generated/schema";
import { import {
createOrLoadCancelData, createOrLoadCancelData,
createOrLoadChangedOwner,
createOrLoadDsa, createOrLoadDsa,
createOrLoadExecute, createOrLoadExecute,
createOrLoadExecuteMetaData,
createOrLoadExecutionParams, createOrLoadExecutionParams,
createOrLoadSpell, createOrLoadFeeTransferData,
createOrLoadSubmit, createOrLoadSubmit,
createOrLoadSwap, createOrLoadSwap,
createOrLoadSystemCallData,
createOrLoadSystemCancelData, createOrLoadSystemCancelData,
createOrLoadTransaction,
createOrUpdateAutomationFeeData,
createOrUpdateBufferHfData,
createOrUpdateMinHfData,
} from "./insta-index"; } from "./insta-index";
export function handleLogSubmitAutomation(event: LogSubmittedAutomation): void { 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 = let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString(); event.transaction.hash.toHexString() + event.logIndex.toString();
@ -44,6 +60,7 @@ export function handleLogSubmitAutomation(event: LogSubmittedAutomation): void {
log.info("ID: {}", [dsaId]); log.info("ID: {}", [dsaId]);
let dsa = createOrLoadDsa(dsaId); let dsa = createOrLoadDsa(dsaId);
dsa.user = event.params.user;
let submitData = createOrLoadSubmit(eventId); let submitData = createOrLoadSubmit(eventId);
submitData.user = event.params.user; submitData.user = event.params.user;
submitData.userId = event.params.id; submitData.userId = event.params.id;
@ -51,13 +68,22 @@ export function handleLogSubmitAutomation(event: LogSubmittedAutomation): void {
submitData.thresholdHF = event.params.thresholdHF; submitData.thresholdHF = event.params.thresholdHF;
submitData.currentHf = event.params.currentHf; submitData.currentHf = event.params.currentHf;
submitData.account = dsaId; 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(); submitData.save();
dsa.save(); dsa.save();
} }
export function handleLogCancelAutomation(event: LogCancelledAutomation): void { 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 = let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString(); event.transaction.hash.toHexString() + event.logIndex.toString();
@ -68,13 +94,22 @@ export function handleLogCancelAutomation(event: LogCancelledAutomation): void {
log.info("ID: {}", [dsaId]); log.info("ID: {}", [dsaId]);
let dsa = createOrLoadDsa(dsaId); let dsa = createOrLoadDsa(dsaId);
dsa.user = event.params.user;
let cancelData = createOrLoadCancelData(eventId); let cancelData = createOrLoadCancelData(eventId);
cancelData.user = event.params.user; cancelData.user = event.params.user;
cancelData.userId = event.params.id; cancelData.userId = event.params.id;
cancelData.nonce = event.params.nonce; cancelData.nonce = event.params.nonce;
cancelData.account = dsaId; 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(); cancelData.save();
dsa.save(); dsa.save();
} }
@ -82,7 +117,8 @@ export function handleLogCancelAutomation(event: LogCancelledAutomation): void {
export function handleSystemCancelledAutomation( export function handleSystemCancelledAutomation(
event: LogSystemCancelledAutomation event: LogSystemCancelledAutomation
): void { ): void {
let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); let dsaId =
event.params.user.toHexString() + "#" + event.params.id.toString();
let eventId = let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString(); event.transaction.hash.toHexString() + event.logIndex.toString();
@ -93,6 +129,7 @@ export function handleSystemCancelledAutomation(
log.info("ID: {}", [dsaId]); log.info("ID: {}", [dsaId]);
let dsa = createOrLoadDsa(dsaId); let dsa = createOrLoadDsa(dsaId);
dsa.user = event.params.user;
let cancelData = createOrLoadSystemCancelData(eventId); let cancelData = createOrLoadSystemCancelData(eventId);
cancelData.user = event.params.user; cancelData.user = event.params.user;
@ -100,43 +137,24 @@ export function handleSystemCancelledAutomation(
cancelData.nonce = event.params.nonce; cancelData.nonce = event.params.nonce;
cancelData.errorCode = event.params.errorCode; cancelData.errorCode = event.params.errorCode;
cancelData.account = dsaId; 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(); cancelData.save();
dsa.save(); dsa.save();
} }
export function handleLogExecuteAutomationMetadata( export function handleLogExecuteAutomation(
event: LogExecutedAutomation event: LogExecutedAutomation
): void { ): void {
let dsaId = event.params.user.toHexString() + "#" + event.params.id.toString(); let dsaId =
let eventId = event.params.user.toHexString() + "#" + event.params.id.toString();
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 eventId = let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString(); event.transaction.hash.toHexString() + event.logIndex.toString();
@ -147,6 +165,7 @@ export function handleLogExecuteAutomation(
log.info("ID: {}", [dsaId]); log.info("ID: {}", [dsaId]);
let dsa = createOrLoadDsa(dsaId); let dsa = createOrLoadDsa(dsaId);
dsa.user = event.params.user;
let executeData = createOrLoadExecute(eventId); let executeData = createOrLoadExecute(eventId);
let params = createOrLoadExecutionParams(eventId); let params = createOrLoadExecutionParams(eventId);
@ -156,50 +175,183 @@ export function handleLogExecuteAutomation(
executeData.finalHf = event.params.finalHf; executeData.finalHf = event.params.finalHf;
executeData.initialHf = event.params.initialHf; executeData.initialHf = event.params.initialHf;
executeData.automationFee = event.params.automationFee; executeData.automationFee = event.params.automationFee;
params.collateralToken = event.params.params.collateralToken; params.collateralToken = event.params.params.collateralToken;
params.debtToken = event.params.params.debtToken; params.debtToken = event.params.params.debtToken;
params.collateralAmount = event.params.params.collateralAmount; params.collateralAmount = event.params.params.collateralAmount;
params.debtAmount = event.params.params.debtAmount; params.debtAmount = event.params.params.debtAmount;
params.collateralAmountWithTotalFee = event.params.params.collateralAmountWithTotalFee; params.collateralAmountWithTotalFee =
event.params.params.collateralAmountWithTotalFee;
executeData.isSafe = event.params.isSafe;
executeData.metaData = event.params.metadata;
let swaps = createOrLoadSwap(eventId); let swaps = createOrLoadSwap(eventId);
swaps.buyToken = event.params.params.swap.buyToken; swaps.buyToken = event.params.params.swap.buyToken;
swaps.sellToken = event.params.params.swap.sellToken; swaps.sellToken = event.params.params.swap.sellToken;
swaps.sellAmt = event.params.params.swap.sellAmt; swaps.sellAmt = event.params.params.swap.sellAmt;
swaps.unitAmt = event.params.params.swap.unitAmt; swaps.unitAmt = event.params.params.swap.unitAmt;
swaps.callData = event.params.params.swap.callData; swaps.callData = event.params.params.swap.callData;
let spells = createOrLoadSpell(eventId); params.swap = swaps.id;
spells._datas = event.params.spells._datas;
spells._targets = event.params.spells._targets;
params.swap = swaps.id;
executeData.params = params.id; executeData.params = params.id;
executeData.spells = spells.id;
executeData.account = dsaId; 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(); params.save();
swaps.save(); swaps.save();
spells.save();
executeData.save(); executeData.save();
dsa.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<tokens.length; i++) {
dataTokens.push(tokens[i]);
dataAmounts.push(amounts[i]);
}
data.tokens = dataTokens;
data.amount = dataAmounts;
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;
data.transactionDetail = transaction.id;
transaction.save();
data.save();
}
export function handleLogSystemCall(event: LogSystemCall): void {
let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString();
let data = createOrLoadSystemCallData(eventId);
data.sender = event.params.sender;
data.actionId = event.params.actionId;
data.metaData = event.params.metadata;
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;
data.transactionDetail = transaction.id;
transaction.save();
data.save();
}
export function handleLogUpdateAutomationFee(event: LogUpdatedAutomationFee): void {
let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString();
let data = createOrUpdateAutomationFeeData(eventId);
data.oldAutomationFee = event.params.oldAutomationFee;
data.newAutomationFee = event.params.newAutomationFee;
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;
data.transactionDetail = transaction.id;
transaction.save();
data.save();
}
export function handleUpdatedBufferHf(event: LogUpdatedBufferHf): void {
let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString();
let data = createOrUpdateBufferHfData(eventId);
data.oldBuffer = event.params.oldBufferHf;
data.newBuffer = event.params.newBufferHf;
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;
data.transactionDetail = transaction.id;
transaction.save();
data.save();
}
export function handleLogUpdatedMinHf(event: LogUpdatedMinHf): void {
let eventId =
event.transaction.hash.toHexString() + event.logIndex.toString();
let data = createOrUpdateMinHfData(eventId);
data.oldMinHf = event.params.oldMinHf;
data.newMinHf = event.params.newMinHf;
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;
data.transactionDetail = transaction.id;
transaction.save();
data.save();
}
export function handleExecutors(event: LogFlippedExecutors): void { export function handleExecutors(event: LogFlippedExecutors): void {
let id = "ALL" let id = "ALL";
let executors_ = Executor.load(id); let executors_ = Executor.load(id);
if(executors_ == null){ if (executors_ == null) {
executors_ = new Executor(id); executors_ = new Executor(id);
executors_.executors = []; executors_.executors = [];
} }
let execArr = executors_.executors; let execArr = executors_.executors;
let statusArr = event.params.status; let statusArr = event.params.status;
for(let i=0;i<event.params.executors.length;i++){ for (let i = 0; i < event.params.executors.length; i++) {
let index = execArr.indexOf(event.params.executors[i]); let index = execArr.indexOf(event.params.executors[i]);
if(statusArr[i] === true){ if (statusArr[i] === true) {
if(index == -1){ if (index == -1) {
execArr.push(event.params.executors[i]); execArr.push(event.params.executors[i]);
} }
} else { } else {
if(index != -1){ if (index != -1) {
execArr.splice(index-1, 1); execArr.splice(index - 1, 1);
} }
} }
} }

View File

@ -4,17 +4,8 @@ import {
Bytes, Bytes,
DataSourceContext, DataSourceContext,
} from "@graphprotocol/graph-ts"; } from "@graphprotocol/graph-ts";
import { import { Account, ExecutionParams, SubmitData, Swap, Spell, ExecuteData, CancelData, SystemCancelData, TransactionData, ChangedOwner, FeeTransferData, SystemCallData, UpdateAutomationFeeData, UpdateBufferHfData, UpdateMinHfData } from "../generated/schema";
InstaIndex, import { InstaAutomation } from "../generated/InstaAutomation/InstaAutomation";
LogAccountCreated,
LogNewAccount,
LogNewCheck,
LogNewMaster,
LogUpdateMaster,
} from "../generated/InstaIndex/InstaIndex";
import { Account, ExecutionParams, SubmitData, Swap, Spell, ExecuteData, ExecuteMetaData, CancelData, SystemCancelData } from "../generated/schema";
import { InstaAutomation } from "../generated/InstaIndex/InstaAutomation";
import { InstaList } from "../generated/InstaIndex/InstaList";
import { InstaAutomation as InstaAutomationABI } from "../generated/templates"; import { InstaAutomation as InstaAutomationABI } from "../generated/templates";
export const ZERO = new BigInt(0); export const ZERO = new BigInt(0);
@ -25,6 +16,7 @@ export function createOrLoadDsa(id: string): Account {
let account = Account.load(id); let account = Account.load(id);
if (account == null) { if (account == null) {
account = new Account(id); account = new Account(id);
account.user = ADDR_ZERO;
} }
return account; return account;
} }
@ -38,10 +30,35 @@ export function createOrLoadSubmit(id: string): SubmitData {
submitData.safeHF = ZERO; submitData.safeHF = ZERO;
submitData.thresholdHF = ZERO; submitData.thresholdHF = ZERO;
submitData.currentHf = ZERO; submitData.currentHf = ZERO;
submitData.transactionDetail = createOrLoadTransaction(id).id;
} }
return submitData; return submitData;
} }
export function createOrLoadTransaction(id: string): TransactionData {
let transactionData = TransactionData.load(id);
if(transactionData == null) {
transactionData = new TransactionData(id);
transactionData.blockNumber = ZERO;
transactionData.timeStamp = ZERO;
transactionData.logIndex = ZERO;
transactionData.transactionHash = ADDR_ZERO;
transactionData.transactionLogIndex = ZERO;
}
return transactionData;
}
export function createOrLoadChangedOwner(id: string): ChangedOwner {
let ownerData = ChangedOwner.load(id);
if(ownerData == null) {
ownerData = new ChangedOwner(id);
ownerData.oldOwner = ADDR_ZERO;
ownerData.newOwner = ADDR_ZERO;
ownerData.transactionDetail = createOrLoadTransaction(id).id;
}
return ownerData;
}
export function createOrLoadExecutionParams(id: string): ExecutionParams { export function createOrLoadExecutionParams(id: string): ExecutionParams {
let params = ExecutionParams.load(id); let params = ExecutionParams.load(id);
if(params == null) { if(params == null) {
@ -72,16 +89,6 @@ export function createOrLoadSwap(id: string): Swap {
return swap; return swap;
} }
export function createOrLoadSpell(id: string): Spell {
let spell = Spell.load(id);
if(spell == null){
spell = new Spell(id);
spell._datas = [];
spell._targets = [];
}
return spell;
}
export function createOrLoadExecute(id: string): ExecuteData { export function createOrLoadExecute(id: string): ExecuteData {
let data = ExecuteData.load(id); let data = ExecuteData.load(id);
if(data == null) { if(data == null) {
@ -93,20 +100,9 @@ export function createOrLoadExecute(id: string): ExecuteData {
data.initialHf = ZERO; data.initialHf = ZERO;
data.automationFee = 0; data.automationFee = 0;
data.params = createOrLoadExecutionParams(id).id; data.params = createOrLoadExecutionParams(id).id;
data.spells = createOrLoadSpell(id).id; data.transactionDetail = createOrLoadTransaction(id).id;
}
return data;
}
export function createOrLoadExecuteMetaData(id: string): ExecuteMetaData {
let data = ExecuteMetaData.load(id);
if(data == null) {
data = new ExecuteMetaData(id);
data.user = ADDR_ZERO;
data.userId = ZERO;
data.nonce = ZERO;
data.isSafe = false; data.isSafe = false;
data.metadata = new Bytes(0); data.metaData = new Bytes(0);
} }
return data; return data;
} }
@ -118,6 +114,7 @@ export function createOrLoadCancelData(id: string): CancelData {
data.user = ADDR_ZERO; data.user = ADDR_ZERO;
data.userId = ZERO; data.userId = ZERO;
data.nonce = ZERO; data.nonce = ZERO;
data.transactionDetail = createOrLoadTransaction(id).id;
} }
return data; return data;
} }
@ -131,6 +128,65 @@ export function createOrLoadSystemCancelData(id: string): SystemCancelData {
data.userId = ZERO; data.userId = ZERO;
data.nonce = ZERO; data.nonce = ZERO;
data.errorCode = 0; data.errorCode = 0;
data.transactionDetail = createOrLoadTransaction(id).id;
}
return data;
}
export function createOrLoadFeeTransferData(id: string): FeeTransferData {
let data = FeeTransferData.load(id);
if(data == null) {
data = new FeeTransferData(id);
data.recipient = ADDR_ZERO;
data.from = ADDR_ZERO;
data.tokens = [];
data.amount = [];
data.transactionDetail = createOrLoadTransaction(id).id;
}
return data;
}
export function createOrLoadSystemCallData(id: string): SystemCallData {
let data = SystemCallData.load(id);
if(data == null) {
data = new SystemCallData(id);
data.sender = ADDR_ZERO;
data.actionId = "";
data.metaData = new Bytes(0);
data.transactionDetail = createOrLoadTransaction(id).id;
}
return data;
}
export function createOrUpdateAutomationFeeData(id: string): UpdateAutomationFeeData {
let data = UpdateAutomationFeeData.load(id);
if(data == null) {
data = new UpdateAutomationFeeData(id);
data.oldAutomationFee = 0;
data.newAutomationFee = 0;
data.transactionDetail = createOrLoadTransaction(id).id;
}
return data;
}
export function createOrUpdateBufferHfData(id: string): UpdateBufferHfData {
let data = UpdateBufferHfData.load(id);
if(data == null) {
data = new UpdateBufferHfData(id);
data.oldBuffer = ZERO;
data.newBuffer = ZERO;
data.transactionDetail = createOrLoadTransaction(id).id;
}
return data;
}
export function createOrUpdateMinHfData(id: string): UpdateMinHfData {
let data = UpdateMinHfData.load(id);
if(data == null) {
data = new UpdateMinHfData(id);
data.oldMinHf = ZERO;
data.newMinHf = ZERO;
data.transactionDetail = createOrLoadTransaction(id).id;
} }
return data; return data;
} }

View File

@ -4,11 +4,11 @@ schema:
dataSources: dataSources:
- kind: ethereum - kind: ethereum
name: InstaAutomation name: InstaAutomation
network: avalanche network: matic
source: source:
abi: InstaAutomation abi: InstaAutomation
address: "0x08c1c01be430C9381AD2794412C3E940254CD97c" address: "0x3cF499Dbd2aBB6505f48Db27a9871523A38e6e2C"
startBlock: 18160000 startBlock: 31471200
mapping: mapping:
kind: ethereum/events kind: ethereum/events
apiVersion: 0.0.5 apiVersion: 0.0.5
@ -24,24 +24,36 @@ dataSources:
- CancelData - CancelData
- SystemCancelData - SystemCancelData
- Executors - Executors
- Spell - ChangedOwner
- Swap - FeeTransferData
- ExceutionParams - SystemCallData
- UpdateAutomationFeeData
- UpdateBufferHfData
- UpdateMinHfData
eventHandlers: eventHandlers:
- event: LogCancelledAutomation(indexed address,indexed uint32,indexed uint32) - event: LogCancelledAutomation(indexed address,indexed uint32,indexed uint32)
handler: handleLogCancelAutomation handler: handleLogCancelAutomation
- event: LogSubmittedAutomation(indexed address,indexed
uint32,uint128,uint128,uint128)
handler: handleLogSubmitAutomation
- event: LogExecutedAutomationParams(indexed address,indexed uint32,indexed
uint32,uint128,uint128,uint16,(address,address,uint256,uint256,uint256,(address,address,uint256,uint256,bytes),uint256,uint256),(string[],bytes[]))
handler: handleLogExecuteAutomation
- event: LogExecutedAutomation(indexed address,indexed uint32,indexed - event: LogExecutedAutomation(indexed address,indexed uint32,indexed
uint32,bool,bytes) uint32,(address,address,uint256,uint256,uint256,(address,address,uint256,uint256,bytes),uint256,uint256),bool,uint16,bytes,uint128,uint128)
handler: handleLogExecuteAutomationMetadata handler: handleLogExecuteAutomation
- event: LogFeeTransferred(indexed address,address[],uint256[])
handler: handleLogFeeTransferred
- event: LogFlippedExecutors(address[],bool[])
handler: handleExecutors
- event: LogSystemCall(indexed address,string,bytes)
handler: handleLogSystemCall
- event: LogSystemCancelledAutomation(indexed address,indexed uint32,indexed - event: LogSystemCancelledAutomation(indexed address,indexed uint32,indexed
uint32,uint8) uint32,uint8)
handler: handleSystemCancelledAutomation handler: handleSystemCancelledAutomation
- event: LogFlippedExecutors(address[],bool[]) - event: LogUpdatedAutomationFee(uint16,uint16)
handler: handleExecutors handler: handleLogUpdateAutomationFee
- event: LogUpdatedBufferHf(uint128,uint128)
handler: handleUpdatedBufferHf
- event: LogUpdatedMinHf(uint128,uint128)
handler: handleLogUpdatedMinHf
- event: LogSubmittedAutomation(indexed address,indexed
uint32,uint128,uint128,uint128)
handler: handleLogSubmitAutomation
- event: LogChangedOwner(indexed address,indexed address)
handler: handleLogChangedOwner
file: ./src/insta-automation.ts file: ./src/insta-automation.ts