Skip to content

Commit

Permalink
feat: updated AptosProvider, examples and contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsc0x committed Oct 14, 2024
1 parent a0c5c3c commit 0aa527a
Show file tree
Hide file tree
Showing 24 changed files with 235 additions and 136 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Account, AccountAddress, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { UnderlyingTokensClient } from "../src/clients/underlyingTokensClient";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider } from "../src/clients";
import { testnetConfig } from "../src/configs/testnet";
import { UnderlyingTokensClient } from "../../src/clients/underlyingTokensClient";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider } from "../../src/clients";
import { testnetConfig } from "../../src/configs/testnet";

const UNDERLYING_MANAGER_PRIVATE_KEY = "0x0";
const ADDRESSES_TO_FUND = ["0x0"].map((addr) =>
Expand All @@ -12,7 +12,7 @@ const fundAmount = BigInt(1000);

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
// all underlying-tokens-related operations client
const underlyingTokensClient = new UnderlyingTokensClient(aptosProvider);
// all pool-related operations client
Expand Down
10 changes: 4 additions & 6 deletions examples/setAssetsPrice.ts → examples/admin/setAssetPrices.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable no-console */
/* eslint-disable no-await-in-loop */
import dotenv from "dotenv";
import { Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { OracleClient, PoolClient } from "../src/clients";
import { AptosProvider } from "../src/clients/aptosProvider";
import { testnetConfig } from "../src/configs/testnet";
import { OracleClient, PoolClient } from "../../src/clients";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { testnetConfig } from "../../src/configs/testnet";

dotenv.config();

Expand All @@ -17,7 +15,7 @@ const priceMapper = {

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);

if (!process.env.AAVE_MOCK_ORACLE_PRIVATE_KEY) {
throw new Error(`AAVE_MOCK_ORACLE_PRIVATE_KEY env was not found`);
Expand Down
9 changes: 4 additions & 5 deletions examples/setupTtestnet.ts → examples/admin/setupTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-await-in-loop */
import dotenv from "dotenv";
import { Account, AccountAddress, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { AptosProvider } from "../src/clients/aptosProvider";
import { testnetConfig } from "../src/configs/testnet";
import { PoolClient, UnderlyingTokensClient } from "../src/clients";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { testnetConfig } from "../../src/configs/testnet";
import { PoolClient, UnderlyingTokensClient } from "../../src/clients";

dotenv.config();

Expand Down Expand Up @@ -130,7 +129,7 @@ const poolSigner = Account.fromPrivateKey({
});

(async () => {
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);

const poolClient = new PoolClient(aptosProvider, poolSigner);
const underlyingTokenClient = new UnderlyingTokensClient(
Expand Down
8 changes: 4 additions & 4 deletions examples/borrow.ts → examples/users/borrow.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Account, Ed25519Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../src/clients";
import { testnetConfig } from "../src/configs/testnet";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../../src/clients";
import { testnetConfig } from "../../src/configs/testnet";

const USER_APTOS_ACCOUNT_PRIVATE_KEY = "0x0";
const CURRENCY_TO_BORROW = "DAI";
const AMOUNT_TO_BORROW = "100";

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
// all pool-related operations client
const poolClient = new PoolClient(aptosProvider);
// user account
Expand Down
8 changes: 4 additions & 4 deletions examples/getAddresses.ts → examples/users/getAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AptosProvider } from "../src/clients";
import { PoolAddressesProviderClient } from "../src/clients/poolAddressesProviderClient";
import { testnetConfig } from "../src/configs/testnet";
import { AptosProvider } from "../../src/clients";
import { PoolAddressesProviderClient } from "../../src/clients/poolAddressesProviderClient";
import { testnetConfig } from "../../src/configs/testnet";

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);

// pool addresses provider
const poolAddressesProviderClient = new PoolAddressesProviderClient(
Expand Down
6 changes: 3 additions & 3 deletions examples/getAptos.ts → examples/users/getAptos.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Account, AccountAddress, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { AptosProvider } from "../src/clients";
import { testnetConfig } from "../src/configs/testnet";
import { AptosProvider } from "../../src/clients";
import { testnetConfig } from "../../src/configs/testnet";

const aptFunderPrivateKey = "0x0";
const addressesToFund = ["0x0"].map((addr) => AccountAddress.fromString(addr));
const fundAmount = BigInt(0.5);

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);

try {
// set the tx sender
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ATokensClient } from "../src/clients/aTokensClient";
import { UnderlyingTokensClient } from "../src/clients/underlyingTokensClient";
import { UiPoolDataProviderClient } from "../src/clients/uiPoolDataProvider";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider } from "../src/clients/aptosProvider";
import { testnetConfig } from "../src/configs/testnet";
import { VariableTokensClient } from "../src/clients/variableTokensClient";
import { ATokensClient } from "../../src/clients/aTokensClient";
import { UnderlyingTokensClient } from "../../src/clients/underlyingTokensClient";
import { UiPoolDataProviderClient } from "../../src/clients/uiPoolDataProvider";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { testnetConfig } from "../../src/configs/testnet";
import { VariableTokensClient } from "../../src/clients/variableTokensClient";

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);

// all atokens-related operations client
const aTokensClient = new ATokensClient(aptosProvider);
Expand Down
12 changes: 6 additions & 6 deletions examples/getUserData.ts → examples/users/getUserData.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { AccountAddress } from "@aptos-labs/ts-sdk";
import { UnderlyingTokensClient } from "../src/clients/underlyingTokensClient";
import { UiPoolDataProviderClient } from "../src/clients/uiPoolDataProvider";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider } from "../src/clients/aptosProvider";
import { testnetConfig } from "../src/configs/testnet";
import { UnderlyingTokensClient } from "../../src/clients/underlyingTokensClient";
import { UiPoolDataProviderClient } from "../../src/clients/uiPoolDataProvider";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { testnetConfig } from "../../src/configs/testnet";

const USER_APTOS_ACCOUNT = "0x0";

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);

