Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana #296

Merged
merged 52 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3e170ed
Solana WIP
mliu Sep 1, 2024
e762ca8
update
mliu Sep 3, 2024
0b7a8fd
Widget
mliu Sep 4, 2024
de76674
lend supply
mliu Sep 6, 2024
b7d538b
Redeem and cancel
mliu Sep 7, 2024
e352c77
Borrow WIP
mliu Sep 9, 2024
f1f5f20
Solana SDK
mliu Sep 10, 2024
963ca1e
Update yarn lock
mliu Sep 10, 2024
fa48e78
Update yarn.lock
mliu Sep 10, 2024
7766c83
Remove react dep from shared package
mliu Sep 10, 2024
dbe95d2
Fix deps
mliu Sep 10, 2024
4c13dfb
Fix build
mliu Sep 10, 2024
99e0987
Empty commit
mliu Sep 10, 2024
000ef9b
Fix tests
mliu Sep 11, 2024
4ef52b3
Fix broken branch, add create lender accounts function
mliu Sep 11, 2024
75fa4ff
fix tests
mliu Sep 11, 2024
60b58de
Docs
mliu Sep 11, 2024
10ec4cd
solana details page (#301)
shan-57blocks Sep 12, 2024
0bd4a98
Solana details page (#302)
shan-57blocks Sep 12, 2024
aafa80d
Network switcher
mliu Sep 12, 2024
c0e0d29
solana pool list info (#303)
shan-57blocks Sep 13, 2024
60c42c2
Solana add approved lender (#304)
shan-57blocks Sep 15, 2024
137e1dc
Recent acitivities (#307)
shan-57blocks Sep 16, 2024
da0c509
Borrow payback
mliu Sep 16, 2024
b77303b
Arf pool
mliu Sep 17, 2024
f049d3f
solana lender activities (#309)
shan-57blocks Sep 17, 2024
6c8e015
Remove memo
mliu Sep 17, 2024
ed48d14
Merge pull request #308 from 00labs/borrow-payback
mliu Sep 17, 2024
a79b1de
Fix token
mliu Sep 17, 2024
3f0ace7
Empty commit
mliu Sep 17, 2024
2c34311
Redemption content changes, bugfixes, cancel redemption improvements …
mliu Sep 19, 2024
5e2c988
solana utilization rate (#314)
shan-57blocks Sep 19, 2024
7821904
solana borrow (#318)
shan-57blocks Sep 23, 2024
68bed93
solana signin (#320)
shan-57blocks Sep 30, 2024
3b6186e
solana kyc (#321)
shan-57blocks Oct 8, 2024
3697d5c
fix solana signin issue (#323)
shan-57blocks Oct 10, 2024
9afaa1d
solana campaign (#322)
shan-57blocks Oct 10, 2024
9f3e124
Solana new pool (#324)
shan-57blocks Oct 12, 2024
3bb760c
update solana campaign (#325)
shan-57blocks Oct 16, 2024
071736b
account authenticate (#326)
shan-57blocks Oct 17, 2024
4ccec95
migrate to solana graph service (#327)
shan-57blocks Oct 17, 2024
535a717
get huma account (#330)
shan-57blocks Oct 21, 2024
4fbf999
Notifi V2
mliu Aug 7, 2024
95f7a95
Update
mliu Aug 16, 2024
3048135
Fix types
mliu Aug 29, 2024
7beb3e4
Remove type package json update
mliu Sep 5, 2024
21551fd
Remove commented code
mliu Sep 6, 2024
b2f0afd
Remove CI token from production publish
mliu Sep 17, 2024
8639dd2
Fix token
mliu Sep 17, 2024
e76ed81
Use CI token
mliu Sep 18, 2024
3e0e692
Merge branch 'develop' into solana
mliu Oct 21, 2024
033fbab
Skip broken test
mliu Oct 21, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/beta-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Beta NPM Packages Publishing
on:
pull_request:
types: [closed]
branches: ["develop", "v2"]
branches: ['develop', 'v2', 'solana']
workflow_dispatch:

jobs:
Expand All @@ -22,8 +22,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.13.0
registry-url: "https://registry.npmjs.org"
cache: "yarn"
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'

- name: Cache Yarn dependencies
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Huma Monorepo CI
on:
pull_request:
types: [opened, synchronize]
branches: ["develop", "master", "v2"]
branches: ['develop', 'master', 'v2']

jobs:
ci:
Expand All @@ -16,7 +16,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.13.0
cache: "yarn"
cache: 'yarn'

- name: Cache Yarn dependencies
uses: actions/cache@v3
Expand Down
26 changes: 25 additions & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,37 @@
"startLoadRWR": "ts-node src/loadReceivablesOfOwnerWithMetadata.ts",
"startGetPoolBalanceCreditV2": "ts-node src/getPoolBalanceAndCreditV2.ts",
"startBurnReceivableV2": "ts-node src/burnReceivableV2.ts",
"solanaCreateReceivable": "ts-node src/solana/createReceivable.ts",
"solanaDeclarePayment": "ts-node src/solana/declarePayment.ts",
"solanaSubmitReceivable": "ts-node src/solana/submitReceivable.ts",
"solanaFetchReceivable": "ts-node src/solana/fetchReceivable.ts",
"solanaFetchBorrowerDetails": "ts-node src/solana/fetchBorrowerDetails.ts",
"solanaDrawdown": "ts-node src/solana/drawdown.ts",
"solanaPayback": "ts-node src/solana/payback.ts",
"lint-staged": "lint-staged"
},
"dependencies": {
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"@coral-xyz/anchor": "^0.30.1",
"@solana/spl-token": "^0.4.8",
"@solana/web3.js": "^1.95.3",
"lodash": "^4.17.21",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-react-ui": "^0.9.35",
"@solana/wallet-adapter-wallets": "^0.19.32",
"@coral-xyz/borsh": "^0.30.1",
"@mui/icons-material": "^5.3.0",
"@mui/material": "^5.0.6",
"@mui/styles": "^5.0.2",
"@mui/system": "^5.0.6",
"@mui/x-date-pickers": "^5.0.7",
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0"
},
"peerDependencies": {},
"lint-staged": {
"src/**/*.{js,ts,tsx,css,sass,less,graphql}": []
}
Expand Down
66 changes: 66 additions & 0 deletions packages/examples/src/solana/createReceivable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Connection, Keypair, sendAndConfirmTransaction } from '@solana/web3.js'
import {
AnchorProvider,
BN,
setProvider,
Wallet,
web3,
} from '@coral-xyz/anchor'
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared'
import {
HumaSolanaContext,
HumaSolanaReceivableHelper,
} from '@huma-finance/sdk'

require('dotenv').config()

async function main() {
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY
const connection = new Connection(
'https://api.devnet.solana.com',
'confirmed',
)

const keypair = web3.Keypair.fromSecretKey(
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)),
)
const wallet = new Wallet(keypair)
setProvider(new AnchorProvider(connection, wallet))

const solanaHumaContext = new HumaSolanaContext({
publicKey: wallet.publicKey,
connection: connection,
chainId: SolanaChainEnum.SolanaDevnet,
poolName: POOL_NAME.HumaCreditLine,
})

const humaReceivableHelper = new HumaSolanaReceivableHelper({
solanaContext: solanaHumaContext,
})

const newAsset = Keypair.generate()

const oneWeekFromNow = Math.floor(Date.now() / 1000) + 7 * 24 * 60 * 60
const tx = await humaReceivableHelper.buildCreateReceivableTransaction(
newAsset,
{
name: 'Test Receivable',
uri: 'https://test.com',
currencyCode: '840',
receivableAmount: new BN(100),
maturityDate: new BN(oneWeekFromNow),
referenceId: 'test-reference-id2',
},
)

console.log(tx)

const txResult = await sendAndConfirmTransaction(connection, tx, [
newAsset,
keypair,
])

console.log(txResult)
}

main()
52 changes: 52 additions & 0 deletions packages/examples/src/solana/declarePayment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Connection, Keypair, sendAndConfirmTransaction } from '@solana/web3.js'
import {
AnchorProvider,
BN,
setProvider,
Wallet,
web3,
} from '@coral-xyz/anchor'
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared'
import {
HumaSolanaContext,
HumaSolanaReceivableHelper,
} from '@huma-finance/sdk'

require('dotenv').config()

async function main() {
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY
const connection = new Connection(
'https://api.devnet.solana.com',
'confirmed',
)

const keypair = web3.Keypair.fromSecretKey(
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)),
)
const wallet = new Wallet(keypair)
setProvider(new AnchorProvider(connection, wallet))

const solanaHumaContext = new HumaSolanaContext({
publicKey: wallet.publicKey,
connection: connection,
chainId: SolanaChainEnum.SolanaDevnet,
poolName: POOL_NAME.HumaCreditLine,
})

const humaReceivableHelper = new HumaSolanaReceivableHelper({
solanaContext: solanaHumaContext,
})

const tx = await humaReceivableHelper.buildDeclarePaymentTransaction(
'test-reference-id',
new BN(1),
)

console.log(tx)

const txResult = await sendAndConfirmTransaction(connection, tx, [keypair])
console.log(txResult)
}

main()
46 changes: 46 additions & 0 deletions packages/examples/src/solana/drawdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Connection, Keypair, sendAndConfirmTransaction } from '@solana/web3.js'
import {
AnchorProvider,
BN,
setProvider,
Wallet,
web3,
} from '@coral-xyz/anchor'
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared'
import { HumaSolanaContext, HumaSolanaProgramHelper } from '@huma-finance/sdk'

require('dotenv').config()

async function main() {
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY
const connection = new Connection(
'https://api.devnet.solana.com',
'confirmed',
)

const keypair = web3.Keypair.fromSecretKey(
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)),
)
const wallet = new Wallet(keypair)
setProvider(new AnchorProvider(connection, wallet))

const solanaHumaContext = new HumaSolanaContext({
publicKey: wallet.publicKey,
connection: connection,
chainId: SolanaChainEnum.SolanaDevnet,
poolName: POOL_NAME.HumaCreditLine,
})

const humaSolanaProgramHelper = new HumaSolanaProgramHelper({
solanaContext: solanaHumaContext,
})

const tx = await humaSolanaProgramHelper.buildDrawdownTransaction(new BN(10))

console.log(tx)

const txResult = await sendAndConfirmTransaction(connection, tx, [keypair])
console.log(txResult)
}

main()
43 changes: 43 additions & 0 deletions packages/examples/src/solana/fetchBorrowerDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Connection, Keypair, sendAndConfirmTransaction } from '@solana/web3.js'
import {
AnchorProvider,
BN,
setProvider,
Wallet,
web3,
} from '@coral-xyz/anchor'
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared'
import { HumaSolanaContext, HumaSolanaProgramHelper } from '@huma-finance/sdk'

require('dotenv').config()

async function main() {
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY
const connection = new Connection(
'https://api.devnet.solana.com',
'confirmed',
)

const keypair = web3.Keypair.fromSecretKey(
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)),
)
const wallet = new Wallet(keypair)
setProvider(new AnchorProvider(connection, wallet))

const solanaHumaContext = new HumaSolanaContext({
publicKey: wallet.publicKey,
connection: connection,
chainId: SolanaChainEnum.SolanaDevnet,
poolName: POOL_NAME.HumaCreditLine,
})

const humaSolanaProgramHelper = new HumaSolanaProgramHelper({
solanaContext: solanaHumaContext,
})

const data = await humaSolanaProgramHelper.getAccountInfo()

console.log(data)
}

main()
40 changes: 40 additions & 0 deletions packages/examples/src/solana/fetchReceivable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Connection } from '@solana/web3.js'
import { AnchorProvider, setProvider, Wallet, web3 } from '@coral-xyz/anchor'
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared'
import {
HumaSolanaContext,
HumaSolanaReceivableHelper,
} from '@huma-finance/sdk'

require('dotenv').config()

async function main() {
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY
const connection = new Connection(
'https://api.devnet.solana.com',
'confirmed',
)

const keypair = web3.Keypair.fromSecretKey(
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)),
)
const wallet = new Wallet(keypair)
setProvider(new AnchorProvider(connection, wallet))

const solanaHumaContext = new HumaSolanaContext({
publicKey: wallet.publicKey,
connection: connection,
chainId: SolanaChainEnum.SolanaDevnet,
poolName: POOL_NAME.HumaCreditLine,
})

const humaReceivableHelper = new HumaSolanaReceivableHelper({
solanaContext: solanaHumaContext,
})

const res = await humaReceivableHelper.getReceivableInfo('test-reference-id')

console.log(res)
}

main()
49 changes: 49 additions & 0 deletions packages/examples/src/solana/payback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Connection, Keypair, sendAndConfirmTransaction } from '@solana/web3.js'
import {
AnchorProvider,
BN,
setProvider,
Wallet,
web3,
} from '@coral-xyz/anchor'
import { POOL_NAME, SolanaChainEnum } from '@huma-finance/shared'
import { HumaSolanaContext, HumaSolanaProgramHelper } from '@huma-finance/sdk'

require('dotenv').config()

async function main() {
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY
const connection = new Connection(
'https://api.devnet.solana.com',
'confirmed',
)

const keypair = web3.Keypair.fromSecretKey(
Buffer.from(JSON.parse(TEST_PRIVATE_KEY)),
)
const wallet = new Wallet(keypair)
setProvider(new AnchorProvider(connection, wallet))

const solanaHumaContext = new HumaSolanaContext({
publicKey: wallet.publicKey,
connection: connection,
chainId: SolanaChainEnum.SolanaDevnet,
poolName: POOL_NAME.HumaCreditLine,
})

const humaSolanaProgramHelper = new HumaSolanaProgramHelper({
solanaContext: solanaHumaContext,
})

const tx = await humaSolanaProgramHelper.buildPaymentTransaction(
new BN(5),
true /* principalOnly */,
)

console.log(tx)

const txResult = await sendAndConfirmTransaction(connection, tx, [keypair])
console.log(txResult)
}

main()
Loading
Loading