Skip to content

Commit 428ac5c

Browse files
🧹 Stargate state snapshot: Collection Token information [5/N] (#24)
1 parent 05a4cf8 commit 428ac5c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

‎packages/stg-evm-v2/devtools/src/asset/sdk.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export class Asset extends Ownable implements IAsset {
7979
}
8080
}
8181

82+
@AsyncRetriable()
83+
async getToken(): Promise<OmniAddress | undefined> {
84+
return ignoreZero(await this.contract.contract.token())
85+
}
86+
8287
@AsyncRetriable()
8388
async getLPToken(): Promise<OmniAddress | undefined> {
8489
// We want to return undefined if there is no lpToken function defined on the asset as opposed to throwing

‎packages/stg-evm-v2/devtools/src/asset/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface IAsset extends IOmniSDK, IOwnable {
3434
isPaused(): Promise<boolean>
3535
setPaused(pause: boolean): Promise<OmniTransaction>
3636

37+
getToken(): Promise<OmniAddress | undefined>
3738
getLPToken(): Promise<OmniAddress | undefined>
3839
}
3940

‎packages/stg-evm-v2/tasks/snapshot.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,12 @@ const createCollectAsset =
172172
const sdk = await createSdk(point)
173173

174174
logger.verbose(`Collecting basic information`)
175-
const [owner, paused, addressConfig, lpTokenAddress] = await Promise.all([
175+
const [owner, paused, addressConfig, lpTokenAddress, tokenAddress] = await Promise.all([
176176
sdk.getOwner(),
177177
sdk.isPaused(),
178178
sdk.getAddressConfig(),
179179
sdk.getLPToken(),
180+
sdk.getToken(),
180181
])
181182

182183
// Now we'll check the OFT paths
@@ -199,13 +200,17 @@ const createCollectAsset =
199200
const lpToken =
200201
lpTokenAddress == null ? undefined : await collectERC20({ address: lpTokenAddress, eid: point.eid })
201202

203+
// If the asset has an LP token attached, we'll collect its information
204+
const token = tokenAddress == null ? undefined : await collectERC20({ address: tokenAddress, eid: point.eid })
205+
202206
// For now we'll collect nothing at all
203207
const snapshot: AssetSnapshot = {
204208
address: point.address,
205209
addressConfig,
206210
owner,
207211
paused,
208212
lpToken,
213+
token,
209214
oftPaths: oftPaths.flat(),
210215
}
211216

@@ -313,6 +318,7 @@ interface AssetSnapshot {
313318
address: OmniAddress
314319
addressConfig: AddressConfig
315320
lpToken?: ERC20TokenSnapshot
321+
token?: ERC20TokenSnapshot
316322
oftPaths: OFTPath[]
317323
}
318324

0 commit comments

Comments
 (0)