Skip to content

Commit

Permalink
Config acala lsd staking (#75)
Browse files Browse the repository at this point in the history
* config lsd-staking for Acala

* update proxy address on Acala

* update start block
  • Loading branch information
wangjj9219 authored Sep 20, 2023
1 parent 3505b5b commit 7797762
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
8 changes: 4 additions & 4 deletions packages/lsd-staking/lsd.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"type": "uint256"
}
],
"name": "LSDPoolConverted",
"name": "LSTPoolConverted",
"type": "event"
},
{
Expand Down Expand Up @@ -454,7 +454,7 @@
"type": "uint256"
}
],
"internalType": "struct UpgradeableStakingLSD.ConvertInfo",
"internalType": "struct UpgradeableStakingLST.ConvertInfo",
"name": "",
"type": "tuple"
}
Expand All @@ -470,12 +470,12 @@
"type": "uint256"
},
{
"internalType": "enum UpgradeableStakingLSD.ConvertType",
"internalType": "enum UpgradeableStakingLST.ConvertType",
"name": "convertType",
"type": "uint8"
}
],
"name": "convertLSDPool",
"name": "convertLSTPool",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down
12 changes: 6 additions & 6 deletions packages/lsd-staking/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ runner:
schema:
file: ./schema.graphql
network:
chainId: "0x3035b88c212be330a1a724c675d56d53a5016ec32af1790738832db0227ac54c"
endpoint: wss://mandala-tc9-rpc.aca-staging.network
chainId: "0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c"
endpoint: wss://acala-rpc-1.aca-api.network
chaintypes:
file: './dist/chain-types.js'
dataSources:
- kind: substrate/AcalaEvm
startBlock: 560000
startBlock: 4538300
processor:
file: "./node_modules/@subql/acala-evm-processor/dist/bundle.js"
options:
abi: lsd
address: "0x6dd151013dfce4a6bd3353c89373227ae90d9aa1"
address: "0x7fe92ec600f15cd25253b421bc151c51b0276b7d"
assets:
lsd:
file: "./lsd.abi.json"
Expand Down Expand Up @@ -61,8 +61,8 @@ dataSources:
filter:
topics:
- ClaimReward(address sender, uint256 poolId, IERC20 rewardType, uint256 amount)
- handler: handleLSDPoolConverted
- handler: handleLSTPoolConverted
kind: substrate/AcalaEvmEvent
filter:
topics:
- LSDPoolConverted(uint256 poolId, address beforeShareType, address afterShareType, uint256 beforeShareTokenAmount, uint256 afterShareTokenAmount)
- LSTPoolConverted(uint256 poolId, address beforeShareType, address afterShareType, uint256 beforeShareTokenAmount, uint256 afterShareTokenAmount)
2 changes: 1 addition & 1 deletion packages/lsd-staking/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type ClaimRewardRecord @entity {
amount: BigInt!
}

