diff --git a/README.md b/README.md index da80f4b8..8b0ddba2 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,16 @@ Let's take the `test_coin` package as an example: - `README.md` description of the package, explain the usage of the package. +## Learn More About the Project with LLM + +We recommend using [DeepWiki](https://deepwiki.com/scallop-io/sui-lending-protocol) to gain a deeper understanding of the project's architecture, core concepts, and implementation details. + ## Use Scallop SDK to interact with the contracts It's recommended to use the Scallop SDK to interact with the contracts, see the official documentation: [How to use Scallop SDK](https://github.com/scallop-io/sui-scallop-sdk) +or even generate demo code and transaction examples directly through [DeepWiki](https://deepwiki.com/scallop-io/sui-scallop-sdk) integrated LLM interface. + ## Integrate with Scallop Protocol in SUI Move The protocol is designed to be simple, efficient, and secure. diff --git a/mainnet-data-setup/add-new-pool.ts b/mainnet-data-setup/add-new-pool.ts index 7da19a06..6d6e4e46 100644 --- a/mainnet-data-setup/add-new-pool.ts +++ b/mainnet-data-setup/add-new-pool.ts @@ -16,19 +16,20 @@ import { buildMultiSigTx } from './multi-sig'; import { BorrowLimits } from './borrow-limits'; import { suiKit } from 'sui-elements'; import { xOracleTxBuilder } from 'contracts/sui_x_oracle'; +import { riskModels } from './risk-models'; -async function addNewPool_haedal() { +async function addNewPool_haWal() { const tx = new SuiTxBlock(); - const coin = 'haedal'; - const dustCoinId = '0xd63a0ac2bf7bc0a79e5b2bada85a9eb9b7e3e88a1a8c6b8b692b86bd4d168ecb'; // This is used to keep a minimum amount of the coin in the pool + const coin = 'haWal'; + const dustCoinId = '0xd4be5cdd137a8b26a03c46de227d188c1e385edddf3743e465fc453323e0763e'; // This is used to keep a minimum amount of the coin in the pool const coinType = coinTypes[coin]; protocolTxBuilder.addInterestModel(tx, interestModels[coin], coinType); + protocolTxBuilder.addRiskModel(tx, riskModels[coin], coinType); protocolTxBuilder.addLimiter(tx, outflowRateLimiters[coin], coinType); protocolTxBuilder.setSupplyLimit(tx, SupplyLimits[coin], coinType); protocolTxBuilder.setBorrowLimit(tx, BorrowLimits[coin], coinType); protocolTxBuilder.updateBorrowFee(tx, borrowFees[coin], coinType); protocolTxBuilder.setFlashloanFee(tx, FlashloanFees[coin], coinType); - protocolTxBuilder.updateIsolatedAssetStatus(tx, true, coinType); pythRuleTxBuilder.registerPythFeed(tx, oracles[coin].pythPriceObjectId, pythRuleTxBuilder.calculatePriceConfidenceTolerance(2), coinType); xOracleTxBuilder.addPrimaryPriceUpdateRuleV2(tx, coinType, pythRuleStructType); @@ -50,4 +51,4 @@ async function addNewPool_haedal() { return txBytes; } -addNewPool_haedal().then(console.log); \ No newline at end of file +addNewPool_haWal().then(console.log); \ No newline at end of file diff --git a/mainnet-data-setup/asset-oracles.ts b/mainnet-data-setup/asset-oracles.ts index cf7b4413..3a7f32f0 100644 --- a/mainnet-data-setup/asset-oracles.ts +++ b/mainnet-data-setup/asset-oracles.ts @@ -34,4 +34,6 @@ export const oracles: Record = { usdy: { numerator: 3, denominator: 1000 }, wal: { numerator: 10, denominator: 1000 }, haedal: { numerator: 10, denominator: 1000 }, + wWal: { numerator: 10, denominator: 1000 }, + haWal: { numerator: 10, denominator: 1000 }, } diff --git a/mainnet-data-setup/borrow-limits.ts b/mainnet-data-setup/borrow-limits.ts index bc3bd26d..d71171f1 100644 --- a/mainnet-data-setup/borrow-limits.ts +++ b/mainnet-data-setup/borrow-limits.ts @@ -20,13 +20,15 @@ export const BorrowLimits: Record = { nativeUsdc: 5e7 * Math.pow(10, coinDecimals.nativeUsdc), sbEth: 5e3 * Math.pow(10, coinDecimals.sbEth), deep: 180_000_000 * Math.pow(10, coinDecimals.deep), - fud: 2_400_000_000_000 * Math.pow(10, coinDecimals.fud), + fud: 0 * Math.pow(10, coinDecimals.fud), fdusd: 5e6 * Math.pow(10, coinDecimals.fdusd), // 5M sbUsdt: 1e7 * Math.pow(10, coinDecimals.sbUsdt), - blub: 24e12 * Math.pow(10, coinDecimals.blub), // 24T + blub: 0 * Math.pow(10, coinDecimals.blub), mUsd: 2e6 * Math.pow(10, coinDecimals.mUsd), // 2M ns: 5e6 * Math.pow(10, coinDecimals.ns), // 5M usdy: 5e6 * Math.pow(10, coinDecimals.usdy), // 5M wal: 18_000_000 * Math.pow(10, coinDecimals.wal), // 18M haedal: 5_000_000 * Math.pow(10, coinDecimals.haedal), // 5M + wWal: 8_000_000 * Math.pow(10, coinDecimals.wWal), // 8M + haWal: 8_000_000 * Math.pow(10, coinDecimals.haWal), // 8M } diff --git a/mainnet-data-setup/chain-data.ts b/mainnet-data-setup/chain-data.ts index 3dca70e1..e7121c3a 100644 --- a/mainnet-data-setup/chain-data.ts +++ b/mainnet-data-setup/chain-data.ts @@ -20,6 +20,9 @@ export type SupportedCollaterals = | 'usdy' | 'wal' | 'deep' + | 'haedal' + | 'wWal' + | 'haWal' ; export type SupportedBaseAssets = @@ -47,6 +50,8 @@ export type SupportedBaseAssets = | 'usdy' | 'wal' | 'haedal' + | 'wWal' + | 'haWal' ; export const coinTypes = { @@ -75,6 +80,8 @@ export const coinTypes = { usdy: '0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY', wal: '0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL', haedal: '0x3a304c7feba2d819ea57c3542d68439ca2c386ba02159c740f7b406e592c62ea::haedal::HAEDAL', + wWal: '0xb1b0650a8862e30e3f604fd6c5838bc25464b8d3d827fbd58af7cb9685b832bf::wwal::WWAL', + haWal: '0x8b4d553839b219c3fd47608a0cc3d5fcc572cb25d41b7df3833208586a8d2470::hawal::HAWAL', }; export const coinMetadataIds = { @@ -103,6 +110,8 @@ export const coinMetadataIds = { usdy: '0xd8dd6cf839e2367de6e6107da4b4361f44798dd6cf26d094058d94e4cee25e36', wal: '0xcf8a31804ae40cb3e7183fe57320f87467a7750d4fa701bca1ffbb1edd37781e', haedal: '0xcc89fcc22f0d13de3688b94fa16d64a22079186a941914280c67101ff754263c', + wWal: '0xb99b3755f138d5a56b3bbc1b9cc19ed7da9be82c79844b39ff84d5c438ee5c40', + haWal: '0x285c96e598e2861a898eff9331a5ffeb9e2199cdb02f6ba52f311b0fab5c47cf', }; export const coinDecimals = { @@ -131,4 +140,6 @@ export const coinDecimals = { usdy: 6, wal: 9, haedal: 9, + wWal: 9, + haWal: 9, } diff --git a/mainnet-data-setup/flashloan-fees.ts b/mainnet-data-setup/flashloan-fees.ts index 340c6bbc..66b5ae05 100644 --- a/mainnet-data-setup/flashloan-fees.ts +++ b/mainnet-data-setup/flashloan-fees.ts @@ -29,4 +29,6 @@ export const FlashloanFees: Record = { usdy: 10, wal: 10, haedal: 10, + wWal: 10, + haWal: 10, } diff --git a/mainnet-data-setup/interest-models.ts b/mainnet-data-setup/interest-models.ts index 105ea143..cd1787f2 100644 --- a/mainnet-data-setup/interest-models.ts +++ b/mainnet-data-setup/interest-models.ts @@ -112,7 +112,7 @@ export const wormholeUsdtInterestModel: InterestModel = { midKink, // 80% highKink, // 90% - revenueFactor: 30 * (scale / 100), // 30% + revenueFactor: 20 * (scale / 100), // 20% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.wormholeUsdt - 2), // 0.01 USDT @@ -228,10 +228,10 @@ export const nativeUsdcInterestModel: InterestModel = { borrowRateOnHighKink: getRatePerSec(25), // 25% maxBorrowRate: getRatePerSec(150), // 150% - midKink, // 80% - highKink, // 90% + midKink: 85 * (scale / 100), // 85% + highKink: 95 * (scale / 100), // 95% - revenueFactor: 30 * (scale / 100), // 30% + revenueFactor: 20 * (scale / 100), // 20% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.nativeUsdc - 2), // 0.01 USDC @@ -265,7 +265,7 @@ export const deepInterestModel: InterestModel = { midKink, // 80% highKink, // 90% - revenueFactor: 40 * (scale / 100), // 40% + revenueFactor: 30 * (scale / 100), // 30% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.deep + 1), // 10 DEEP @@ -296,10 +296,10 @@ export const fdusdInterestModel: InterestModel = { borrowRateOnHighKink: getRatePerSec(25), // 25% maxBorrowRate: getRatePerSec(150), // 150% - midKink, // 80% - highKink, // 90% + midKink: 85 * (scale / 100), // 85% + highKink: 95 * (scale / 100), // 95% - revenueFactor: 30 * (scale / 100), // 30% + revenueFactor: 20 * (scale / 100), // 20% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.fdusd - 2), // 0.01 FDUSD @@ -313,10 +313,10 @@ export const sbUsdtInterestModel: InterestModel = { borrowRateOnHighKink: getRatePerSec(25), // 25% maxBorrowRate: getRatePerSec(150), // 150% - midKink, // 80% - highKink, // 90% + midKink: 85 * (scale / 100), // 85% + highKink: 95 * (scale / 100), // 95% - revenueFactor: 30 * (scale / 100), // 30% + revenueFactor: 20 * (scale / 100), // 20% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.sbUsdt - 2), // 0.01 USDT @@ -347,10 +347,10 @@ export const usdyInterestModel: InterestModel = { borrowRateOnHighKink: getRatePerSec(25), // 25% maxBorrowRate: getRatePerSec(150), // 150% - midKink, // 80% - highKink, // 90% + midKink: 85 * (scale / 100), // 85% + highKink: 95 * (scale / 100), // 95% - revenueFactor: 30 * (scale / 100), // 30% + revenueFactor: 20 * (scale / 100), // 20% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.usdy - 2), // 0.01 USDY @@ -402,7 +402,7 @@ export const haedalInterestModel: InterestModel = { highKink, // 90% revenueFactor: 40 * (scale / 100), // 40% - borrowWeight: (scale * 1.25), // 125% + borrowWeight, // 100% scale, minBorrowAmount: 10 ** (coinDecimals.haedal - 1), // 0.1 NS }; @@ -418,12 +418,46 @@ export const walInterestModel: InterestModel = { midKink, // 80% highKink, // 90% - revenueFactor: 40 * (scale / 100), // 40% + revenueFactor: 30 * (scale / 100), // 30% borrowWeight, // 1 scale, minBorrowAmount: 10 ** (coinDecimals.wal - 2), // 0.01 WAL }; +export const wWalInterestModel: InterestModel = { + baseBorrowRatePerSec: getRatePerSec(20), + interestRateScale, + + borrowRateOnMidKink: getRatePerSec(30), // 30% + borrowRateOnHighKink: getRatePerSec(50), // 50% + maxBorrowRate: getRatePerSec(600), // 600% + + midKink, // 80% + highKink, // 90% + + revenueFactor: 30 * (scale / 100), // 30% + borrowWeight, // 1 + scale, + minBorrowAmount: 10 ** (coinDecimals.wWal - 2), // 0.01 wWAL +}; + +export const haWalInterestModel: InterestModel = { + baseBorrowRatePerSec: getRatePerSec(20), + interestRateScale, + + borrowRateOnMidKink: getRatePerSec(30), // 30% + borrowRateOnHighKink: getRatePerSec(50), // 50% + maxBorrowRate: getRatePerSec(600), // 600% + + midKink, // 80% + highKink, // 90% + + revenueFactor: 30 * (scale / 100), // 30% + borrowWeight, // 1 + scale, + minBorrowAmount: 10 ** (coinDecimals.haWal - 2), // 0.01 haWAL +}; + export const interestModels: Record = { sui: suiInterestModel, sca: scaInterestModel, @@ -449,4 +483,6 @@ export const interestModels: Record = { usdy: usdyInterestModel, wal: walInterestModel, haedal: haedalInterestModel, + wWal: wWalInterestModel, + haWal: haWalInterestModel, } diff --git a/mainnet-data-setup/outflow-rate-limiters.ts b/mainnet-data-setup/outflow-rate-limiters.ts index 85fef29e..954621c4 100644 --- a/mainnet-data-setup/outflow-rate-limiters.ts +++ b/mainnet-data-setup/outflow-rate-limiters.ts @@ -9,17 +9,17 @@ const outflowSegmentDuration = 60 * 30 // 30 minutes export const outflowRateLimiters: Record = { sui: { - outflowLimit: 3 * 10 ** (6 + coinDecimals.sui), // 3 million SUI per day + outflowLimit: 1 * 10 ** (6 + coinDecimals.sui), // 1 million SUI per day outflowCycleDuration, outflowSegmentDuration, }, afSui: { - outflowLimit: 10 ** (5 + coinDecimals.afSui), // 100k afSUI per day + outflowLimit: 5_000 * 10 ** (coinDecimals.afSui), // 5k afSUI per day outflowCycleDuration, outflowSegmentDuration, }, haSui: { - outflowLimit: 10 ** (5 + coinDecimals.haSui), // 100K haSUI per day + outflowLimit: 5_000 * 10 ** (coinDecimals.haSui), // 5k haSUI per day outflowCycleDuration, outflowSegmentDuration, }, @@ -34,7 +34,7 @@ export const outflowRateLimiters: Record = { @@ -195,4 +222,7 @@ export const riskModels: Record = { usdy: usdyRiskModel, wal: walRiskModel, deep: deepRiskModel, + haedal: haedalRiskModel, + wWal: wWalRiskModel, + haWal: haWalRiskModel, } diff --git a/mainnet-data-setup/stop-borrow.ts b/mainnet-data-setup/stop-borrow.ts new file mode 100644 index 00000000..7ea2cf2e --- /dev/null +++ b/mainnet-data-setup/stop-borrow.ts @@ -0,0 +1,33 @@ +import { SuiTxBlock } from '@scallop-io/sui-kit'; +import { + protocolTxBuilder, +} from '../contracts/protocol'; +import { coinTypes } from './chain-data'; +import { BorrowLimits } from './borrow-limits'; +import { suiKit } from 'sui-elements'; +import { buildMultiSigTx } from './multi-sig'; + +export const stopBorrow = async () => { + const suiTxBlock = new SuiTxBlock(); + const borrowLimitList: { type: string, limit: number }[] = []; + for(const key of Object.keys(coinTypes)) { + const coinType = coinTypes[key as keyof typeof coinTypes]; + const borrowLimit = BorrowLimits[key as keyof typeof BorrowLimits]; + if (borrowLimit !== undefined) { + borrowLimitList.push({ type: coinType, limit: 0 }); + } + } + + borrowLimitList.forEach(pair => { + protocolTxBuilder.setBorrowLimit(suiTxBlock, pair.limit, pair.type); + }); + + const txBytes = await buildMultiSigTx(suiTxBlock); + const resp = await suiKit.client().dryRunTransactionBlock({ + transactionBlock: txBytes + }) + console.log(resp.effects.status); + return txBytes +} + +stopBorrow().then(console.log).catch(console.error).finally(() => process.exit(0)); diff --git a/mainnet-data-setup/stop-lending-borrowing.ts b/mainnet-data-setup/stop-lending-borrowing.ts new file mode 100644 index 00000000..faea9221 --- /dev/null +++ b/mainnet-data-setup/stop-lending-borrowing.ts @@ -0,0 +1,47 @@ +import { SuiTxBlock } from '@scallop-io/sui-kit'; +import { + protocolTxBuilder, +} from '../contracts/protocol'; +import { coinTypes } from './chain-data'; +import { BorrowLimits } from './borrow-limits'; +import { suiKit } from 'sui-elements'; +import { buildMultiSigTx } from './multi-sig'; +import { SupplyLimits } from './supply-limits'; + +export const stopLendingBorrow = async () => { + const suiTxBlock = new SuiTxBlock(); + const supplyLimitList: { type: string, limit: number }[] = []; + for(const key of Object.keys(coinTypes)) { + const coinType = coinTypes[key as keyof typeof coinTypes]; + const supplyLimit = SupplyLimits[key as keyof typeof SupplyLimits]; + if (supplyLimit !== undefined) { + supplyLimitList.push({ type: coinType, limit: 0 }); + } + } + + supplyLimitList.forEach(pair => { + protocolTxBuilder.setSupplyLimit(suiTxBlock, pair.limit, pair.type); + }); + + const borrowLimitList: { type: string, limit: number }[] = []; + for(const key of Object.keys(coinTypes)) { + const coinType = coinTypes[key as keyof typeof coinTypes]; + const borrowLimit = BorrowLimits[key as keyof typeof BorrowLimits]; + if (borrowLimit !== undefined) { + borrowLimitList.push({ type: coinType, limit: 0 }); + } + } + + borrowLimitList.forEach(pair => { + protocolTxBuilder.setBorrowLimit(suiTxBlock, pair.limit, pair.type); + }); + + const txBytes = await buildMultiSigTx(suiTxBlock); + const resp = await suiKit.client().dryRunTransactionBlock({ + transactionBlock: txBytes + }) + console.log(resp.effects.status); + return txBytes +} + +stopLendingBorrow().then(console.log).catch(console.error).finally(() => process.exit(0)); diff --git a/mainnet-data-setup/stop-lending.ts b/mainnet-data-setup/stop-lending.ts new file mode 100644 index 00000000..466bef52 --- /dev/null +++ b/mainnet-data-setup/stop-lending.ts @@ -0,0 +1,34 @@ +import { SuiTxBlock } from '@scallop-io/sui-kit'; +import { + protocolTxBuilder, +} from '../contracts/protocol'; +import { coinTypes } from './chain-data'; +import { BorrowLimits } from './borrow-limits'; +import { suiKit } from 'sui-elements'; +import { buildMultiSigTx } from './multi-sig'; +import { SupplyLimits } from './supply-limits'; + +export const stopLending = async () => { + const suiTxBlock = new SuiTxBlock(); + const supplyLimitList: { type: string, limit: number }[] = []; + for(const key of Object.keys(coinTypes)) { + const coinType = coinTypes[key as keyof typeof coinTypes]; + const supplyLimit = SupplyLimits[key as keyof typeof SupplyLimits]; + if (supplyLimit !== undefined) { + supplyLimitList.push({ type: coinType, limit: 0 }); + } + } + + supplyLimitList.forEach(pair => { + protocolTxBuilder.setSupplyLimit(suiTxBlock, pair.limit, pair.type); + }); + + const txBytes = await buildMultiSigTx(suiTxBlock); + const resp = await suiKit.client().dryRunTransactionBlock({ + transactionBlock: txBytes + }) + console.log(resp.effects.status); + return txBytes +} + +stopLending().then(console.log).catch(console.error).finally(() => process.exit(0)); diff --git a/mainnet-data-setup/supply-limits.ts b/mainnet-data-setup/supply-limits.ts index 10e845d7..e9ceb883 100644 --- a/mainnet-data-setup/supply-limits.ts +++ b/mainnet-data-setup/supply-limits.ts @@ -12,7 +12,7 @@ export const SupplyLimits: Record = { afSui: 1e6 * Math.pow(10, coinDecimals.afSui), haSui: 10e6 * Math.pow(10, coinDecimals.haSui), // 10M vSui: 0 * Math.pow(10, coinDecimals.vSui), // 0 - cetus: 2e6 * Math.pow(10, coinDecimals.cetus), + cetus: 10e6 * Math.pow(10, coinDecimals.cetus), wormholeEth: 0 * Math.pow(10, coinDecimals.wormholeEth), wormholeBtc: 0 * Math.pow(10, coinDecimals.wormholeBtc), sbwBTC: 20 * Math.pow(10, coinDecimals.sbwBTC), @@ -20,7 +20,7 @@ export const SupplyLimits: Record = { nativeUsdc: 7e7 * Math.pow(10, coinDecimals.nativeUsdc), sbEth: 5e3 * Math.pow(10, coinDecimals.sbEth), deep: 200e6 * Math.pow(10, coinDecimals.deep), // 200M - fud: 25e11 * Math.pow(10, coinDecimals.fud), + fud: 0 * Math.pow(10, coinDecimals.fud), fdusd: 20e6 * Math.pow(10, coinDecimals.fdusd), sbUsdt: 1e7 * Math.pow(10, coinDecimals.sbUsdt), // 10M blub: 25e12 * Math.pow(10, coinDecimals.blub), // 25T @@ -29,4 +29,6 @@ export const SupplyLimits: Record = { usdy: 5e6 * Math.pow(10, coinDecimals.usdy), // 5M wal: 25_000_000 * Math.pow(10, coinDecimals.wal), // 25M haedal: 20_000_000 * Math.pow(10, coinDecimals.haedal), // 20M + wWal: 10_000_000 * Math.pow(10, coinDecimals.wWal), // 10M + haWal: 10_000_000 * Math.pow(10, coinDecimals.haWal), // 10M }