const uiPoolDataProviderClient = new UiPoolDataProviderClient(aptosProvider);
const poolClient = new PoolClient(aptosProvider);
Expand Down
8 changes: 4 additions & 4 deletions examples/repay.ts → examples/users/repay.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Account, Ed25519Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { MaxUint256 } from "ethers";
import { BigNumber } from "bignumber.js";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../src/clients";
import { testnetConfig } from "../src/configs/testnet";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../../src/clients";
import { testnetConfig } from "../../src/configs/testnet";

const USER_APTOS_ACCOUNT_PRIVATE_KEY = "0x0";
const CURRENCY_TO_REPAY = "DAI";
Expand All @@ -12,7 +12,7 @@ const USE_A_TOKENS = true;

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
// all pool-related operations client
const poolClient = new PoolClient(aptosProvider);
// user account
Expand Down
13 changes: 5 additions & 8 deletions examples/supply.ts → examples/users/supply.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
/* eslint-disable no-console */
/* eslint-disable no-await-in-loop */
import { Account, Ed25519Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../src/clients";
import { testnetConfig } from "../src/configs/testnet";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../../src/clients";
import { testnetConfig } from "../../src/configs/testnet";

const USER_APTOS_ACCOUNT_PRIVATE_KEY =
"0xf5e502058d6995bccf625107f12f138cc4ff3f57b1487a256a6dec23f338f831";
const USER_APTOS_ACCOUNT_PRIVATE_KEY = "0x0";
const CURRENCY_TO_SUPPLY = "DAI";
const AMOUNT_TO_SUPPLY = "100";

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
// all pool-related operations client
const poolClient = new PoolClient(aptosProvider);
// user account
Expand Down
13 changes: 5 additions & 8 deletions examples/withdraw.ts → examples/users/withdraw.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
/* eslint-disable no-console */
/* eslint-disable no-await-in-loop */
import { Account, Ed25519Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { PoolClient } from "../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../src/clients";
import { testnetConfig } from "../src/configs/testnet";
import { PoolClient } from "../../src/clients/poolClient";
import { AptosProvider, CoreClient } from "../../src/clients";
import { testnetConfig } from "../../src/configs/testnet";

const USER_APTOS_ACCOUNT_PRIVATE_KEY =
"0xf5e502058d6995bccf625107f12f138cc4ff3f57b1487a256a6dec23f338f831";
const USER_APTOS_ACCOUNT_PRIVATE_KEY = "0x0";
const CURRENCY_TO_WITHDRAW = "DAI";
const AMOUNT_TO_WITHDRAW = "100";

(async () => {
// global aptos provider
const aptosProvider = new AptosProvider(testnetConfig);
const aptosProvider = AptosProvider.fromConfig(testnetConfig);
// all pool-related operations client
const poolClient = new PoolClient(aptosProvider);
// user account
Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
"update-version-patch": "pnpm version patch",
"test": "jest",
"test:cov": "jest --coverage",
"supply": "ts-node examples/supply.ts",
"borrow": "ts-node examples/borrow.ts",
"withdraw": "ts-node examples/withdraw.ts",
"repay": "ts-node examples/repay.ts",
"get-aptos": "ts-node examples/getAptos.ts",
"get-addresses": "ts-node examples/getAddresses.ts",
"get-user-data": "ts-node examples/getUserData.ts",
"setup-testnet": "ts-node examples/setupTestnet.ts",
"supply": "ts-node examples/users/supply.ts",
"borrow": "ts-node examples/users/borrow.ts",
"withdraw": "ts-node examples/users/withdraw.ts",
"repay": "ts-node examples/users/repay.ts",
"get-aptos": "ts-node examples/quiries/getAptos.ts",
"get-addresses": "ts-node examples/quiries/getAddresses.ts",
"get-user-data": "ts-node examples/quiries/getUserData.ts",
"setup-testnet": "ts-node examples/admin/setupTestnet.ts",
"mint-underlyings": "ts-node examples/admin/mintUnderlyings.ts",
"set-asset-prices": "ts-node examples/admin/setAssetPrices.ts",
"lint": "eslint . --no-cache --ignore-pattern 'bundle.js'",
"lint:fix": "eslint . --fix --no-cache --ignore-pattern 'bundle.js'",
"prettier": "prettier --check .",
Expand Down Expand Up @@ -71,7 +73,8 @@
"events": "^3.3.0",
"jest-environment-jsdom": "^29.7.0",
"tslib": "^2.7.0",
"util": "^0.12.5"
"util": "^0.12.5",
"yaml": "^2.6.0"
},
"devDependencies": {
"@types/bn.js": "^5.1.6",
Expand Down
31 changes: 17 additions & 14 deletions pnpm-lock.yaml

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

Loading

0 comments on commit 0aa527a

Please sign in to comment.