type LSDPoolConvertedRecord @entity {
type LSTPoolConvertedRecord @entity {
id: ID!

blockTimestamp: Date!
Expand Down
12 changes: 6 additions & 6 deletions packages/lsd-staking/src/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AcalaEvmEvent } from '@subql/acala-evm-processor';
import { NewPoolEvent, RewardsDeductionRateSetEvent, RewardRuleUpdateEvent, StakeEvent, UnstakeEvent, ClaimRewardEvent, LSDPoolConvertedEvent } from '../types/contracts/LsdAbi';
import { Pool, RewardRule, ClaimedReward, RewardSupply, NewPoolRecord, RewardsDeductionRateSetRecord, RewardRuleUpdateRecord, StakeRecord, UnstakeRecord, ClaimRewardRecord, LSDPoolConvertedRecord } from '../types';
import { NewPoolEvent, RewardsDeductionRateSetEvent, RewardRuleUpdateEvent, StakeEvent, UnstakeEvent, ClaimRewardEvent, LSTPoolConvertedEvent } from '../types/contracts/LsdAbi';
import { Pool, RewardRule, ClaimedReward, RewardSupply, NewPoolRecord, RewardsDeductionRateSetRecord, RewardRuleUpdateRecord, StakeRecord, UnstakeRecord, ClaimRewardRecord, LSTPoolConvertedRecord } from '../types';

export async function handleNewPool(
event: AcalaEvmEvent<NewPoolEvent['args']>
Expand Down Expand Up @@ -116,18 +116,18 @@ export async function handleClaimReward(
await claimRewardRecordEntity.save();
}

export async function handleLSDPoolConverted(
event: AcalaEvmEvent<LSDPoolConvertedEvent['args']>
export async function handleLSTPoolConverted(
event: AcalaEvmEvent<LSTPoolConvertedEvent['args']>
): Promise<void> {

const [poolId, beforeShareType, afterShareType, beforeShareTokenAmount, afterShareTokenAmount] = event.args;
logger.info('LSDPoolConverted: {}', [poolId, beforeShareType, afterShareType, beforeShareTokenAmount, afterShareTokenAmount]);
logger.info('LSTPoolConverted: {}', [poolId, beforeShareType, afterShareType, beforeShareTokenAmount, afterShareTokenAmount]);

const poolIdEntity = await Pool.get(poolId.toString());
poolIdEntity.convertedType = afterShareType.toString();
poolIdEntity.convertedExchangeRate = afterShareTokenAmount.toBigInt() * BigInt(10 ^ 18) / beforeShareTokenAmount.toBigInt();
await poolIdEntity.save();

const lsdPoolConvertedRecordEntity = new LSDPoolConvertedRecord(`${event.transactionHash}-${event.logIndex}`, event.blockTimestamp, event.from, poolId.toBigInt(), beforeShareType.toString(), afterShareType.toString(), beforeShareTokenAmount.toBigInt(), afterShareTokenAmount.toBigInt());
const lsdPoolConvertedRecordEntity = new LSTPoolConvertedRecord(`${event.transactionHash}-${event.logIndex}`, event.blockTimestamp, event.from, poolId.toBigInt(), beforeShareType.toString(), afterShareType.toString(), beforeShareTokenAmount.toBigInt(), afterShareTokenAmount.toBigInt());
await lsdPoolConvertedRecordEntity.save();
}
6 changes: 3 additions & 3 deletions packages/lsd-staking/src/types/abi-interfaces/LsdAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

InitializedEvent,

LSDPoolConvertedEvent,
LSTPoolConvertedEvent,

NewPoolEvent,

Expand Down Expand Up @@ -37,7 +37,7 @@ import {

export type InitializedLog = EthereumLog<InitializedEvent["args"]>

export type LSDPoolConvertedLog = EthereumLog<LSDPoolConvertedEvent["args"]>
export type LSTPoolConvertedLog = EthereumLog<LSTPoolConvertedEvent["args"]>

export type NewPoolLog = EthereumLog<NewPoolEvent["args"]>

Expand Down Expand Up @@ -84,7 +84,7 @@ import {

export type ConvertInfosTransaction = EthereumTransaction<Parameters<LsdAbi['functions']['convertInfos']>>

export type ConvertLSDPoolTransaction = EthereumTransaction<Parameters<LsdAbi['functions']['convertLSDPool']>>
export type ConvertLSTPoolTransaction = EthereumTransaction<Parameters<LsdAbi['functions']['convertLSTPool']>>

export type EarnedTransaction = EthereumTransaction<Parameters<LsdAbi['functions']['earned']>>

Expand Down
48 changes: 24 additions & 24 deletions packages/lsd-staking/src/types/contracts/LsdAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {
PromiseOrValue,
} from "./common";

export declare namespace UpgradeableStakingLSD {
export declare namespace UpgradeableStakingLST {
export type ConvertInfoStruct = {
convertedShareType: PromiseOrValue<string>;
convertedExchangeRate: PromiseOrValue<BigNumberish>;
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface LsdAbiInterface extends utils.Interface {
"addPool(address)": FunctionFragment;
"claimRewards(uint256)": FunctionFragment;
"convertInfos(uint256)": FunctionFragment;
"convertLSDPool(uint256,uint8)": FunctionFragment;
"convertLSTPool(uint256,uint8)": FunctionFragment;
"earned(uint256,address,address)": FunctionFragment;
"exit(uint256)": FunctionFragment;
"initialize()": FunctionFragment;
Expand Down Expand Up @@ -120,7 +120,7 @@ export interface LsdAbiInterface extends utils.Interface {
| "addPool"
| "claimRewards"
| "convertInfos"
| "convertLSDPool"
| "convertLSTPool"
| "earned"
| "exit"
| "initialize()"
Expand Down Expand Up @@ -185,7 +185,7 @@ export interface LsdAbiInterface extends utils.Interface {
values: [PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "convertLSDPool",
functionFragment: "convertLSTPool",
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
Expand Down Expand Up @@ -344,7 +344,7 @@ export interface LsdAbiInterface extends utils.Interface {
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "convertLSDPool",
functionFragment: "convertLSTPool",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "earned", data: BytesLike): Result;
Expand Down Expand Up @@ -423,7 +423,7 @@ export interface LsdAbiInterface extends utils.Interface {
events: {
"ClaimReward(address,uint256,address,uint256)": EventFragment;
"Initialized(uint8)": EventFragment;
"LSDPoolConverted(uint256,address,address,uint256,uint256)": EventFragment;
"LSTPoolConverted(uint256,address,address,uint256,uint256)": EventFragment;
"NewPool(uint256,address)": EventFragment;
"OperationPauseStatusSet(uint256,uint8,bool)": EventFragment;
"OwnershipTransferred(address,address)": EventFragment;
Expand All @@ -437,7 +437,7 @@ export interface LsdAbiInterface extends utils.Interface {

getEvent(nameOrSignatureOrTopic: "ClaimReward"): EventFragment;
getEvent(nameOrSignatureOrTopic: "Initialized"): EventFragment;
getEvent(nameOrSignatureOrTopic: "LSDPoolConverted"): EventFragment;
getEvent(nameOrSignatureOrTopic: "LSTPoolConverted"): EventFragment;
getEvent(nameOrSignatureOrTopic: "NewPool"): EventFragment;
getEvent(nameOrSignatureOrTopic: "OperationPauseStatusSet"): EventFragment;
getEvent(nameOrSignatureOrTopic: "OwnershipTransferred"): EventFragment;
Expand Down Expand Up @@ -469,20 +469,20 @@ export type InitializedEvent = TypedEvent<[number], InitializedEventObject>;

export type InitializedEventFilter = TypedEventFilter<InitializedEvent>;

export interface LSDPoolConvertedEventObject {
export interface LSTPoolConvertedEventObject {
poolId: BigNumber;
beforeShareType: string;
afterShareType: string;
beforeShareTokenAmount: BigNumber;
afterShareTokenAmount: BigNumber;
}
export type LSDPoolConvertedEvent = TypedEvent<
export type LSTPoolConvertedEvent = TypedEvent<
[BigNumber, string, string, BigNumber, BigNumber],
LSDPoolConvertedEventObject
LSTPoolConvertedEventObject
>;

export type LSDPoolConvertedEventFilter =
TypedEventFilter<LSDPoolConvertedEvent>;
export type LSTPoolConvertedEventFilter =
TypedEventFilter<LSTPoolConvertedEvent>;

export interface NewPoolEventObject {
poolId: BigNumber;
Expand Down Expand Up @@ -641,9 +641,9 @@ export interface LsdAbi extends BaseContract {
convertInfos(
poolId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<[UpgradeableStakingLSD.ConvertInfoStructOutput]>;
): Promise<[UpgradeableStakingLST.ConvertInfoStructOutput]>;

convertLSDPool(
convertLSTPool(
poolId: PromiseOrValue<BigNumberish>,
convertType: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
Expand Down Expand Up @@ -831,9 +831,9 @@ export interface LsdAbi extends BaseContract {
convertInfos(
poolId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<UpgradeableStakingLSD.ConvertInfoStructOutput>;
): Promise<UpgradeableStakingLST.ConvertInfoStructOutput>;

convertLSDPool(
convertLSTPool(
poolId: PromiseOrValue<BigNumberish>,
convertType: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
Expand Down Expand Up @@ -1021,9 +1021,9 @@ export interface LsdAbi extends BaseContract {
convertInfos(
poolId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<UpgradeableStakingLSD.ConvertInfoStructOutput>;
): Promise<UpgradeableStakingLST.ConvertInfoStructOutput>;

convertLSDPool(
convertLSTPool(
poolId: PromiseOrValue<BigNumberish>,
convertType: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
Expand Down Expand Up @@ -1187,20 +1187,20 @@ export interface LsdAbi extends BaseContract {
"Initialized(uint8)"(version?: null): InitializedEventFilter;
Initialized(version?: null): InitializedEventFilter;

"LSDPoolConverted(uint256,address,address,uint256,uint256)"(
"LSTPoolConverted(uint256,address,address,uint256,uint256)"(
poolId?: null,
beforeShareType?: null,
afterShareType?: null,
beforeShareTokenAmount?: null,
afterShareTokenAmount?: null
): LSDPoolConvertedEventFilter;
LSDPoolConverted(
): LSTPoolConvertedEventFilter;
LSTPoolConverted(
poolId?: null,
beforeShareType?: null,
afterShareType?: null,
beforeShareTokenAmount?: null,
afterShareTokenAmount?: null
): LSDPoolConvertedEventFilter;
): LSTPoolConvertedEventFilter;

"NewPool(uint256,address)"(
poolId?: null,
Expand Down Expand Up @@ -1315,7 +1315,7 @@ export interface LsdAbi extends BaseContract {
overrides?: CallOverrides
): Promise<BigNumber>;

convertLSDPool(
convertLSTPool(
poolId: PromiseOrValue<BigNumberish>,
convertType: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
Expand Down Expand Up @@ -1508,7 +1508,7 @@ export interface LsdAbi extends BaseContract {
overrides?: CallOverrides
): Promise<PopulatedTransaction>;

convertLSDPool(
convertLSTPool(
poolId: PromiseOrValue<BigNumberish>,
convertType: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const _abi = [
type: "uint256",
},
],
name: "LSDPoolConverted",
name: "LSTPoolConverted",
type: "event",
},
{
Expand Down Expand Up @@ -462,7 +462,7 @@ const _abi = [
type: "uint256",
},
],
internalType: "struct UpgradeableStakingLSD.ConvertInfo",
internalType: "struct UpgradeableStakingLST.ConvertInfo",
name: "",
type: "tuple",
},
Expand All @@ -478,12 +478,12 @@ const _abi = [
type: "uint256",
},
{
internalType: "enum UpgradeableStakingLSD.ConvertType",
internalType: "enum UpgradeableStakingLST.ConvertType",
name: "convertType",
type: "uint8",
},
],
name: "convertLSDPool",
name: "convertLSTPool",
outputs: [],
stateMutability: "nonpayable",
type: "function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import assert from 'assert';



export type LSDPoolConvertedRecordProps = Omit<LSDPoolConvertedRecord, NonNullable<FunctionPropertyNames<LSDPoolConvertedRecord>>| '_name'>;
export type LSTPoolConvertedRecordProps = Omit<LSTPoolConvertedRecord, NonNullable<FunctionPropertyNames<LSTPoolConvertedRecord>>| '_name'>;

export class LSDPoolConvertedRecord implements Entity {
export class LSTPoolConvertedRecord implements Entity {

constructor(

Expand Down Expand Up @@ -66,32 +66,32 @@ export class LSDPoolConvertedRecord implements Entity {


get _name(): string {
return 'LSDPoolConvertedRecord';
return 'LSTPoolConvertedRecord';
}

async save(): Promise<void>{
let id = this.id;
assert(id !== null, "Cannot save LSDPoolConvertedRecord entity without an ID");
await store.set('LSDPoolConvertedRecord', id.toString(), this);
assert(id !== null, "Cannot save LSTPoolConvertedRecord entity without an ID");
await store.set('LSTPoolConvertedRecord', id.toString(), this);
}
static async remove(id:string): Promise<void>{
assert(id !== null, "Cannot remove LSDPoolConvertedRecord entity without an ID");
await store.remove('LSDPoolConvertedRecord', id.toString());
assert(id !== null, "Cannot remove LSTPoolConvertedRecord entity without an ID");
await store.remove('LSTPoolConvertedRecord', id.toString());
}

static async get(id:string): Promise<LSDPoolConvertedRecord | undefined>{
assert((id !== null && id !== undefined), "Cannot get LSDPoolConvertedRecord entity without an ID");
const record = await store.get('LSDPoolConvertedRecord', id.toString());
static async get(id:string): Promise<LSTPoolConvertedRecord | undefined>{
assert((id !== null && id !== undefined), "Cannot get LSTPoolConvertedRecord entity without an ID");
const record = await store.get('LSTPoolConvertedRecord', id.toString());
if (record){
return this.create(record as LSDPoolConvertedRecordProps);
return this.create(record as LSTPoolConvertedRecordProps);
}else{
return;
}
}



static create(record: LSDPoolConvertedRecordProps): LSDPoolConvertedRecord {
static create(record: LSTPoolConvertedRecordProps): LSTPoolConvertedRecord {
assert(typeof record.id === 'string', "id must be provided");
let entity = new this(

Expand Down
Loading

0 comments on commit 7797762

Please sign in to comment.