Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ npm install @alphafi/alphalend-sdk
an ESM context or via a bundler.
- **No `postinstall` / patches.** Earlier work-in-progress used a `patch-package`
hook to fix `@naviprotocol/lending` under v2; that would have broken consumer
installs. The flash-loan helpers are now vendored (`src/vendor/naviFlashloan.ts`),
so installing this package runs no lifecycle scripts and pulls no Navi dependency.
installs. The flash-loan helpers now come from `@naviprotocol/lending@^2`
(a runtime dependency), which is `@mysten/sui` v2-native and import-safe — the
previous vendored copy has been removed. Installing this package still runs no
lifecycle scripts. (NAVI v2's split `.d.ts` don't resolve under
`moduleResolution: NodeNext`, so a small local declaration shim,
`src/naviprotocol-lending.d.ts`, types the flash-loan helpers; the runtime
bundle itself is unaffected.)

## Getting Started

Expand Down
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"@7kprotocol/sdk-ts": "^3.4.1",
"@cetusprotocol/aggregator-sdk": "^1.5.5",
"@naviprotocol/lending": "2.0.3",
"@pythnetwork/pyth-sui-js": "^2.2.0",
"@types/bn.js": "^5.2.0",
"decimal.js": "^10.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/core/flashRepay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
flashloanPTB,
repayFlashLoanPTB,
getAllFlashLoanAssets,
} from "../vendor/naviFlashloan.js";
} from "@naviprotocol/lending";
import { Decimal } from "decimal.js";
import { FlashRepayParams } from "./types.js";
import type { AlphalendClient } from "./client.js";
Expand Down
41 changes: 41 additions & 0 deletions src/naviprotocol-lending.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// NAVI v2 (@naviprotocol/lending) ships ESM `.d.ts` files with extensionless
// relative re-exports, which don't resolve under `moduleResolution: NodeNext`
// (the runtime bundle is a single self-contained file and works fine). Declare
// the flash-loan helpers we use so they type-resolve. Remove if NAVI fixes
// their packaging.
declare module "@naviprotocol/lending" {
Comment thread
Zorag44 marked this conversation as resolved.
type NaviTx = import("@mysten/sui/transactions").Transaction;
type NaviTxResult = import("@mysten/sui/transactions").TransactionResult;

export function getAllFlashLoanAssets(options?: {
env?: "prod" | "dev";
cacheTime?: number;
disableCache?: boolean;
market?: string;
}): Promise<
Array<{
max: string;
min: string;
assetId: number;
poolId: string;
supplierFee: number;
flashloanFee: number;
coinType: string;
}>
>;

export function flashloanPTB(
tx: NaviTx,
identifier: string,
amount: number | NaviTxResult,
options?: { env?: "prod" | "dev"; market?: string },
): Promise<NaviTxResult[]>;

export function repayFlashLoanPTB(
tx: NaviTx,
identifier: string,
receipt: NaviTxResult | string,
coinObject: NaviTxResult | string,
options?: { env?: "prod" | "dev"; market?: string },
): Promise<NaviTxResult[]>;
}
Loading
Loading