@scallop-io/sui-scallop-sdk
Advanced tools
Comparing version 1.4.19 to 1.4.20
import type { GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetOwnedObjectsParams, SuiObjectData, SuiObjectDataOptions } from '@mysten/sui/client'; | ||
import type { SuiObjectArg } from '@scallop-io/sui-kit'; | ||
import type { SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit'; | ||
export declare const queryKeys: { | ||
@@ -42,3 +42,3 @@ api: { | ||
})[]; | ||
getTotalVeScaTreasuryAmount: (refreshArgs?: any[], vescaAmountArgs?: (string | SuiObjectData)[]) => (string | { | ||
getTotalVeScaTreasuryAmount: (refreshArgs?: any[], vescaAmountArgs?: (string | SuiObjectData | SuiTxArg)[]) => (string | { | ||
refreshArgs: string; | ||
@@ -45,0 +45,0 @@ vescaAmountArgs: string; |
@@ -108,2 +108,4 @@ import type { MarketPool } from './core'; | ||
export type TotalValueLocked = { | ||
supplyLendingValue: number; | ||
supplyCollateralValue: number; | ||
supplyValue: number; | ||
@@ -113,2 +115,4 @@ borrowValue: number; | ||
supplyValueChangeRatio?: number; | ||
supplyLendingValueChangeRatio?: number; | ||
supplyCollateralValueChangeRatio?: number; | ||
borrowValueChangeRatio?: number; | ||
@@ -115,0 +119,0 @@ totalValueChangeRatio?: number; |
{ | ||
"name": "@scallop-io/sui-scallop-sdk", | ||
"version": "1.4.19", | ||
"version": "1.4.20", | ||
"description": "Typescript sdk for interacting with Scallop contract on SUI", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import { Transaction } from '@mysten/sui/transactions'; | ||
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'; | ||
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit'; | ||
import { | ||
SuiTxBlock as SuiKitTxBlock, | ||
SUI_CLOCK_OBJECT_ID, | ||
} from '@scallop-io/sui-kit'; | ||
import { getObligations, getObligationLocked } from '../queries'; | ||
@@ -111,3 +113,7 @@ import { requireSender } from '../utils'; | ||
borrowIncentiveIds.obligationAccessStore, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
] | ||
@@ -131,3 +137,7 @@ ); | ||
veScaKey, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -147,3 +157,7 @@ [] | ||
obligationId, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
] | ||
@@ -163,3 +177,7 @@ ); | ||
obligationId, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -179,3 +197,7 @@ [rewardType] | ||
veScaKey, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
] | ||
@@ -182,0 +204,0 @@ ); |
@@ -129,3 +129,7 @@ import { Transaction } from '@mysten/sui/transactions'; | ||
coreIds.xOracle, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -141,3 +145,12 @@ [coinType] | ||
`${coreIds.protocolPkg}::mint::mint`, | ||
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
coreIds.version, | ||
coreIds.market, | ||
coin, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
@@ -152,3 +165,12 @@ ); | ||
`${coreIds.protocolPkg}::mint::mint_entry`, | ||
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
coreIds.version, | ||
coreIds.market, | ||
coin, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
@@ -163,3 +185,12 @@ ); | ||
`${coreIds.protocolPkg}::redeem::redeem`, | ||
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
coreIds.version, | ||
coreIds.market, | ||
marketCoin, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
@@ -174,3 +205,12 @@ ); | ||
`${coreIds.protocolPkg}::redeem::redeem_entry`, | ||
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
coreIds.version, | ||
coreIds.market, | ||
marketCoin, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
@@ -193,3 +233,7 @@ ); | ||
coreIds.xOracle, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -220,3 +264,7 @@ [coinType] | ||
coreIds.xOracle, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -240,3 +288,7 @@ [coinType, referralWitnessType] | ||
coreIds.xOracle, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -256,3 +308,7 @@ [coinType] | ||
coin, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -461,3 +517,3 @@ [coinType] | ||
await updateOracles(builder, txBlock, updateCoinNames); | ||
return await txBlock.borrowWithReferral( | ||
return txBlock.borrowWithReferral( | ||
obligationInfo.obligationId, | ||
@@ -464,0 +520,0 @@ obligationInfo.obligationKey as SuiObjectArg, |
@@ -234,3 +234,15 @@ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils'; | ||
const typeArgs = [coinType]; | ||
txBlock.moveCall(target, [xOracleId, request, SUI_CLOCK_OBJECT_ID], typeArgs); | ||
txBlock.moveCall( | ||
target, | ||
[ | ||
xOracleId, | ||
request, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
typeArgs | ||
); | ||
return txBlock; | ||
@@ -261,3 +273,12 @@ }; | ||
`${packageId}::rule::set_price`, | ||
[request, holderId, registryId, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
request, | ||
holderId, | ||
registryId, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
@@ -289,3 +310,12 @@ ); | ||
`${packageId}::rule::set_price`, | ||
[request, aggregatorId, registryId, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
request, | ||
aggregatorId, | ||
registryId, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
@@ -321,5 +351,15 @@ ); | ||
`${packageId}::rule::set_price`, | ||
[request, stateId, feedObjectId, registryId, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
request, | ||
stateId, | ||
feedObjectId, | ||
registryId, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[coinType] | ||
); | ||
}; |
@@ -45,3 +45,7 @@ import { ScallopBuilder } from 'src/models'; | ||
veScaTable, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -62,3 +66,7 @@ [] | ||
referralIds.referralTiers, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -77,3 +85,7 @@ [coinType] | ||
referralIds.referralRevenuePool, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -95,3 +107,7 @@ [coinType] | ||
veScaKey, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -98,0 +114,0 @@ [coinType] |
@@ -139,3 +139,10 @@ import { Transaction } from '@mysten/sui/transactions'; | ||
`${spoolIds.spoolPkg}::user::new_spool_account`, | ||
[stakePoolId, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
stakePoolId, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[marketCoinType] | ||
@@ -153,3 +160,12 @@ ); | ||
`${spoolIds.spoolPkg}::user::stake`, | ||
[stakePoolId, stakeAccount, coin, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
stakePoolId, | ||
stakeAccount, | ||
coin, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[marketCoinType] | ||
@@ -167,3 +183,12 @@ ); | ||
`${spoolIds.spoolPkg}::user::unstake`, | ||
[stakePoolId, stakeAccount, amount, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
stakePoolId, | ||
stakeAccount, | ||
amount, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[marketCoinType] | ||
@@ -186,3 +211,12 @@ ); | ||
`${spoolIds.spoolPkg}::user::redeem_rewards`, | ||
[stakePoolId, rewardPoolId, stakeAccount, SUI_CLOCK_OBJECT_ID], | ||
[ | ||
stakePoolId, | ||
rewardPoolId, | ||
stakeAccount, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
[marketCoinType, rewardCoinType] | ||
@@ -189,0 +223,0 @@ ); |
@@ -102,3 +102,7 @@ import { | ||
unlockAtInSecondTimestamp, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -118,3 +122,7 @@ [] | ||
newUnlockAtInSecondTimestamp, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -134,3 +142,7 @@ [] | ||
scaCoin, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -151,3 +163,7 @@ [] | ||
newUnlockAtInSecondTimestamp, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -166,3 +182,7 @@ [] | ||
veScaIds.treasury, | ||
SUI_CLOCK_OBJECT_ID, | ||
txBlock.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
], | ||
@@ -169,0 +189,0 @@ [] |
@@ -8,3 +8,3 @@ import type { | ||
} from '@mysten/sui/client'; | ||
import type { SuiObjectArg } from '@scallop-io/sui-kit'; | ||
import type { SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit'; | ||
@@ -80,3 +80,3 @@ export const queryKeys = { | ||
refreshArgs?: any[], | ||
vescaAmountArgs?: (string | SuiObjectData)[] | ||
vescaAmountArgs?: (string | SuiObjectData | SuiTxArg)[] | ||
) => [ | ||
@@ -83,0 +83,0 @@ 'rpc', |
@@ -817,3 +817,4 @@ import BigNumber from 'bignumber.js'; | ||
let supplyValue = BigNumber(0); | ||
let supplyLendingValue = BigNumber(0); | ||
let supplyCollateralValue = BigNumber(0); | ||
let borrowValue = BigNumber(0); | ||
@@ -830,2 +831,7 @@ | ||
totalValueChangeRatio: tvlIndexer.totalValueChangeRatio, | ||
supplyLendingValue: tvlIndexer.supplyLendingValue, | ||
supplyLendingValueChangeRatio: tvlIndexer.supplyLendingValueChangeRatio, | ||
supplyCollateralValue: tvlIndexer.supplyCollateralValue, | ||
supplyCollateralValueChangeRatio: | ||
tvlIndexer.supplyCollateralValueChangeRatio, | ||
}; | ||
@@ -836,3 +842,3 @@ return tvl; | ||
for (const pool of Object.values(market.pools)) { | ||
supplyValue = supplyValue.plus( | ||
supplyLendingValue = supplyLendingValue.plus( | ||
BigNumber(pool.supplyCoin).multipliedBy(pool.coinPrice) | ||
@@ -847,3 +853,3 @@ ); | ||
for (const collateral of Object.values(market.collaterals)) { | ||
supplyValue = supplyValue.plus( | ||
supplyCollateralValue = supplyCollateralValue.plus( | ||
BigNumber(collateral.depositCoin).multipliedBy(collateral.coinPrice) | ||
@@ -854,5 +860,10 @@ ); | ||
const tvl: TotalValueLocked = { | ||
supplyValue: supplyValue.toNumber(), | ||
supplyValue: supplyLendingValue.plus(supplyCollateralValue).toNumber(), | ||
supplyLendingValue: supplyLendingValue.toNumber(), | ||
supplyCollateralValue: supplyCollateralValue.toNumber(), | ||
borrowValue: borrowValue.toNumber(), | ||
totalValue: supplyValue.minus(borrowValue).toNumber(), | ||
totalValue: supplyLendingValue | ||
.plus(supplyCollateralValue) | ||
.minus(borrowValue) | ||
.toNumber(), | ||
}; | ||
@@ -859,0 +870,0 @@ |
@@ -186,9 +186,25 @@ import BigNumber from 'bignumber.js'; | ||
const txb = new SuiTxBlock(); | ||
// refresh query | ||
const refreshQueryTarget = `${veScaPkgId}::treasury::refresh`; | ||
const refreshArgs = [veScaConfig, veScaTreasury, SUI_CLOCK_OBJECT_ID]; | ||
const refreshArgs = [ | ||
veScaConfig, | ||
veScaTreasury, | ||
txb.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
]; | ||
// query total veSca amount | ||
const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`; | ||
const veScaAmountArgs = [veScaTreasury, SUI_CLOCK_OBJECT_ID]; | ||
const veScaAmountArgs = [ | ||
veScaTreasury, | ||
txb.sharedObjectRef({ | ||
objectId: SUI_CLOCK_OBJECT_ID, | ||
mutable: false, | ||
initialSharedVersion: '1', | ||
}), | ||
]; | ||
@@ -214,4 +230,2 @@ // resolve each args | ||
const txb = new SuiTxBlock(); | ||
// refresh first | ||
@@ -218,0 +232,0 @@ txb.moveCall(refreshQueryTarget, resolvedRefreshArgs); |
@@ -141,2 +141,4 @@ import type { MarketPool } from './core'; | ||
export type TotalValueLocked = { | ||
supplyLendingValue: number; | ||
supplyCollateralValue: number; | ||
supplyValue: number; | ||
@@ -146,4 +148,6 @@ borrowValue: number; | ||
supplyValueChangeRatio?: number; | ||
supplyLendingValueChangeRatio?: number; | ||
supplyCollateralValueChangeRatio?: number; | ||
borrowValueChangeRatio?: number; | ||
totalValueChangeRatio?: number; | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2747672
39182
159