Skip to content

Commit

Permalink
Spaebean/bs3/UI updates (#1113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Space-Bean authored Sep 23, 2024
2 parents 65428ba + d0234b3 commit 17a15ca
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ const PipelineConvertFormInner = ({
return;
}
try {
const callDatas = sdk.contracts.beanstalk.interface.encodeFunctionData(
'pipelineConvert',
[
sourceToken.address,
pickedDeposits.crates.map((c) => c.stem),
pickedDeposits.crates.map((c) => c.amount.toBigNumber()),
targetToken.address,
data.advPipeCalls,
]
);

console.log('[pipelineconvert/callstatic]', {
callData: callDatas,
});

const result = await sdk.contracts.beanstalk.callStatic.pipelineConvert(
sourceToken.address,
pickedDeposits.crates.map((c) => c.stem),
Expand Down
7 changes: 5 additions & 2 deletions projects/ui/src/components/Silo/Token/DepositConvertTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,13 @@ const DepositConvertTable = ({
const isMultiSelect = selectType === 'multi';
const isLambdaView = slug === 'lambda';

console.log('rows: ', rows);
console.log('selected: ', selected);

const allColumns = useMemo<GridColumns<FarmerTokenConvertRow>>(
() => [
{
field: 'deposit',
field: 'deposits',
flex: 1,
minWidth: 150,
headerName: 'Deposits',
Expand Down Expand Up @@ -251,7 +254,7 @@ const DepositConvertTable = ({

const handleRowClick: GridEventListener<'rowClick'> = useCallback(
(params) => {
setSelected(params.row.id, selectType);
setSelected(params.row.key, selectType);
},
[setSelected, selectType]
);
Expand Down
10 changes: 3 additions & 7 deletions projects/ui/src/components/Silo/Token/TokenDepositsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Token, TokenValue } from '@beanstalk/sdk';
import BigNumber from 'bignumber.js';
import { deliveryBoxIcon, minimizeWindowIcon } from '~/img/icon';
import { useTokens } from '~/hooks/beanstalk/useTokens';
import { ethers } from 'ethers';
import DepositsTable from './DepositsTable';
import { useTokenDepositsContext } from './TokenDepositsContext';

Expand Down Expand Up @@ -104,11 +105,6 @@ export default TokenDepositsOverview;
/**
* Shorten an Silo Deposit Id for UI display.
*/
export function trimDepositId(
address: string,
options?: { start?: number; end?: number }
) {
const start = options?.start || 4;
const end = options?.end || 2;
return `${address.substring(0, start)}${address ? `...${address.slice(-end)}` : ''}`;
export function trimDepositId(address: string) {
return `...${ethers.BigNumber.from(address).toHexString().slice(-6)}`;
}
4 changes: 2 additions & 2 deletions projects/ui/src/components/Silo/Token/TokenLambdaConvert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const TokenLambdaConvert = ({ token }: { token: ERC20Token }) => {
let ttlDeltaStalk = sdk.tokens.STALK.fromHuman('0');
let ttlDeltaSeed = sdk.tokens.SEEDS.fromHuman('0');

Object.entries(updateableDepositsById).forEach(([_, deposit]) => {
Object.entries(updateableDepositsById).forEach(([key, deposit]) => {
const currentBDV = oneTokenBDV.mul(deposit.amount);
const deltaBDV = currentBDV.sub(deposit.bdv);

if (deposit.bdv.gte(currentBDV)) return;
const deltaStalk = deposit.seeds.mul(deltaBDV);
const deltaSeed = deltaBDV.div(deposit.bdv).mul(deposit.seeds);
updateable.push({
key: `...${deposit.id.toHexString().slice(-13)}`,
key: key,
currentBDV: currentBDV,
deltaBDV: deltaBDV,
deltaStalk: deltaStalk,
Expand Down

0 comments on commit 17a15ca

Please sign in to comment.