Skip to content

Commit

Permalink
support ctoken
Browse files Browse the repository at this point in the history
  • Loading branch information
0xodia committed Jan 10, 2025
1 parent 2d0445d commit 48c5213
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion solend-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solendprotocol/solend-sdk",
"version": "0.13.38",
"version": "0.13.39",
"private": true,
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
10 changes: 7 additions & 3 deletions solend-sdk/src/core/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type ActionConfigType = {
type SupportType =
| "wrap"
| "unwrap"
| "refreshReserve"
| "refreshReserves"
| "refreshObligation"
| "createObligation"
Expand All @@ -121,7 +122,7 @@ const ACTION_SUPPORT_REQUIREMENTS: {
],
repay: ["wsol", "wrap"],
mint: ["wsol", "wrap", "cAta"],
redeem: ["wsol", "ata", "refreshReserves", "unwrap"],
redeem: ["wsol", "ata", "refreshReserve", "unwrap"],
depositCollateral: ["createObligation"],
withdrawCollateral: ["cAta", "refreshReserves", "refreshObligation"],
forgive: ["refreshReserves", "refreshObligation"],
Expand Down Expand Up @@ -1157,6 +1158,9 @@ export class SolendActionCore {
await this.addUnwrapIx();
}
break;
case "refreshReserve":
await this.addRefreshReservesIxs(true);
break;
case "refreshReserves":
await this.addRefreshReservesIxs();
break;
Expand Down Expand Up @@ -1468,15 +1472,15 @@ export class SolendActionCore {
}
}

private async addRefreshReservesIxs() {
private async addRefreshReservesIxs(singleReserve?: boolean) {
// Union of addresses
const reserveMap = this.pool.reserves.reduce((acc, reserve) => {
acc[reserve.address] = reserve;
return acc;
}, {} as Record<string, ReserveType>);

const allReserveAddresses = Array.from(
new Set([
new Set(singleReserve ? [this.reserve.address] : [
...this.depositReserves.map((e) => e.toBase58()),
...this.borrowReserves.map((e) => e.toBase58()),
this.reserve.address,
Expand Down
2 changes: 2 additions & 0 deletions solend-sdk/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type TokenMetadata = {
symbol: string;
logoUri: string | undefined;
decimals: number;
underlyingToken?: string;
};
};

Expand All @@ -41,6 +42,7 @@ export type WalletAssetType = {
decimals: number;
address: string;
logo?: string;
underlyingToken?: string;
};

export type WalletType = Array<WalletAssetType>;
Expand Down
1 change: 1 addition & 0 deletions solend-sdk/src/core/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function formatWalletAssets(
? `w${nativeTokenSymbol}`
: mintAddress,
logoUri: tokenMetadata?.logoUri,
underlyingToken: tokenMetadata?.underlyingToken,
};
})
.filter(Boolean) as WalletType;
Expand Down

0 comments on commit 48c5213

Please sign in to comment.